8be7ca89f8c4c7f01e772a2512beda5b3afe27d6
[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
171 (add-target (group "check-scaffold-tests/7" #:dependencies (filter (target-prefix? "check-scaffold/tests/7") %targets)))
172
173 (add-target (group "check-scaffold-tests" #:dependencies (filter (target-prefix? "check-scaffold/tests") %targets)))
174
175 (add-target (cpp.mescc "mlibc/libc-mes+tcc.c"))
176 (add-target (compile.mescc "mlibc/libc-mes+tcc.c"))
177
178 (define* (add-tcc-test name)
179   (add-target (bin.gcc (string-append "scaffold/tinycc/" name ".c") #:libc #f #:includes '("scaffold/tinycc")))
180   (add-target (check (string-append "scaffold/tinycc/" name ".mlibc-gcc") #:baseline (string-append "scaffold/tinycc/" name ".expect")))
181
182   (add-target (bin.mescc (string-append "scaffold/tinycc/" name ".c") #:includes '("scaffold/tinycc")))
183   (add-target (check (string-append "scaffold/tinycc/" name ".guile") #:baseline (string-append "scaffold/tinycc/" name ".expect"))))
184 (map
185  add-tcc-test
186  '("00_assignment"
187    "01_comment"
188    "02_printf"
189    "03_struct"
190    "04_for"
191    "05_array"
192    "06_case"
193    "07_function"
194    "08_while"
195    "09_do_while"
196
197    "10_pointer"
198    "11_precedence"
199    "12_hashdefine"
200    "13_integer_literals"
201    "14_if"
202    "15_recursion"
203    "16_nesting"
204    "17_enum"
205    "18_include"
206    "19_pointer_arithmetic"
207
208    "20_pointer_comparison"
209    "21_char_array"
210    ;;"22_floating_point"       ; float
211    ;;"23_type_coercion"        ; float
212    ;;"24_math_library"         ; float
213    "25_quicksort"
214    ;;"27_sizeof"               ; float
215    ;;"28_strings"              ; TODO: strncpy strchr strrchr memset memcpy memcmp
216    "29_array_address"
217
218    ;;"30_hanoi"                ; fails with GCC
219    "31_args"
220    ;;"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"))))))
221    ;;"34_array_assignment"     ; fails with GCC
222    "33_ternary_op"
223    "35_sizeof"
224    ;;"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"))))))))
225    ;; "37_sprintf"             ; integer formatting unsupported
226    ;;"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"))))))
227    ;;"39_typedef"              ; unsupported: (decl (decl-spec-list (stor-spec (typedef)) (type-spec (typename "MyFunStruct"))) (init-declr-list (init-declr (ptr-declr (pointer) (ident "MoreFunThanEver")))))
228
229    ;;"40_stdio"                ; f* functions
230    "41_hashif"
231    ;;"42_function_pointer"     ; f* functions
232    "43_void_param"
233    "44_scoped_declarations"
234    ;; "45_empty_for"           ; unsupported
235    ;;"46_grep"                 ; f* functions
236    "47_switch_return"
237    "48_nested_break"
238    ;;"49_bracket_evaluation"   ; float
239
240    "50_logical_second_arg"
241    ;;"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"))))))
242    ;;"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"))))
243    "54_goto"
244    ;;"55_lshift_type"          ; unsigned
245    ))
246
247 (add-target (group "check-scaffold-tinycc" #:dependencies (filter (target-prefix? "check-scaffold/tinycc") %targets)))
248
249 ;;(add-target (group "check-scaffold" #:dependencies (filter (target-prefix? "check-scaffold") %targets)))
250
251 (add-target (bin.gcc "scaffold/main.c"))
252 (add-target (check "scaffold/main.gcc" #:exit 42))
253
254 (add-target (bin.gcc "scaffold/main.c" #:libc #f))
255 (add-target (check "scaffold/main.mlibc-gcc" #:exit 42))
256
257 (add-target (bin.mescc "scaffold/main.c" #:libc mini-libc-mes.E))
258 (add-target (check "scaffold/main.mini-guile" #:exit 42))
259
260 (add-target (bin.mescc "scaffold/main.c"))
261 (add-target (check "scaffold/main.guile" #:exit 42))
262
263
264 (add-target (bin.gcc "scaffold/hello.c"))
265 (add-target (check "scaffold/hello.gcc" #:exit 42))
266
267 (add-target (bin.gcc "scaffold/hello.c" #:libc #f))
268 (add-target (check "scaffold/hello.mlibc-gcc" #:exit 42))
269
270 (add-target (bin.mescc "scaffold/hello.c" #:libc mini-libc-mes.E))
271 (add-target (check "scaffold/hello.mini-guile" #:exit 42))
272
273 (add-target (bin.mescc "scaffold/hello.c"))
274 (add-target (check "scaffold/hello.guile" #:exit 42))
275
276
277 (add-target (bin.gcc "scaffold/m.c"))
278 (add-target (check "scaffold/m.gcc" #:exit 255))
279
280 (add-target (bin.gcc "scaffold/m.c" #:libc #f))
281 (add-target (check "scaffold/m.mlibc-gcc" #:exit 255))
282
283 (add-target (bin.mescc "scaffold/m.c"))
284 (add-target (check "scaffold/m.guile" #:exit 255))
285
286 (add-target (bin.gcc "scaffold/micro-mes.c" #:libc #f))
287 (add-target (check "scaffold/micro-mes.mlibc-gcc" #:exit 6)) ; arg1 arg2 arg3 arg4 arg5
288
289 (add-target (bin.mescc "scaffold/micro-mes.c"))
290 (add-target (check "scaffold/micro-mes.guile" #:exit 6)) ; arg1 arg2 arg3 arg4 arg5
291
292 (add-target (group "check-scaffold" #:dependencies (filter (target-prefix? "check-scaffold") %targets)))
293
294 (define snarf-bases
295   '("gc" "lib" "math" "mes" "posix" "reader" "vector"))
296
297 (define bla
298   `(,@(map (cut string-append "src/" <> ".c") snarf-bases)
299     ,@(map (cut string-append "src/" <> ".mes.h") snarf-bases)
300     ,@(map (cut string-append "src/" <> ".mes.i") snarf-bases)
301     ,@(map (cut string-append "src/" <> ".mes.environment.i") snarf-bases)))
302
303 (define gcc-snarf-targets
304   (list
305    (add-target (snarf "src/gc.c" #:mes? #f))
306    (add-target (snarf "src/lib.c" #:mes? #f))
307    (add-target (snarf "src/math.c" #:mes? #f))
308    (add-target (snarf "src/mes.c" #:mes? #f))
309    (add-target (snarf "src/posix.c" #:mes? #f))
310    (add-target (snarf "src/reader.c" #:mes? #f))
311    (add-target (snarf "src/vector.c" #:mes? #f))))
312
313 (define mes-snarf-targets
314   (list
315    (add-target (snarf "src/gc.c"))
316    (add-target (snarf "src/lib.c" #:mes? #t))
317    (add-target (snarf "src/math.c" #:mes? #t))
318    (add-target (snarf "src/mes.c" #:mes? #t))
319    (add-target (snarf "src/posix.c" #:mes? #t))
320    (add-target (snarf "src/reader.c" #:mes? #t))
321    (add-target (snarf "src/vector.c" #:mes? #t))))
322
323 (add-target (bin.gcc "src/mes.c" #:dependencies gcc-snarf-targets
324                      #:defines `("FIXED_PRIMITIVES=1"
325                                  "MES_FULL=1"
326                                  "POSIX=1"
327                                  ,(string-append "VERSION=\"" %version "\"")
328                                  ,(string-append "MODULEDIR=\"" (string-append %prefix (if (string-null? %prefix) "" "/") %moduledir "/") "\"")
329                                  ,(string-append "PREFIX=\"" %prefix "\""))
330                      #:includes '("src")))
331
332 (add-target (bin.gcc "src/mes.c" #:libc #f
333                      #:dependencies mes-snarf-targets
334                      #:defines `("FIXED_PRIMITIVES=1"
335                                  "MES_FULL=1"
336                                  ,(string-append "VERSION=\"" %version "\"")
337                                  ,(string-append "MODULEDIR=\"" (string-append %prefix (if (string-null? %prefix) "" "/") "/" %moduledir "/") "\"")
338                                  ,(string-append "PREFIX=\"" %prefix "\""))
339                      #:includes '("src")))
340
341 (add-target (bin.mescc "src/mes.c" #:dependencies mes-snarf-targets
342                        #:defines `("FIXED_PRIMITIVES=1"
343                                    "MES_FULL=1"
344                                    ,(string-append "VERSION=\"" %version "\"")
345                                    ,(string-append "MODULEDIR=\"" (string-append %prefix (if (string-null? %prefix) "" "/") %moduledir "/") "\"")
346                                    ,(string-append "PREFIX=\"" %prefix "\""))
347                        #:includes '("src")))
348
349 (define mes-tests
350   '("tests/read.test"
351     "tests/base.test"
352     "tests/closure.test"
353     "tests/quasiquote.test"
354     "tests/let.test"
355     "tests/scm.test"
356     "tests/display.test"
357     "tests/cwv.test"
358     "tests/math.test"
359     "tests/vector.test"
360     "tests/srfi-1.test"
361     "tests/srfi-13.test"
362     "tests/srfi-14.test"
363     "tests/optargs.test"
364     "tests/fluids.test"
365     "tests/catch.test"
366     "tests/psyntax.test"
367     "tests/pmatch.test"
368     "tests/let-syntax.test"
369     "tests/guile.test"
370     "tests/record.test"
371     ;;sloooowwww
372     ;;"tests/match.test"
373     ;;"tests/peg.test"
374     ))
375
376 (define (add-mes.gcc-test o)
377   (add-target (target (file-name o)))
378   (add-target (check o #:dependencies (list (get-target "src/mes.mlibc-gcc")))))
379
380 (define (add-mes.guile-test o)
381   (add-target (target (file-name o)))
382   (add-target (check o #:dependencies (list (get-target "src/mes.guile")))))
383
384 ;; takes long, and should always pass if...
385 ;;(for-each add-mes.gcc-test mes-tests)
386
387 ;; ...mes.guile passes :-)
388 (for-each add-mes.guile-test mes-tests)
389
390 ;; FIXME: run tests/base.test
391 (setenv "MES" "src/mes.guile")
392
393 (add-target (install "guile/mescc.scm" #:dir "bin" #:substitutes #t))
394 (add-target (install "scripts/mescc.mes" #:dir "bin" #:substitutes #t))
395 (add-target (install "scripts/repl.mes" #:dir "bin" #:substitutes #t))
396 (define bootstrap? #f)
397 (if bootstrap?
398     (add-target (install "src/mes.mes" #:dir "bin" #:installed-name "mes"))
399     (add-target (install "src/mes.guile" #:dir "bin" #:installed-name "mes")))
400
401 (define* ((install-dir #:key dir) name)
402   (add-target (install name  #:dir (string-append dir "/" (dirname name)))))
403
404 (add-target (install "module/mes/base-0.mes" #:dir (string-append %moduledir "/mes") #:substitutes #t))
405 (add-target (install "module/language/c99/compiler.mes" #:dir (string-append %moduledir "/language/c99") #:substitutes #t))
406
407 (define %module-dir "share/mes")
408 (for-each
409  (lambda (f)
410    ((install-dir #:dir (string-append %module-dir)) f))
411  '("module/language/c99/compiler.mes"
412    "module/language/c99/compiler.scm"
413    "module/language/c99/info.mes"
414    "module/language/c99/info.scm"
415    "module/language/paren.mes"
416    "module/mes/M1.mes"
417    "module/mes/M1.scm"
418    "module/mes/as-i386.mes"
419    "module/mes/as-i386.scm"
420    "module/mes/as.mes"
421    "module/mes/as.scm"
422    ;;"module/mes/base-0.mes"
423    "module/mes/base.mes"
424    "module/mes/bytevectors.mes"
425    "module/mes/bytevectors.scm"
426    "module/mes/catch.mes"
427    "module/mes/display.mes"
428    "module/mes/elf.mes"
429    "module/mes/elf.scm"
430    "module/mes/fluids.mes"
431    "module/mes/getopt-long.mes"
432    "module/mes/getopt-long.scm"
433    "module/mes/guile.mes"
434    "module/mes/lalr.mes"
435    "module/mes/lalr.scm"
436    "module/mes/let.mes"
437    "module/mes/match.mes"
438    "module/mes/match.scm"
439    "module/mes/optargs.mes"
440    "module/mes/optargs.scm"
441    "module/mes/peg.mes"
442    "module/mes/peg/cache.scm"
443    "module/mes/peg/codegen.scm"
444    "module/mes/peg/simplify-tree.scm"
445    "module/mes/peg/string-peg.scm"
446    "module/mes/peg/using-parsers.scm"
447    "module/mes/pmatch.mes"
448    "module/mes/pmatch.scm"
449    "module/mes/posix.mes"
450    "module/mes/pretty-print.mes"
451    "module/mes/pretty-print.scm"
452    "module/mes/psyntax-0.mes"
453    "module/mes/psyntax-1.mes"
454    "module/mes/psyntax.mes"
455    "module/mes/psyntax.pp"
456    "module/mes/psyntax.ss"
457    "module/mes/quasiquote.mes"
458    "module/mes/quasisyntax.mes"
459    "module/mes/quasisyntax.scm"
460    "module/mes/read-0.mes"
461    "module/mes/record-0.mes"
462    "module/mes/record.mes"
463    "module/mes/repl.mes"
464    "module/mes/scm.mes"
465    "module/mes/syntax.mes"
466    "module/mes/syntax.scm"
467    "module/mes/test.mes"
468    "module/mes/tiny-0.mes"
469    "module/mes/type-0.mes"
470    "module/nyacc/lalr.mes"
471    "module/nyacc/lang/c99/cpp.mes"
472    "module/nyacc/lang/c99/parser.mes"
473    "module/nyacc/lang/calc/parser.mes"
474    "module/nyacc/lang/util.mes"
475    "module/nyacc/lex.mes"
476    "module/nyacc/parse.mes"
477    "module/nyacc/util.mes"
478    "module/rnrs/arithmetic/bitwise.mes"
479    "module/srfi/srfi-0.mes"
480    "module/srfi/srfi-1.mes"
481    "module/srfi/srfi-1.scm"
482    "module/srfi/srfi-13.mes"
483    "module/srfi/srfi-14.mes"
484    "module/srfi/srfi-16.mes"
485    "module/srfi/srfi-16.scm"
486    "module/srfi/srfi-26.mes"
487    "module/srfi/srfi-26.scm"
488    "module/srfi/srfi-43.mes"
489    "module/srfi/srfi-9-psyntax.mes"
490    "module/srfi/srfi-9.mes"
491    "module/srfi/srfi-9.scm"
492    "module/sxml/xpath.mes"
493    "module/sxml/xpath.scm"))
494
495 (define* ((install-guile-dir #:key dir) name)
496   (add-target (install (string-append "guile/" name) #:dir (string-append dir "/" (dirname name)))))
497
498 (for-each
499  (lambda (f)
500    ((install-guile-dir #:dir (string-append %guiledir)) f))
501  %scm-files)
502
503 (for-each
504  (lambda (f)
505    ((install-guile-dir #:dir (string-append %godir)) f))
506  %go-files)
507
508 (add-target (install "mlibc/libc-mes.E" #:dir "lib"))
509 (add-target (install "mlibc/libc-mes.M1" #:dir "lib"))
510 (add-target (install "mlibc/libc-mes+tcc.E" #:dir "lib"))
511 (add-target (install "mlibc/libc-mes+tcc.M1" #:dir "lib"))
512 (add-target (install "mlibc/mini-libc-mes.E" #:dir "lib"))
513 (add-target (install "mlibc/mini-libc-mes.M1" #:dir "lib"))
514
515 (for-each
516  (lambda (f)
517    ((install-dir #:dir "share/") f))
518  '("mlibc/include/alloca.h"
519    "mlibc/include/assert.h"
520    "mlibc/include/ctype.h"
521    "mlibc/include/dlfcn.h"
522    "mlibc/include/errno.h"
523    "mlibc/include/fcntl.h"
524    "mlibc/include/features.h"
525    "mlibc/include/inttypes.h"
526    "mlibc/include/libgen.h"
527    "mlibc/include/limits.h"
528    "mlibc/include/locale.h"
529    "mlibc/include/math.h"
530    "mlibc/include/mlibc.h"
531    "mlibc/include/setjmp.h"
532    "mlibc/include/signal.h"
533    "mlibc/include/stdarg.h"
534    "mlibc/include/stdbool.h"
535    "mlibc/include/stdint.h"
536    "mlibc/include/stdio.h"
537    "mlibc/include/stdlib.h"
538    "mlibc/include/stdnoreturn.h"
539    "mlibc/include/string.h"
540    "mlibc/include/strings.h"
541    "mlibc/include/sys/cdefs.h"
542    "mlibc/include/sys/mman.h"
543    "mlibc/include/sys/stat.h"
544    "mlibc/include/sys/time.h"
545    "mlibc/include/sys/timeb.h"
546    "mlibc/include/sys/types.h"
547    "mlibc/include/sys/ucontext.h"
548    "mlibc/include/sys/wait.h"
549    "mlibc/include/time.h"
550    "mlibc/include/unistd.h"))
551
552 (for-each
553  (compose add-target (cut install <> #:dir "share/doc/mes"))
554  '("AUTHORS"
555    ;;"ChangeLog"
556    "COPYING"
557    "HACKING"
558    "INSTALL"
559    "NEWS"
560    "README"
561    "doc/ANNOUNCE-0.9"))
562
563 (add-target (install "doc/fosdem/fosdem.pdf" #:dir "share/doc/mes"))
564
565 (define (main args)
566   (cond ((member "all-go" args) #t)
567         ((member "clean-go" args) (map delete-file (filter file-exists? %go-files)))
568         ((member "clean" args) (clean))
569         ((member "list" args) (display (string-join (map target-file-name %targets) "\n" 'suffix)))
570         ((member "help" args) (format #t "Usage: ./make.scm [TARGET]...
571
572 Targets:
573     all
574     all-go
575     check
576     clean
577     clean-go
578     help~a
579     install
580     list
581 "
582                                       (string-join (filter (negate (cut string-index <> #\/)) (map target-file-name %targets)) "\n    " 'prefix)))
583         (else
584          (let ((targets (match args
585                           (() (filter (negate check-target?) %targets))
586                           ((? (cut member "all" <>)) (filter (conjoin (negate install-target?)
587                                                                       (negate check-target?))
588                                                              %targets))
589                           ((? (cut member "check" <>)) (filter check-target? %targets))
590                           ((? (cut member "install" <>)) (filter install-target? %targets))
591                           (_ (filter-map (cut get-target <>) args)))))
592            (for-each build targets)
593            ;;((@@ (mes make) store) #:print 0)
594            (exit %status)))))
595
596 (main (cdr (command-line)))