Simplify toplevel read.
[mes.git] / GNUmakefile
1 .PHONY: all check clean default distclean help install release
2 default: all
3
4 .config.make: configure GNUmakefile
5         ./configure
6
7 OUT:=out
8 CFLAGS:=-std=c99 -O3 -finline-functions
9 #CFLAGS:=-std=c99 -O0
10 #CFLAGS:=-pg -std=c99 -O0
11 #CFLAGS:=-std=c99 -O0 -g
12
13 export BOOT
14 ifneq ($(BOOT),)
15 CFLAGS+=-DBOOT=1
16 endif
17
18 include .config.make
19 -include .local.make
20 include make/install.make
21
22
23 all: mes
24
25 mes.o: mes.c
26 mes.o: mes.c mes.environment.h mes.environment.i mes.symbols.i
27 mes.o: define.c define.environment.h define.environment.i
28 mes.o: lib.c lib.environment.h lib.environment.i
29 mes.o: math.c math.environment.h math.environment.i
30 mes.o: quasiquote.c quasiquote.environment.h quasiquote.environment.i
31 mes.o: string.c string.environment.h string.environment.i
32 mes.o: type.c type.environment.h type.environment.i
33
34 clean:
35         rm -f mes mes.o *.environment.i *.symbols.i *.environment.h *.cat a.out
36
37 distclean: clean
38         rm -f .config.make
39
40 %.environment.h %.environment.i %.symbols.i: %.c build-aux/mes-snarf.scm
41         build-aux/mes-snarf.scm $<
42
43 check: all guile-check mes-check
44
45 TESTS:=\
46  tests/base.test\
47  tests/closure.test\
48  tests/quasiquote.test\
49  tests/let.test\
50  tests/vector.test\
51  tests/scm.test\
52  tests/record.test\
53  tests/let-syntax.test\
54  tests/match.test\
55 #
56
57 BASE-0:=module/mes/base-0.mes
58 MES-0:=guile/mes-0.scm
59 MES:=./mes
60
61 mes-check: all
62         set -e; for i in $(TESTS); do ./$$i; done
63
64 guile-check:
65         set -e; for i in $(TESTS); do\
66                 guile -s <(cat $(MES-0) $$(scripts/include.mes $$i | grep -Ev 'let.mes|quasiquote.mes|base-0|loop-0|srfi-0') $$i);\
67         done
68         set -e; for i in $(TESTS); do\
69                 guile -s <(cat $(MES-0) module/mes/test.mes $$i);\
70         done
71
72 MAIN_C:=doc/examples/main.c
73 mescc: all
74         scripts/mescc.mes $(MAIN_C)
75         ./a.out
76
77 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/')
78         echo '(compile)' | cat $^ - > $@
79
80 guile-mescc: mescc.cat
81         cat $(MAIN_C) | guile -s $^ > a.out
82         chmod +x a.out
83         ./a.out
84
85 help: help-top
86
87 install: all
88
89 release: all
90
91 help:
92         @echo
93
94 define HELP_TOP
95 Usage: make [OPTION]... [TARGET]...
96
97 Targets:
98   all             update everything
99   check           run unit tests
100   clean           remove all generated stuff
101   dist            create tarball in $(TARBALL)
102   distclean       also clean configuration
103   mescc           compile cc/main.c to a.out
104   install         install in $$(PREFIX) [$(PREFIX)]
105   release         make a release
106   update-hash     update hash in guix.scm
107 endef
108 export HELP_TOP
109 help-top:
110         @echo "$$HELP_TOP"