2016-05-15 22:07:44 +00:00
|
|
|
.PHONY: all check default
|
|
|
|
CFLAGS=-std=c99 -O3 -finline-functions
|
|
|
|
#CFLAGS=-g
|
|
|
|
|
|
|
|
default: all
|
|
|
|
|
2016-07-09 11:23:58 +00:00
|
|
|
all: mes boot.mes
|
2016-05-15 22:07:44 +00:00
|
|
|
|
2016-07-09 21:12:25 +00: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;\
|
|
|
|
grep -E '^(scm [*])*[a-z_]+ \(.*\)( {|$$)' $< | grep -Ev '\(.*(char |bool |int )' | sed -e 's,^scm [*],,' | sort |\
|
|
|
|
while read f; do\
|
|
|
|
fun=$$(echo $$f | sed -e 's,^scm [*],,' -e 's,{.*,,');\
|
|
|
|
name=$$(echo $$fun | sed -e 's,^scm [\*],,' | grep -o '^[^ ]*');\
|
2016-07-10 10:52:53 +00:00
|
|
|
scm_name=$$(echo $$name | sed -e 's,_p$$,?,' -e 's,_x$$,!,' -e 's,^builtin_,,' -re 's,(.*)_$$,c:\1,' | sed \
|
|
|
|
-e 's,^divide$$,/,'\
|
|
|
|
-e 's,^is?$$,=,'\
|
|
|
|
-e 's,^less?$$,<,'\
|
|
|
|
-e 's,^minus$$,-,'\
|
|
|
|
-e 's,^multiply$$,*,'\
|
|
|
|
-e 's,^plus$$,+,'\
|
|
|
|
-e 's,_,-,g');\
|
2016-07-09 21:12:25 +00:00
|
|
|
args=$$(echo $$fun | grep -o 'scm [\*]' | wc -l);\
|
2016-07-10 20:43:23 +00:00
|
|
|
[ "$$(echo $$fun | fgrep -o ... )" = "..." ] && args=n;\
|
2016-07-09 21:12:25 +00: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
|
|
|
|
|
2016-05-15 22:07:44 +00:00
|
|
|
check: all
|
|
|
|
./mes.test
|
|
|
|
./mes.test ./mes
|
2016-07-09 13:16:30 +00:00
|
|
|
cat scm.mes test.mes | ./mes
|
2016-07-09 11:23:58 +00:00
|
|
|
|
2016-07-10 08:55:05 +00:00
|
|
|
boot.mes: mes.mes loop2.mes scm.mes test.mes
|
2016-07-09 11:23:58 +00:00
|
|
|
cat $^ > $@
|
2016-05-29 11:44:03 +00:00
|
|
|
|
|
|
|
boot: all
|
|
|
|
./mes < boot.mes
|
2016-07-09 11:23:58 +00:00
|
|
|
|
|
|
|
run: all
|
2016-07-09 13:16:30 +00:00
|
|
|
cat scm.mes test.mes | ./mes
|