OFLAGS += -Wall -Wno-unused -O3 -DNDEBUG
|
|
GFLAGS += -Wall -Wno-unused -g
|
|
PFLAGS += $(OFLAGS) -pg
|
|
CFLAGS += -D_GNU_SOURCE -I/opt/local/include
|
|
LDLIBS += -L/opt/local/lib
|
|
LDLIBS += -lgc -lm
|
|
|
|
MAIN = minproto
|
|
|
|
all : $(MAIN)
|
|
|
|
% : %.c
|
|
$(CC) $(GFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
|
|
|
|
%-opt : %.c
|
|
$(CC) $(OFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
|
|
|
|
%-prof : %.c
|
|
$(CC) $(PFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
|
|
|
|
%.c : %.leg
|
|
leg -o $@ $<
|
|
|
|
test : $(MAIN)
|
|
./$(MAIN) test.txt 2>&1 | tee test.out
|
|
@diff test.ref test.out && echo '\012--- PASSED ---'
|
|
|
|
testref : $(MAIN)
|
|
./$(MAIN) test.txt 2>&1 | tee test.ref
|
|
|
|
bench : $(MAIN)-opt
|
|
time ./$(MAIN)-opt -O bench.txt
|
|
time ./$(MAIN)-opt -O bench.txt
|
|
time ./$(MAIN)-opt -O bench.txt
|
|
|
|
sieve : $(MAIN)-opt
|
|
time ./$(MAIN)-opt -O bench-sieve.txt
|
|
time ./$(MAIN)-opt -O bench-sieve.txt
|
|
time ./$(MAIN)-opt -O bench-sieve.txt
|
|
|
|
profile : $(MAIN)-prof
|
|
./$(MAIN)-prof -O < bench.txt
|
|
gprof ./$(MAIN)-prof gmon.out
|
|
|
|
FILES = Makefile $(MAIN).leg bench.txt test.txt test2.txt
|
|
|
|
checkpoint : .FORCE
|
|
tar cvfz ckpt/minproto-$(shell date "+%Y%m%d-%H%M%S").tgz $(FILES)
|
|
|
|
clean : .FORCE
|
|
rm -rf $(MAIN) $(MAIN)-opt $(MAIN)-prof *.o *.dSYM *.sync-conflict-*
|
|
|
|
spotless : clean
|
|
rm -f *~
|
|
|
|
stats : .FORCE
|
|
@echo $(shell tr -d ' \t\\' < minproto.leg | sort -u | wc -l) lines of code
|
|
|
|
.FORCE :
|