01a35f2d2f2f4a6c17312cda033f0beb84463ed8
[mes.git] / make.scm
1 #! /bin/sh
2 # -*- scheme -*-
3 exec ${GUILE-guile} --no-auto-compile -L . -L guile -C . -C guile -s "$0" ${1+"$@"}
4 !#
5
6 (use-modules (srfi srfi-26)
7              (guix shell-utils))
8
9 ;; FIXME: .go dependencies
10 ;; workaround: always update .go before calculating hashes
11 ;;(use-modules ((mes make) #:select (sytem**)))
12 (define %scm-files
13   '("guix/make.scm"
14     "guix/records.scm"
15     "guix/shell-utils.scm"
16     "language/c99/compiler.scm"
17     "language/c99/info.scm"
18     "mes/as-i386.scm"
19     "mes/as.scm"
20     "mes/bytevectors.scm"
21     "mes/elf.scm"
22     "mes/guile.scm"
23     "mes/M1.scm"))
24 (define %go-files (map (compose (cut string-append <> ".go") (cut string-drop-right <> 4)) %scm-files))
25 (setenv "srcdir" ".")
26 (setenv "host" %host-type)
27 (with-directory-excursion "guile"
28   (apply system* `("guile"
29                    "--no-auto-compile"
30                    "-L" "."
31                    "-C" "."
32                    "-s"
33                    "../build-aux/compile-all.scm"
34                    ,@%scm-files)))
35
36 (use-modules (srfi srfi-1)
37              (ice-9 curried-definitions)
38              (ice-9 match)
39              (guix make))
40
41 (add-target (bin.mescc "stage0/exit-42.c" #:libc #f))
42 (add-target (check "stage0/exit-42.0-guile" #:signal 11))  ; FIXME: segfault
43
44 (add-target (cpp.mescc "mlibc/mini-libc-mes.c"))
45 (add-target (compile.mescc "mlibc/mini-libc-mes.c"))
46
47 (add-target (bin.mescc "stage0/exit-42.c" #:libc mini-libc-mes.E))
48 (add-target (check "stage0/exit-42.mini-guile" #:exit 42))
49
50 (add-target (cpp.mescc "mlibc/libc-mes.c"))
51 (add-target (compile.mescc "mlibc/libc-mes.c"))
52
53 (add-target (bin.mescc "stage0/exit-42.c"))
54 (add-target (check "stage0/exit-42.guile" #:exit 42))
55
56 (define* (add-scaffold-test name #:key (exit 0) (libc libc-mes.E))
57   (add-target (bin.gcc (string-append "scaffold/tests/" name ".c") #:libc #f))
58   (add-target (check (string-append "scaffold/tests/" name ".mlibc-gcc") #:exit exit))
59
60   (add-target (bin.mescc (string-append "scaffold/tests/" name ".c") #:libc libc))
61   (add-target (check (string-append "scaffold/tests/" name "." (cond ((not libc) "0-")
62                                                                      ((eq? libc mini-libc-mes.E) "mini-")
63                                                                      (else "")) "guile") #:exit exit)))
64
65 (add-scaffold-test "t" #:libc mini-libc-mes.E)
66 ;;(add-scaffold-test "t" #:libc libc-mes+tcc.E)
67
68 ;; tests/00: exit, functions without libc
69 (add-scaffold-test "00-exit-0" #:libc #f)
70 (add-scaffold-test "01-return-0" #:libc #f)
71 (add-scaffold-test "02-return-1" #:libc #f #:exit 1)
72 (add-scaffold-test "03-call" #:libc #f)
73 (add-scaffold-test "04-call-0" #:libc #f)
74 (add-scaffold-test "05-call-1" #:libc #f #:exit 1)
75 (add-scaffold-test "06-call-!1" #:libc #f)
76
77 (add-target (group "check-scaffold-tests/0" #:dependencies (filter (target-prefix? "check-scaffold/tests/0") %targets)))
78
79 ;; tests/10: control without libc
80 (for-each
81  (cut add-scaffold-test <> #:libc #f)
82  '("10-if-0"
83    "11-if-1"
84    "12-if-=="
85    "13-if-!="
86    "14-if-goto"
87    "15-if-!f"
88    "16-if-t"))
89
90 (add-target (group "check-scaffold-tests/1" #:dependencies (filter (target-prefix? "check-scaffold/tests/1") %targets)))
91
92 ;; tests/20: loop without libc
93 (for-each
94  (cut add-scaffold-test <> #:libc #f)
95  '("20-while"
96    "21-char[]"
97    "22-while-char[]"
98    "23-pointer"))
99
100 (add-target (group "check-scaffold-tests/2" #:dependencies (filter (target-prefix? "check-scaffold/tests/2") %targets)))
101
102 ;; tests/30: call, compare: mini-libc-mes.c
103 (for-each
104  (cut add-scaffold-test <> #:libc mini-libc-mes.E)
105  '("30-strlen"
106    "31-eputs"
107    "32-compare"
108    "33-and-or"
109    "34-pre-post"
110    "35-compare-char"
111    "36-compare-arithmetic"
112    "37-compare-assign"
113    "38-compare-call"))
114
115 (add-target (group "check-scaffold-tests/3" #:dependencies (filter (target-prefix? "check-scaffold/tests/3") %targets)))
116
117 ;; tests/40: control: mini-libc-mes.c
118 (for-each
119  (cut add-scaffold-test <> #:libc mini-libc-mes.E)
120  '("40-if-else"
121    "41-?"
122    "42-goto-label"
123    "43-for-do-while"
124    "44-switch"
125    "45-void-call"))
126
127 (add-target (group "check-scaffold-tests/4" #:dependencies (filter (target-prefix? "check-scaffold/tests/4") %targets)))
128
129 ;; tests/50: libc-mes.c
130 (for-each
131  add-scaffold-test
132  '("50-assert"
133    "51-strcmp"
134    "52-itoa"
135    "54-argv"))
136
137 (add-target (group "check-scaffold-tests/5" #:dependencies (filter (target-prefix? "check-scaffold/tests/5") %targets)))
138
139 ;; tests/60: building up to scaffold/m.c, scaffold/micro-mes.c
140 (for-each
141  add-scaffold-test
142  '("60-math"
143    "61-array"
144    "63-struct-cell"
145    "64-make-cell"
146    "65-read"))
147
148 (add-target (group "check-scaffold-tests/6" #:dependencies (filter (target-prefix? "check-scaffold/tests/6") %targets)))
149
150 ;; tests/70: and beyond src/mes.c -- building up to 8cc.c, pcc.c, tcc.c, libguile/eval.c
151 (for-each
152  add-scaffold-test
153  '("70-printf"
154    "71-struct-array"
155    "72-typedef-struct-def"
156    "73-union"
157    "74-multi-line-string"
158    "75-struct-union"
159    "76-pointer-arithmetic"
160    "77-pointer-assign"
161    "78-union-struct"
162    "79-int-array"
163    "7a-struct-char-array"
164    "7b-struct-int-array"
165    "7c-dynarray"
166    "7d-cast-char"
167    "7e-struct-array-access"
168    "7f-struct-pointer-arithmetic"
169    "7g-struct-byte-word-field"
170    "7h-struct-assign"
171    "7i-struct-struct"
172    "7j-strtoull"
173    "7k-for-each-elem"
174    "7l-struct-any-size-array"))
175
176 (add-target (group "check-scaffold-tests/7" #:dependencies (filter (target-prefix? "check-scaffold/tests/7") %targets)))
177
178 (add-target (group "check-scaffold-tests" #:dependencies (filter (target-prefix? "check-scaffold/tests") %targets)))
179
180 (add-target (cpp.mescc "mlibc/libc-mes+tcc.c"))
181 (add-target (compile.mescc "mlibc/libc-mes+tcc.c"))
182
183 (define* (add-tcc-test name)
184   (add-target (bin.gcc (string-append "scaffold/tinycc/" name ".c") #:libc #f #:includes '("scaffold/tinycc")))
185   (add-target (check (string-append "scaffold/tinycc/" name ".mlibc-gcc") #:baseline (string-append "scaffold/tinycc/" name ".expect")))
186
187   (add-target (bin.mescc (string-append "scaffold/tinycc/" name ".c") #:includes '("scaffold/tinycc")))
188   (add-target (check (string-append "scaffold/tinycc/" name ".guile") #:baseline (string-append "scaffold/tinycc/" name ".expect"))))
189 (map
190  add-tcc-test
191  '("00_assignment"
192    "01_comment"
193    "02_printf"
194    "03_struct"
195    "04_for"
196    "05_array"
197    "06_case"
198    "07_function"
199    "08_while"
200    "09_do_while"
201
202    "10_pointer"
203    "11_precedence"
204    "12_hashdefine"
205    "13_integer_literals"
206    "14_if"
207    "15_recursion"
208    "16_nesting"
209    "17_enum"
210    "18_include"
211    "19_pointer_arithmetic"
212
213    "20_pointer_comparison"
214    "21_char_array"
215    ;;"22_floating_point"       ; float
216    ;;"23_type_coercion"        ; float
217    ;;"24_math_library"         ; float
218    "25_quicksort"
219    ;;"27_sizeof"               ; float
220    ;;"28_strings"              ; TODO: strncpy strchr strrchr memset memcpy memcmp
221    "29_array_address"
222
223    ;;"30_hanoi"                ; fails with GCC
224    "31_args"
225    ;;"32_led"                  ; unsupported: (decl (decl-spec-list (stor-spec (static)) (type-spec (fixed-type "int"))) (init-declr-list (init-declr (array-of (ident "d") (p-expr (fixed "32"))))))
226    ;;"34_array_assignment"     ; fails with GCC
227    "33_ternary_op"
228    "35_sizeof"
229    ;;"36_array_initialisers"   ; unspported: (decl (decl-spec-list (type-spec (fixed-type "int"))) (init-declr-list (init-declr (array-of (ident "Array") (p-expr (fixed "10"))) (initzer (initzer-list (initzer (p-expr (fixed "12"))) (initzer (p-expr (fixed "34"))) (initzer (p-expr (fixed "56"))) (initzer (p-expr (fixed "78"))) (initzer (p-expr (fixed "90"))) (initzer (p-expr (fixed "123"))) (initzer (p-expr (fixed "456"))) (initzer (p-expr (fixed "789"))) (initzer (p-expr (fixed "8642"))) (initzer (p-expr (fixed "9753"))))))))
230    ;; "37_sprintf"             ; integer formatting unsupported
231    ;;"38_multiple_array_index" ; unspported: (decl (decl-spec-list (type-spec (fixed-type "int"))) (init-declr-list (init-declr (array-of (array-of (ident "a") (p-expr (fixed "4"))) (p-expr (fixed "4"))))))
232    ;;"39_typedef"              ; unsupported: (decl (decl-spec-list (stor-spec (typedef)) (type-spec (typename "MyFunStruct"))) (init-declr-list (init-declr (ptr-declr (pointer) (ident "MoreFunThanEver")))))
233
234    ;;"40_stdio"                ; f* functions
235    "41_hashif"
236    ;;"42_function_pointer"     ; f* functions
237    "43_void_param"
238    "44_scoped_declarations"
239    ;; "45_empty_for"           ; unsupported
240    ;;"46_grep"                 ; f* functions
241    "47_switch_return"
242    "48_nested_break"
243    ;;"49_bracket_evaluation"   ; float
244
245    "50_logical_second_arg"
246    ;;"51_static"               ; unsupported: (decl (decl-spec-list (stor-spec (static)) (type-spec (fixed-type "int"))) (init-declr-list (init-declr (ident "fred") (initzer (p-expr (fixed "1234"))))))
247    ;;"52_unnamed_enum"         ; unsupported: (decl (decl-spec-list (stor-spec (typedef)) (type-spec (enum-def (enum-def-list (enum-defn (ident "e")) (enum-defn (ident "f")) (enum-defn (ident "g")))))) (init-declr-list (init-declr (ident "h"))))
248    "54_goto"
249    ;;"55_lshift_type"          ; unsigned
250    ))
251
252 (add-target (group "check-scaffold-tinycc" #:dependencies (filter (target-prefix? "check-scaffold/tinycc") %targets)))
253
254 ;;(add-target (group "check-scaffold" #:dependencies (filter (target-prefix? "check-scaffold") %targets)))
255
256 ;; (add-target (bin.gcc "scaffold/main.c"))
257 ;; (add-target (check "scaffold/main.gcc" #:exit 42))
258
259 ;; (add-target (bin.gcc "scaffold/main.c" #:libc #f))
260 ;; (add-target (check "scaffold/main.mlibc-gcc" #:exit 42))
261
262 ;; (add-target (bin.mescc "scaffold/main.c" #:libc mini-libc-mes.E))
263 ;; (add-target (check "scaffold/main.mini-guile" #:exit 42))
264
265 ;; (add-target (bin.mescc "scaffold/main.c"))
266 ;; (add-target (check "scaffold/main.guile" #:exit 42))
267
268
269 (add-target (bin.gcc "scaffold/hello.c"))
270 (add-target (check "scaffold/hello.gcc" #:exit 42))
271
272 (add-target (bin.gcc "scaffold/hello.c" #:libc #f))
273 (add-target (check "scaffold/hello.mlibc-gcc" #:exit 42))
274
275 (add-target (bin.mescc "scaffold/hello.c" #:libc mini-libc-mes.E))
276 (add-target (check "scaffold/hello.mini-guile" #:exit 42))
277
278 (add-target (bin.mescc "scaffold/hello.c"))
279 (add-target (check "scaffold/hello.guile" #:exit 42))
280
281
282 (add-target (bin.gcc "scaffold/m.c"))
283 (add-target (check "scaffold/m.gcc" #:exit 255))
284
285 (add-target (bin.gcc "scaffold/m.c" #:libc #f))
286 (add-target (check "scaffold/m.mlibc-gcc" #:exit 255))
287
288 (add-target (bin.mescc "scaffold/m.c"))
289 (add-target (check "scaffold/m.guile" #:exit 255))
290
291 (add-target (bin.gcc "scaffold/micro-mes.c" #:libc #f))
292 (add-target (check "scaffold/micro-mes.mlibc-gcc" #:exit 6)) ; arg1 arg2 arg3 arg4 arg5
293
294 (add-target (bin.mescc "scaffold/micro-mes.c"))
295 (add-target (check "scaffold/micro-mes.guile" #:exit 6)) ; arg1 arg2 arg3 arg4 arg5
296
297 (add-target (group "check-scaffold" #:dependencies (filter (target-prefix? "check-scaffold") %targets)))
298
299 (define snarf-bases
300   '("gc" "lib" "math" "mes" "posix" "reader" "vector"))
301
302 (define bla
303   `(,@(map (cut string-append "src/" <> ".c") snarf-bases)
304     ,@(map (cut string-append "src/" <> ".mes.h") snarf-bases)
305     ,@(map (cut string-append "src/" <> ".mes.i") snarf-bases)
306     ,@(map (cut string-append "src/" <> ".mes.environment.i") snarf-bases)))
307
308 (define gcc-snarf-targets
309   (list
310    (add-target (snarf "src/gc.c" #:mes? #f))
311    (add-target (snarf "src/lib.c" #:mes? #f))
312    (add-target (snarf "src/math.c" #:mes? #f))
313    (add-target (snarf "src/mes.c" #:mes? #f))
314    (add-target (snarf "src/posix.c" #:mes? #f))
315    (add-target (snarf "src/reader.c" #:mes? #f))
316    (add-target (snarf "src/vector.c" #:mes? #f))))
317
318 (define mes-snarf-targets
319   (list
320    (add-target (snarf "src/gc.c"))
321    (add-target (snarf "src/lib.c" #:mes? #t))
322    (add-target (snarf "src/math.c" #:mes? #t))
323    (add-target (snarf "src/mes.c" #:mes? #t))
324    (add-target (snarf "src/posix.c" #:mes? #t))
325    (add-target (snarf "src/reader.c" #:mes? #t))
326    (add-target (snarf "src/vector.c" #:mes? #t))))
327
328 (add-target (bin.gcc "src/mes.c" #:dependencies gcc-snarf-targets
329                      #:defines `("FIXED_PRIMITIVES=1"
330                                  "MES_FULL=1"
331                                  "POSIX=1"
332                                  ,(string-append "VERSION=\"" %version "\"")
333                                  ,(string-append "MODULEDIR=\"" (string-append %prefix (if (string-null? %prefix) "" "/") %moduledir "/") "\"")
334                                  ,(string-append "PREFIX=\"" %prefix "\""))
335                      #:includes '("src")))
336
337 (add-target (bin.gcc "src/mes.c" #:libc #f
338                      #:dependencies mes-snarf-targets
339                      #:defines `("FIXED_PRIMITIVES=1"
340                                  "MES_FULL=1"
341                                  ,(string-append "VERSION=\"" %version "\"")
342                                  ,(string-append "MODULEDIR=\"" (string-append %prefix (if (string-null? %prefix) "" "/") "/" %moduledir "/") "\"")
343                                  ,(string-append "PREFIX=\"" %prefix "\""))
344                      #:includes '("src")))
345
346 (add-target (bin.mescc "src/mes.c" #:dependencies mes-snarf-targets
347                        #:defines `("FIXED_PRIMITIVES=1"
348                                    "MES_FULL=1"
349                                    ,(string-append "VERSION=\"" %version "\"")
350                                    ,(string-append "MODULEDIR=\"" (string-append %prefix (if (string-null? %prefix) "" "/") %moduledir "/") "\"")
351                                    ,(string-append "PREFIX=\"" %prefix "\""))
352                        #:includes '("src")))
353
354 (define mes-tests
355   '("tests/read.test"
356     "tests/base.test"
357     "tests/closure.test"
358     "tests/quasiquote.test"
359     "tests/let.test"
360     "tests/scm.test"
361     "tests/display.test"
362     "tests/cwv.test"
363     "tests/math.test"
364     "tests/vector.test"
365     "tests/srfi-1.test"
366     "tests/srfi-13.test"
367     "tests/srfi-14.test"
368     "tests/optargs.test"
369     "tests/fluids.test"
370     "tests/catch.test"
371     "tests/psyntax.test"
372     "tests/pmatch.test"
373     "tests/let-syntax.test"
374     "tests/guile.test"
375     "tests/record.test"
376     ;;sloooowwww
377     ;;"tests/match.test"
378     ;;"tests/peg.test"
379     ))
380
381 (define (add-mes.gcc-test o)
382   (add-target (target (file-name o)))
383   (add-target (check o #:dependencies (list (get-target "src/mes.mlibc-gcc")))))
384
385 (define (add-mes.guile-test o)
386   (add-target (target (file-name o)))
387   (add-target (check o #:dependencies (list (get-target "src/mes.guile")))))
388
389 ;; takes long, and should always pass if...
390 ;;(for-each add-mes.gcc-test mes-tests)
391
392 ;; ...mes.guile passes :-)
393 (for-each add-mes.guile-test mes-tests)
394
395 ;; FIXME: run tests/base.test
396 (setenv "MES" "src/mes.guile")
397
398 (add-target (install "guile/mescc.scm" #:dir "bin" #:substitutes #t))
399 (add-target (install "scripts/mescc.mes" #:dir "bin" #:substitutes #t))
400 (add-target (install "scripts/repl.mes" #:dir "bin" #:substitutes #t))
401 (define bootstrap? #f)
402 (if bootstrap?
403     (add-target (install "src/mes.mes" #:dir "bin" #:installed-name "mes"))
404     (add-target (install "src/mes.guile" #:dir "bin" #:installed-name "mes")))
405
406 (define* ((install-dir #:key dir) name)
407   (add-target (install name  #:dir (string-append dir "/" (dirname name)))))
408
409 (add-target (install "module/mes/base-0.mes" #:dir (string-append %moduledir "/mes") #:substitutes #t))
410 (add-target (install "module/language/c99/compiler.mes" #:dir (string-append %moduledir "/language/c99") #:substitutes #t))
411
412 (define %module-dir "share/mes")
413 (for-each
414  (lambda (f)
415    ((install-dir #:dir (string-append %module-dir)) f))
416  '("module/language/c99/compiler.mes"
417    "module/language/c99/compiler.scm"
418    "module/language/c99/info.mes"
419    "module/language/c99/info.scm"
420    "module/language/paren.mes"
421    "module/mes/M1.mes"
422    "module/mes/M1.scm"
423    "module/mes/as-i386.mes"
424    "module/mes/as-i386.scm"
425    "module/mes/as.mes"
426    "module/mes/as.scm"
427    ;;"module/mes/base-0.mes"
428    "module/mes/base.mes"
429    "module/mes/bytevectors.mes"
430    "module/mes/bytevectors.scm"
431    "module/mes/catch.mes"
432    "module/mes/display.mes"
433    "module/mes/elf.mes"
434    "module/mes/elf.scm"
435    "module/mes/fluids.mes"
436    "module/mes/getopt-long.mes"
437    "module/mes/getopt-long.scm"
438    "module/mes/guile.mes"
439    "module/mes/lalr.mes"
440    "module/mes/lalr.scm"
441    "module/mes/let.mes"
442    "module/mes/match.mes"
443    "module/mes/match.scm"
444    "module/mes/optargs.mes"
445    "module/mes/optargs.scm"
446    "module/mes/peg.mes"
447    "module/mes/peg/cache.scm"
448    "module/mes/peg/codegen.scm"
449    "module/mes/peg/simplify-tree.scm"
450    "module/mes/peg/string-peg.scm"
451    "module/mes/peg/using-parsers.scm"
452    "module/mes/pmatch.mes"
453    "module/mes/pmatch.scm"
454    "module/mes/posix.mes"
455    "module/mes/pretty-print.mes"
456    "module/mes/pretty-print.scm"
457    "module/mes/psyntax-0.mes"
458    "module/mes/psyntax-1.mes"
459    "module/mes/psyntax.mes"
460    "module/mes/psyntax.pp"
461    "module/mes/psyntax.ss"
462    "module/mes/quasiquote.mes"
463    "module/mes/quasisyntax.mes"
464    "module/mes/quasisyntax.scm"
465    "module/mes/read-0.mes"
466    "module/mes/record-0.mes"
467    "module/mes/record.mes"
468    "module/mes/repl.mes"
469    "module/mes/scm.mes"
470    "module/mes/syntax.mes"
471    "module/mes/syntax.scm"
472    "module/mes/test.mes"
473    "module/mes/tiny-0.mes"
474    "module/mes/type-0.mes"
475    "module/nyacc/lalr.mes"
476    "module/nyacc/lang/c99/cpp.mes"
477    "module/nyacc/lang/c99/parser.mes"
478    "module/nyacc/lang/calc/parser.mes"
479    "module/nyacc/lang/util.mes"
480    "module/nyacc/lex.mes"
481    "module/nyacc/parse.mes"
482    "module/nyacc/util.mes"
483    "module/rnrs/arithmetic/bitwise.mes"
484    "module/srfi/srfi-0.mes"
485    "module/srfi/srfi-1.mes"
486    "module/srfi/srfi-1.scm"
487    "module/srfi/srfi-13.mes"
488    "module/srfi/srfi-14.mes"
489    "module/srfi/srfi-16.mes"
490    "module/srfi/srfi-16.scm"
491    "module/srfi/srfi-26.mes"
492    "module/srfi/srfi-26.scm"
493    "module/srfi/srfi-43.mes"
494    "module/srfi/srfi-9-psyntax.mes"
495    "module/srfi/srfi-9.mes"
496    "module/srfi/srfi-9.scm"
497    "module/sxml/xpath.mes"
498    "module/sxml/xpath.scm"))
499
500 (define* ((install-guile-dir #:key dir) name)
501   (add-target (install (string-append "guile/" name) #:dir (string-append dir "/" (dirname name)))))
502
503 (for-each
504  (lambda (f)
505    ((install-guile-dir #:dir (string-append %guiledir)) f))
506  %scm-files)
507
508 (for-each
509  (lambda (f)
510    ((install-guile-dir #:dir (string-append %godir)) f))
511  %go-files)
512
513 (add-target (install "mlibc/libc-mes.E" #:dir "lib"))
514 (add-target (install "mlibc/libc-mes.M1" #:dir "lib"))
515 (add-target (install "mlibc/libc-mes+tcc.E" #:dir "lib"))
516 (add-target (install "mlibc/libc-mes+tcc.M1" #:dir "lib"))
517 (add-target (install "mlibc/mini-libc-mes.E" #:dir "lib"))
518 (add-target (install "mlibc/mini-libc-mes.M1" #:dir "lib"))
519
520 (for-each
521  (lambda (f)
522    ((install-dir #:dir "share/") f))
523  '("mlibc/include/alloca.h"
524    "mlibc/include/assert.h"
525    "mlibc/include/ctype.h"
526    "mlibc/include/dlfcn.h"
527    "mlibc/include/errno.h"
528    "mlibc/include/fcntl.h"
529    "mlibc/include/features.h"
530    "mlibc/include/inttypes.h"
531    "mlibc/include/libgen.h"
532    "mlibc/include/limits.h"
533    "mlibc/include/locale.h"
534    "mlibc/include/math.h"
535    "mlibc/include/mlibc.h"
536    "mlibc/include/setjmp.h"
537    "mlibc/include/signal.h"
538    "mlibc/include/stdarg.h"
539    "mlibc/include/stdbool.h"
540    "mlibc/include/stdint.h"
541    "mlibc/include/stdio.h"
542    "mlibc/include/stdlib.h"
543    "mlibc/include/stdnoreturn.h"
544    "mlibc/include/string.h"
545    "mlibc/include/strings.h"
546    "mlibc/include/sys/cdefs.h"
547    "mlibc/include/sys/mman.h"
548    "mlibc/include/sys/stat.h"
549    "mlibc/include/sys/time.h"
550    "mlibc/include/sys/timeb.h"
551    "mlibc/include/sys/types.h"
552    "mlibc/include/sys/ucontext.h"
553    "mlibc/include/sys/wait.h"
554    "mlibc/include/time.h"
555    "mlibc/include/unistd.h"))
556
557 (for-each
558  (compose add-target (cut install <> #:dir "share/doc/mes"))
559  '("AUTHORS"
560    ;;"ChangeLog"
561    "COPYING"
562    "HACKING"
563    "INSTALL"
564    "NEWS"
565    "README"
566    "doc/ANNOUNCE-0.9"))
567
568 (add-target (install "doc/fosdem/fosdem.pdf" #:dir "share/doc/mes"))
569
570 (define (main args)
571   (cond ((member "all-go" args) #t)
572         ((member "clean-go" args) (map delete-file (filter file-exists? %go-files)))
573         ((member "clean" args) (clean))
574         ((member "list" args) (display (string-join (map target-file-name %targets) "\n" 'suffix)))
575         ((member "help" args) (format #t "Usage: ./make.scm [TARGET]...
576
577 Targets:
578     all
579     all-go
580     check
581     clean
582     clean-go
583     help~a
584     install
585     list
586 "
587                                       (string-join (filter (negate (cut string-index <> #\/)) (map target-file-name %targets)) "\n    " 'prefix)))
588         (else
589          (let ((targets (match args
590                           (() (filter (negate check-target?) %targets))
591                           ((? (cut member "all" <>)) (filter (conjoin (negate install-target?)
592                                                                       (negate check-target?))
593                                                              %targets))
594                           ((? (cut member "check" <>)) (filter check-target? %targets))
595                           ((? (cut member "install" <>)) (filter install-target? %targets))
596                           (_ (filter-map (cut get-target <>) args)))))
597            (for-each build targets)
598            ;;((@@ (mes make) store) #:print 0)
599            (exit %status)))))
600
601 (main (cdr (command-line)))