# Makefile for tkmorph
#
# Written and Copyright (C) 1996 by Michael J. Gourlay

## C compiler
## ----------
##
#CC = gcc
CC = cc -32


## Include file path
## -----------------
##
## This points to where the "tcl.h" and "tk.h" files reside.
##
INCS= -I/usr/local/include


## C compiler flags
## ----------------
##
CFLAGS = -g $(INCS)


## TCL/Tk libraries
## ----------------
##
## Use the TCL 7.5 and Tk 4.1 versions.
##
LIBPATH=/usr/local/lib

TCL_LIB = $(LIBPATH)/libtcl7.5.a
TK_LIB = $(LIBPATH)/libtk4.1.a


## Libraries
## ---------
##
LIBS=$(TK_LIB) $(TCL_LIB) -lX11 -lm


## Linker flags
## ------------
##
LDFLAGS=$(LIBS)


## Delete utility
## --------------
##
RM=rm


## Object file extension
## ---------------------
##
OBJ=o

## Executable file extension
## -------------------------
##
EXE=


## File with the "main" routine
## ----------------------------
##
MAIN=tkAppInit.$(OBJ)




# - ifeq/endif:  The code between the "ifeq/endif" blocks is for MS
# -- Windoze using Borland "make".  However, Borland "make" doesn't
# -- understand "ifeq/endif" blocks.  In fact, neither does the Unix
# -- "make".  However, Gnu "make" does understand them.  The reason for
# -- using these nonstandard and nonportable make commands is that it's
# -- easier for me, with a text editor, to just commend out a single
# -- "ifeq/endif" pair than it is for me to go to each variable and change
# -- its value.  The way it's set up, using these "ifeq/endif" blocks, I
# -- use Gnu "make" when I'm on a Unix machine, so that the MSWin stuff is
# -- ignored, and I comment out the "ifeq/endif" lines, and add comments
# -- to the Unix targets.

ifeq "$(SYSTEM)" "MSWin"


#### ==================================
####
#### for MS Windoze using Borland make:
####
#### ==================================


## Borland C compiler base directory
## ---------------------------------
##
BORLAND=c:\bc5

CC=$(BORLAND)\bin\bcc32  ## MS Windoze with Borland C 5.0
INCS= -I"c:/PROGRAM FILES/TCL/include"  -I.
CFLAGS = -k -Od -v $(INCS)  ## MS Windoze
TCL_LIB = tcl75.lib  ## MS Windoze
TK_LIB = tk41.lib  ## MS Windoze
LIBS=$(TK_LIB) $(TCL_LIB) import32 cw32i  ## MS Windoze w/ Borland

## Borland C linker flags:
##
## -Tpe : Target is a Windows .EXE file
## -aa: Build a 32-bit Windows application (not run in a DOS console)
## -c: symbols are case significant
##
LDFLAGS=-Tpe -aa -c $(BORLAND)\lib\c0w32


RM=del  ## MS Windoze

OBJ=obj  ## MS Windoze

EXE=.exe

## MS Windoze uses a completely fucked up main routine.
##
MAIN=winMain.$(OBJ) tkConsole.$(OBJ)  ## MS Windoze


endif




OBJS = file.$(OBJ) \
       image_tcl.$(OBJ) \
       hash.$(OBJ) \
       mesh.$(OBJ) \
       mesh_tcl.$(OBJ) \
       my_malloc.$(OBJ) \
       rgba_image.$(OBJ) \
       spl-array.$(OBJ) \
       spline.$(OBJ) \
       tga-24.$(OBJ) \
       tga-write.$(OBJ) \
       tkImgTGA.$(OBJ) \
       tkmorph-init.$(OBJ) \
       warp.$(OBJ) \
       warp_tcl.$(OBJ) \
       $(MAIN)


######## ------- ########
########         ########
######## Targets ########
########         ########
######## ------- ########


all: tkmorph$(EXE)


## Zip from Info-ZIP:  for MS Windoze machine while keeping long file names
##
DIST = *.[ch] *.tk *.rc *.ico Makefile README SUMS FILES

zip:
	zip tkmorph.zip $(DIST)

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

back: SUMS
	if [ -d backup ]; then echo "'backup' already exists" ; exit 1 ; fi
	if [ ! -d backup ]; then mkdir backup ; fi
	cp -p Makefile Makefile.orig
	cp -p README tkmorph.README
	ls -ltr > FILES
	cp -p $(DIST) backup
	@echo
	@echo "NOW DO  mv backup `date +%d%b%y | tr '[A-Z]' '[a-z]'`"
	@echo


# Running makedepend with all .c files will complain about the files
# that belong to a different operating system.  That's okay.  Just
# ignore those messages.  Just make sure that those complains aren't for
# the operating system that you're trying to compile for.
#
depend:
	@echo ""
	@echo "---------------------------------------------------"
	@echo "Some warnings here are expected and okay to ignore."
	@echo "On a Unix machine, you can ignore messages about"
	@echo "'tkConsole.c' and 'winMain.c'."
	@echo "---------------------------------------------------"
	@echo ""
	makedepend $(INCS) *.c

clean:
	-$(RM) *.$(OBJ)

veryclean: clean
	-$(RM) tkmorph
	-$(RM) core




#### =========================
####
#### System dependant targets:
####
#### =========================

## --------
## for Unix
## --------
##
## Comment this out for Borland Make on MS Windoze.

tkmorph: $(OBJS)
	$(CC) -o $@ $(OBJS) $(LDFLAGS)




ifeq "$(SYSTEM)" "MSWin"


## ----------------------------------
## for MS Windoze using Borland make:
## ----------------------------------

.suffixes: .c .dll .lib .obj .exe

IMPLIB  = $(BORLAND)\bin\Implib
RC      = $(BORLAND)\bin\brcc32
TLINK32 = $(BORLAND)\bin\tlink32


.dll.lib:
	$(IMPLIB) -c $@ $<


.rc.res:
	$(RC) -i$(INCS) $<


## Borland Make has some weird syntax which I'll explain:
##
## The @ followed by a file name is used by the command to supply
## arguments to the command.  This is done to overcome the DOS 128
## character command line limit.
##
## The &&| creates a temporary file with contents being all of the lines
## until the next time the | character is at the beginning of a line.
##
#tkmorph: $(OBJS)
#	$(CC) -o $@ @&&|
#$(OBJS) $(LDFLAGS)
#|


tkmorph.exe: $(OBJS) $(TCL_LIB) $(TK_LIB) tkmorph.res
	$(TLINK32) @&&|
$(LDFLAGS) $(OBJS)
$@
-x
$(LIBS)
|, &&|
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
|, tkmorph.res

$(TCL_LIB): c:/local/tcl7.5/win/tcl75.dll
$(TK_LIB): c:/local/tk4.1/win/tk41.dll


endif




# DO NOT DELETE

file.o: /usr/include/stdio.h /usr/include/standards.h /usr/include/sgidefs.h
file.o: /usr/include/string.h file.h
hash.o: /usr/include/stdio.h /usr/include/standards.h /usr/include/sgidefs.h
hash.o: /usr/include/stdlib.h /usr/local/include/tcl.h
hash.o: /usr/local/include/tk.h /usr/include/X11/Xlib.h
hash.o: /usr/include/sys/types.h /usr/include/X11/X.h
hash.o: /usr/include/X11/Xfuncproto.h /usr/include/X11/Xosdefs.h
hash.o: /usr/include/stddef.h hash.h
image_tcl.o: /usr/include/stdio.h /usr/include/standards.h
image_tcl.o: /usr/include/sgidefs.h /usr/include/stdlib.h
image_tcl.o: /usr/local/include/tcl.h my_malloc.h rgba_image.h hash.h
image_tcl.o: image_tcl.h /usr/local/include/tk.h /usr/include/X11/Xlib.h
image_tcl.o: /usr/include/sys/types.h /usr/include/X11/X.h
image_tcl.o: /usr/include/X11/Xfuncproto.h /usr/include/X11/Xosdefs.h
image_tcl.o: /usr/include/stddef.h
mesh.o: /usr/include/stdio.h /usr/include/standards.h /usr/include/sgidefs.h
mesh.o: /usr/include/stdlib.h my_malloc.h file.h mesh.h
mesh_tcl.o: /usr/include/stdio.h /usr/include/standards.h
mesh_tcl.o: /usr/include/sgidefs.h /usr/include/stdlib.h
mesh_tcl.o: /usr/local/include/tcl.h hash.h my_malloc.h mesh.h mesh_tcl.h
my_malloc.o: /usr/include/stdio.h /usr/include/standards.h
my_malloc.o: /usr/include/sgidefs.h /usr/include/stdlib.h
my_malloc.o: /usr/include/malloc.h my_malloc.h
rgba_image.o: my_malloc.h tga.h /usr/include/stdio.h /usr/include/standards.h
rgba_image.o: /usr/include/sgidefs.h rgba_image.h
spl-array.o: /usr/include/stdio.h /usr/include/standards.h
spl-array.o: /usr/include/sgidefs.h /usr/include/stdlib.h /usr/include/math.h
spl-array.o: my_malloc.h spline.h spl-array.h
spline.o: /usr/include/stdio.h /usr/include/standards.h
spline.o: /usr/include/sgidefs.h /usr/include/stdlib.h /usr/include/math.h
spline.o: spline.h my_malloc.h
tga-24.o: /usr/include/stdio.h /usr/include/standards.h
tga-24.o: /usr/include/sgidefs.h /usr/include/memory.h my_malloc.h file.h
tga-24.o: tga.h rgba_image.h
tga-write.o: /usr/include/stdio.h /usr/include/standards.h
tga-write.o: /usr/include/sgidefs.h /usr/include/memory.h file.h tga.h
tga-write.o: rgba_image.h
tkAppInit.o: /usr/local/include/tk.h /usr/include/X11/Xlib.h
tkAppInit.o: /usr/include/sys/types.h /usr/include/standards.h
tkAppInit.o: /usr/include/sgidefs.h /usr/include/X11/X.h
tkAppInit.o: /usr/include/X11/Xfuncproto.h /usr/include/X11/Xosdefs.h
tkAppInit.o: /usr/include/stddef.h
tkConsole.o: tkInt.h /usr/local/include/tk.h /usr/include/X11/Xlib.h
tkConsole.o: /usr/include/sys/types.h /usr/include/standards.h
tkConsole.o: /usr/include/sgidefs.h /usr/include/X11/X.h
tkConsole.o: /usr/include/X11/Xfuncproto.h /usr/include/X11/Xosdefs.h
tkConsole.o: /usr/include/stddef.h /usr/local/include/tcl.h tkPort.h
tkImgTGA.o: /usr/include/stdio.h /usr/include/standards.h
tkImgTGA.o: /usr/include/sgidefs.h /usr/include/stdlib.h
tkImgTGA.o: /usr/local/include/tcl.h /usr/local/include/tk.h
tkImgTGA.o: /usr/include/X11/Xlib.h /usr/include/sys/types.h
tkImgTGA.o: /usr/include/X11/X.h /usr/include/X11/Xfuncproto.h
tkImgTGA.o: /usr/include/X11/Xosdefs.h /usr/include/stddef.h tkImgTGA.h
tkImgTGA.o: rgba_image.h tga.h
tkMain.o: /usr/local/include/tk.h /usr/include/X11/Xlib.h
tkMain.o: /usr/include/sys/types.h /usr/include/standards.h
tkMain.o: /usr/include/sgidefs.h /usr/include/X11/X.h
tkMain.o: /usr/include/X11/Xfuncproto.h /usr/include/X11/Xosdefs.h
tkMain.o: /usr/include/stddef.h
tkmorph-init.o: /usr/local/include/tcl.h /usr/local/include/tk.h
tkmorph-init.o: /usr/include/X11/Xlib.h /usr/include/sys/types.h
tkmorph-init.o: /usr/include/standards.h /usr/include/sgidefs.h
tkmorph-init.o: /usr/include/X11/X.h /usr/include/X11/Xfuncproto.h
tkmorph-init.o: /usr/include/X11/Xosdefs.h /usr/include/stddef.h tkImgTGA.h
tkmorph-init.o: image_tcl.h rgba_image.h mesh_tcl.h warp_tcl.h tkmorph-init.h
warp.o: /usr/include/stdio.h /usr/include/standards.h /usr/include/sgidefs.h
warp.o: my_malloc.h spl-array.h warp.h
warp_tcl.o: /usr/include/stdio.h /usr/include/standards.h
warp_tcl.o: /usr/include/sgidefs.h /usr/include/stdlib.h
warp_tcl.o: /usr/local/include/tcl.h my_malloc.h mesh.h rgba_image.h hash.h
warp_tcl.o: mesh_tcl.h image_tcl.h /usr/local/include/tk.h
warp_tcl.o: /usr/include/X11/Xlib.h /usr/include/sys/types.h
warp_tcl.o: /usr/include/X11/X.h /usr/include/X11/Xfuncproto.h
warp_tcl.o: /usr/include/X11/Xosdefs.h /usr/include/stddef.h warp_tcl.h
winMain.o: /usr/local/include/tk.h /usr/include/X11/Xlib.h
winMain.o: /usr/include/sys/types.h /usr/include/standards.h
winMain.o: /usr/include/sgidefs.h /usr/include/X11/X.h
winMain.o: /usr/include/X11/Xfuncproto.h /usr/include/X11/Xosdefs.h
winMain.o: /usr/include/stddef.h /usr/include/malloc.h /usr/include/locale.h
winMain.o: tkmorph-init.h /usr/local/include/tcl.h
