EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@

LDFLAGS = @LDFLAGS@

#Some Users might have problems with linking against -lz, this is because there is probably an
#old version of it hanging around in the X dirs, you can add -L/usr/lib to the begging of there 
#options to fix it.
#LIBS = -L/usr/lib @MAGICK_LIBS@ @ZLIB_LIBS@ @LIBS@ @WMF_LIBS@ @TTF_LIBS@ @XPM_LIBS@ @X_LIBS@ @X11@ @X_EXTRA_LIBS@ -lm
LIBS =  @MAGICK_LIBS@ @LIB_PNG@ @ZLIB_LIBS@ @LIBS@ @WMF_LIBS@ @TTF_LIBS@ @XPM_LIBS@ @X_LIBS@ @X11@ @X_EXTRA_LIBS@ -lm

GETOPT = @LIBOBJS@

ICONV = @ICONV@
RICONVOBJS = \
iconv/codepage-874.$(OBJEXT)    \
iconv/codepage-1250.$(OBJEXT)   \
iconv/codepage-1251.$(OBJEXT)   \
iconv/codepage-1254.$(OBJEXT)   \
iconv/codepage-1257.$(OBJEXT)   \
iconv/codepage-1252.$(OBJEXT)   \
iconv/codepage-1255.$(OBJEXT)   \
iconv/codepage-1253.$(OBJEXT)   \
iconv/codepage-1256.$(OBJEXT)   \
iconv/koi8-r.$(OBJEXT)          \
iconv/iso-8859-15.$(OBJEXT)     \
iconv/tis-620.$(OBJEXT)         \
iconv/utf-8.$(OBJEXT)           \
iconv/iconv.$(OBJEXT)
ICONVOBJS =  @ICONVOBJS@

MAGICK = @MAGICK@
RMAGICKOBJS = \
magick/magick.$(OBJEXT) \
magick/image.$(OBJEXT) \
magick/blob.$(OBJEXT) \
magick/colors.$(OBJEXT) \
magick/error.$(OBJEXT) \
magick/transform.$(OBJEXT) \
magick/compress.$(OBJEXT) \
magick/memory.$(OBJEXT) \
magick/utility.$(OBJEXT) \
magick/png.$(OBJEXT) \
magick/bmp.$(OBJEXT) \
magick/signature.$(OBJEXT)
MAGICKOBJS =  @MAGICKOBJS@

#abi's picky warning checks
#CC = @CC@ -Wall -W -ansi -pedantic

CC = @CC@

LEX = @LEX@

SHELL=/bin/sh

RANLIB = @RANLIB@

AR = ar

LN = ln

INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@

@SET_MAKE@

prefix=@prefix@
exec_prefix=@exec_prefix@
srcdir=@srcdir@
bindir=@bindir@
libdir=@libdir@
mandir=@mandir@
includedir = @includedir@
PERL = @PERL@

VPATH = @srcdir@

CFLAGS = @CFLAGS@ @DEFS@ @ZLIB_CFLAGS@ -I. -I./ -I$(srcdir)/ -I$(srcdir)/getopt-wv/ -I$(srcdir)/iconv/ -I$(srcdir)/magick/ -I$(srcdir)/expat/xmlparse/ @TTF_CFLAGS@ @WMF_CFLAGS@ -DTTFDIR=\"$(libdir)/wv/ttf\" -DXMLCONFIG=\"$(libdir)/wv/wvConfig.xml\" -DHTMLCONFIG=\"$(libdir)/wv/wvHtml.xml\" 

CFLAGS += \
	-I$(srcdir)/libole2/ \
	-I$(srcdir)/glib-wv/ \
	-I$(srcdir)/oledecod/ 
	

MKINSTALLDIRS = $(srcdir)/mkinstalldirs

SHELL = /bin/sh

.SUFFIXES: .C .$(OBJEXT)

MYOBJECTS =	\
	support.$(OBJEXT) \
	list.$(OBJEXT) \
	piecetable.$(OBJEXT) \
	stylesheet.$(OBJEXT) \
	sprm.$(OBJEXT) \
	blip.$(OBJEXT) \
	utf.$(OBJEXT) \
	field.$(OBJEXT) \
	references.$(OBJEXT) \
	gpprl.$(OBJEXT) \
	papchpsep.$(OBJEXT) \
	hyperlink.$(OBJEXT) \
	decompresswmf.$(OBJEXT) \
	annotations.$(OBJEXT) \
	dop.$(OBJEXT) \
	roman.$(OBJEXT) \
	fib.$(OBJEXT) \
	frd.$(OBJEXT) \
	atrd.$(OBJEXT) \
	sed.$(OBJEXT) \
	font.$(OBJEXT) \
	ffn.$(OBJEXT) \
	fld.$(OBJEXT) \
	bkf.$(OBJEXT) \
	dttm.$(OBJEXT) \
	generic.$(OBJEXT) \
	error.$(OBJEXT) \
	unicode.$(OBJEXT) \
	sttbf.$(OBJEXT) \
	xst.$(OBJEXT) \
	fspa.$(OBJEXT) \
	fdoa.$(OBJEXT) \
	lst.$(OBJEXT) \
	lvl.$(OBJEXT) \
	lfo.$(OBJEXT) \
	nfc.$(OBJEXT) \
	ordinal.$(OBJEXT) \
	summary.$(OBJEXT) \
	filetime.$(OBJEXT) \
	chp.$(OBJEXT) \
	brc.$(OBJEXT) \
	anld.$(OBJEXT) \
	shd.$(OBJEXT) \
	dcs.$(OBJEXT) \
	numrm.$(OBJEXT) \
	asumyi.$(OBJEXT) \
	version.$(OBJEXT) \
	lspd.$(OBJEXT) \
	phe.$(OBJEXT) \
	tlp.$(OBJEXT) \
	tc.$(OBJEXT) \
	tap.$(OBJEXT) \
	pap.$(OBJEXT) \
	bintree.$(OBJEXT) \
	decode_simple.$(OBJEXT) \
	pcd.$(OBJEXT) \
	prm.$(OBJEXT) \
	clx.$(OBJEXT) \
	bte.$(OBJEXT) \
	bx.$(OBJEXT) \
	fkp.$(OBJEXT) \
	text.$(OBJEXT) \
	decode_complex.$(OBJEXT) \
	wvTextEngine.$(OBJEXT) \
	wvHtmlEngine.$(OBJEXT) \
	wvConfig.$(OBJEXT) \
	wvparse.$(OBJEXT) \
	reasons.$(OBJEXT) \
	sep.$(OBJEXT) \
	anlv.$(OBJEXT) \
	olst.$(OBJEXT) \
	asumy.$(OBJEXT) \
	bkd.$(OBJEXT) \
	bkl.$(OBJEXT) \
	dogrid.$(OBJEXT) \
	doptypography.$(OBJEXT) \
	pgd.$(OBJEXT) \
	rs.$(OBJEXT) \
	rr.$(OBJEXT) \
	tbd.$(OBJEXT) \
	ftxbxs.$(OBJEXT) \
	wkb.$(OBJEXT) \
	graphics.$(OBJEXT) \
	picf.$(OBJEXT) \
	crc32.$(OBJEXT) \
	md5.$(OBJEXT) \
	rc4.$(OBJEXT) \
	decrypt97.$(OBJEXT) \
	decrypt95.$(OBJEXT) \
	twips.$(OBJEXT) \
	table.$(OBJEXT) \
	symbol.$(OBJEXT) \
	fopt.$(OBJEXT) \
	fbse.$(OBJEXT) \
	escher.$(OBJEXT) \
	bmptopng.$(OBJEXT) \
	basename.$(OBJEXT) \
	laolareplace.$(OBJEXT) 
	
OLE = \
	libole2/ms-ole.$(OBJEXT) \
	glib-wv/garray.$(OBJEXT) \
	glib-wv/gmem.$(OBJEXT) \
	glib-wv/gslist.$(OBJEXT) \
	glib-wv/gtree.$(OBJEXT) \
	glib-wv/glist.$(OBJEXT) \
	glib-wv/gmessages.$(OBJEXT) \
	glib-wv/gstrfuncs.$(OBJEXT) \
	oledecod/oledecod.$(OBJEXT)
	

#XML = -Lexpat/lib -lxmlparse -lxmltok
XML = 	expat/xmlparse/xmlparse.$(OBJEXT) \
    	expat/xmlparse/hashtable.$(OBJEXT) \
		expat/xmltok/xmltok.$(OBJEXT) \
    	expat/xmltok/xmlrole.$(OBJEXT)


all: wvSummary$(EXEEXT) wvHtml$(EXEEXT) wvConvert$(EXEEXT) wvText$(EXEEXT) wvSimpleCLX$(EXEEXT) wvVersion$(EXEEXT) wv-libconfig wv-incconfig

wvSummary$(EXEEXT): wvSummary.$(OBJEXT) $(GETOPT) OLEDECODE LIBOLE2 libwv.a 
	$(CC)  -o $@ wvSummary.$(OBJEXT) $(GETOPT) -L. -lwv $(LIBS) $(LDFLAGS)

wvSimpleCLX$(EXEEXT): wvSimpleCLX.$(OBJEXT) $(GETOPT) OLEDECODE LIBOLE2 libwv.a
	$(CC)  -o $@ wvSimpleCLX.$(OBJEXT) $(GETOPT) -L. -lwv $(LIBS) $(LDFLAGS)

wvVersion$(EXEEXT): wvVersion.$(OBJEXT) $(GETOPT) OLEDECODE LIBOLE2 libwv.a
	$(CC)  -o $@ wvVersion.$(OBJEXT) $(GETOPT) -L. -lwv $(LIBS) $(LDFLAGS)

wvConvert$(EXEEXT): wvConvert.$(OBJEXT) $(GETOPT) OLEDECODE LIBOLE2 libwv.a
	$(CC)  -o $@ wvConvert.$(OBJEXT) $(GETOPT) -L. -lwv $(LIBS) $(LDFLAGS)

wvText$(EXEEXT): wvConvert$(EXEEXT)
	$(LN) -s wvConvert$(EXEEXT) wvText$(EXEEXT)

wvHtml$(EXEEXT): wvHtml.$(OBJEXT) $(GETOPT) OLEDECODE LIBOLE2 libwv.a
	$(CC)  -o $@ wvHtml.$(OBJEXT) $(GETOPT) -L. -lwv $(LIBS) $(LDFLAGS)

wvGraphicConvert$(EXEEXT): wvGraphicConvert.$(OBJEXT) $(GETOPT) OLEDECODE LIBOLE2 libwv.a
	$(CC)  -o $@ wvGraphicConvert.$(OBJEXT) $(GETOPT) -L. -lwv $(LIBS) $(LDFLAGS)

wv-libconfig: Makefile
	rm -f wv-libconfig
	echo \#\!/bin/sh > wv-libconfig
	echo echo -L$(libdir) -lwv $(LIBS) $(LDFLAGS) >> wv-libconfig

wv-incconfig: Makefile
	rm -f wv-incconfig
	echo \#\!/bin/sh > wv-incconfig
	echo echo @ZLIB_CFLAGS@ -I$(includedir) @WMF_CFLAGS@ >> wv-incconfig

lex.yy.c: parser.lex
	$(LEX) parser.lex

testparse$(EXEEXT):  testparse.$(OBJEXT) $(GETOPT) OLEDECODE LIBOLE2 libwv.a
	$(CC)  -o $@ testparse.$(OBJEXT) $(GETOPT) -L. -lwv $(LIBS)  $(LDFLAGS)

error.$(OBJEXT): $(srcdir)/error.c Makefile
	$(CC) $(CFLAGS) -c $(srcdir)/$*.c 

laolareplace.$(OBJEXT): $(srcdir)/laolareplace.c 
	$(CC) $(CFLAGS) -c $(srcdir)/$*.c 

libwv.a:	$(MYOBJECTS) XMLPARSER $(ICONV) $(MAGICK) OLEDECODE LIBOLE2
	$(AR) rc $@ $(MYOBJECTS) $(ICONVOBJS) $(MAGICKOBJS) $(XML) $(OLE)
	$(RANLIB) $@

ICONV:
	@echo making iconv in iconv
	@(cd iconv && $(MAKE)) || exit 1

MAGICK:
	@echo making magick in magick  
	@(cd magick && $(MAKE)) || exit 1


OLEDECODE:
	@echo making oledecod in oledecod
	@(cd oledecod && $(MAKE)) || exit 1


XMLPARSER:
	@echo making expat in expat
	@(cd expat && $(MAKE)) || exit 1

LIBOLE2:	GLIB-WV
	@echo making libole2 in libole2
	@(cd libole2 && $(MAKE)) || exit 1
	
GLIB-WV:
	@echo making glib-wv in glib-wv
	@(cd glib-wv && $(MAKE)) || exit 1

%.$(OBJEXT): $(srcdir)/%.c 
	$(CC) $(CFLAGS) -c $(srcdir)/$*.c 

cleansub:
	@echo cleaning oledecod in oledecod
	@(cd oledecod && $(MAKE) clean) || exit 1
	@echo cleaning expat in expat
	@(cd expat && $(MAKE) clean) || exit 1
	@echo cleaning iconv in iconv 
	@(cd iconv && $(MAKE) clean) || exit 1
	@echo cleaning magick in magick
	@(cd magick && $(MAKE) clean) || exit 1
	@echo cleaning libole2 in libole2
	@(cd libole2 && $(MAKE) clean) || exit 1
	@echo cleaning glib-wv in glib-wv
	@(cd glib-wv && $(MAKE) clean) || exit 1
	
clean: cleansub
	rm -rf *.$(OBJEXT) $(GETOPT) wvHtml$(EXEEXT) wvConvert$(EXEEXT) wvText$(EXEEXT) wvSummary$(EXEEXT) wvVersion$(EXEEXT) wvSimpleCLX$(EXEEXT) wvGraphicConvert$(EXEEXT) core a.$(OBJEXT)ut *.a

distclean: realcleansub
	rm -rf analyze config.cache config.status config.log Makefile config.h *.a *.$(OBJEXT) wv-incconfig wv-libconfig wvSummary$(EXEEXT) wvVersion$(EXEEXT) wvSimpleCLX$(EXEEXT) wvHtml$(EXEEXT) wvConvert$(EXEEXT) wvText$(EXEEXT) wvGraphicConvert$(EXEEXT) core out* analyze/* .pure lex.yy.c libtool

realclean: distclean

realcleansub:
	@echo real cleaning oledecod in oledecod
	@(cd oledecod && $(MAKE) realclean) || exit 1
	@echo real cleaning expat in expat
	@(cd expat && $(MAKE) realclean) || exit 1
	@echo real cleaning iconv in iconv 
	@(cd iconv && $(MAKE) realclean) || exit 1
	@echo real cleaning magick in magick
	@(cd magick && $(MAKE) realclean) || exit 1
	@echo real cleaning libole2 in libole2
	@(cd libole2 && $(MAKE) realclean) || exit 1
	@echo real cleaning gilb-wv in glib-wv
	@(cd glib-wv && $(MAKE) realclean) || exit 1

installdirs:
	$(MKINSTALLDIRS) $(bindir) \
	$(mandir) \
	$(mandir)/man1 \
	$(libdir) \
	$(libdir)/wv\
	$(libdir)/wv/wingdingfont \
	$(libdir)/wv/patterns \
	$(libdir)/wv/ttf \
	$(includedir)
	

install: installdirs all
	$(INSTALL) $(srcdir)/wvSummary$(EXEEXT) $(bindir)/wvSummary$(EXEEXT)
	$(INSTALL) $(srcdir)/wvSimpleCLX$(EXEEXT) $(bindir)/wvSimpleCLX$(EXEEXT)
	$(INSTALL) $(srcdir)/wvVersion$(EXEEXT) $(bindir)/wvVersion$(EXEEXT)
	$(INSTALL) $(srcdir)/wvConvert$(EXEEXT) $(bindir)/wvConvert$(EXEEXT)
	$(RM) -f $(bindir)/wvText$(EXEEXT)
	$(LN) -s $(bindir)/wvConvert$(EXEEXT) $(bindir)/wvText$(EXEEXT)
	$(INSTALL) $(srcdir)/wvHtml$(EXEEXT) $(bindir)/wvHtml$(EXEEXT)
	$(INSTALL) $(srcdir)/wv-libconfig $(bindir)/wv-libconfig
	$(INSTALL) $(srcdir)/wv-incconfig $(bindir)/wv-incconfig
	$(INSTALL_DATA) $(srcdir)/wvHtml.1 $(mandir)/man1/
	$(INSTALL_DATA) wv.h $(includedir)/wv.h
	$(INSTALL_DATA) $(srcdir)/libwv.a $(libdir)/libwv.a
	$(INSTALL_DATA) $(srcdir)/wvHtml.xml $(libdir)/wv/wvHtml.xml
	$(INSTALL_DATA) $(srcdir)/wvConfig.xml $(libdir)/wv/wvConfig.xml
	for filename in wingdingfont/*.gif; do \
		$(INSTALL_DATA) $$filename $(libdir)/wv/wingdingfont; \
	done
	for filename in patterns/*.gif patterns/*.jpg; do \
		$(INSTALL_DATA) $$filename $(libdir)/wv/patterns; \
	done



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