--- stack/Makefile 2002/03/07 03:28:29 1.5 +++ stack/Makefile 2003/08/05 09:09:51 1.16 @@ -25,19 +25,46 @@ .SUFFIXES: .SUFFIXES: .c .o + +srcdir = . ## -CFLAGS=-Wall -g +CFLAGS=-Wall -g -O2 -pg -fprofile-arcs -ftest-coverage -foptimize-sibling-calls +#CFLAGS=-Wall -g -O0 +## Linux LDFLAGS=-ldl -lmcheck -Xlinker --export-dynamic +## Other junk +#LDFLAGS=-Xlinker --export-dynamic + +all: stack TAGS + +stack stack.bb stack.bbg: stack.c stack.h symbols + $(CC) -I$(srcdir) $(LDFLAGS) $(CFLAGS) symbols.o stack.c -o stack -all: stack +symbols: symbols.c stack.h + $(CC) -I$(srcdir) $(CFLAGS) -c symbols.c -o symbols.o + +check: stack + @echo Checking... + @$(SHELL) -c 'a="`$(srcdir)/fib.st`"; set -x; [ "$$a" = 6765 ]' + @$(SHELL) -c 'a="`$(srcdir)/fib2.st`"; set -x; [ "$$a" = 6765 ]' + @$(SHELL) -c 'a="`$(srcdir)/fac.st`"; set -x; [ "$$a" = 3628800 ]' + @$(SHELL) -c 'a="`echo '\''[ 1 2 ] a def; a rcl; a rcl; setcar; print;'\'' | ./stack | dd count=1 2>/dev/null`"; set -x; [ "$$a" = "[ #0# 2 ]" ]' + @$(SHELL) -c 'a="`echo '\''[ 1 2 ] a def; a rcl; a rcl; setcdr; print;'\'' | ./stack | dd count=1 2>/dev/null`"; set -x; [ "$$a" = "[ 1 . #0# ]" ]' -stack: stack.c stack.h - $(CC) -I$(srcdir) $(CFLAGS) $(LDFLAGS) stack.c -o $@ +TAGS: $(shell find $(srcdir) -path $(srcdir)/CVS -prune -o -name "*.[ch]" -print) + etags $^ + +clean: + rm -f gmon.out mtrace.log stack.bb stack.bbg stack.da stack.c.gcov stack symbols.o TAGS mtrace: stack MALLOC_TRACE=mtrace.log ./stack mtrace stack mtrace.log -check: stack - [ $(shell ./fib.st) = 832040 ] +gcov: stack.c.gcov + +stack.c.gcov: stack.da + gcov $(srcdir)/stack.c + +stack.da: check