| 1 |
;;; |
| 2 |
;;; build-standalone |
| 3 |
;;; |
| 4 |
;;; Copyright (c) 2000-2014 Shiro Kawai <[email protected]> |
| 5 |
;;; |
| 6 |
;;; Redistribution and use in source and binary forms, with or without |
| 7 |
;;; modification, are permitted provided that the following conditions |
| 8 |
;;; are met: |
| 9 |
;;; |
| 10 |
;;; 1. Redistributions of source code must retain the above copyright |
| 11 |
;;; notice, this list of conditions and the following disclaimer. |
| 12 |
;;; |
| 13 |
;;; 2. Redistributions in binary form must reproduce the above copyright |
| 14 |
;;; notice, this list of conditions and the following disclaimer in the |
| 15 |
;;; documentation and/or other materials provided with the distribution. |
| 16 |
;;; |
| 17 |
;;; 3. Neither the name of the authors nor the names of its contributors |
| 18 |
;;; may be used to endorse or promote products derived from this |
| 19 |
;;; software without specific prior written permission. |
| 20 |
;;; |
| 21 |
;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 22 |
;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 23 |
;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 24 |
;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 25 |
;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 26 |
;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
| 27 |
;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 28 |
;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 29 |
;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 30 |
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 31 |
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 |
;;; |
| 33 |
|
| 34 |
(use gauche.cgen.standalone) |
| 35 |
(use gauche.parseopt) |
| 36 |
|
| 37 |
(define (usage) |
| 38 |
(print "Usage: build-standalone [-o outfile][-I dir][--header-dir dir][--library-dir dir] main.scm lib/library.scm ...") |
| 39 |
(print) |
| 40 |
(print "Options:") |
| 41 |
(display (option-parser-help-string)) |
| 42 |
(print) |
| 43 |
(print "The file <main.scm> is the main script file; usually it contains 'main'") |
| 44 |
(print "procedure. Other files <lib/library.scm> ... are extra library files needed") |
| 45 |
(print "by <main.scm>. They are loaded before executing main.scm.") |
| 46 |
(exit 1)) |
| 47 |
|
| 48 |
(define (main args) |
| 49 |
(let-args (cdr args) |
| 50 |
([outfile "o=s{OUTFILE}" |
| 51 |
? "Specify output file name. When omitted, the basename of |
| 52 |
the main source file is used."] |
| 53 |
[incdirs "I*=s{DIR}" |
| 54 |
? "Specify the search path of extra files (lib/library.scm ...) |
| 55 |
if they're not relative to the current directory. |
| 56 |
This option can be given multiple times."] |
| 57 |
[defs "D*=s{VAR[=VAL]}" |
| 58 |
? "Add C preprocessor definitions while compiling the generated |
| 59 |
C code. This option can be given multiple times."] |
| 60 |
[hdrdirs "header-dir*=s{DIR}" |
| 61 |
? "Alternative include directory to find gauche.h etc. |
| 62 |
Specify this if you don't want to use installed Gauche's |
| 63 |
header files. This option can be given multiple times."] |
| 64 |
[libdirs "library-dir*=s{DIR}" |
| 65 |
? "Alternative library directory to find libgauche-static. |
| 66 |
Specify this if you don't want to use installed Gauche's |
| 67 |
library. This option can be given multiple times."] |
| 68 |
[keepc "keep-c-file" |
| 69 |
? "Do not delete intermediate C file after compilation. |
| 70 |
This is for troubleshooting."] |
| 71 |
[dynamic "dynamic" |
| 72 |
? "Instead of statically linking libgauche, use the system's |
| 73 |
library at runtime. The resulting binary requires libgauche |
| 74 |
to run, so it's not really 'standalone', but the binary size |
| 75 |
is much smaller."] |
| 76 |
[else _ (usage)] |
| 77 |
. files) |
| 78 |
(when (null? files) (usage)) |
| 79 |
(build-standalone (car files) |
| 80 |
:outfile outfile |
| 81 |
:extra-files (cdr files) |
| 82 |
:include-dirs incdirs |
| 83 |
:cpp-definitions defs |
| 84 |
:header-dirs hdrdirs |
| 85 |
:library-dirs libdirs |
| 86 |
:dynamic dynamic |
| 87 |
:keep-c-file keepc)) |
| 88 |
0) |
| 89 |
|
| 90 |
;; Local variables: |
| 91 |
;; mode: scheme |
| 92 |
;; end: |