# for debug, makefile lib for a_plant: make DBX="-DDEBUG=cerr -g" lib
EKSdir=/usr3/dechao/eks
DBX= -g
LIBS= -L${EKSdir}/lib -lEKS -lIntrinsics -lDimensions -lm
CFLAGS= -I../../dimensions -I../../intrinsics -I../../base -I../../base/theory -I../../base/site -I../../base/building -I../../tax_1 -I../../tax_2 -I../../plant -pic ${DBX}
LFLAGS= -hbx
SRC= ABoiler.C ABoiler_def.C ACard_reader.C ACard_reader_def.C AComponent.C AComponent_def.C AConnection.C AConnection_def.C APrinter.C APrinter_def.C APump.C APump_def.C ARadiator.C ARadiator_def.C ARoom.C ARoom_def.C ASystem.C ASystem_def.C Context_pb.C Context_pb_def.C Ideal_pipe.C Ideal_pipe_def.C Type_5.C Type_5_def.C
OBJ= ABoiler.o ABoiler_def.o ACard_reader.o ACard_reader_def.o AComponent.o AComponent_def.o AConnection.o AConnection_def.o APrinter.o APrinter_def.o APump.o APump_def.o ARadiator.o ARadiator_def.o ARoom.o ARoom_def.o ASystem.o ASystem_def.o Context_pb.o Context_pb_def.o Ideal_pipe.o Ideal_pipe_def.o Type_5.o Type_5_def.o

plant_2:	${OBJ}

all:	plant_2 plant_1

plant_1:
	cd ..; make all

VERSION=`cat ${EKSdir}/lib/.version`
lib:	all
	echo ${VERSION}
	ld -o ${EKSdir}/lib/libEKS.so.${VERSION} -assert pure-text  \
		../../base/[A-Z]*.o ../../base/*/[A-Z]*.o ../../tax_1/[A-Z]*.o\
		../../tax_2/[A-Z]*.o ../../plant/[A-Z]*.o [A-Z]*.o
	ar cr ${EKSdir}/lib/libEKS.sa.${VERSION}  ../../base/EKS.o
	ranlib ${EKSdir}/lib/libEKS.sa.${VERSION}

static_lib: all
	ar cr ${EKSdir}/lib/libEKS.a  \
		../../base/[A-Z]*.o  ../../base/*/[A-Z]*.o  ../../tax_1/[A-Z]*.o
		../../tax_2/[A-Z]*.o ../[A-Z]*.o [A-Z]*.o

build_template:	plant_2 make_meta_for.o desc_def_for.o instantiate.o
	CC ${CFLAGS} -o ${EKSdir}/bin/build_template   ../../base/build_template.o \
			make_meta_for.o  desc_def_for.o  instantiate.o \
			${LIBS}

describe_data:	plant_2 make_meta_for.o desc_def_for.o instantiate.o
	CC ${CFLAGS} -o ${EKSdir}/bin/describe_data   ../../base/describe_data.o \
			make_meta_for.o  desc_def_for.o  instantiate.o \
			${LIBS}

get_data_and_run_model:	plant_2 make_meta_for.o desc_def_for.o instantiate.o
	CC ${CFLAGS} -o ${EKSdir}/bin/get_data_and_run_model   ../../base/get_data_and_run_model.o \
			make_meta_for.o  desc_def_for.o  instantiate.o \
			${LIBS}

run_model:	plant_2 make_meta_for.o desc_def_for.o instantiate.o
	CC ${CFLAGS} -o ${EKSdir}/bin/run_model   ../../base/run_model.o  \
			make_meta_for.o  desc_def_for.o  instantiate.o \
			${LIBS}

make_meta_for.o:	../../standalone/make_meta_for.C
	CC ${CFLAGS} -I. -c -DDEMO1 -DDEMO2 -DDEMOA ../../standalone/make_meta_for.C

instantiate.o:		../../standalone/instantiate.C
	CC ${CFLAGS} -I. -c -DDEMO1 -DDEMO2 -DDEMOA ../../standalone/instantiate.C

desc_def_for.o:		../../standalone/desc_def_for.C
	CC ${CFLAGS} -I. -c -DDEMO1 -DDEMO2 -DDEMOA ../../standalone/desc_def_for.C

destroy.o:		../../standalone/destroy.C
	CC ${CFLAGS} -I. -c -DDEMO1 -DDEMO2 -DDEMOA ../../standalone/destroy.C


clean:
	rm -f core lintout makeout tags makefile.bak *.o *.cyi

lintout: ${SRC}
	\@rm -f lintout
	lint ${LFLAGS} ${SRC} >lintout

errs:
	\@rm -f makeout
	make main1 >makeout

tags:	${SRC}
	\@rm -f tags
	ctags ${SRC}

source:
	mv makefile makefile.bak
	head -6 makefile.bak >makefile
	echo SRC= `ls *.C` >>makefile
	echo OBJ= `ls *.C | sed s/C$$/o/` >>makefile
	tail +9 <makefile.bak >>makefile

depend: ${SRC}
	for i in ${SRC};  \
	do \
		/lib/cpp  -M -Y/usr/CC/incl $$i \
		|  sort -u \
		|  sed -e 's, \./, ,' \
		|  awk ' \
				{ if ($$1 != prev) { \
					if (rec != "")   print rec; \
					rec = $$0;  prev = $$1;\
			 	  } else { \
					if ($$2 !~ /CC/) { \
						print rec "   \\"; \
						rec = "\t" $$2}\
					} \
				} \
			END { print rec } \
		'; \
	done >makedep
	echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	cp makefile makefile.bak
	ed - makefile <eddep
	rm eddep makedep
	echo '' >>makefile
	echo '# DEPENDENCIES MUST END AT END OF FILE' >>makefile
	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >>makefile
	echo '# see make depend above' >>makefile

.SUFFIXES: .C
.C.o:
	CC ${CFLAGS} -c $*.C

# DO NOT DELETE THIS LINE -- make depend uses it

ABoiler.o: ABoiler.h   \
	ABoiler_def.h   \
	AComponent.h   \
	AComponent_def.h   \
	ABoiler.C
ABoiler_def.o: ABoiler_def.h   \
	AComponent_def.h   \
	ABoiler_def.C
ACard_reader.o: ACard_reader.h   \
	ACard_reader_def.h   \
	AComponent.h   \
	AComponent_def.h   \
	ACard_reader.C
ACard_reader_def.o: ACard_reader_def.h   \
	AComponent.h   \
	AComponent_def.h   \
	ACard_reader_def.C
AComponent.o: AComponent.h   \
	AComponent_def.h   \
	AComponent.C
AComponent_def.o: AComponent_def.h   \
	AComponent_def.C
AConnection.o: AComponent.h   \
	AComponent_def.h   \
	AConnection.h   \
	AConnection_def.h   \
	AConnection.C
AConnection_def.o: AConnection_def.h   \
	AConnection_def.C
APrinter.o: AComponent.h   \
	AComponent_def.h   \
	APrinter.h   \
	APrinter_def.h   \
	APrinter.C
APrinter_def.o: AComponent.h   \
	AComponent_def.h   \
	APrinter_def.h   \
	APrinter_def.C
APump.o: AComponent.h   \
	AComponent_def.h   \
	APump.h   \
	APump_def.h   \
	APump.C
APump_def.o: AComponent_def.h   \
	APump_def.h   \
	APump_def.C
ARadiator.o: AComponent.h   \
	AComponent_def.h   \
	ARadiator.h   \
	ARadiator_def.h   \
	ARadiator.C
ARadiator_def.o: AComponent_def.h   \
	ARadiator_def.h   \
	ARadiator_def.C
ARoom.o: AComponent.h   \
	AComponent_def.h   \
	ARoom.h   \
	ARoom_def.h   \
	ARoom.C
ARoom_def.o: AComponent_def.h   \
	ARoom_def.h   \
	ARoom_def.C
ASystem.o: AComponent.h   \
	AComponent_def.h   \
	AConnection.h   \
	AConnection_def.h   \
	ASystem.h   \
	ASystem_def.h   \
	ASystem.C
ASystem_def.o: ASystem_def.h   \
	ASystem_def.C
Context_pb.o: AComponent.h   \
	AComponent_def.h   \
	AConnection.h   \
	AConnection_def.h   \
	ASystem.h   \
	Context_pb.h   \
	Context_pb_def.h   \
	Context_pb.C
Context_pb_def.o: AComponent.h   \
	AComponent_def.h   \
	AConnection.h   \
	AConnection_def.h   \
	ASystem.h   \
	ASystem_def.h   \
	Context_pb_def.h   \
	Context_pb_def.C
Ideal_pipe.o: AComponent.h   \
	AComponent_def.h   \
	Ideal_pipe.h   \
	Ideal_pipe_def.h   \
	Ideal_pipe.C
Ideal_pipe_def.o: AComponent_def.h   \
	Ideal_pipe_def.h   \
	Ideal_pipe_def.C
Type_5.o: AComponent.h   \
	AComponent_def.h   \
	Type_5.h   \
	Type_5_def.h   \
	Type_5.C
Type_5_def.o: AComponent_def.h   \
	Type_5_def.h   \
	Type_5_def.C

# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above
