# Change the following to specify the desired output language
# Currently only ENGLISH is supported.
LANGUAGE= ENGLISH

# You must use an ANSI C compiler (like gcc)
CC= gcc
CFLAGS= -Wall -D${LANGUAGE} -g -DHAVE_FGETLN -DHAVE_STRDUP

SRCS=main.c read.c database.c index.c interpret.c output.c tags.c \
	nstrdup.c templates.c
OBJS=main.o read.o database.o index.o interpret.o output.o tags.o \
	nstrdup.o templates.o
HDRS=database.h index.h interpret.h node.h output.h read.h tags.h \
	version.h templates.h
DOCS=doc/Welcome.html doc/copying.html doc/registering.html \
	doc/about.html doc/version.html \
	doc/downloading.html doc/running.html \
	doc/running_unix.html doc/running_unix_simple.html \
	doc/running_unix_options.html \
	doc/running_unix_problems.html doc/running_unix_solutions.html \
	doc/running_unix_uploading.html \
	doc/running_windows.html doc/running_windows_simple.html \
	doc/running_windows_options.html \
	doc/running_windows_problems.html doc/running_windows_solutions.html \
	doc/running_windows_uploading.html \
	doc/output.html doc/options.html doc/inlining.html doc/templates.html \
	doc/whatsnew.html

ged2html: ${OBJS}
	${CC} ${CFLAGS} -o ged2html ${OBJS}

main.o: main.c node.h read.h database.h output.h tags.h templates.h version.h
	${CC} ${CFLAGS} -c main.c

read.o: read.c node.h read.h tags.h
	${CC} ${CFLAGS} -c read.c

database.o: database.c node.h database.h index.h tags.h
	${CC} ${CFLAGS} -c database.c

index.o: index.c database.h index.h node.h
	${CC} ${CFLAGS} -c index.c

interpret.o: interpret.c database.h interpret.h node.h output.h tags.h\
	templates.h version.h
	${CC} ${CFLAGS} -c interpret.c

output.o: output.c tags.h node.h database.h interpret.h output.h templates.h\
	version.h
	${CC} ${CFLAGS} -c output.c

templates.o: templates.c templates.h
	${CC} ${CFLAGS} -c templates.c

tags.o: tags.c tags.h
	${CC} ${CFLAGS} -c tags.c

nstrdup.o: nstrdup.c
	${CC} ${CFLAGS} -c nstrdup.c

clean:
	rm  -f ged2html *.o *~ #*
	cd doc; rm -f *~ #*

indiv.tpl: ged2html
	./ged2html -t - > indiv.tpl

index.tpl: ged2html
	./ged2html -T - > index.tpl

surname.tpl: ged2html
	./ged2html -S - > surname.tpl

sources.tpl: ged2html
	./ged2html -R - > sources.tpl

doc.htm: ${DOCS}
	cat ${DOCS} > doc.htm

register.exe: register.exe.uue
	uudecode < register.exe.uue
	gunzip register.exe.gz

register.hlp: register.hlp.uue
	uudecode < register.hlp.uue
	gunzip register.hlp.gz

release: COPYRIGHT README.1ST doc.htm \
		indiv.tpl index.tpl surname.tpl sources.tpl \
		Makefile ${HDRS} ${SRCS} ${DOCS} \
		ged2html.exe g2h.exe \
		register.exe register.hlp \
		doc/gedstand.t82 royal92.ged
	tar cfz release.tar.gz \
		COPYRIGHT README.1ST \
		indiv.tpl index.tpl surname.tpl sources.tpl \
		Makefile ${HDRS} ${SRCS} ${DOCS} \
		doc/gedstand.t82 royal92.ged
	zip release.zip \
		COPYRIGHT README.1ST doc.htm \
		indiv.tpl index.tpl surname.tpl sources.tpl \
		register.exe register.hlp \
		ged2html.exe g2h.exe \
		royal92.ged

