#
# Main Makefile for Thot/Amaya source tree
# Generated from Makefile.in
# Daniel Veillard, 1997
#

@VPATHOPT@= @srcdir@
THOTDIR = @top_srcdir@
THOTINCLUDES = @THOTINCLUDES@
LIBZ = @LIBZ@

include Options

LIBWWW	   = libwww
LIBRAPTOR  = libraptor
LIBJPEG	   = libjpeg
LIBPNG	   = libpng

#MKP: adding davlib
SUBDIRS	= @SUBDIRS@ tools thotlib tablelib batch drawlib indexlib annotlib amaya thot @DAVDIR@
EXTRA_SUBDIRS= misc pluginlib $(LIBRAPTOR) $(LIBWWW)

prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
bindir = @bindir@

srcdir	= $(THOTDIR)


default : tools thotlib tablelib batch amaya_prog @PRINTIFNOTGL@

amaya : amaya_prog tools thotlib tablelib @PRINTIFNOTGL@

print : tools thotlib tablelib print_prog

Options:
	@CP@ Options.orig Options

force :

batch: rebuild force
	@(if test -d batch ; then cd batch ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" ; fi)

tools: rebuild force
	@(if test -d tools ; then cd tools ; \
	  $(MAKE) CC="$(CC)" CFLAGS="-O" all ; fi)

thotlib: rebuild force
	@(if test -d thotlib ; then cd thotlib ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" all ; fi)

amaya_prog: rebuild force bin/str
	@(if test -d amaya ; then cd amaya ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" amaya ; fi)

print_prog: rebuild force bin/str
	@(if test -d thotlib ; then cd thotlib ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" print ; fi)

misc: rebuild force
	@(if test -d misc ; then cd misc ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" all ; fi)

all : rebuild
	@(for dir in $(SUBDIRS) ;\
	  do if test -d $$dir ; then cd $$dir ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" all ; \
	  cd .. ; fi ;done )

clean : rebuild
	$(RM) libpng.a libz.a libjpeg.a
	@(for dir in $(SUBDIRS) $(EXTRA_SUBDIRS) ;\
	  do if test -d $$dir ; then cd $$dir ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" clean ; \
	  cd .. ; fi ;done )

tempclean : 
	find ../ -name '.#*' -print0 | xargs -0r rm -f
	find ../ -name \*~ -exec rm {} \;
	find ../ \( -name '*~' -o -name '#*#' \) -print0 | xargs --no-run-if-empty --null rm -vf

install : rebuild
	@(for dir in $(SUBDIRS) ;\
	  do if test -d $$dir ; then cd $$dir ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" install ; \
	  cd .. ; fi ;done )

uninstall : 
	@(for dir in $(SUBDIRS) ;\
	  do if test -d $$dir ; then cd $$dir ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" uninstall ; \
	  cd .. ; fi ;done )

update :
	@(cd $(THOTDIR) ; cvs update -dP)
	@(if [ -d $(THOTDIR)/../$(LIBWWW) ] ; then \
	  cd $(THOTDIR)/../$(LIBWWW) ; cvs update -dP; fi)

commit :
	@(cd $(THOTDIR) ; cvs commit)

stubs:
	@(cd javalib ; $(MAKE) stubs)

classes: force
	@(PWD=`pwd` ; PATH="$$PWD/bin:$$PATH" ; export PATH ; \
	  if test -d $$PWD/$(THOTDIR) ; then CLASSES=$$PWD/$(THOTDIR)/classes;\
	  else CLASSES=$(THOTDIR)/classes ; fi ; \
	  CLASSPATH=".:$$CLASSES:$$CLASSES/classes.zip:$$CLASSES/thotlib.zip:$$CLASSES/jigsaw.zip:$$CLASSES/amaya.zip:$$CLASSES/biss.zip";export CLASSPATH;\
	  cd $(THOTDIR)/classes ; $(MAKE) )

zips: force
	@(cd javalib ;  $(MAKE) zips);

# 	@(PWD=`pwd` ; PATH="$$PWD/bin:$$PATH" ; export PATH ; \
# 	  if test -d $$PWD/$(THOTDIR) ; then CLASSES=$$PWD/$(THOTDIR)/classes;\
# 	  else CLASSES=$(THOTDIR)/classes ; fi ; \
# 	  CLASSPATH=".:$$CLASSES:$$CLASSES/classes.zip:$$CLASSES/thotlib.zip:\
# $$CLASSES/jigsaw.zip:$$CLASSES/amaya.zip:$$CLASSES/biss.zip";export CLASSPATH;\
# 	  cd $(THOTDIR)/classes ; $(MAKE) zips)

tools/mkdep/mkdep :
	@(cd tools/mkdep ; $(MAKE) CC="$(CC)" CFLAGS="-O" mkdep)

depend depends : rebuild tools/mkdep/mkdep
	@(for dir in $(SUBDIRS) ;\
	  do if test -d $$dir ; then cd $$dir ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" depend ; \
	  cd .. ; fi ;done )

bin/cextract :
	@(cd tools/cextract-$(CEXTRACT_VER) ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" cextract)

proto : rebuild bin/cextract
	@(for dir in $(SUBDIRS) ;\
	  do if test -d $$dir ; then cd $$dir ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" proto ; \
	  cd .. ; fi ;done )

mkid : 
	@(echo rebuilding $(THOTDIR)/ID reference file)
	@(cd $(THOTDIR); mkid --lang-map=makes/id-lang.map . classes/org/w3c/*)

#
# Rule du rebuild the Thot schemas
#

bin/str : force
	@(cd batch ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" str prs tra printstr)

schemas : rebuild bin/str
	@(bindir=`pwd`/bin ; cd $(THOTDIR)/schemas ; \
	  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" THOTDIR=".." THOTSCH="../schemas:../schemasOPERA" \
	  COMPSCH="."  COMPSTR="$$bindir/str" COMPPRS="$$bindir/prs" \
	  COMPTRA="$$bindir/tra" PRINTSTR="$$bindir/printstr" all)

#
# Rules to rebuild the libWWW package
#

# MKP: adding libwwwdav
AMAYA_LIBWWW_STANDARD_LIBS = \
	libwwwapp \
	libwwwhttp \
	libwwwhtml \
	libwwwmime \
	libwwwcache \
	libwwwstream \
	libwwwfile \
	libwwwdir \
	libwwwtrans \
	libwwwcore \
	libwwwutils \
	libwwwftp \
	@MAKE_LIBWWW_RDF_PARSER@ \
	libwwwzip \
        @LIBDAV@

libwww_config :
	@(if [ ! -d $(THOTDIR)/../$(LIBWWW) ] ; then \
	      $(ECHO) "Error libwww dir not found at $(THOTDIR)/../$(LIBWWW)" ; \
	  fi)
	@(if [ ! -d $(LIBWWW) ] ; then \
		$(MKDIR) $(LIBWWW) ; \
          fi)
#MKP: adding --with-dav
	@(localdir=`pwd` ; libwwwdir="$$localdir/../../$(LIBWWW)" ; \
	  cd $(LIBWWW) ; unset LANG; \
	  if [ ! -f Makefile -o ! -f wwwconf.h ] ; then \
	  	$$libwwwdir/configure \
			--disable-shared \
			@WITHDAV@ \
			--with-zlib; \
		$(ECHO) "libwww is configured" ; \
	  fi)

libwww_make_module_md5 \
libmd5 : force
		@(localdir=`pwd`; \
		 cd $(LIBWWW)/modules/md5 ; \
		 $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS) $(EXPAT_OPTIONS)" \
		 CPPFLAGS="$(CPPFLAGS) $(THOTINCLUDES)" \
	        	    libmd5.la)

libwww_install_module_md5 : force
		@(if [ -e libmd5.a -a ! -L libmd5.a ] ; then \
			$(RM) libmd5.a ; \
		  fi ; \
		  if [ ! -L libmd5.a ] ; then \
			$(LN_S) $(LIBWWW)/modules/md5/.libs/libmd5.a ./libmd5.a ; \
		  fi)

libwww_make_module_expat \
libexpat : force
		@(localdir=`pwd`; \
		  cd $(LIBWWW)/modules/expat/ ; \
		  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS) $(EXPAT_OPTIONS) -DXML_AMAYA" \
		  CPPFLAGS="$(CPPFLAGS)" \
	        	    )

libwww_install_module_expat : force
		@(if [ -e libxmlparse.a -a ! -L libxmlparse.a ] ; then \
			$(RM) libxmlparse.a ; \
		  fi ; \
		  if [ ! -L libxmlparse.a ] ; then \
			$(LN_S) $(LIBWWW)/modules/expat/xmlparse/.libs/libxmlparse.a ./libxmlparse.a ; \
		  fi)
		@(if [ -e libxmltok.a -a ! -L libxmltok.a ] ; then \
			$(RM) libxmltok.a ; \
		  fi ; \
		  if [ ! -L libxmltok.a ] ; then \
			$(LN_S) $(LIBWWW)/modules/expat/xmltok/.libs/libxmltok.a ./libxmltok.a ; \
		  fi)


libwww_make_standard_libs \
$(AMAYA_LIBWWW_STANDARD_LIBS) : force
		@(localdir=`pwd`; \
		  all_libs="" ; \
		  for lib in $(AMAYA_LIBWWW_STANDARD_LIBS) ; do \
		      all_libs="$$all_libs $$lib.la" ; \
		   done ; \
		  cd $(LIBWWW)/Library/src ; \
		  $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS) $(EXPAT_OPTIONS)" \
		  CPPFLAGS="$(CPPFLAGS) $(THOTINCLUDES)" \
			     $$all_libs)

libwww_install_standard : force
		@(for lib in $(AMAYA_LIBWWW_STANDARD_LIBS) ; do \
		    if [ -e $$lib.a -a ! -L $$lib.a ] ; then \
			$(RM) $$lib.a ;  \
		    fi ; \
		    if [ ! -L $$lib.a ] ; then \
			$(LN_S) $(LIBWWW)/Library/src/.libs/$$lib.a ./$$lib.a ; \
		    fi ; \
		done)

libwww_make_module_libs : libwww_make_module_md5 libwww_make_module_expat
libwww_make : libwww_make_module_libs libwww_make_standard_libs
libwww_install_modules : libwww_install_module_md5 libwww_install_module_expat
libwww_install : libwww_install_modules libwww_install_standard 

libwww : libwww_config libwww_make
		@($(ECHO) "libwww is installed")

#
# Rules to build the raptor RDF package
#

libraptor_config: @MAKERAPTOR@ force
	@(if [ ! -e "$(THOTDIR)/$(LIBRAPTOR)" ] ; then \
	      $(ECHO) "Error raptor dir not found at $(THOTDIR)/$(LIBRAPTOR)" ; \
	  fi)
	@(if [ ! -e "$(THOTDIR)/$(LIBRAPTOR)/expat" ] ; then \
	      libwwwdir="$(THOTDIR)/../$(LIBWWW)" ; \
	      echo $$libwwwdir ; \
	      $(LN_S) "$$libwwwdir/modules/expat" "$(THOTDIR)/$(LIBRAPTOR)/expat" ; \
	  fi)
	 @(if [ ! -d "$(LIBRAPTOR)" ] ; then \
		$(MKDIR) $(LIBRAPTOR) ; \
          fi)
	 @(localdir=`pwd` ; raptordir="$$localdir/../$(LIBRAPTOR)" ; \
	  cd $(LIBRAPTOR) ; unset LANG; \
	  if [ ! -f Makefile -o ! -f config.h ] ; then \
	  	CFLAGS="-I$$raptordir/expat/xmlparse" \
			$$raptordir/configure \
			--without-shared \
			--with-expat ; \
		$(ECHO) "libraptor is configured" ; \
	  fi)

libraptor_make: @MAKERAPTOR@ force
	@(localdir=`pwd`; \
	  cd $(LIBRAPTOR) ; \
	  if [ ! -e .libs/libraptor.a -a -e libraptor.la ] ; then \
             $(RM) libraptor.la ; \
          fi ; \
	  $(MAKE) CC="$(CC)" CFLAGS="-I$$localdir/../$(LIBRAPTOR)/expat/xmlparse $(CFLAGS)" \
		  CPPFLAGS="$(CPPFLAGS)" \
	)

libraptor: @MAKERAPTOR@ libraptor_config libraptor_make
	@($(ECHO) "libraptor is installed")

#
# Rules to rebuild the libjpeg package
#

libjpeg libjpeg.a : force
	@($(RM) $(THOTDIR)/libjpeg/*.o)
	@(cd libjpeg ; $(MAKE) CC="$(CC)" CFLAGS="-O")

#
# Rules to rebuild the libpng package
#

libpng libpng.a : force
	@($(RM) $(THOTDIR)/libpng/*.o)
	@(cd libpng ; $(MAKE) CC="$(CC)" CFLAGS="-O")

#
# Rules to rebuild the libpng package
#

libz libz.a : force
	@($(RM) $(THOTDIR)/libpng/libz/*.o)
	@(cd libpng/zlib ; $(MAKE) CC="$(CC)" CFLAGS="-O")


#
# This section try to maintain the Makefile(s) up-to-date in
# case the autoconf sources are modified.
#

MAKEFILE_IN= \
@EXTRA_MAKEFILE_IN@ \
$(THOTDIR)/Options.in \
$(THOTDIR)/configure.in \
$(THOTDIR)/Makefile.in \
$(THOTDIR)/libjpeg/Makefile.in \
$(THOTDIR)/batch/Makefile.in \
$(THOTDIR)/libjpeg/Makefile.in \
$(THOTDIR)/libpng/Makefile.in \
$(THOTDIR)/libpng/zlib/Makefile.in \
$(THOTDIR)/tablelib/Makefile.in \
$(THOTDIR)/thotlib/Makefile.in \
$(THOTDIR)/thotlib/include/Makefile.in \
$(THOTDIR)/tools/Makefile.in \
$(THOTDIR)/tools/mkdep/Makefile.in \
$(THOTDIR)/tools/cextract-1.7/Makefile.in

rebuild : tools/mkdep/mkdep Makefile

${srcdir}/config.h.in: stamp-h.in

${srcdir}/stamp-h.in: configure.in config.h.in
	cd ${srcdir} && autoheader
	echo timestamp > ${srcdir}/stamp-h.in

stamp.h: config.h.in config.status
	./config.status

Makefile: $(MAKEFILE_IN) config.status
	./config.status

config.status: configure
	./config.status --recheck

tags:	dummy
	rm -f ../TAGS
	find ../ -name "*.[hc]" -print | xargs etags --declarations -a -o ../TAGS

dummy:


