prefix	= ../../../..
exec_prefix = ${prefix}
bindir	= ${exec_prefix}/bin

CC	= gcc
CFLAGS	= -I/data/davidb/greenstone3-svn-mingw/gs2build/ext/gnome-lib/linux/include 
EXEEXT	= 

INSTALL = /usr/bin/install -c

# I've renamed it rtftohtm as win3.1 needs <= 8 letters... jrm21
# libdir, relative to bindir
RELATIVELIBDIR=../../etc/packages/rtftohtm
# for installation...
LIBDIR=../$(RELATIVELIBDIR)

IDIRS=-ILibs/OTHER -ILibs/h

TRFILES=ansi.gen cpg1252.gen html-map mac.gen pc.gen pca.gen \
	ansi.sym cpg1252.sym html-trn mac.sym pc.sym pca.sym \
	Libs/lib/rtf-ctrl 

OBJS= htmlout.o transinit.o html-unix.o rtftohtml.o

LIBRARIES=Libs/OTHER/libtokenscan.a Libs/lib/librtf.a Libs/lib-unix/lib-unix.a



all: rtftohtml$(EXEEXT)

rtftohtml$(EXEEXT): $(LIBRARIES) $(OBJS)
	$(CC)   $(CFLAGS) $(OBJS) $(LIBRARIES) -o rtftohtml$(EXEEXT)

#install: all $(TRFILES)
install: all
	$(INSTALL) rtftohtml$(EXEEXT) $(bindir)
## conf files are now in Greenstone CVS.
#	mkdir -p $(LIBDIR)
#	chmod 644 $(TRFILES)
#	cp $(TRFILES) $(LIBDIR)

clean:	
	cd Libs/h ; $(MAKE) $(MFLAGS) clean
	cd Libs/lib ; $(MAKE) $(MFLAGS) clean
	cd Libs/OTHER ; $(MAKE) $(MFLAGS) clean
	cd Libs/lib-unix ; $(MAKE) $(MFLAGS) clean
	rm -f $(OBJS) rtftohtml 

distclean: clean
	rm -f Makefile Libs/h/Makefile Libs/lib/Makefile Libs/lib-unix/Makefile Libs/OTHER/Makefile config.status config.cache config.log

$(LIBRARIES):
	cd Libs/OTHER ; $(MAKE) $(MFLAGS)
	cd Libs/h ; $(MAKE) $(MFLAGS)
	cd Libs/lib ; $(MAKE) $(MFLAGS)
	cd Libs/lib-unix ; $(MAKE) $(MFLAGS) CFLAGS='$(CFLAGS) -DLIBDIR=\"$(RELATIVELIBDIR)\"'
#		$(MAKE) $(MFLAGS) CFLAGS='$(CFLAGS) -DLIBDIR=\"$(LIBDIR)\"

rtftohtml.o:	rtftohtml.c rtftohtml.h Libs/h/rtf.h 
	$(CC)   $(CFLAGS) -c $(IDIRS) $*.c

html-unix.o:	html-unix.c Libs/h/rtf-unix.h
	$(CC)   $(CFLAGS) -c $(IDIRS) $*.c

htmlout.o:	htmlout.c rtftohtml.h Libs/h/rtf.h
	$(CC)   $(CFLAGS) -c $(IDIRS) $*.c

transinit.o:	transinit.c rtftohtml.h Libs/h/rtf.h Libs/OTHER/tokenscan.h
	$(CC)   $(CFLAGS) -c $(IDIRS) $*.c


