/*
Copyright (c) 1991, 1992, 1993 Xerox Corporation.  All Rights Reserved.  

Unlimited use, reproduction, and distribution of this software is
permitted.  Any copy of this software must include both the above
copyright notice of Xerox Corporation and this paragraph.  Any
distribution of this software must comply with all applicable United
States export control laws.  This software is made available AS IS,
and XEROX CORPORATION DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE, AND NOTWITHSTANDING ANY OTHER
PROVISION CONTAINED HEREIN, ANY LIABILITY FOR DAMAGES RESULTING FROM
THE SOFTWARE OR ITS USE IS EXPRESSLY DISCLAIMED, WHETHER ARISING IN
CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, EVEN IF
XEROX CORPORATION IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

$Id: Imakefile,v 1.41 1997/11/07 06:28:16 janssen Exp $
*/

LOCALINCLUDES = -I../../runtime/kernel
DEFINES = -DDEFAULT_INTERFACE_PATH=\".:$(ILUHOME)/interfaces\" -DILU_INTERFACE_HOME=\"$(ILUHOME)/interfaces\" -DIDL2ISL_BINDIR=\"$(DESTDIR)/bin\"
ILUCINCLUDES =

NormalObjectRule()

scan.o : scan.c
shs.o : shs.c shs.h
typeuid.o : typeuid.c shs.h
util.o : util.c iluptype.h
iluptype.h : iluconf.h
iluparse.o : iluconf.h

#ifdef ADD_DIRECT_OMG_IDL_SUPPORT
DISTMAKE = cd ../idl ; make idlparser.o idlscan.o
DISTCLEAN = cd ../idl ; rm -f idlparser.o idlscan.o
IDLOBJS = ../idl/idlparser.o ../idl/idlscan.o
#else
DISTMAKE = :
DISTCLEAN = :
IDLOBJS = :
#endif

$(IDLOBJS) :
	$(DISTMAKE)

LibraryTarget(libilu-parser.a, iluparse.o typeuid.o shs.o pathname.o malloc.o util.o aprintf.o $(IDLOBJS))
ProgramTarget(islscan, scan.o, libilu-parser.a,)

iluconf.h : ../../runtime/kernel/iluconf.h
	-rm -f iluconf.h
	cp ../../runtime/kernel/iluconf.h .

iluparse.c iluparse.h:	iluparse.c.dist iluparse.h.dist
	-rm -f iluparse.c iluparse.h
	cp iluparse.c.dist iluparse.c
	cp iluparse.h.dist iluparse.h

dist:: iluparse.c.dist iluparse.h.dist

iluparse.c.dist iluparse.h.dist: ilu.bison
	$(BISON) -p iluparse -d ilu.bison
	-rm -f iluparse.c iluparse.h.dist
	mv ilu.bison.tab.c iluparse.c.dist
	mv ilu.bison.tab.h iluparse.h.dist

CleanTarget(iluparse.c iluparse.h)

InstallProgram(islscan, $(DESTDIR)/bin)
InstallRO(libilu-parser.a, $(DESTDIR)/lib)
InstallRO(iluptype.h, $(DESTDIR)/include)
InstallRO(ilu.isl, $(DESTDIR)/interfaces)
InstallRO(iluhttp.isl, $(DESTDIR)/interfaces)
InstallRO(islscan.1, $(DESTDIR)/man/man1)

/* Generate, in ../../runtime/kernel/ilutpcod.{c,h}, a set of registrations
   for the ILU built-in types, including their type ID as calculated by
   the code in ./typeuid.c.
*/

dist::
	rm -f version.h
	( echo "#define ILU_VERSION $(RELNUM)" ; echo "#define ILU_VERSION_STRING \"$(RELNUM)\"" ) >version.h
	( echo "#define ILU_MAJOR_VERSION $(RELNUM)" | sed -e 's/\([0-9]*\)\..*/\1/' ) >>version.h 
	( echo "#define ILU_MINOR_VERSION $(RELNUM)" | sed -e 's/\([0-9]*\)\.\([0-9]*\).*/\2/' ) >>version.h 
	chmod 444 version.h

dist::
	$(DISTMAKE)
	make genregs
	-rm -f ../../runtime/kernel/ilutpcod.c ../../runtime/kernel/ilutpcod.h
	./genregs "../../runtime/kernel/ilutpcod"
	-rm -f genregs *.o *.a
	$(DISTCLEAN)

genregs: version.h genregs.o libilu-parser.a
	$(ANSI_C_COMPILER) -o genregs $(CFLAGS) genregs.c libilu-parser.a
