/* ********************************************************************** *\
 *         Copyright IBM Corporation 1988,1991 - All Rights Reserved      *
 *        For full copyright information see:'andrew/config/COPYRITE'     *
\* ********************************************************************** */
#ifdef _IBMR2
BSDLIB = -lbsd
#endif 

YFLAGS = -d -v

TOKENS = ../tokens
LOCALINCLUDES = -I${TOKENS}
DEFINES = -DYYDEBUG

INTERPOBJS = interp.o gen.o dump.o search.o  error.o  nevent.o  call.o real.o
NESSOBJS =  ness.o  nesscomp.o   ${INTERPOBJS}

DOBJS = ness.do nessv.do nessmark.do nesssym.do nessruna.do
IHFILES = ness.ih nessv.ih nessmark.ih nesssym.ih 
OBJS = ${NESSOBJS} nessv.o nessmark.o 


#ifdef WM_ENV
WMLIB = 	${BASEDIR}/lib/libwm.a
#endif /* WM_ENV */


ATKLIBS=	${BASEDIR}/lib/atk/libframe.a  \
		${BASEDIR}/lib/atk/libtext.a  \
		${BASEDIR}/lib/atk/libsupport.a  \
		${BASEDIR}/lib/atk/libsupviews.a \
		${BASEDIR}/lib/atk/libbasics.a
LIBS =		${ATKLIBS}  \
		${BASEDIR}/lib/libclass.a  \
		${MALLOCLIB}  \
		${BASEDIR}/lib/liberrors.a  \
		${UTILLIB}   \
		${WMLIB}

#ifdef LIBDL_ENV
/*
 * We have to make sure the "shared" directory is made when we do "depend",
 * because to do a "depend" we need the ".h" files, to get the ".h" files
 * we need to have "nodeclass" built", to get "nodeclass" built we need
 * to have "nodeclss.o" built, and with the generic ".c.o" rule, in order
 * to have "nodeclss.o" built we need the "shared" subdirectory.
 */
depend::
	@if [ ! -d shared ]; then mkdir shared; else exit 0; fi
#endif

all:: init

NormalObjectRule()
NormalATKRule()

.SUFFIXES: .h .hn
.hn.h:
	$(RM) $*.h
	./nodeclass $*.hn

call.h nevent.h gen.h compdefs.h: nodeclass

init:: call.h nevent.h gen.h compdefs.h

ProgramTarget(nodeclass, nodeclss.o, , )


InstallClassFiles($(DOBJS),$(IHFILES))
DynamicMultiObject(ness.do, ${NESSOBJS}, ${BASEDIR}/lib/atk/libbasics.a ${UTILLIB}, -lm ${BSDLIB})
DynamicMultiObject(nessv.do, nessv.o, ${BASEDIR}/lib/atk/libbasics.a, -lm)


/* nesscomp.c is distributed with the sources to avoid getting the local
yaccpar.  nesscomp.c should be remade whenever nesscomp.gra changes, but
then it would be remade even if the times of extraction of the sources
was in the wrong order.  So the dependency on nesscomp.gra is omitted.

(Suggestions for a better method are welcome.)
*/
nesscomp.c:: nesscomp.gra  ${TOKENS}/yaccpar ${TOKENS}/buildy ${TOKENS}/reyacc
	echo "nesscomp.c NOT REBUILT FROM nesscomp.gra"
# nesscomp.c:: nesscomp.gra ${TOKENS}/yaccpar ${TOKENS}/buildy ${TOKENS}/reyacc
#
#	${TOKENS}/buildy nesscomp.gra nesscomp.z
#	$(YACC) ${YFLAGS} $*.z
#	-$(RM) $*.c
#	$(RM) $*.z
#	$(MV) y.tab.c $*.c	
#	${TOKENS}/reyacc $*.c ${TOKENS}/yaccpar

LibraryTarget(libness.a, $(OBJS))
InstallLibrary(libness.a, ${DESTDIR}/lib/atk)

ClassTestProgramTarget(nesst, nesst.o, ${LIBS} /usr/lib/libm.a, ${BSDLIB})
ClassTestProgramTarget(goodness, goodness.o ${NESSOBJS} nessmark.o  nesssym.o , ${TOKENS}/libtokens.a ${LIBS}, -lm ${BSDLIB})
ClassTestProgramTarget(nessrun, nessrun.o ${NESSOBJS} nessmark.o  nesssym.o , ${TOKENS}/libtokens.a ${LIBS}, -lm ${BSDLIB})

/* InstallProgram(nessrun, ${DESTDIR}/bin) */
InstallLink(runapp, ${DESTDIR}/bin/ness)
InstallLink(runapp, ${DESTDIR}/bin/nessrun)
InstallFile(nesswarn.d, ${INSTMANFLAGS}, ${DESTDIR}/lib/ness)
InstallFile(error.h, $(INSTINCFLAGS), $(DESTDIR)/include)

CleanTarget(y.tab.c y.output nesscomp.y *.sysyacc)
CleanTarget(call.h gen.h compdefs.h nevent.h)
CleanTarget(nessrun nodeclass goodness nesst)

DependTarget(init)

checkin:	 Imakefile  nesscomp.gra nesscomp.c  nodeclss.n  *.ch  *.hn  \
		call.c  dump.c  error.c  gen.c  goodness.c  interp.c  interpt.c  \
		ness.c  nessmark.c  nessrun.c  nessruna.c  nesssym.c  nessv.c  
		nevent.c  real.c  search.c  \
		envt.h  error.h  interp.h  \
		nessrun.ci  nodeclss.h  nessmrkt.c  nesswarn.d  nesst.c  notes.d
	ci   -l  $?
	touch checkin


