Minimal (?) protype-based language.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

83 lines
2.3 KiB

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
# LLVM stupidity: PGO flags, filenames, and process are all incompatible with GCC
CC := /opt/local/bin/gcc-mp-12
endif
GFLAGS += -Wall -Wno-unused -g
OFLAGS += $(GFLAGS) -O3 -DNDEBUG -DTYPECODES=1 -DDELOPT=1 -Wno-array-bounds
PFLAGS += $(OFLAGS) -pg
CFLAGS += -D_GNU_SOURCE -I/opt/local/include
LDLIBS += -L/opt/local/lib
LDLIBS += -lgc -lm -lffi
MAIN = minproto
all : $(MAIN)
% : %.c %.grammar
$(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 $@ $<
%.grammar : %.leg
( sed "/%{/,/%}/d" $< | sed "/%%/,\$$d" ) > $@
tests : .FORCE
$(MAKE) clean all GFLAGS="-Wno-unused -g -DTYPECODES=1 -DELOPT=1"
-./$(MAIN) test.txt > test.out 2>&1
@diff test.ref test.out && echo '\012--- PASSED ---'
$(MAKE) clean all GFLAGS="-Wno-unused -g -DTYPECODES=0 -DELOPT=0"
-./$(MAIN) test.txt > test.out 2>&1
@diff test.ref test.out && echo '\012--- PASSED ---'
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
release : .FORCE
rm -f *.gcda
$(MAKE) clean all GFLAGS="-DNDEBUG -DTYPECODES=1 -DDELOPT=1 -DPROFILE=1 -O3 -fprofile-correction -fprofile-generate"
./$(MAIN) -O profile-generate.txt profile-generate.txt profile-generate.txt profile-generate.txt
$(MAKE) clean all GFLAGS="-DNDEBUG -DTYPECODES=1 -DDELOPT=1 -DPROFILE=1 -O3 -fprofile-correction -fprofile-use"
./$(MAIN) -O profile-generate.txt
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 :