vpath %.c   $(SRCDIR)
vpath %.h   $(SRCDIR)
vpath %.inc $(SRCDIR)

#DEPEND rule copied from gnu make manual
%.d: %.c
	set -e; $(CC) -MM $(CFLAGS) $< \
| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
[ -s $@ ] || rm -f $@

#generate the final version of the flags
LCDEFS = $(OPTIMIZER) $(LCOPTS) $(REG_LCDEFS)
CFLAGS = $(LCDEFS) $(DBMFLAGS) $(WOFF)
include $(DEPEND)

#
#create the include file
#for storing the flags inside the program
#

aprog:
	echo "Cflags = strdup(\"Compile info: \n`date` \nby `whoami` \non `echo $(HOSTNAME)` \nusing $(CC) `$(CC) --version | head -1` \nCFLAGS: $(CFLAGS)\");" > ../getcflags.inc;\
	$(MAKE) prog;

#then make the final program
prog: $(OBJECTS) $(DEPEND)
	$(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LDFLAGS)
