#
# Usage:
#
# This file would be called "Makefile.def".  If given another name,
# change the definition of MKDEF below.
#
# Only the SRC, TARGET and FPGSRC variables have to be defined.  If
# SRC is given as an shell pattern, make sure it does not match the
# pattern "FPGSRC*.m" The first time the system is compiled, the
# command "make -f Makefile.def Makefile" has to be run.  This should
# finish with a message "REDO the make command".  The "Makefile" is
# then ready to be used in the normal way by typing "make".
#
# If any changes in dependencies (include directives) are made, run
# "make depend".  This will result in "REDO the make command" in the
# same way "make -f Makefile.def Makefile" did.  The same thing will
# happen if any changes are made to the fpg grammar.
#
SRC=	abssyx.m aux.m lextenv.m test.m setbag.m show.m unlextenv.m 
TARGET=	testtenv
FPGSRC=	tenv

#
# These variables might also have to be adjusted to local conditions.
#
FPG=	fpg - -s -v
# INCLIB=	/usr/local/lib/lmlc/mlib
INCLIB= /usr/src/local/lml/src/mlib
LMLC=	lmlc
MKDEF=	Makefile.def

#
# Nothing below this line should have to be changed.
#
# START AUTODEFS
OBJ=	abssyx.o \
	aux.o \
	lextenv.o \
	test.o \
	setbag.o \
	show.o \
	unlextenv.o \
	tenv.o \
	tenvlt.o \
	tenvr0.o \
	tenvr1.o \
	tenvr2.o \
	tenvr3.o \
	tenvr4.o \
	tenvr5.o \
	tenvr6.o \
	tenvr7.o \
	tenvr8.o \
	tenvr9.o \
	tenvs0.o \
	tenvs1.o \
	tenvs11.o \
	tenvs16.o \
	tenvs17.o \
	tenvs2.o \
	tenvs4.o \
	tenvs6.o \
	tenvs8.o \
	tenvs9.o \
	tenvt.o \
	$(PLACEHOLDER)
# END AUTODEFS

.SUFFIXES: .m

.m.o:
	@sh -c ' \
		for dep in $?; do \
			case $$dep in \
				$<) set -x; exec $(LMLC) -c $< ;; \
				*.o) dep=`basename $$dep .o`.t ;; \
			esac; \
			case `ls -t $@ $$dep 2>/dev/null` in \
				$@*) : ;; \
				*) set -x; exec $(LMLC) -c $< ;; \
			esac \
		done; \
		set -x; touch $@'

$(TARGET) : Makefile $(OBJ)
	$(LMLC) -o $@ $(OBJ)

Makefile : $(MKDEF) $(FPGSRC).m
	echo -n OBJ= > obj
	-for src in $(SRC) $(FPGSRC)*.m; do \
		base=`basename $$src .m`; \
		test -f $$base.t || touch $$base.t; \
		echo "	$$base.o \\" >> obj; \
	done
	echo '	$$(PLACEHOLDER)' >> obj
	for src in $(SRC) $(FPGSRC)*.m; do \
		/lib/cpp -M -I$(INCLIB) $$src \
			| sed -e 's/\.t$$/.o/' -e 's|\./||'; \
	done > dep
	sed -n	-e '1,/^# START AUTODEFS$$/p' \
		-e '/^# START AUTODEFS$$/r obj' \
		-e '/^# START AUTODEFS$$/r sobj' \
		-e '/^# END AUTODEFS$$/,/^# AUTOMATIC/p' \
		-e '/^# AUTOMATIC/r dep' $(MKDEF) > Makefile
	rm -f obj dep
	@echo REDO the make command
	@false

$(FPGSRC).m : $(FPGSRC).ff
	rm -f $(FPGSRC)[rs][0-9]*.m
	$(FPG) $(FPGSRC).ff
	-for obj in $(FPGSRC)[rs][0-9]*.o; do \
		base=`basename $$obj .o`; \
		test -f $$base.m || rm -f $$obj $$base.t; \
	done

depend :
	rm -f Makefile; make -f $(MKDEF) Makefile
# AUTOMATIC DEPENDENCIES
abssyx.o: abssyx.m
abssyx.o: setbag.o
aux.o: aux.m
lextenv.o: lextenv.m
lextenv.o: tenvt.o
test.o: test.m
test.o: abssyx.o
test.o: lextenv.o
test.o: unlextenv.o
test.o: tenv.o
test.o: show.o
setbag.o: setbag.m
setbag.o: aux.o
show.o: show.m
show.o: abssyx.o
unlextenv.o: unlextenv.m
unlextenv.o: tenvt.o
tenv.o: tenv.m
tenv.o: tenvlt.o
tenv.o: tenvt.o
tenv.o: tenvs0.o
tenvlt.o: tenvlt.m
tenvr0.o: tenvr0.m
tenvr0.o: abssyx.o
tenvr0.o: tenvlt.o
tenvr0.o: tenvt.o
tenvr1.o: tenvr1.m
tenvr1.o: abssyx.o
tenvr1.o: tenvlt.o
tenvr1.o: tenvt.o
tenvr2.o: tenvr2.m
tenvr2.o: abssyx.o
tenvr2.o: tenvlt.o
tenvr2.o: tenvt.o
tenvr3.o: tenvr3.m
tenvr3.o: abssyx.o
tenvr3.o: tenvlt.o
tenvr3.o: tenvt.o
tenvr4.o: tenvr4.m
tenvr4.o: abssyx.o
tenvr4.o: tenvlt.o
tenvr4.o: tenvt.o
tenvr5.o: tenvr5.m
tenvr5.o: abssyx.o
tenvr5.o: tenvlt.o
tenvr5.o: tenvt.o
tenvr6.o: tenvr6.m
tenvr6.o: abssyx.o
tenvr6.o: tenvlt.o
tenvr6.o: tenvt.o
tenvr7.o: tenvr7.m
tenvr7.o: abssyx.o
tenvr7.o: tenvlt.o
tenvr7.o: tenvt.o
tenvr8.o: tenvr8.m
tenvr8.o: abssyx.o
tenvr8.o: tenvlt.o
tenvr8.o: tenvt.o
tenvr9.o: tenvr9.m
tenvr9.o: abssyx.o
tenvr9.o: tenvlt.o
tenvr9.o: tenvt.o
tenvs0.o: tenvs0.m
tenvs0.o: tenvlt.o
tenvs0.o: tenvt.o
tenvs0.o: tenvr1.o
tenvs0.o: tenvs1.o
tenvs0.o: tenvs2.o
tenvs1.o: tenvs1.m
tenvs1.o: tenvlt.o
tenvs1.o: tenvt.o
tenvs1.o: tenvr0.o
tenvs11.o: tenvs11.m
tenvs11.o: tenvlt.o
tenvs11.o: tenvt.o
tenvs11.o: tenvr7.o
tenvs16.o: tenvs16.m
tenvs16.o: tenvlt.o
tenvs16.o: tenvt.o
tenvs16.o: tenvr9.o
tenvs17.o: tenvs17.m
tenvs17.o: tenvlt.o
tenvs17.o: tenvt.o
tenvs17.o: tenvr8.o
tenvs2.o: tenvs2.m
tenvs2.o: tenvlt.o
tenvs2.o: tenvt.o
tenvs2.o: tenvr1.o
tenvs2.o: tenvs4.o
tenvs2.o: tenvs17.o
tenvs2.o: tenvs16.o
tenvs2.o: tenvs9.o
tenvs2.o: tenvs6.o
tenvs2.o: tenvs8.o
tenvs4.o: tenvs4.m
tenvs4.o: tenvlt.o
tenvs4.o: tenvt.o
tenvs4.o: tenvr3.o
tenvs6.o: tenvs6.m
tenvs6.o: tenvlt.o
tenvs6.o: tenvt.o
tenvs6.o: tenvr6.o
tenvs8.o: tenvs8.m
tenvs8.o: tenvlt.o
tenvs8.o: tenvt.o
tenvs8.o: tenvr2.o
tenvs9.o: tenvs9.m
tenvs9.o: tenvlt.o
tenvs9.o: tenvt.o
tenvs9.o: tenvr5.o
tenvs9.o: tenvr4.o
tenvs9.o: tenvs4.o
tenvs9.o: tenvs17.o
tenvs9.o: tenvs16.o
tenvs9.o: tenvs6.o
tenvs9.o: tenvs11.o
tenvt.o: tenvt.m
