mes/GNUmakefile

50 lines
1.4 KiB
Makefile
Raw Normal View History

.PHONY: all check default
CFLAGS=-std=c99 -O3 -finline-functions
2016-07-11 09:38:02 +01:00
#CFLAGS=-std=c99 -g
default: all
all: mes boot.mes
2016-07-09 22:12:25 +01:00
#mes.o: mes.c mes.h
mes: mes.c mes.h
mes.h: mes.c GNUmakefile
( echo '#if MES'; echo '#if MES' 1>&2;\
2016-07-11 20:50:59 +01:00
grep -E '^(scm [*])*[a-z0-9_]+ \(.*\)( {|$$)' $< | grep -Ev '\(.*(char |bool |int )' | sed -e 's,^scm [*],,' | sort |\
2016-07-09 22:12:25 +01:00
while read f; do\
fun=$$(echo $$f | sed -e 's,^scm [*],,' -e 's,{.*,,');\
name=$$(echo $$fun | sed -e 's,^scm [\*],,' | grep -o '^[^ ]*');\
2016-07-11 09:38:02 +01:00
scm_name=$$(echo $$name | sed -e 's,_to_,->,' -e 's,_p$$,?,' -e 's,_x$$,!,' -e 's,^builtin_,,' -re 's,(.*)_$$,c:\1,' | sed \
2016-07-10 11:52:53 +01:00
-e 's,^divide$$,/,'\
-e 's,^is?$$,=,'\
2016-07-16 12:24:38 +01:00
-e 's,^greater?$$,>,'\
2016-07-10 11:52:53 +01:00
-e 's,^less?$$,<,'\
-e 's,^minus$$,-,'\
-e 's,^multiply$$,*,'\
-e 's,^plus$$,+,'\
-e 's,_,-,g');\
2016-07-09 22:12:25 +01:00
args=$$(echo $$fun | grep -o 'scm [\*]' | wc -l);\
2016-07-10 21:43:23 +01:00
[ "$$(echo $$fun | fgrep -o ... )" = "..." ] && args=n;\
2016-07-09 22:12:25 +01:00
echo "scm *$$fun;";\
echo "scm scm_$$name = {FUNCTION$$args, .name=\"$$scm_name\", .function$$args=&$$name};";\
echo "a = add_environment (a, \"$$scm_name\", &scm_$$name);" 1>&2;\
done; echo '#endif'; echo '#endif' 1>&2) > $@ 2>environment.i
check: all
./mes.test
./mes.test ./mes
cat scm.mes test.mes | ./mes
2016-07-10 09:55:05 +01:00
boot.mes: mes.mes loop2.mes scm.mes test.mes
cat $^ > $@
2016-05-29 12:44:03 +01:00
boot: all
./mes < boot.mes
run: all
cat scm.mes test.mes | ./mes
2016-10-18 21:19:57 +01:00
syntax: all
cat scm.mes syntax.mes | ./mes