#
# Usage:
#
# Only the SRC and TARGET variables has to be instantiated.  The first time
# the command "make -f Makefile.def depend" has to be run.  If any changes
# in dependencies (include directives) are made thereafter, run
# "make depend".
#
SRC=	stream.m fmatrix.m slapm.m slap.m sfloatop.m
OB =	
TARGET=	slap

#
# Nothing below this line should have to be changed.
#
INCLIB=	/usr/local/lib/lmlc/mlib
LMLC=	lmlc

# START AUTODEFS
OBJ=	stream.o \
	fmatrix.o \
	slapm.o \
	slap.o \
	sfloatop.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): $(OBJ)
	$(LMLC) -o $@ $(OBJ) $(OB)

depend : Makefile.def
	echo -n OBJ= > obj
	-for src in $(SRC); do \
		base=`basename $$src .m`; \
		test -f $$base.t || touch $$base.t; \
		echo "	$$base.o \\" >> obj; \
	done
	echo '	$$(PLACEHOLDER)' >> obj
	for src in $(SRC); 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 '/^# END AUTODEFS$$/,/^# AUTOMATIC DEPENDENCIES$$/p' \
		-e '/^# AUTOMATIC DEPENDENCIES$$/r dep' Makefile.def > Makefile
	rm -f obj dep

# AUTOMATIC DEPENDENCIES
stream.o: stream.m
fmatrix.o: fmatrix.m
slapm.o: slapm.m
slapm.o: fmatrix.o
slapm.o: slap.o
slap.o: slap.m
slap.o: fmatrix.o
slap.o: stream.o
slap.o: sfloatop.o
sfloatop.o: sfloatop.m
sfloatop.o: stream.o
