| 1 |
#! /bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
# |
| 6 |
# Generates gauche-config.c, paths_arch.c and lib/gauche/config.scm |
| 7 |
# |
| 8 |
# This file is generated from genconfig.in.in by gen-genconfig.scm. |
| 9 |
# DO NOT EDIT. |
| 10 |
# |
| 11 |
|
| 12 |
host=@host@ |
| 13 |
xhost=@xhost@ |
| 14 |
gauche_version=@GAUCHE_VERSION@ |
| 15 |
|
| 16 |
case "$xhost" in |
| 17 |
*mingw*|*winnt*) |
| 18 |
# On Windows we can't rely on the paths set by configure. |
| 19 |
# We find the location of the binary and calculate the prefix path |
| 20 |
# from it instead. The '@' mark will be replaced by the prefix path |
| 21 |
# at runtime. |
| 22 |
prefix=@ |
| 23 |
exec_prefix=@ |
| 24 |
pathfix='sed -e sx/x\\xg -e sx\\x\\\\xg' |
| 25 |
pathsep=";" |
| 26 |
;; |
| 27 |
*darwin*-framework) |
| 28 |
# On MacOSX Framework build, we also calculate the paths at runtime, |
| 29 |
# so we can make a framework bundle that can be placed anywhere. |
| 30 |
prefix=@ |
| 31 |
exec_prefix=@ |
| 32 |
pathfix="cat" |
| 33 |
pathsep=":" |
| 34 |
;; |
| 35 |
*) |
| 36 |
# Standard configured paths |
| 37 |
prefix=${prefix:-@prefix@} |
| 38 |
|
| 39 |
exec_prefix=@exec_prefix@ |
| 40 |
pathfix="cat" |
| 41 |
pathsep=":" |
| 42 |
;; |
| 43 |
esac |
| 44 |
|
| 45 |
datarootdir=@datarootdir@ # for autoconf 2.60 and later. |
| 46 |
garchabi=gauche-@GAUCHE_ABI_VERSION@ |
| 47 |
garchdir=@libdir@/$garchabi |
| 48 |
gdatadir=@datadir@/$garchabi |
| 49 |
|
| 50 |
mandir=`echo @mandir@ | $pathfix` |
| 51 |
infodir=`echo @infodir@ | $pathfix` |
| 52 |
|
| 53 |
gauche_incdir=`echo "$garchdir/$gauche_version/include" | $pathfix` |
| 54 |
gauche_libdir=`echo "$gdatadir/$gauche_version/lib" | $pathfix` |
| 55 |
gauche_aclocaldir=`echo "$gdatadir/$gauche_version/" | $pathfix` |
| 56 |
gauche_archdir=`echo "$garchdir/$gauche_version/$host" | $pathfix` |
| 57 |
gauche_siteincdir=`echo "$garchdir/site/include" | $pathfix` |
| 58 |
gauche_sitelibdir=`echo "$gdatadir/site/lib" | $pathfix` |
| 59 |
gauche_sitearchdir=`echo "$garchdir/site/$host" | $pathfix` |
| 60 |
gauche_pkgincdir=`echo '${libdir}'"/$garchabi/site/include" | $pathfix` |
| 61 |
gauche_pkglibdir=`echo '${datadir}'"/$garchabi/site/lib" | $pathfix` |
| 62 |
gauche_pkgarchdir=`echo '${libdir}'"/$garchabi/site/$host" | $pathfix` |
| 63 |
|
| 64 |
gauche_libs="@LIBS@" |
| 65 |
gauche_configure_args="@GAUCHE_CONFIGURE_ARGS@" |
| 66 |
arch="$host" |
| 67 |
|
| 68 |
# If we search Gauche install path relative to the runtime, the --prefix |
| 69 |
# argument given to 'configure' is irrelevant. Particulary, if we build |
| 70 |
# Windows installer, the path given to --prefix is only meaningful for |
| 71 |
# the host that makes the installer, and it doesn't make sense to show |
| 72 |
# it to the user (via 'gauche-config --reconfigure', for example). |
| 73 |
# So we remove the '--prefix' argument from gauche_configure_args. |
| 74 |
# NB: The following sed script fails if argument of --prefix contains |
| 75 |
# pathname including spaces. For now, only a limited people builds |
| 76 |
# Windows installer so we make it so. |
| 77 |
if [ "$prefix" = "@" ]; then |
| 78 |
gauche_configure_args=`echo $gauche_configure_args | sed -e "s/'--prefix=[^ ']*'//g" -e 's/--prefix=[^ ]*//g'` |
| 79 |
fi |
| 80 |
if [ "$exec_prefix" = "@" ]; then |
| 81 |
gauche_configure_args=`echo $gauche_configure_args | sed -e "s/'--exec-prefix=[^ ']*'//g" -e 's/--exec-prefix=[^ ]*//g'` |
| 82 |
fi |
| 83 |
|
| 84 |
local_inc="@LOCAL_INC@" |
| 85 |
local_lib="@LOCAL_LIB@" |
| 86 |
|
| 87 |
static_libs="@STATIC_LIBS@" |
| 88 |
|
| 89 |
incdirs=`echo $gauche_incdir | sed s/^-I//`${pathsep}`echo $gauche_siteincdir | sed s/^-I//` |
| 90 |
if [ ! -z "@LOCAL_INCDIRS@" ]; then |
| 91 |
incdirs="$incdirs${pathsep}@LOCAL_INCDIRS@" |
| 92 |
fi |
| 93 |
archdirs=`echo $gauche_archdir | sed s/^-L//`${pathsep}`echo $gauche_sitearchdir | sed s/^-L//` |
| 94 |
if [ ! -z "@LOCAL_LIBDIRS@" ]; then |
| 95 |
archdirs="$archdirs${pathsep}@LOCAL_LIBDIRS@" |
| 96 |
fi |
| 97 |
|
| 98 |
cc="@CC@" |
| 99 |
cpp="@CPP@" |
| 100 |
default_cflags="@DEFAULT_CFLAGS@" |
| 101 |
cppflags="@CPPFLAGS@" |
| 102 |
|
| 103 |
object_suffix="@OBJEXT@" |
| 104 |
executable_suffix="@EXEEXT@" |
| 105 |
rpath_flag="@RPATH_FLAG@" |
| 106 |
shlib_so_suffix="@SHLIB_SO_SUFFIX@" |
| 107 |
shlib_so_cflags="@SHLIB_SO_CFLAGS@" |
| 108 |
shlib_so_ldflags="@SHLIB_SO_LDFLAGS@" |
| 109 |
shlib_so_libs="@SHLIB_LIBS_FOR_EXT@" |
| 110 |
shlib_dylib_suffix="@SHLIB_DYLIB_SUFFIX@" |
| 111 |
shlib_dylib_ldflags="@SHLIB_DYLIB_LDFLAGS@" |
| 112 |
shlib_main_ldflags="@SHLIB_MAIN_LDFLAGS@" |
| 113 |
libgauche_so="@LIBGAUCHE_SO@" |
| 114 |
|
| 115 |
#============================================================ |
| 116 |
# gauche-config.c |
| 117 |
# |
| 118 |
cat > gauche-config.c.tmp.$$ <<EOF |
| 119 |
/* Generated automatically by genconfig. DO NOT EDIT */ |
| 120 |
|
| 121 |
/* The small program gauche-config is installed in the same place |
| 122 |
as gosh, and used to retrieve various configuration information |
| 123 |
later. It is made a separate program from gosh for quicker |
| 124 |
startup and avoiding complications of dynamic library etc. |
| 125 |
It used to be a shell script, but turned into a C program |
| 126 |
so that it works on the platform that lacks sh. */ |
| 127 |
|
| 128 |
#if defined(__MINGW32__) || defined(_MSC_VER) |
| 129 |
#define _CRT_SECURE_NO_DEPRECATE 1 |
| 130 |
#define _CRT_SECURE_NO_WARNINGS 1 |
| 131 |
#include <winsock2.h> /* MinGW needs this before windows.h */ |
| 132 |
#include <windows.h> |
| 133 |
#include <shlwapi.h> |
| 134 |
#endif |
| 135 |
|
| 136 |
#include <stdio.h> |
| 137 |
#include <stdlib.h> |
| 138 |
#include <string.h> |
| 139 |
#include <stdarg.h> |
| 140 |
#include <errno.h> |
| 141 |
#include <ctype.h> |
| 142 |
|
| 143 |
static void usage (void) { |
| 144 |
fputs("Usage: gauche-config [option ...]\n" |
| 145 |
"Multiple options can be given.\n" |
| 146 |
"\n" |
| 147 |
"General parameter\n" |
| 148 |
" -V\n" |
| 149 |
" The current Gauche version.\n" |
| 150 |
"\n" |
| 151 |
"Parameters to compile applications using Gauche\n" |
| 152 |
" -I\n" |
| 153 |
" Include path options required to compile programs using Gauche\n" |
| 154 |
" (Note: This doesn't work if Gauche installation directory\n" |
| 155 |
" path contains whitespaces. See --incdirs below.)\n" |
| 156 |
" -L\n" |
| 157 |
" Library path options required to link programs using Gauche\n" |
| 158 |
" (Note: This doesn't work if Gauche installation directory\n" |
| 159 |
" path contains whitespaces. See --archdirs below.)\n" |
| 160 |
" -l\n" |
| 161 |
" Link library options required to link programs using Gauche.\n" |
| 162 |
" --cc\n" |
| 163 |
" The name of the C compiler used to compile this Gauche.\n" |
| 164 |
" --cpp\n" |
| 165 |
" The command to run the C preprocessor.\n" |
| 166 |
" --ac\n" |
| 167 |
" The directory that contains Gauche-specific autoconf macros.\n" |
| 168 |
" --reconfigure\n" |
| 169 |
" The command line used to configure the current installation.\n" |
| 170 |
" --arch\n" |
| 171 |
" The autoconf-style architecture signature (cpu-vendor-kernel-os).\n" |
| 172 |
" --incdirs\n" |
| 173 |
" --archdirs\n" |
| 174 |
" The list of directory names to be looked for include files and\n" |
| 175 |
" libraries, respectively. Each directory name may be quoted if\n" |
| 176 |
" it contains whitespaces, and separated by ':' on Unix platforms, or\n" |
| 177 |
" by ';' on Windows platforms.\n" |
| 178 |
" --local-incdir\n" |
| 179 |
" --local-libdir\n" |
| 180 |
" These are '-I' and '-L' flags for additional local headers/libraries\n" |
| 181 |
" to search, given by '--with-local' configure flags. Note that those\n" |
| 182 |
" are also included in '-I', '-L', '--incdirs', and '--archdirs'.\n" |
| 183 |
"\n" |
| 184 |
"Parameters to install files\n" |
| 185 |
" --prefix\n" |
| 186 |
" The directory prefix set by configure.\n" |
| 187 |
" --sysincdir\n" |
| 188 |
" --siteincdir\n" |
| 189 |
" --pkgincdir\n" |
| 190 |
" Directories where system|site|package header files of extensions go.\n" |
| 191 |
" --syslibdir\n" |
| 192 |
" --sitelibdir\n" |
| 193 |
" --pkglibdir\n" |
| 194 |
" Directories where system|site|package scheme files go.\n" |
| 195 |
" --sysarchdir\n" |
| 196 |
" --sitearchdir\n" |
| 197 |
" --pkgarchdir\n" |
| 198 |
" Directories where system|site|package DSO files go.\n" |
| 199 |
" --mandir\n" |
| 200 |
" --infodir\n" |
| 201 |
" Directories where gauche manpage and info docs are installed.\n" |
| 202 |
"\n" |
| 203 |
"Parameters to help building extensions\n" |
| 204 |
" --object-suffix\n" |
| 205 |
" The extension of the compiled objects (e.g. 'o' or 'obj').\n" |
| 206 |
" --executable-suffix\n" |
| 207 |
" The extension of the executable including a period (empty on Unix systems,\n" |
| 208 |
" '.exe' on Windows.\n" |
| 209 |
" --so-suffix\n" |
| 210 |
" The extension for dynamically loadable (dlopen-able) modules (e.g. 'so').\n" |
| 211 |
" --so-cflags\n" |
| 212 |
" Additional CFLAGS to create dynamically loadable modules.\n" |
| 213 |
" --so-ldflags\n" |
| 214 |
" Additional LDFLAGS to create dynamically loadable modules.\n" |
| 215 |
" --so-libs\n" |
| 216 |
" Additional libraries required to create dynamically loadable modules.\n" |
| 217 |
" --dylib-suffix\n" |
| 218 |
" The extension for dynamically linked libraries (as opposed to dlopen()ed)\n" |
| 219 |
" Usually the same as --so-suffix, but OSX wants 'dylib'.\n" |
| 220 |
" --dylib-ldflags\n" |
| 221 |
" LDFLAGS to create dynamically linked libraries.\n" |
| 222 |
" --rpath-flag\n" |
| 223 |
" Compiler flag(s) to embed RPATH\n" |
| 224 |
" --default-cflags\n" |
| 225 |
" This is the CFLAGS used to compile Gauche, and to be used to compile\n" |
| 226 |
" extensions as well.\n" |
| 227 |
" --cppflags\n" |
| 228 |
" Compiler flag(s) passed to C preprocessor\n" |
| 229 |
" --static-libs\n" |
| 230 |
" List of library link flags ('-llib') required to link Gauche statically.\n" |
| 231 |
" Similar to '-l', but this includes the libraries that are used\n" |
| 232 |
" for extension modules, and also the static library itself,\n" |
| 233 |
" that is -lgauche-static-X.X.\n" |
| 234 |
" --libgauche-so\n" |
| 235 |
" The base name of dynamically linked libgauche.\n" |
| 236 |
,stderr); |
| 237 |
exit(1); |
| 238 |
} |
| 239 |
|
| 240 |
static struct cmd_rec { |
| 241 |
const char *cmd; |
| 242 |
const char *value; |
| 243 |
} cmds[] = { |
| 244 |
{"-V", "$gauche_version"}, |
| 245 |
{"-I", "-I$gauche_incdir"}, |
| 246 |
{"-L", "-L$gauche_archdir $local_lib"}, |
| 247 |
{"-l", "-l$garchabi $gauche_libs"}, |
| 248 |
{"--cc", "$cc"}, |
| 249 |
{"--cpp", "$cpp"}, |
| 250 |
{"--ac", "$gauche_aclocaldir"}, |
| 251 |
{"--reconfigure", "./configure $gauche_configure_args"}, |
| 252 |
{"--arch", "$arch"}, |
| 253 |
{"--incdirs", "$incdirs"}, |
| 254 |
{"--archdirs", "$archdirs"}, |
| 255 |
{"--local-incdir", "$local_inc"}, |
| 256 |
{"--local-libdir", "$local_lib"}, |
| 257 |
{"--prefix", "$prefix"}, |
| 258 |
{"--sysincdir", "$gauche_incdir"}, |
| 259 |
{"--siteincdir", "$gauche_siteincdir"}, |
| 260 |
{"--pkgincdir", "$gauche_pkgincdir"}, |
| 261 |
{"--syslibdir", "$gauche_libdir"}, |
| 262 |
{"--sitelibdir", "$gauche_sitelibdir"}, |
| 263 |
{"--pkglibdir", "$gauche_pkglibdir"}, |
| 264 |
{"--sysarchdir", "$gauche_archdir"}, |
| 265 |
{"--sitearchdir", "$gauche_sitearchdir"}, |
| 266 |
{"--pkgarchdir", "$gauche_pkgarchdir"}, |
| 267 |
{"--mandir", "$mandir"}, |
| 268 |
{"--infodir", "$infodir"}, |
| 269 |
{"--object-suffix", "$object_suffix"}, |
| 270 |
{"--executable-suffix", "$executable_suffix"}, |
| 271 |
{"--so-suffix", "$shlib_so_suffix"}, |
| 272 |
{"--so-cflags", "$shlib_so_cflags"}, |
| 273 |
{"--so-ldflags", "$shlib_so_ldflags"}, |
| 274 |
{"--so-libs", "$shlib_so_libs"}, |
| 275 |
{"--dylib-suffix", "$shlib_dylib_suffix"}, |
| 276 |
{"--dylib-ldflags", "$shlib_dylib_ldflags"}, |
| 277 |
{"--rpath-flag", "$rpath_flag"}, |
| 278 |
{"--default-cflags", "$default_cflags"}, |
| 279 |
{"--cppflags", "$cppflags"}, |
| 280 |
{"--static-libs", "$static_libs"}, |
| 281 |
{"--libgauche-so", "$libgauche_so"}, |
| 282 |
{ NULL, NULL } |
| 283 |
}; |
| 284 |
|
| 285 |
#if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) |
| 286 |
/* mbs <-> wcs stuff */ |
| 287 |
#include "win-compat.c" |
| 288 |
static void errfn(const char *fmt,...); /*definition in paths.c*/ |
| 289 |
#define SCM_MBS2WCS(s) mbs2wcs(s, FALSE, errfn) |
| 290 |
#define SCM_WCS2MBS(s) wcs2mbs(s, FALSE, errfn) |
| 291 |
#else /* !(defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) */ |
| 292 |
#define SCM_MBS2WCS(s) (s) |
| 293 |
#define SCM_WCS2MBS(s) (s) |
| 294 |
#endif /* !(defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) */ |
| 295 |
|
| 296 |
#include "paths.c" |
| 297 |
|
| 298 |
static int process(const char *arg, int check) |
| 299 |
{ |
| 300 |
struct cmd_rec *cp = cmds; |
| 301 |
while (cp->cmd != NULL) { |
| 302 |
if (strcmp(cp->cmd, arg) == 0) { |
| 303 |
if (!check) printf("%s\\n", replace_install_dir(cp->value)); |
| 304 |
return 1; |
| 305 |
} |
| 306 |
cp++; |
| 307 |
} |
| 308 |
return 0; |
| 309 |
} |
| 310 |
|
| 311 |
int main(int argc, char **argv) |
| 312 |
{ |
| 313 |
#if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) |
| 314 |
(void)&mbs2wcs; /* suppress unused function warning */ |
| 315 |
(void)&wcs2mbs; |
| 316 |
#endif /* (defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) */ |
| 317 |
(void)get_libgauche_path(); /* ditto */ |
| 318 |
|
| 319 |
if (argc < 2) usage(); |
| 320 |
if (strcmp(argv[1], "--fixup-extension") == 0) { |
| 321 |
fprintf(stderr, "(fixup-extension is no longer needed.)\n"); |
| 322 |
} else { |
| 323 |
char **av; |
| 324 |
for (av = argv+1; *av; av++) { |
| 325 |
if (!process(*av, 1)) usage(); |
| 326 |
} |
| 327 |
for (av = argv+1; *av; av++) { |
| 328 |
process(*av, 0); |
| 329 |
} |
| 330 |
} |
| 331 |
return 0; |
| 332 |
} |
| 333 |
|
| 334 |
EOF |
| 335 |
mv gauche-config.c.tmp.$$ gauche-config.c |
| 336 |
|
| 337 |
#============================================================ |
| 338 |
# paths_arch.c |
| 339 |
# |
| 340 |
cat > paths_arch.c.tmp.$$ <<EOF |
| 341 |
/* Generated by genconfig. DO NOT EDIT */ |
| 342 |
static const char *gauche_arch = "$arch"; |
| 343 |
static const char *gauche_lib_dir = "$gauche_libdir"; |
| 344 |
static const char *gauche_arch_dir = "$gauche_archdir"; |
| 345 |
static const char *gauche_site_lib_dir ="$gauche_sitelibdir"; |
| 346 |
static const char *gauche_site_arch_dir = "$gauche_sitearchdir"; |
| 347 |
EOF |
| 348 |
|
| 349 |
mv paths_arch.c.tmp.$$ paths_arch.c |
| 350 |
|
| 351 |
#============================================================ |
| 352 |
# lib/gauche/config.scm |
| 353 |
# |
| 354 |
mkdir -p ../lib/gauche |
| 355 |
cat > ../lib/gauche/config.scm.tmp.$$ <<EOF |
| 356 |
;; Generated by genconfig. DO NOT EDIT |
| 357 |
(define-module gauche.config |
| 358 |
(export gauche-config)) |
| 359 |
(select-module gauche.config) |
| 360 |
|
| 361 |
(define (gauche-config param) |
| 362 |
(cond [(assoc param *configurations*) => (^p (replace-install-dir (cadr p)))] |
| 363 |
[else (error "unknown configuration parameter name" param)])) |
| 364 |
|
| 365 |
(define (replace-install-dir str) |
| 366 |
(let1 ss (string-split str #\@) |
| 367 |
(if (length<=? ss 1) |
| 368 |
str |
| 369 |
(if-let1 d ((with-module gauche.internal %gauche-runtime-directory)) |
| 370 |
(string-join ss d) |
| 371 |
(error "Couldn't obtain installation directory to complete " str))))) |
| 372 |
|
| 373 |
(define *configurations* |
| 374 |
(quote ( |
| 375 |
("-V" "$gauche_version") |
| 376 |
("-I" "-I$gauche_incdir") |
| 377 |
("-L" "-L$gauche_archdir $local_lib") |
| 378 |
("-l" "-l$garchabi $gauche_libs") |
| 379 |
("--cc" "$cc") |
| 380 |
("--cpp" "$cpp") |
| 381 |
("--ac" "$gauche_aclocaldir") |
| 382 |
("--reconfigure" "./configure $gauche_configure_args") |
| 383 |
("--arch" "$arch") |
| 384 |
("--incdirs" "$incdirs") |
| 385 |
("--archdirs" "$archdirs") |
| 386 |
("--local-incdir" "$local_inc") |
| 387 |
("--local-libdir" "$local_lib") |
| 388 |
("--prefix" "$prefix") |
| 389 |
("--sysincdir" "$gauche_incdir") |
| 390 |
("--siteincdir" "$gauche_siteincdir") |
| 391 |
("--pkgincdir" "$gauche_pkgincdir") |
| 392 |
("--syslibdir" "$gauche_libdir") |
| 393 |
("--sitelibdir" "$gauche_sitelibdir") |
| 394 |
("--pkglibdir" "$gauche_pkglibdir") |
| 395 |
("--sysarchdir" "$gauche_archdir") |
| 396 |
("--sitearchdir" "$gauche_sitearchdir") |
| 397 |
("--pkgarchdir" "$gauche_pkgarchdir") |
| 398 |
("--mandir" "$mandir") |
| 399 |
("--infodir" "$infodir") |
| 400 |
("--object-suffix" "$object_suffix") |
| 401 |
("--executable-suffix" "$executable_suffix") |
| 402 |
("--so-suffix" "$shlib_so_suffix") |
| 403 |
("--so-cflags" "$shlib_so_cflags") |
| 404 |
("--so-ldflags" "$shlib_so_ldflags") |
| 405 |
("--so-libs" "$shlib_so_libs") |
| 406 |
("--dylib-suffix" "$shlib_dylib_suffix") |
| 407 |
("--dylib-ldflags" "$shlib_dylib_ldflags") |
| 408 |
("--rpath-flag" "$rpath_flag") |
| 409 |
("--default-cflags" "$default_cflags") |
| 410 |
("--cppflags" "$cppflags") |
| 411 |
("--static-libs" "$static_libs") |
| 412 |
("--libgauche-so" "$libgauche_so") |
| 413 |
))) |
| 414 |
|
| 415 |
EOF |
| 416 |
|
| 417 |
mv ../lib/gauche/config.scm.tmp.$$ ../lib/gauche/config.scm |
| 418 |
|
| 419 |
# Local variables: |
| 420 |
# mode: shell-script |
| 421 |
# end: |