source: project/release/5/chicken-belt/trunk/chicken-build.scm @ 35758

Last change on this file since 35758 was 35758, checked in by evhan, 2 years ago

chicken-belt: Add C5 port

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1#!/bin/sh
2#| -*- mode: scheme -*-
3exec csi -s $0 "$@"
4|#
5
6(import (matchable)
7        (chicken io)
8        (chicken pathname)
9        (chicken process)
10        (srfi 13))
11
12(include "chicken-env.scm")
13
14(define (usage #!optional (print printf-newline))
15  (print "Usage: ~A [OPTION ...] NAME
16Build Chicken in current directory and install it to $CHICKENS/NAME.
17
18Options:
19  -b, --bootstrap
20    build and use a bootstrap Chicken
21
22  -c, --chicken CHICKEN_NAME
23    use $CHICKENS/CHICKEN_NAME/bin/chicken for compiling
24
25  -n, --no-spotless
26    don't run make spotless before building
27
28  -d, --debug
29    make a debug build
30
31  -t, --test
32    test the build after installation
33
34  -h, --help
35    show this help"
36         (pathname-file (program-name))))
37
38(define build-boot-chicken? #f)
39(define debug-build? #f)
40(define chicken-name #f)
41(define chicken-bin #f)
42(define spotless? #t)
43(define test? #f)
44
45(when (null? (command-line-arguments))
46  (usage fail))
47
48(let loop ((args (command-line-arguments)))
49  (match args
50    (((or "-b" "--bootstrap") rest ...)
51     (set! build-boot-chicken? #t)
52     (loop rest))
53    (((or "-d" "--debug") rest ...)
54     (set! debug-build? #t)
55     (loop rest))
56    (((or "-n" "--no-spotless") rest ...)
57     (set! spotless? #f)
58     (loop rest))
59    (((or "-t" "--test") rest ...)
60     (set! test? #t)
61     (loop rest))
62    (((or "-c" "--chicken") rest ...)
63     (when (null? rest)
64       (printf-error "Missing argument for -c~%")
65       (usage fail))
66     (set! chicken-bin (make-pathname (make-pathname chicken-coop (car rest)) "bin/chicken"))
67     (loop (cdr rest)))
68    (((or "-h" "--help") rest ...)
69     (usage)
70     (exit))
71    ((name) (=> skip)
72     (if (equal? #\- (string-ref name 0))
73         (skip)
74         (set! chicken-name name)))
75    (rest
76     (unless (null? rest)
77       (printf-error "Invalid arguments: ~S~%" rest)
78       (usage fail)))))
79
80(assert-chicken-coop-exists)
81
82(unless chicken-name
83  (printf-error "Missing NAME~%")
84  (usage fail))
85
86(when (equal? chicken-link chicken-name)
87  (fail "Invalid installation name: ~S" chicken-name))
88
89(define chicken-path
90  (normalize-pathname (make-pathname chicken-coop chicken-name)))
91
92(define (run name . args)
93  (receive (pid success? status)
94      (process-wait (process-run name args))
95    (unless (and success? (zero? status))
96      (exit 1))))
97
98(define purge? #f)
99
100(when (file-exists? chicken-path)
101  (printf "Chicken already exists: ~A~%" chicken-path)
102  (let loop ()
103    (display "Continue? This will purge the existing directory before installation. (yes/no/abort) ")
104    (flush-output)
105    (let ((r (string-trim-both (read-line))))
106      (cond ((string=? r "no"))
107            ((string=? r "yes")
108             (set! purge? #t))
109            ((string=? r "abort")
110             (exit))
111            (else (loop))))))
112
113(when spotless?
114  (run "make" "spotless"))
115
116(when chicken-bin
117  (set-environment-variable! "CHICKEN" chicken-bin))
118
119(when build-boot-chicken?
120  (run "make" "boot-chicken")
121  (set-environment-variable! "CHICKEN" "./chicken-boot")
122  (run "make" "spotless"))
123
124(when debug-build?
125  (set-environment-variable! "DEBUGBUILD" "1"))
126
127(set-environment-variable! "PREFIX" chicken-path)
128
129(run "make")
130
131(when purge?
132  (delete-directory chicken-path 'recursive))
133
134(create-directory chicken-path)
135(run "make" "install")
136
137(when test?
138  (run "make" "check"))
Note: See TracBrowser for help on using the repository browser.