#  FACILITY
#  --------
#
#	makefile 
#
#      (makefile. on VMS - I'd call the file Makefile if I could, but 
#       the sources for Cword are currently stored on a VMS system where 
#       filename case *in*sensitivity is the norm)
#
#  ABSTRACT
#  --------
#
#       Single makefile for building Cword on any U*X system:
#
#	1. ULTRIX
#	2. SunOS
#	3. AIX
#	4. OSF/1 (Digital Unix)
#	5. HP-UX
#
#
#  AUTHORS
#  -------
#
#	James A. Lundon
#
#  CREATION DATE
#  -------------
#
#	1 March 1993
#

#  To change any of the defined macros do the following:
#
#      % make -f makefile CC="?" 
#

#
#  Example builds using CC at makefile command line: make -f makefile
#
#  ULTRIX:
#      Local: "CC=c89 -ansi"
#
#  OSF/1:
#      Local: "CC=cc"
#
#  HP-UX:
#      GNU: "CC=gcc"
#      Local: "CC=c89 -Aa -D_HPUX_SOURCE"
#
#      To Purify Cword the command at the command line is: 
#          % make purify "CC=purify c89 -Aa -D_HPUX_SOURCE"
#
#  Sun-OS:
#      Local: ??
#
#  AIX:
#      Local: ??
#

CC	=	cc
SQLPRE	=	sqlpre
COPTS	=	-c
RM	=	rm -f

OBJECTS  =	fileio.o utils.o\
		grid.o memman.o\
		match.o messages.o\
		verify.o generate.o\
		unix.o soundex.o\
		stats.o word.o\
		print.o charui.o\
		anagram.o webster.o\
		defaults.o clue.o\
		seed.o breakdic.o\
		cl.o strll.o\
		main.o

SOURCES =	fileio.c utils.c\
		grid.c memman.c\
		match.c messages.c\
		verify.c generate.c\
		unix.c soundex.c\
		stats.c word.c\
		print.c charui.c\
		anagram.c webster.c\
		defaults.c clue.c\
		seed.c breakdic.c\
		cl.c strll.c\
		main.c

#
#  Various targets that can be built using this makefile.
#
#  "make clean" will delete all objects.
#
#  "make lint" will lint Cword and produce a file called cword.lint.
#
#  "make purify" will produce a PURIFY'd Cword executable.
#  Extremely useful (with a capital E)!
#

#
#  Remember each action is two tabs in from column 1.  No spaces are 
#  allowed in any action lines.  If spaces are found, the following 
#  cryptic make error:
#
#  "Make: Must be a separator on rules line x.  Stop."
#
#  is returned.  This little feature caused me multiple hours of fun 
#  when I first encountered it a while back :-(.
#
#  The error doesn't even point to the line where the trouble
#  actually takes place.  The line reported in usually the next 
#  action line after the line in which the actual problem is found!
#

ALL : cword breakdic 
		@ echo Built Cword distribution

cword : $(OBJECTS)
		$(CC) -o $@ $(OBJECTS) -lm
		@ echo Cword built

breakdic : breakdic_main.o
		$(CC) -o $@ breakdic_main.o -lm
		@ echo breakdic built

#
#  ?? Have to re-define COPTS to allow for the definition of DB in the 
#  four Cword modules which have rdb functionality.  There must be a 
#  better way of doing this ??
#

#
#  OSF/1 - DEC Rdb specific link statement.  If you are using another 
#  vendor's Rdb product, please let me know.
#

cword_rdb : rdb.o $(OBJECTS)
		$(CC) -o $@ $(OBJECTS) rdb.o -lm -lsql -lrdbshr -lcosi -lots
		@ echo cword_rdb built

clean :
		$(RM) $(OBJECTS) rdb.o breakdic_main.o
		@ echo Deleted Cword related objects

lint :
		@ echo Please wait as linting of Cword takes place
		@ lint -ucx $(SOURCES) > cword.lint
		@ lint *.ln >> cword.lint
		@ echo Lint output placed in file called cword.lint

purify : $(OBJECTS)
		$(CC) -o cword_purify $(OBJECTS) -lm
		@ echo cword_purify built

#
#  ?? Could shorten all these targets to perform the same task ??
#
#  all_objects = $(OBJECTS)
#
#		$(CC) $(OBJECTS) $(CLAGS) -o $@
#

main.o : main.c main.h
		$(CC) $(COPTS) main.c -o $@

print.o : print.c print.h
		$(CC) $(COPTS) print.c -o $@

fileio.o : fileio.c fileio.h
		$(CC) $(COPTS) fileio.c -o $@

utils.o : utils.c utils.h
		$(CC) $(COPTS) utils.c -o $@

grid.o : grid.c grid.h
		$(CC) $(COPTS) grid.c -o $@

memman.o : memman.c memman.h
		$(CC) $(COPTS) memman.c -o $@

match.o : match.c match.h
		$(CC) $(COPTS) match.c -o $@

messages.o : messages.c messages.h
		$(CC) $(COPTS) messages.c -o $@

verify.o : verify.c verify.h
		$(CC) $(COPTS) verify.c -o $@

soundex.o : soundex.c soundex.h
		$(CC) $(COPTS) soundex.c -o $@

stats.o : stats.c stats.h
		$(CC) $(COPTS) stats.c -o $@

unix.o : unix.c unix.h
		$(CC) $(COPTS) unix.c -o $@ 

word.o : word.c word.h
		$(CC) $(COPTS) word.c -o $@ 

charui.o : charui.c charui.h
		$(CC) $(COPTS) charui.c -o $@ 

anagram.o : anagram.c anagram.h
		$(CC) $(COPTS) anagram.c -o $@ 

webster.o : webster.c webster.h
		$(CC) $(COPTS) webster.c -o $@ 

generate.o : generate.c generate.h
		$(CC) $(COPTS) generate.c -o $@ 

defaults.o : defaults.c defaults.h
		$(CC) $(COPTS) defaults.c -o $@ 

clue.o : clue.c clue.h
		$(CC) $(COPTS) clue.c -o $@ 

seed.o : seed.c seed.h
		$(CC) $(COPTS) seed.c -o $@ 

breakdic.o : breakdic.c messages.h
		$(CC) $(COPTS) breakdic.c -o $@ 

cl.o : cl.c cl.h
		$(CC) $(COPTS) cl.c -o $@ 

strll.o : strll.c strll.h
		$(CC) $(COPTS) strll.c -o $@

#
#  Special case: build rdb on Digital Unix (formally OSF/1)
#

rdb.o : rdb.sc rdb.h
		$(SQLPRE) -l cc rdb.sc -o $@

#
#  Separate object for standalone breakdic by defining MAIN
#

breakdic_main.o : breakdic.c messages.h
		$(CC) $(COPTS) breakdic.c -o $@ -DMAIN
