NAME	= libdom
VERSION	= 0.01

CC	= @CC@
CXX	= @CXX@ 
#CC	= insight

CFLAGS	= @CFLAGS@
CXXFLAGS= @CXXFLAGS@

#CFLAGS	= -Wall -g -DDEBUG
#CFLAGS	= -Wall -O6

MICO	= /gnome/mico
MICOIDL	= $(MICO)/idl/idl
MICOCXX	= $(MICO)/admin/mico-c++
MICOLD	= $(MICO)/admin/mico-ld
MICOINCL= -I$(MICO)/include -I$(MICO)/include/ministl


INCL	= -DHAVE_CONFIG_H -I.
EXTRAFLAGS= -Wall

RM	= @RM@ -f
MV	= @MV@ 
LN	= @LN_S@

prefix	= @prefix@
exec_prefix= @exec_prefix@
bindir	= @bindir@
libdir	= @libdir@
sysconfdir = @sysconfdir@
datadir	= @datadir@
mandir	= @prefix@/man
srcdir	= @srcdir@

OBJS	= DOM.o Attribute.o NodeIterator.o TreeIterator.o AttributeList.o \
          Element.o Node.o Text.o Document.o DocumentContext.o
SRCS	= DOM.c Attribute.c NodeIterator.c TreeIterator.c AttributeList.c \
          Element.c Node.c Text.c Document.c DocumentContext.c \
	  DOM.h Attribute.h NodeIterator.h TreeIterator.h AttributeList.h \
          Element.h PI.h node.h Comment.h Node.h Text.h Document.h \
	  DocumentContext.h \
          dom-core.idl dom-xml.idl

FILES	= configure configure.in config.h.in install-sh stamp-h.in Makefile.in \
          $(SRCS)

%.o: %.c
	$(CC) $(CFLAGS) $(EXTRAFLAGS) $(INCL) -c $<
 
%.o: %.cc
	$(CXX) $(CXXFLAGS) $(INCL) -c $<

all : core

core : $(OBJS) # dom-core.o dom-core-glue.o

clean :
	$(RM) *.o dom-core.cc dom-core.h core libdom.a

dom-core.cc dom-core.h: $(srcdir)/dom-core.idl
	$(MICOIDL) $(srcdir)/dom-core.idl

dom-core.o : dom-core.cc dom-core.h
	$(MICOCXX) $(INCL) $(MICOINCL) -c dom-core.cc

dom-core-glue.o : dom-core-glue.cc dom-core.h
	$(MICOCXX) $(INCL) $(MICOINCL) -c dom-core-glue.cc

depends .depends: $(srcdir)/*.h
	$(CC) $(CFLAGS) -MM *.c > .depends

tests : tester
	@(for i in test/* ; do \
	  if [ ! -d $$i ] ; then \
	  if [ ! -f result/`basename $$i` ] ; then \
	      echo New test file `basename $$i` ; \
	      ./tester $$i > result/`basename $$i` ; \
	  else \
	      echo Testing `basename $$i` ; \
	      ./tester $$i > result.`basename $$i` ; \
	      diff result/`basename $$i` result.`basename $$i` ; \
	      rm result.`basename $$i` ; \
	  fi ; fi ; done)


install : libdom.a
	if [ ! -d $(libdir) ] ; then \
	   @INSTALL@ -d $(libdir) ;\
	fi
	@INSTALL@ -m 644 libdom.a $(libdir)

uninstall :
	$(RM) $(libdir)/libdom.a

include .depends

distrib : clean
	@$(LN) . $(NAME)-$(VERSION)
	@($(TAR) cvf - `for i in $(FILES) ; do echo $(NAME)-$(VERSION)/$$i ; \
	  done` | $(GZIP) > $(NAME)-$(VERSION).tar.gz)
	@$(RM) $(NAME)-$(VERSION)

#
# This section try to maintain the Makefile(s) up-to-date in
# case the autoconf sources are modified.
#
MAKEFILE_IN= \
	$(srcdir)/configure.in \
	$(srcdir)/Makefile.in

$(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


