source: project/chicken/tags/0.1071/extend-csi.in @ 17995

Last change on this file since 17995 was 17995, checked in by felix winkelmann, 9 years ago

imported historic version of chicken (0.1071)

File size: 1.5 KB
Line 
1#! %bindir%/csi -script
2;;;; extend-csi - Recompile `csi' with added library units - felix
3
4
5(define home "%chicken_home%")
6(define cc "%cc%")
7(define linkflags "%linkflags%")
8(define csi-extra-units #<<EOF
9%csi_extra_units%
10EOF
11)
12(define csi-compile-options "-optimize-level 2 -quiet -postlude \"(##csi#run)\"")
13
14(define (usage)
15  (display #<<EOF
16Usage: extend-csi UNITNAME | OPTION ...
17
18  -output-file FILENAME         generate interpreter with this name
19                                (defaults to `csi-2')
20
21EOF
22)
23  (exit 64) )
24
25(define (invoke fstr . args)
26  (let ([str (apply sprintf fstr args)])
27    (print str)
28    (unless (zero? (system str)) (error "shell command failed")) ) )
29
30(let ([out "csi-2"]
31      [units '()] )
32  (let loop ([args (command-line-arguments)])
33    (cond [(null? args)
34           (when (null? units) (usage))
35           (invoke "%bindir%/chicken ~A/src/csi.scm ~A -prologue ~A/src/build.scm ~A -prelude \"(declare ~S)\""
36                   home csi-compile-options home csi-extra-units
37                   (cons 'uses (reverse (map string->symbol units))) )
38           (let ([objs (string-concatenate (map (lambda (u) (string-append u ".o")) units) " ")])
39             (invoke "~A ~A out.c ~A `chicken-config -cflags -libs -extra-libs` -o ~A"
40                     cc linkflags objs out)
41             (invoke "rm -f out.c") ) ]
42          [(string=? "-output-file" (car args))
43           (unless (pair? (cdr args)) (usage))
44           (set! out (cadr args))
45           (loop (cddr args)) ]
46          [else
47           (set! units (cons (car args) units))
48           (loop (cdr args)) ] ) ) )
Note: See TracBrowser for help on using the repository browser.