2016-10-15 22:34:23 +00:00
|
|
|
.PHONY: all check clean default distclean help install release
|
|
|
|
default: all
|
|
|
|
|
|
|
|
.config.make: configure GNUmakefile
|
|
|
|
./configure
|
|
|
|
|
|
|
|
OUT:=out
|
2016-07-27 06:49:45 +00:00
|
|
|
CFLAGS:=-std=c99 -O3 -finline-functions
|
2016-10-15 22:34:23 +00:00
|
|
|
#CFLAGS:=-std=c99 -O0
|
2016-10-12 19:14:06 +00:00
|
|
|
#CFLAGS:=-pg -std=c99 -O0
|
|
|
|
#CFLAGS:=-std=c99 -O0 -g
|
2016-07-27 06:49:45 +00:00
|
|
|
|
2016-10-15 22:34:23 +00:00
|
|
|
include .config.make
|
|
|
|
-include .local.make
|
|
|
|
include make/install.make
|
|
|
|
|
2016-05-15 22:07:44 +00:00
|
|
|
|
2016-07-18 20:43:16 +00:00
|
|
|
all: mes
|
2016-05-15 22:07:44 +00:00
|
|
|
|
2016-07-09 21:12:25 +00:00
|
|
|
mes: mes.c mes.h
|
|
|
|
|
2016-10-12 21:40:11 +00:00
|
|
|
clean:
|
2016-10-16 12:57:30 +00:00
|
|
|
rm -f mes environment.i symbols.i mes.h *.cat a.out
|
2016-10-12 21:40:11 +00:00
|
|
|
|
2016-10-15 22:34:23 +00:00
|
|
|
distclean: clean
|
|
|
|
rm -f .config.make
|
|
|
|
|
2016-07-09 21:12:25 +00:00
|
|
|
mes.h: mes.c GNUmakefile
|
2016-07-22 10:23:23 +00:00
|
|
|
( echo '#if MES_C'; echo '#if MES_FULL' 1>&2;\
|
2016-07-11 19:50:59 +00:00
|
|
|
grep -E '^(scm [*])*[a-z0-9_]+ \(.*\)( {|$$)' $< | grep -Ev '\(.*(char |bool |int )' | sed -e 's,^scm [*],,' | sort |\
|
2016-07-09 21:12:25 +00: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 08:38:02 +00: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 10:52:53 +00:00
|
|
|
-e 's,^divide$$,/,'\
|
|
|
|
-e 's,^is?$$,=,'\
|
2016-07-16 11:24:38 +00:00
|
|
|
-e 's,^greater?$$,>,'\
|
2016-07-10 10:52:53 +00:00
|
|
|
-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-10-08 06:41:30 +00:00
|
|
|
grep -oE '^scm ([a-z_]+) = {SYMBOL,' mes.c | cut -d' ' -f 2 |\
|
|
|
|
while read f; do\
|
|
|
|
echo "symbols = cons (&$$f, symbols);";\
|
|
|
|
done > symbols.i
|
2016-07-09 21:12:25 +00:00
|
|
|
|
2016-10-08 06:38:29 +00:00
|
|
|
check: all guile-check mes-check
|
|
|
|
|
2016-10-12 21:40:11 +00:00
|
|
|
TESTS:=\
|
|
|
|
tests/base.test\
|
|
|
|
tests/closure.test\
|
|
|
|
tests/quasiquote.test\
|
|
|
|
tests/let.test\
|
|
|
|
tests/scm.test\
|
|
|
|
tests/record.test\
|
|
|
|
tests/let-syntax.test\
|
|
|
|
tests/match.test\
|
|
|
|
#
|
|
|
|
|
|
|
|
BASE-0:=module/mes/base-0.mes
|
|
|
|
MES-0:=guile/mes-0.scm
|
|
|
|
MES:=./mes
|
2016-07-09 11:23:58 +00:00
|
|
|
|
2016-10-12 21:40:11 +00:00
|
|
|
mes-check: all
|
2016-10-16 15:34:51 +00:00
|
|
|
for i in $(TESTS); do ./$$i; done
|
2016-10-16 07:44:52 +00:00
|
|
|
|
2016-07-23 13:17:03 +00:00
|
|
|
guile-check:
|
2016-10-12 21:40:11 +00:00
|
|
|
for i in $(TESTS); do\
|
2016-10-16 15:34:51 +00:00
|
|
|
guile -s <(cat $(MES-0) $$(scripts/include.mes $$i | grep -Ev 'let.mes|quasiquote.mes|base-0|srfi-0') $$i);\
|
2016-10-12 21:40:11 +00:00
|
|
|
done
|
|
|
|
for i in $(TESTS); do\
|
|
|
|
guile -s <(cat $(MES-0) module/mes/test.mes $$i);\
|
|
|
|
done
|
2016-07-24 21:18:53 +00:00
|
|
|
|
2016-10-16 12:57:30 +00:00
|
|
|
MAIN_C:=doc/examples/main.c
|
2016-07-24 23:12:22 +00:00
|
|
|
mescc: all
|
2016-10-16 12:57:30 +00:00
|
|
|
scripts/mescc.mes $(MAIN_C)
|
2016-10-12 21:40:11 +00:00
|
|
|
./a.out
|
2016-07-24 23:12:22 +00:00
|
|
|
|
2016-10-12 21:40:11 +00:00
|
|
|
mescc.cat: $(MES-0) module/mes/lalr.mes module/mes/elf.mes module/mes/libc-i386.mes $(shell scripts/include.mes scripts/mescc.mes | grep -Ev '/mes/|/srfi/')
|
|
|
|
echo '(compile)' | cat $^ - > $@
|
2016-07-24 21:18:53 +00:00
|
|
|
|
2016-10-10 21:24:44 +00:00
|
|
|
guile-mescc: mescc.cat
|
2016-10-16 12:57:30 +00:00
|
|
|
cat $(MAIN_C) | guile -s $^ > a.out
|
2016-08-12 14:38:59 +00:00
|
|
|
chmod +x a.out
|
2016-10-12 21:40:11 +00:00
|
|
|
./a.out
|
2016-10-15 22:34:23 +00:00
|
|
|
|
|
|
|
help: help-top
|
|
|
|
|
|
|
|
install: all
|
|
|
|
|
|
|
|
release: all
|
|
|
|
|
|
|
|
help:
|
|
|
|
@echo
|
|
|
|
|
|
|
|
define HELP_TOP
|
|
|
|
Usage: make [OPTION]... [TARGET]...
|
|
|
|
|
|
|
|
Targets:
|
|
|
|
all update everything
|
|
|
|
check run unit tests
|
|
|
|
clean remove all generated stuff
|
|
|
|
dist create tarball in $(TARBALL)
|
|
|
|
distclean also clean configuration
|
|
|
|
mescc compile cc/main.c to a.out
|
|
|
|
install install in $$(PREFIX) [$(PREFIX)]
|
|
|
|
release make a release
|
2016-10-18 21:50:09 +00:00
|
|
|
update-hash update hash in guix.scm
|
2016-10-15 22:34:23 +00:00
|
|
|
endef
|
|
|
|
export HELP_TOP
|
|
|
|
help-top:
|
|
|
|
@echo "$$HELP_TOP"
|