## ACGM: all configurations that were in this "Makefile"
## in the old version of xmorph are now in "Makefile.conf" in the main dir
## and there we discuss what has been changed

## this file  is now unused and unusable
## (Makefiles are automatically generated by automake)


# Makefile for xmorph and tkmorph
#
#  Written and Copyright (C) 1994-2000 by Michael J. Gourlay
#
#  This file is part of Xmorph.
#
#  Xmorph is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2, or (at your option)
#  any later version.
#
#  Xmorph is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with Xmorph; see the file LICENSE.  If not, write to
#  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
#  Boston, MA 02111-1307, USA.
#
#  Xmorph is part of GNU software.
#
#
#
# INSTRUCTIONS FOR COMPILING XMORPH:
#
#
# 0) Read the README file.  Then read this Makefile.
#
#
# 1) Make a backup copy of this Makefile.
#
#
# 2) Edit each of the variables in this Makefile before the "SRCS="
#    statement.  Each variable has instructions for how to assign
#    the variable values for various kinds of systems.
#
#
# 3) Some operating systems have a problem with long tokens, so the
#    help strings in help_menu.c will have to be trimmed if you get warnings
#    about long strings from your C compiler.  See the comments in
#    help_menu.c for details.  Most compilers will not have problem with
#    this.
#
#
# 4) On Unix machines, from your shell, type "make depend".
#
#    If this fails or if you do not have makedepend, or if you are not
#    running on a Unix machine, just delete all of the lines (if there
#    are any) below the "depend:" rule near the end of this Makefile.
#    Look for the rule that says "depend:" and read the comments that
#    follow it.  This step is not essential for building programs but it
#    is useful for development and debugging.
#
#    Another alternative is to use "make cleandepend", espeially
#    if you are generating a Makefile for cross-compiling.  the
#    cleandepend target will only generate dependency rules for
#    header files specific to xmorph, not for all header files.
#
#
# 5) From the shell or command prompt, type "make".
#
#
# 6) If there are any errors or compiler complaints, find out why and
#    fix them :).  Then send email to the author explaining the cause of
#    the problem, and its solution.  If it is a big deal, I will put your
#    name in lights for the next release.  See the README file for
#    the internet email address of the author.
#
#    But seriously folks, if you can not figure out the problem, send
#    the author email.  Before complaining, though, read the man
#    pages for your C compiler and your linker.  If you are using
#    static linking and you get a linker problem, try dynamic
#    libraries, and vice versa.
#
#    If all goes well, there will be an executable called "xmorph".
#
#
# 7) From the shell, type "xmorph".
#
#    There are help pages accessible from within xmorph.  If there
#    are any bugs or spelling errors, fix them and/or report them to the
#    author.  See the README file for an email address.
#
#
# 8) To install xmorph on your system, edit INSTALL_BASE in this file
#    and type "make install" as root.  If that fails, place the
#    "xmorph" executable in the standard place on your machine for such
#    things.  There is also an "xmorph.man" file which should be
#    renamed to xmorph.1 and placed in the appropriate directory for
#    manual pages of optional programs.  For most systems, this is
#    /usr/local/man/man1.





## SHELL: Interpretter for executing "make" commands
## -------------------------------------------------
#
# The shell should be Bourne compatible.
# Do not change unless you do not have "/bin/sh".
#

SHELL=/bin/sh




## CC: C compiler
## --------------
#
# You must use an ANSI C compiler.
#
# Apollo w/ Domain/OS, BSD: use /bin/cc
#

#CC=ucbcc
#CC=apcc
#CC=gcc
#CC=/bin/cc
#CC=cc
CC=cc




## INCLUDE: C compiler options to append header file paths
## -------------------------------------------------------
#
# Set INCLUDE to refer to the places where your header files reside.
#
# This should refer to where your TCL and Tk headers are.
#
# If you are building the GIMP plugin version, this should also refer
# to where your GIMP header files are installed.
#
# Solaris: On some Solaris machines, linking with the openwin libraries
# REQUIRES including the openwin headers (not MIT headers!).
# You should then set INCLUDE to have -I/usr/openwin/include
#

#INCLUDE=-I/usr/local/include -I/usr/openwin/include
INCLUDE=-I/usr/local/include




## DEBUG: C compiler options for debugging and/or code optimization
## ----------------------------------------------------------------
#
# For Unix compilers,
#   -O usually means "optimize"
#   -g usually means "debug"
#
# On most compilers, optimization and debugging flags are mutually
# exclusive.  A notable exception is the GNU C compiler, which can
# have both debugging and optimization.
#
#
# SGI native compiler:
#   -fullwarn gives more comprehensive warning messages.
#   -wlint does a lint check.
#
#   Be aware that the N32 C compiler for IRIX 6.2, using -fullwarn
#   will generate stupid warnings about the X include files.  This is
#   the SGI compiler complaining about SGI C code.  Think about it.
#
#
# GCC:
#   -Wall gives more comprehensive warning messages.
#
#
# -DVERBOSE and -DDEBUG are used for development.
# Unless you are working on the code, you will want to omit these.
#

#DEBUG=-O -g -Wall -DVERBOSE -DDEBUG
#DEBUG=-O
#DEBUG=-g3 -O -fullwarn -DVERBOSE -DDEBUG
DEBUG=-g3 -O -fullwarn




## NOWARN: C compiler options to reduce the number of warnings
## -----------------------------------------------------------
#
# The code generated by SWIG is not lint-clean but it does not matter
# so we want to ignore those warnings.

NOWARN=
#NOWARN=-woff 1164,1174,1209,1233,1498,1552




## DEFINES: C precompiler macros
## -----------------------------
#
# GIMP: Adds GIMP plugin functionality to xmorph.
#   Also define NEED_GIMP=1.  If this is defined, then you may run
#   xmorph both as a standalone application, and by adding it to your
#   ~/.gimp/plug-ins directory (usually via a symlink).  From what I
#   understand, this will not work for tkmorph.  See GIMPLIBS, below.
#
# REAL: Size of a "REAL" used by spline code.
#   Correct value is "double".  Do not change.
#
# RGBA_MESH_WARP: flag to tell RgbaImage to include mesh-based warping
#   methods.  Do not change.
#
# RGBA_TK: flag to tell RgbaImage to include Tk Photo image code.
#   DO NOT DEFINE for xmorph.  Only define for tkmorph.
#   Also change the "all" target if RGBA_TK is changed.
#
# RED_GREEN_COLOR_BLIND: uses blue instead of red for color of
#   'destination' mesh lines and points.
#
# STRDUP_PROTO_BROKEN: For some versions of GNU C, the string.h
#   header file has an incorrect prototype for strdup.  If you
#   experience problems compiling, related to the strdup prototype,
#   then define STRDUP_PROTO_BROKEN.


# For tkmorph:
#DEFINES=-DREAL=double -DRGBA_MESH_WARP -DRGBA_TK

# For colorblind:
#DEFINES=-DREAL=double -DRGBA_MESH_WARP -DRED_GREEN_COLOR_BLIND

# For GIMP plugin:
#DEFINES=-DREAL=double -DRGBA_MESH_WARP -DGIMP -DNEED_GIMP=1

# Broken GNU C:
#DEFINES=-DREAL=double -DRGBA_MESH_WARP -DSTRDUP_PROTO_BROKEN

# Most systems:
DEFINES=-DREAL=double -DRGBA_MESH_WARP




## XLIBS: X libraries
## ------------------
#
# Must have the X libraries: X11, MIT Athena Widgets, X Toolkit, X Misc Utils
#
# Linux 2.0: must have /usr/X11/lib
#   or /usr/X11R6/lib explicitly in library search path
#
# SunOS (pre-Solaris): Might have to use static X libraries because
#   dynamic X libraries are incomplete.
#
# Solaris: To link to openwin libraries, add -L/usr/openwin/lib
#
# IRIX6.2: Need to have -lcvt after -lXt
#   If you receive an error about an unresolved symbol named
#   SgCvtCreateConversionContext, you need to include -lcvt.
#   The cvt library is available in the goldengate.sw.goldengate package

# Sun Solaris:
#XLIBS=-L/usr/openwin/lib -lXaw -lXmu -lXext -lXt -lX11

# Linux:
#XLIBS=-L/usr/X11/lib -lXaw -lXmu -lXext -lXt -lX11
#XLIBS=-L/usr/X11R6/lib -lXaw -lXmu -lXext -lXt -lX11

# SGI IRIX:
XLIBS=              -lXaw -lXmu -lXext -lXt -lcvt -lX11




## GIMPLIBS: GIMP libraries
## ------------------------
# If you have defined -DGIMP in the DEFINES section, then xmorph will
# be built to run both as a standalone application and as a GIMP
# plugin.  Here, you need to specify the appropriate GIMP libraries.
#
# Comment out this variable if you have not used -DGIMP.

#GIMPLIBS=-L/usr/local/lib -lgimp -lglib
#GIMPLIBS=-lgimp -lglib




## NON_GUI_LIBS: libraries which are not part of the GUI
## -----------------------------------------------------
#
# Must have the math library (-lm).
#
#
# Linux: Add -ldl if you get link error regarding dlerror, dlopen, or
#   dlsym
#
#
# FreeBSD: Do not use static libraries, because for some reason they
#   do not work.
#
#
# SunOS: Use the /usr/lib/debug/malloc.o module if you want to do
#   memory checking.
#   Also see the CFLAGS comments about memory checking under SunOS.
#
#
# SGI IRIX: Use -lmalloc to link with their special memory allocation
#   routines.  If you get an error about mallopt being
#   unresolved, then you will have to link with the libmalloc
#   shared object.  Do this by specifying -lmalloc here.
#
#   -lmalloc_cv has more robust memory checking

#NON_GUI_LIBS = -lm
#NON_GUI_LIBS = -lm -ldl
#NON_GUI_LIBS = -lm /usr/lib/debug/malloc.o
NON_GUI_LIBS = -lm -lmalloc




## LIBS: loader options to link with libraries
## -------------------------------------------
#
# Read the man page for your linker before sending me email about
# problems.
#
# Apollo w/ Domain/OS, BSD: omit XLIBS

#LIBS = $(GIMPLIBS) $(NON_GUI_LIBS)
LIBS = $(GIMPLIBS) $(XLIBS) $(NON_GUI_LIBS)




# SHLIB_FLAG: flag used to generate shared library
# ------------------------------------------------
SHLIB_FLAG=-shared




# SHLIB_EXT: filename extension for shared libraries
# --------------------------------------------------
SHLIB_EXT=so




## LDFLAGS: Loader options
## -----------------------
#

LDFLAGS=-L/usr/local/lib




## CFLAGS: Miscellaneous C compiler options
## ----------------------------------------
#
# Read the man page for your C compiler before sending me email about
# problems.
#
# SunOS: Add the option -DSUNOS version if you want to do memory checking.
# -- Also see LIBS for another flag relating to memory checking.
#
# HPUX 7.0B: native C compiler needs more symbol table space: +Ns4000
#
# Apollo w/ Domain/OS, BSD: use the -inlib line (contributed by Paul Walker)
#

#CFLAGS=$(DEBUG) $(DEFINES) +Ns4000

#CFLAGS=-O -W0,-inlib,/lib/x11lib.r5 -W0,-inlib,/lib/xawlib.r5 -W0,-inlib,/lib/xextlib.r5 -W0,-inlib,/lib/xtlib.r5 -W0,-inlib,/lib/xmulib.r5

#CFLAGS=$(DEBUG) $(DEFINES) $(INCLUDE) -DSUNOS

CFLAGS=$(DEBUG) $(DEFINES) $(INCLUDE)




## INSTALL_BASE: Directory base to install files
## ---------------------------------------------
INSTALL_BASE=/usr/local








#### ======================================================
#### ======================================================
####
#### Nothing to edit below here
#### (except maybe the makedepend dependencies near the end of this
#### file if you do not have "makedepend")
####
#### ======================================================
#### ======================================================




SRCS=\
     diw_map.c \
     file_menu.c \
     help_menu.c \
     image_cb.c \
     image_diw.c \
     mesh.c \
     mesh_cb.c \
     mesh_menu.c \
     mjg_dialog.c \
     my_malloc.c \
     RgbaImage.c \
     sequence.c \
     spline.c \
     spl-array.c \
     tga.c \
     warp.c \
     warp_menu.c \
     xmorph.c

LIB_OBJS= \
        mesh.o \
        my_malloc.o \
        RgbaImage.o \
        spl-array.o \
        spline.o \
        tga.o \
        warp.o

GUI_OBJS=\
     diw_map.o \
     file_menu.o \
     help_menu.o \
     image_cb.o \
     image_diw.o \
     mesh_cb.o \
     mesh_menu.o \
     mjg_dialog.o \
     sequence.o \
     warp_menu.o \
     xmorph.o

#all: morph.$(SHLIB_EXT)
all: xmorph morph xmorph.man xmorph.info

libmorph.a: $(LIB_OBJS)
	ar cr $@ $(LIB_OBJS)

libmorph.$(SHLIB_EXT): $(LIB_OBJS)
	ld $(SHLIB_FLAG) $(LDFLAGS) $(LIB_OBJS) -o $@

xmorph: main-x.o libmorph.a $(GUI_OBJS)
	@echo ""
	@echo ""
	@echo ""
	@echo ""
	@echo "==== If the next command generates link errors regarding"
	@echo "==== unresolved symbols to Tk routines, then you probably"
	@echo "==== erroneously defined RGBA_TK and you should change"
	@echo "==== the Makefile."
	@echo ""
	@echo ""
	@echo ""
	@echo ""
	$(CC) $(CFLAGS) -o $@ main-x.o $(GUI_OBJS) libmorph.a $(LIBS)

morph: main-cl.o libmorph.a
	$(CC) $(CFLAGS) -o $@ main-cl.o libmorph.a $(NON_GUI_LIBS)

.c$(OBJ): $(SRCS) Makefile
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<

main-x.o: main.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c -DX_GUI main.c -o $@

main-cl.o: main.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c main.c -o $@

xmorph.man: xmorph.1
	nroff -man xmorph.1 > xmorph.man
	col -b < xmorph.man > xmorph.txt

xmorph.info: xmorph.texinfo
	makeinfo xmorph.texinfo

test-tga: tga.o test-tga.c
	$(CC) $(CFLAGS) -o $@ test-tga.c tga.o




install: xmorph xmorph.man libmorph.a libmorph.$(SHLIB_EXT)
	cp xmorph $(INSTALL_BASE)/bin
	cp xmorph.1 $(INSTALL_BASE)/man/man1
	cp libmorph.a $(INSTALL_BASE)/lib
	cp libmorph.$(SHLIB_EXT) $(INSTALL_BASE)/lib




## Wrapper code for morph interpretter.
##
## This code is under construction and not yet ready for public use.

morph_wrap.c: morph.swig RgbaImage.h mesh.h
	@echo ""
	@echo ""
	swig -tcl -o morph_wrap.c morph.swig
	@echo ""
	@echo ""

morph_wrap.o: morph_wrap.c
	$(CC) -c $(CFLAGS) $(NOWARN) morph_wrap.c

morph.$(SHLIB_EXT): morph_wrap.o $(LIB_OBJS)
	@echo ""
	$(CC) $(CFLAGS) $(LDFLAGS) $(SHLIB_FLAG) morph_wrap.o $(LIB_OBJS) $(LIBS) -o $@
	@echo ""




macros:
	@echo ""
	@echo ""
	@echo "This will work for GNU C"
	echo > empty.c
	-cc -E -dM empty.c
	rm empty.c
	@echo ""
	@echo ""
	@echo "This will work for SGI"
	-cc -E -show /dev/null

white:
	@echo ""
	@echo ""
	@echo "These greps should produce no output except ignored errors"
	@echo ""
	@echo ""
	-grep '	' *.[ch]
	-grep ' $$' *.[ch]
	@echo ""

clean:
	-rm -f main-x.o
	-rm -f main-cl.o
	-rm -f $(LIB_OBJS)
	-rm -f $(GUI_OBJS)
	-rm -f core
	-rm -f test-tga
	-rm -f morph_wrap.o
	-rm -f morph_wrap.c

veryclean: clean
	-rm -f morph
	-rm -f xmorph
	-rm -f xmorph.man
	-rm -f xmorph.txt
	-rm -f xmorph.info
	-rm -f libmorph.a
	-rm -f libmorph.$(SHLIB_EXT)
	-rm -f morph.$(SHLIB_EXT)
	-rm -f so_locations
	-rm -f morph_wrap.doc
	-rm -f morph_wrap.html

DIST=COPYLEFT \
     FILES \
     HISTORY \
     LICENSE \
     Makefile \
     Makefile.orig \
     gimp-README \
     README \
     SUMS \
     xmorph.README \
     xmorph.texinfo \
     *.[ch] *.xbm tkmorph *.tk xmorph.1 warp.param *.swig

SUMS:
	sum $(DIST) | sort -n > SUMS

BACKDIR=`date +%Y%b%d | tr '[A-Z]' '[a-z]'`

backup: SUMS white
	@if [ -d backup ]; then echo "'backup' already exists" ; exit 1 ; fi
	@if [ -d $(BACKDIR) ]; then echo "$(BACKDIR) already exists" ; exit 1 ; fi
	mkdir $(BACKDIR)
	cp -p Makefile Makefile.orig
	cp -p README xmorph.README
	ls -ltr > FILES
	cp -p $(DIST) $(BACKDIR)
	#tar cvf - $(DIST) | ( cd $(BACKDIR); tar xvf - )

DISTFILE=xmorph-$(BACKDIR).tar

dist: cleandepend backup
	make morph_wrap.c
	mv morph_wrap.c $(BACKDIR)
	mv $(BACKDIR) xmorph-$(BACKDIR)
	tar cvf $(DISTFILE) xmorph-$(BACKDIR)
	gzip $(DISTFILE)

send: dist
	rcp xmorph-$(BACKDIR).tar.gz ucsub:public_html/Software/Graphics

ctags:
	-ctags    *.[ch]
	-ctags -t *.[ch]

unproto:
	unprotoize $(SRCS)

grind:
	for file in $(SRCS) *.h ; do tgrind -p $$file ; done

ctrace:
	-mkdir trace
	-for cfile in $(SRCS) ; do \
	  ctrace -P -t 20 $$cfile > trace/$$cfile ; \
	done

cleandepend: ctags
	makedepend -Y *.c

depend: ctags
	makedepend $(INCLUDE) $(SRCS)


#### The lines which follow are automatically generated by
#### "makedepend" which is a program that automatically generates
#### dependency lists.  If your system does not have "makedepend"
#### then you should delete the lines after the line that says
#### "DO NOT DELETE THIS LINE"


# DO NOT DELETE THIS LINE -- make depend depends on it.

RgbaImage.o: my_malloc.h tga.h RgbaImage.h
diw_map.o: my_malloc.h select.xbm unselect.xbm spline.h spl-array.h
diw_map.o: RgbaImage.h image_cb.h image_diw.h mesh.h mjg_dialog.h main.h
diw_map.o: diw_map.h
file_menu.o: xmorph.h mjg_dialog.h mesh_cb.h image_cb.h file_menu.h
help_menu.o: xmorph.h mjg_dialog.h help_menu.h
image_cb.o: diw_map.h mesh.h image_diw.h RgbaImage.h mjg_dialog.h main.h
image_cb.o: image_cb.h
image_diw.o: my_malloc.h diw_map.h mesh.h image_diw.h RgbaImage.h main.h
main.o: mesh.h RgbaImage.h main.h
mesh.o: my_malloc.h mesh.h
mesh_cb.o: diw_map.h mesh.h image_diw.h RgbaImage.h mjg_dialog.h mesh_cb.h
mesh_menu.o: mesh_cb.h mesh_menu.h
mjg_dialog.o: mjg_dialog.h my_malloc.h
my_malloc.o: my_malloc.h
sequence.o: diw_map.h mesh.h image_diw.h RgbaImage.h mjg_dialog.h warp.h
sequence.o: my_malloc.h main.h sequence.h
spl-array.o: my_malloc.h spline.h spl-array.h
spline.o: spline.h my_malloc.h
test-tga.o: tga.h RgbaImage.h
tga.o: my_malloc.h tga.h RgbaImage.h
warp-i.o: my_malloc.h warp.h
warp.o: my_malloc.h spline.h spl-array.h warp.h
warp_menu.o: mjg_dialog.h sequence.h diw_map.h mesh.h image_diw.h RgbaImage.h
warp_menu.o: warp_menu.h
xmorph.o: diw_map.h mesh.h image_diw.h RgbaImage.h sequence.h file_menu.h
xmorph.o: mesh_menu.h warp_menu.h help_menu.h my_malloc.h main.h xmorph.h
