| 1 |
;; -*- coding: utf-8 -*- |
| 2 |
;;; |
| 3 |
;;; Generate genconfig.in |
| 4 |
;;; |
| 5 |
|
| 6 |
(use srfi.13) |
| 7 |
(use util.match) |
| 8 |
|
| 9 |
;; |
| 10 |
;; gen-genconfig.scm |
| 11 |
;; + <---- genconfig.in.in : template |
| 12 |
;; | |
| 13 |
;; |<== release tarball creation |
| 14 |
;; | |
| 15 |
;; +-----------------+---------------------------\ |
| 16 |
;; | | | |
| 17 |
;; v v v |
| 18 |
;; genconfig.in doc/gauche-config.1.in doc/man-gauche-config.texi |
| 19 |
;; | | |
| 20 |
;; |<== configure | |
| 21 |
;; v v |
| 22 |
;; genconfig doc/gauche/config.1 |
| 23 |
;; | |
| 24 |
;; |<== make |
| 25 |
;; v |
| 26 |
;; gauche-config.c |
| 27 |
;; paths_arch.c |
| 28 |
;; lib/gauche/config.scm |
| 29 |
;; |
| 30 |
|
| 31 |
;; This script should depend on _released_ Gauche. Do not use pre-release |
| 32 |
;; features. |
| 33 |
|
| 34 |
;; To add a new option to gauche-config, edit *config-parameters*. |
| 35 |
;; |
| 36 |
;; <config-parameter> : <section> | <entry> |
| 37 |
;; <section> : (section <string> [<string-ja>]) ; used in help message |
| 38 |
;; <entry> : (((<option> <source-string>) ...) <help-message> [<help-message-ja>]) |
| 39 |
(define *config-parameters* |
| 40 |
'((section |
| 41 |
"General parameter" |
| 42 |
"一般のパラメータ") |
| 43 |
((("-V" "$gauche_version")) |
| 44 |
"The current Gauche version." |
| 45 |
"現在のGaucheのバージョン") |
| 46 |
|
| 47 |
(section |
| 48 |
"Parameters to compile applications using Gauche" |
| 49 |
"Gaucheを使ったアプリケーションのコンパイルのためのパラメータ") |
| 50 |
((("-I" "-I$gauche_incdir")) |
| 51 |
"Include path options required to compile programs using Gauche\n\ |
| 52 |
(Note: This doesn't work if Gauche installation directory\n\ |
| 53 |
path contains whitespaces. See --incdirs below.)" |
| 54 |
"Gaucheを使ったプログラムをコンパイルするのに必要なインクルードパスオプション\n\ |
| 55 |
(Gaucheのインストール先のパスが空白を含んでいる場合、これは |
| 56 |
使えません。下の--incdirsを見てください。)") |
| 57 |
((("-L" "-L$gauche_archdir $local_lib")) |
| 58 |
"Library path options required to link programs using Gauche\n\ |
| 59 |
(Note: This doesn't work if Gauche installation directory\n\ |
| 60 |
path contains whitespaces. See --archdirs below.)" |
| 61 |
"Gaucheを使ったプログラムをコンパイルするのに必要なライブラリパスオプション\n\ |
| 62 |
(Gaucheのインストール先のパスが空白を含んでいる場合、これは |
| 63 |
使えません。下の--incdirsを見てください。)") |
| 64 |
((("-l" "-l$garchabi $gauche_libs")) |
| 65 |
"Link library options required to link programs using Gauche." |
| 66 |
"Gaucheを使ったプログラムをリンクする時に必要なライブラリオプション") |
| 67 |
((("--cc" "$cc")) |
| 68 |
"The name of the C compiler used to compile this Gauche." |
| 69 |
"このGaucheをコンパイルする時に使われたCコンパイラ名") |
| 70 |
((("--cpp" "$cpp")) |
| 71 |
"The command to run the C preprocessor." |
| 72 |
"Cプリプロセッサを走らせるコマンド") |
| 73 |
((("--ac" "$gauche_aclocaldir")) |
| 74 |
"The directory that contains Gauche-specific autoconf macros." |
| 75 |
"Gauche用のautoconfマクロがインストールされているディレクトリ名") |
| 76 |
((("--reconfigure" "./configure $gauche_configure_args")) |
| 77 |
"The command line used to configure the current installation." |
| 78 |
"現在インストールされているGaucheに使われたconfigureのオプション") |
| 79 |
((("--arch" "$arch")) |
| 80 |
"The autoconf-style architecture signature (cpu-vendor-kernel-os)." |
| 81 |
"autoconf形式のアーキテクチャシグネチャ (cpu-vendor-kernel-os)") |
| 82 |
((("--incdirs" "$incdirs") |
| 83 |
("--archdirs" "$archdirs")) |
| 84 |
"The list of directory names to be looked for include files and\n\ |
| 85 |
libraries, respectively. Each directory name may be quoted if\n\ |
| 86 |
it contains whitespaces, and separated by ':' on Unix platforms, or\n\ |
| 87 |
by ';' on Windows platforms." |
| 88 |
"それぞれ、インクルードファイルとライブラリファイルが探されるディレクトリのリスト。\n\ |
| 89 |
各ディレクトリ名は、それが空白を含んでいる場合はクオートされています。また、\n\ |
| 90 |
それぞれのディレクトリ名の間はUnixでは ':'、Windowsでは ';' で区切られています。") |
| 91 |
((("--local-incdir" "$local_inc") |
| 92 |
("--local-libdir" "$local_lib")) |
| 93 |
"These are '-I' and '-L' flags for additional local headers/libraries\n\ |
| 94 |
to search, given by '--with-local' configure flags. Note that those\n\ |
| 95 |
are also included in '-I', '-L', '--incdirs', and '--archdirs'." |
| 96 |
"これらは、追加のローカルヘッダファイルやライブラリファイルを探すために必要な\n\ |
| 97 |
'-I' および '-L' フラグのリストです。これらはconfigure時の '--with-local' \n\ |
| 98 |
オプションにより設定されます。追加のローカルディレクトリは、'-I'、'-L'、'--incdirs'\n\ |
| 99 |
'--arcdirs' の出力にも含まれます。") |
| 100 |
|
| 101 |
(section |
| 102 |
"Parameters to install files" |
| 103 |
"ファイルをインストールするためのパラメータ") |
| 104 |
((("--prefix" "$prefix")) |
| 105 |
"The directory prefix set by configure." |
| 106 |
"configure時に設定されたディレクトリプレフィクス") |
| 107 |
((("--sysincdir" "$gauche_incdir") |
| 108 |
("--siteincdir" "$gauche_siteincdir") |
| 109 |
("--pkgincdir" "$gauche_pkgincdir")) |
| 110 |
"Directories where system|site|package header files of extensions go." |
| 111 |
"それぞれ、システム/サイト/パッケージレベルの拡張モジュールヘッダファイルが\n\ |
| 112 |
インストールされるべきディレクトリ") |
| 113 |
((("--syslibdir" "$gauche_libdir") |
| 114 |
("--sitelibdir" "$gauche_sitelibdir") |
| 115 |
("--pkglibdir" "$gauche_pkglibdir")) |
| 116 |
"Directories where system|site|package scheme files go." |
| 117 |
"それぞれ、システム/サイト/パッケージのSchemeファイルがインストールされる\n\ |
| 118 |
べきディレクトリ") |
| 119 |
((("--sysarchdir" "$gauche_archdir") |
| 120 |
("--sitearchdir" "$gauche_sitearchdir") |
| 121 |
("--pkgarchdir" "$gauche_pkgarchdir")) |
| 122 |
"Directories where system|site|package DSO files go." |
| 123 |
"それぞれ、システム/サイト/パッケージのDSOファイルがインストールされる\n\ |
| 124 |
べきディレクトリ") |
| 125 |
((("--mandir" "$mandir") |
| 126 |
("--infodir" "$infodir")) |
| 127 |
"Directories where gauche manpage and info docs are installed." |
| 128 |
"それぞれ、Gaucheのmanpageとinfoドキュメントがインストールされるべきディレクトリ") |
| 129 |
|
| 130 |
(section |
| 131 |
"Parameters to help building extensions" |
| 132 |
"拡張モジュールをビルドするためのパラメータ") |
| 133 |
((("--object-suffix" "$object_suffix")) |
| 134 |
"The extension of the compiled objects (e.g. 'o' or 'obj')." |
| 135 |
"コンパイルされたオブジェクトファイルの拡張子 (例: 'o' や 'obj')") |
| 136 |
((("--executable-suffix" "$executable_suffix")) |
| 137 |
"The extension of the executable including a period (empty on Unix systems,\n\ |
| 138 |
'.exe' on Windows." |
| 139 |
"実行可能ファイルの拡張氏(ピリオドを含む)。Unixシステムでは空文字列、 |
| 140 |
Windowsでは '.exe'。") |
| 141 |
((("--so-suffix" "$shlib_so_suffix")) |
| 142 |
"The extension for dynamically loadable (dlopen-able) modules (e.g. 'so')." |
| 143 |
"動的ロード(dlopen)可能なファイルの拡張子 (例: 'so')") |
| 144 |
((("--so-cflags" "$shlib_so_cflags")) |
| 145 |
"Additional CFLAGS to create dynamically loadable modules." |
| 146 |
"動的ロード可能なファイルを作るために追加で必要なCFLAGS") |
| 147 |
((("--so-ldflags" "$shlib_so_ldflags")) |
| 148 |
"Additional LDFLAGS to create dynamically loadable modules." |
| 149 |
"動的ロード可能なファイルを作るために追加で必要なLDFLAGS") |
| 150 |
((("--so-libs" "$shlib_so_libs")) |
| 151 |
"Additional libraries required to create dynamically loadable modules." |
| 152 |
"動的ロード可能なファイルを作るために追加で必要なライブラリ") |
| 153 |
((("--dylib-suffix" "$shlib_dylib_suffix")) |
| 154 |
"The extension for dynamically linked libraries (as opposed to dlopen()ed)\n\ |
| 155 |
Usually the same as --so-suffix, but OSX wants 'dylib'." |
| 156 |
"動的リンクされる (dlopenされるのではない) ライブラリファイルの拡張子。\n\ |
| 157 |
通常は--so-suffixと同じだが、OSXでは 'dylib'。") |
| 158 |
((("--dylib-ldflags" "$shlib_dylib_ldflags")) |
| 159 |
"LDFLAGS to create dynamically linked libraries." |
| 160 |
"動的リンクされるライブラリファイルを作るのに必要なLDFLAGS。") |
| 161 |
((("--rpath-flag" "$rpath_flag")) |
| 162 |
"Compiler flag(s) to embed RPATH" |
| 163 |
"RPATHを埋め込むためのコンパイラフラグ") |
| 164 |
((("--default-cflags" "$default_cflags")) |
| 165 |
"This is the CFLAGS used to compile Gauche, and to be used to compile\n\ |
| 166 |
extensions as well." |
| 167 |
"Gaucheをコンパイルする時に使われたCFLAGS。拡張モジュールをコンパイルする時にも\n\ |
| 168 |
同じフラグを使うべき。") |
| 169 |
((("--cppflags" "$cppflags")) |
| 170 |
"Compiler flag(s) passed to C preprocessor" |
| 171 |
"Cプリプロセッサに渡されるコンパイラフラグ") |
| 172 |
((("--static-libs" "$static_libs")) |
| 173 |
"List of library link flags ('-llib') required to link Gauche statically.\n\ |
| 174 |
Similar to '-l', but this includes the libraries that are used\n\ |
| 175 |
for extension modules, and also the static library itself,\n\ |
| 176 |
that is -lgauche-static-X.X." |
| 177 |
"Gaucheを静的リンクする時に必要なリンクフラグ ('-llib') のリスト。\n\ |
| 178 |
'-l' と似ているが、これは拡張モジュールが必要とするライブラリ、\n\ |
| 179 |
及びGaucheの静的ライブラリ本体('-lgauche-static-X.X')を含んでいる。") |
| 180 |
((("--libgauche-so" "$libgauche_so")) |
| 181 |
"The base name of dynamically linked libgauche." |
| 182 |
"動的リンクされるlibgaucheのbasename") |
| 183 |
|
| 184 |
)) ; end of *config-parameters* |
| 185 |
|
| 186 |
;; |
| 187 |
;; Generating genconfig.in from genconfig.in.in |
| 188 |
;; |
| 189 |
|
| 190 |
(define (generate genconfig.in.in) |
| 191 |
(define (process-line line) |
| 192 |
(cond |
| 193 |
[(equal? line "@@@USAGE@@@") (gen-usage)] |
| 194 |
[(equal? line "@@@COMMAND_TABLE@@@") (gen-command-table)] |
| 195 |
[(equal? line "@@@COMMAND_LIST@@@") (gen-command-list)] |
| 196 |
[(string-prefix? "@@@" line)] |
| 197 |
[else (print line)])) |
| 198 |
|
| 199 |
(call-with-input-file genconfig.in.in |
| 200 |
(^p (for-each process-line (port->string-list p))))) |
| 201 |
|
| 202 |
(define (gen-usage) |
| 203 |
(dolist [e *config-parameters*] |
| 204 |
(match e |
| 205 |
[('section section-e . _) |
| 206 |
(format #t " \"\\n\"\n \"~a\\n\"\n" section-e)] |
| 207 |
[(((opt src) ...) help . _) |
| 208 |
;; TRANSIENT: After 1.0 release, we can switch to use text.fill |
| 209 |
;; (let1 s `(,(map (cut format " ~a\n" <>) (drop-right opt 1)) |
| 210 |
;; ,($ tree->string $ text->filled-stree help |
| 211 |
;; :indent 8 |
| 212 |
;; :lead-in (format " ~a" (last opt)) |
| 213 |
;; :width 78)) |
| 214 |
;; (dolist [h (string-split s #\newline)] |
| 215 |
;; (format #t " \"~a\\n\"\n" h))) |
| 216 |
(dolist [o opt] |
| 217 |
(format #t " \" ~a\\n\"\n" o)) |
| 218 |
(dolist [h (string-split help #\newline)] |
| 219 |
(format #t " \" ~a\\n\"\n" h))]))) |
| 220 |
|
| 221 |
(define (gen-command-table) |
| 222 |
(dolist [e *config-parameters*] |
| 223 |
(match e |
| 224 |
[('section . _) #f] |
| 225 |
[(((opt src) ...) help . _) |
| 226 |
(for-each (^[o s] (format #t " {~s, ~s},\n" o s)) opt src)]))) |
| 227 |
|
| 228 |
(define (gen-command-list) |
| 229 |
(dolist [e *config-parameters*] |
| 230 |
(match e |
| 231 |
[('section . _) #f] |
| 232 |
[(((opt src) ...) help . _) |
| 233 |
(for-each (^[o s] (format #t " (~s ~s)\n" o s)) opt src)]))) |
| 234 |
|
| 235 |
;; Generate info fragment to be included from doc/program.texi |
| 236 |
(define (gen-info) |
| 237 |
(print "@c To be included from program.texi") |
| 238 |
(print "@c Generated by gen-genconfig.scm. DO NOT EDIT.") |
| 239 |
(fold (^[e state] |
| 240 |
(match e |
| 241 |
[('section section-en section-ja) |
| 242 |
(unless (eq? state 'beginning) |
| 243 |
(print "@end table") (print)) |
| 244 |
(print "@c EN") |
| 245 |
(print section-en ":") |
| 246 |
(print "@c JP") |
| 247 |
(print section-ja ":") |
| 248 |
(print "@c COMMON") |
| 249 |
(print "@table @option") |
| 250 |
'cont] |
| 251 |
[(((opt src) ...) help-en help-ja) |
| 252 |
(format #t "@item ~a\n" (car opt)) |
| 253 |
(dolist [o (cdr opt)] |
| 254 |
(format #t "@itemx ~a\n" o)) |
| 255 |
(print "@c EN") |
| 256 |
(print (regexp-replace #/@/ help-en "@@")) |
| 257 |
(print "@c JP") |
| 258 |
(print (regexp-replace #/@/ (or help-ja help-en) "@@")) |
| 259 |
(print "@c COMMON") |
| 260 |
'cont])) |
| 261 |
'beginning *config-parameters*) |
| 262 |
(print "@end table")) |
| 263 |
|
| 264 |
;; Generate manpage |
| 265 |
(define (gen-man) |
| 266 |
(print ".\\\" -*-nroff-*-") |
| 267 |
(print ".TH GAUCHE\\-CONFIG \"1\" \"\" \"Gauche @GAUCHE_VERSION@\" \"Gauche Commands\"") |
| 268 |
(print ".SH NAME") |
| 269 |
(print "gauche-config \\- retrieve configuration parameters of Gauche") |
| 270 |
(print ".SH SYNOPSIS") |
| 271 |
(print ".B gauche-config") |
| 272 |
(print ".I option") |
| 273 |
(print ".br") |
| 274 |
(print ".sp 0.3") |
| 275 |
(print ".SH DESCRIPTION") |
| 276 |
(print ".I Gauche-config") |
| 277 |
(print "displays various parameters specified at the configuration time") |
| 278 |
(print "of the Gauche Scheme implementation. It can be used in Makefile") |
| 279 |
(print "and other configuration scripts that uses Gauche.") |
| 280 |
(print) |
| 281 |
(print ".SH OPTIONS") |
| 282 |
|
| 283 |
(dolist [e *config-parameters*] |
| 284 |
(match e |
| 285 |
[('section section-e . _) |
| 286 |
(print) |
| 287 |
(print ".SS " section-e)] |
| 288 |
[(((opt src) ...) help . _) |
| 289 |
(print ".TP") |
| 290 |
(print ".B " (string-join opt ", ")) |
| 291 |
(print help)])) |
| 292 |
|
| 293 |
(print) |
| 294 |
(print ".SH AUTHORS") |
| 295 |
(print "Shiro Kawai (shiro @ acm . org)") |
| 296 |
(print) |
| 297 |
(print ".SH SEE ALSO") |
| 298 |
(print "gosh(1), gauche-package(1)") |
| 299 |
(print ".PP") |
| 300 |
(print "Gauche Scheme script engine:") |
| 301 |
(print ".br") |
| 302 |
(print "https://practical-scheme.net/gauche/")) |
| 303 |
|
| 304 |
|
| 305 |
(define (main args) |
| 306 |
(match (cdr args) |
| 307 |
[(file) |
| 308 |
(with-output-to-file "genconfig.in" |
| 309 |
(cut generate file)) |
| 310 |
(with-output-to-file "../doc/man-gauche-config.texi" |
| 311 |
(cut gen-info)) |
| 312 |
(with-output-to-file "../doc/gauche-config.1.in" |
| 313 |
(cut gen-man)) |
| 314 |
0] |
| 315 |
[_ (exit 1 "Usage: gosh gen-genconfig.scm <genconfig-template>")])) |