| 1 |
@@@ |
| 2 |
@@@ Template of genconfig.in |
| 3 |
@@@ gen-genconfig.scm processes this file to produce genconfig.in, |
| 4 |
@@@ which will be processed by configure to produce genconfig. |
| 5 |
@@@ |
| 6 |
#! /bin/sh |
| 7 |
|
| 8 |
set -e |
| 9 |
|
| 10 |
# |
| 11 |
# Generates gauche-config.c, paths_arch.c and lib/gauche/config.scm |
| 12 |
# |
| 13 |
# This file is generated from genconfig.in.in by gen-genconfig.scm. |
| 14 |
# DO NOT EDIT. |
| 15 |
# |
| 16 |
|
| 17 |
host=@host@ |
| 18 |
xhost=@xhost@ |
| 19 |
gauche_version=@GAUCHE_VERSION@ |
| 20 |
|
| 21 |
case "$xhost" in |
| 22 |
*mingw*|*winnt*) |
| 23 |
# On Windows we can't rely on the paths set by configure. |
| 24 |
# We find the location of the binary and calculate the prefix path |
| 25 |
# from it instead. The '@' mark will be replaced by the prefix path |
| 26 |
# at runtime. |
| 27 |
prefix=@ |
| 28 |
exec_prefix=@ |
| 29 |
pathfix='sed -e sx/x\\xg -e sx\\x\\\\xg' |
| 30 |
pathsep=";" |
| 31 |
;; |
| 32 |
*darwin*-framework) |
| 33 |
# On MacOSX Framework build, we also calculate the paths at runtime, |
| 34 |
# so we can make a framework bundle that can be placed anywhere. |
| 35 |
prefix=@ |
| 36 |
exec_prefix=@ |
| 37 |
pathfix="cat" |
| 38 |
pathsep=":" |
| 39 |
;; |
| 40 |
*) |
| 41 |
# Standard configured paths |
| 42 |
prefix=${prefix:-@prefix@} |
| 43 |
|
| 44 |
exec_prefix=@exec_prefix@ |
| 45 |
pathfix="cat" |
| 46 |
pathsep=":" |
| 47 |
;; |
| 48 |
esac |
| 49 |
|
| 50 |
datarootdir=@datarootdir@ # for autoconf 2.60 and later. |
| 51 |
garchabi=gauche-@GAUCHE_ABI_VERSION@ |
| 52 |
garchdir=@libdir@/$garchabi |
| 53 |
gdatadir=@datadir@/$garchabi |
| 54 |
|
| 55 |
mandir=`echo @mandir@ | $pathfix` |
| 56 |
infodir=`echo @infodir@ | $pathfix` |
| 57 |
|
| 58 |
gauche_incdir=`echo "$garchdir/$gauche_version/include" | $pathfix` |
| 59 |
gauche_libdir=`echo "$gdatadir/$gauche_version/lib" | $pathfix` |
| 60 |
gauche_aclocaldir=`echo "$gdatadir/$gauche_version/" | $pathfix` |
| 61 |
gauche_archdir=`echo "$garchdir/$gauche_version/$host" | $pathfix` |
| 62 |
gauche_siteincdir=`echo "$garchdir/site/include" | $pathfix` |
| 63 |
gauche_sitelibdir=`echo "$gdatadir/site/lib" | $pathfix` |
| 64 |
gauche_sitearchdir=`echo "$garchdir/site/$host" | $pathfix` |
| 65 |
gauche_pkgincdir=`echo '${libdir}'"/$garchabi/site/include" | $pathfix` |
| 66 |
gauche_pkglibdir=`echo '${datadir}'"/$garchabi/site/lib" | $pathfix` |
| 67 |
gauche_pkgarchdir=`echo '${libdir}'"/$garchabi/site/$host" | $pathfix` |
| 68 |
|
| 69 |
gauche_libs="@LIBS@" |
| 70 |
gauche_configure_args="@GAUCHE_CONFIGURE_ARGS@" |
| 71 |
arch="$host" |
| 72 |
|
| 73 |
# If we search Gauche install path relative to the runtime, the --prefix |
| 74 |
# argument given to 'configure' is irrelevant. Particulary, if we build |
| 75 |
# Windows installer, the path given to --prefix is only meaningful for |
| 76 |
# the host that makes the installer, and it doesn't make sense to show |
| 77 |
# it to the user (via 'gauche-config --reconfigure', for example). |
| 78 |
# So we remove the '--prefix' argument from gauche_configure_args. |
| 79 |
# NB: The following sed script fails if argument of --prefix contains |
| 80 |
# pathname including spaces. For now, only a limited people builds |
| 81 |
# Windows installer so we make it so. |
| 82 |
if [ "$prefix" = "@" ]; then |
| 83 |
gauche_configure_args=`echo $gauche_configure_args | sed -e "s/'--prefix=[^ ']*'//g" -e 's/--prefix=[^ ]*//g'` |
| 84 |
fi |
| 85 |
if [ "$exec_prefix" = "@" ]; then |
| 86 |
gauche_configure_args=`echo $gauche_configure_args | sed -e "s/'--exec-prefix=[^ ']*'//g" -e 's/--exec-prefix=[^ ]*//g'` |
| 87 |
fi |
| 88 |
|
| 89 |
local_inc="@LOCAL_INC@" |
| 90 |
local_lib="@LOCAL_LIB@" |
| 91 |
|
| 92 |
static_libs="@STATIC_LIBS@" |
| 93 |
|
| 94 |
incdirs=`echo $gauche_incdir | sed s/^-I//`${pathsep}`echo $gauche_siteincdir | sed s/^-I//` |
| 95 |
if [ ! -z "@LOCAL_INCDIRS@" ]; then |
| 96 |
incdirs="$incdirs${pathsep}@LOCAL_INCDIRS@" |
| 97 |
fi |
| 98 |
archdirs=`echo $gauche_archdir | sed s/^-L//`${pathsep}`echo $gauche_sitearchdir | sed s/^-L//` |
| 99 |
if [ ! -z "@LOCAL_LIBDIRS@" ]; then |
| 100 |
archdirs="$archdirs${pathsep}@LOCAL_LIBDIRS@" |
| 101 |
fi |
| 102 |
|
| 103 |
cc="@CC@" |
| 104 |
cpp="@CPP@" |
| 105 |
default_cflags="@DEFAULT_CFLAGS@" |
| 106 |
cppflags="@CPPFLAGS@" |
| 107 |
|
| 108 |
object_suffix="@OBJEXT@" |
| 109 |
executable_suffix="@EXEEXT@" |
| 110 |
rpath_flag="@RPATH_FLAG@" |
| 111 |
shlib_so_suffix="@SHLIB_SO_SUFFIX@" |
| 112 |
shlib_so_cflags="@SHLIB_SO_CFLAGS@" |
| 113 |
shlib_so_ldflags="@SHLIB_SO_LDFLAGS@" |
| 114 |
shlib_so_libs="@SHLIB_LIBS_FOR_EXT@" |
| 115 |
shlib_dylib_suffix="@SHLIB_DYLIB_SUFFIX@" |
| 116 |
shlib_dylib_ldflags="@SHLIB_DYLIB_LDFLAGS@" |
| 117 |
shlib_main_ldflags="@SHLIB_MAIN_LDFLAGS@" |
| 118 |
libgauche_so="@LIBGAUCHE_SO@" |
| 119 |
|
| 120 |
#============================================================ |
| 121 |
# gauche-config.c |
| 122 |
# |
| 123 |
cat > gauche-config.c.tmp.$$ <<EOF |
| 124 |
/* Generated automatically by genconfig. DO NOT EDIT */ |
| 125 |
|
| 126 |
/* The small program gauche-config is installed in the same place |
| 127 |
as gosh, and used to retrieve various configuration information |
| 128 |
later. It is made a separate program from gosh for quicker |
| 129 |
startup and avoiding complications of dynamic library etc. |
| 130 |
It used to be a shell script, but turned into a C program |
| 131 |
so that it works on the platform that lacks sh. */ |
| 132 |
|
| 133 |
#if defined(__MINGW32__) || defined(_MSC_VER) |
| 134 |
#define _CRT_SECURE_NO_DEPRECATE 1 |
| 135 |
#define _CRT_SECURE_NO_WARNINGS 1 |
| 136 |
#include <winsock2.h> /* MinGW needs this before windows.h */ |
| 137 |
#include <windows.h> |
| 138 |
#include <shlwapi.h> |
| 139 |
#endif |
| 140 |
|
| 141 |
#include <stdio.h> |
| 142 |
#include <stdlib.h> |
| 143 |
#include <string.h> |
| 144 |
#include <stdarg.h> |
| 145 |
#include <errno.h> |
| 146 |
#include <ctype.h> |
| 147 |
|
| 148 |
static void usage (void) { |
| 149 |
fputs("Usage: gauche-config [option ...]\n" |
| 150 |
"Multiple options can be given.\n" |
| 151 |
@@@USAGE@@@ |
| 152 |
,stderr); |
| 153 |
exit(1); |
| 154 |
} |
| 155 |
|
| 156 |
static struct cmd_rec { |
| 157 |
const char *cmd; |
| 158 |
const char *value; |
| 159 |
} cmds[] = { |
| 160 |
@@@COMMAND_TABLE@@@ |
| 161 |
{ NULL, NULL } |
| 162 |
}; |
| 163 |
|
| 164 |
#if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) |
| 165 |
/* mbs <-> wcs stuff */ |
| 166 |
#include "win-compat.c" |
| 167 |
static void errfn(const char *fmt,...); /*definition in paths.c*/ |
| 168 |
#define SCM_MBS2WCS(s) mbs2wcs(s, FALSE, errfn) |
| 169 |
#define SCM_WCS2MBS(s) wcs2mbs(s, FALSE, errfn) |
| 170 |
#else /* !(defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) */ |
| 171 |
#define SCM_MBS2WCS(s) (s) |
| 172 |
#define SCM_WCS2MBS(s) (s) |
| 173 |
#endif /* !(defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) */ |
| 174 |
|
| 175 |
#include "paths.c" |
| 176 |
|
| 177 |
static int process(const char *arg, int check) |
| 178 |
{ |
| 179 |
struct cmd_rec *cp = cmds; |
| 180 |
while (cp->cmd != NULL) { |
| 181 |
if (strcmp(cp->cmd, arg) == 0) { |
| 182 |
if (!check) printf("%s\\n", replace_install_dir(cp->value)); |
| 183 |
return 1; |
| 184 |
} |
| 185 |
cp++; |
| 186 |
} |
| 187 |
return 0; |
| 188 |
} |
| 189 |
|
| 190 |
int main(int argc, char **argv) |
| 191 |
{ |
| 192 |
#if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) |
| 193 |
(void)&mbs2wcs; /* suppress unused function warning */ |
| 194 |
(void)&wcs2mbs; |
| 195 |
#endif /* (defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) */ |
| 196 |
(void)get_libgauche_path(); /* ditto */ |
| 197 |
|
| 198 |
if (argc < 2) usage(); |
| 199 |
if (strcmp(argv[1], "--fixup-extension") == 0) { |
| 200 |
fprintf(stderr, "(fixup-extension is no longer needed.)\n"); |
| 201 |
} else { |
| 202 |
char **av; |
| 203 |
for (av = argv+1; *av; av++) { |
| 204 |
if (!process(*av, 1)) usage(); |
| 205 |
} |
| 206 |
for (av = argv+1; *av; av++) { |
| 207 |
process(*av, 0); |
| 208 |
} |
| 209 |
} |
| 210 |
return 0; |
| 211 |
} |
| 212 |
|
| 213 |
EOF |
| 214 |
mv gauche-config.c.tmp.$$ gauche-config.c |
| 215 |
|
| 216 |
#============================================================ |
| 217 |
# paths_arch.c |
| 218 |
# |
| 219 |
cat > paths_arch.c.tmp.$$ <<EOF |
| 220 |
/* Generated by genconfig. DO NOT EDIT */ |
| 221 |
static const char *gauche_arch = "$arch"; |
| 222 |
static const char *gauche_lib_dir = "$gauche_libdir"; |
| 223 |
static const char *gauche_arch_dir = "$gauche_archdir"; |
| 224 |
static const char *gauche_site_lib_dir ="$gauche_sitelibdir"; |
| 225 |
static const char *gauche_site_arch_dir = "$gauche_sitearchdir"; |
| 226 |
EOF |
| 227 |
|
| 228 |
mv paths_arch.c.tmp.$$ paths_arch.c |
| 229 |
|
| 230 |
#============================================================ |
| 231 |
# lib/gauche/config.scm |
| 232 |
# |
| 233 |
mkdir -p ../lib/gauche |
| 234 |
cat > ../lib/gauche/config.scm.tmp.$$ <<EOF |
| 235 |
;; Generated by genconfig. DO NOT EDIT |
| 236 |
(define-module gauche.config |
| 237 |
(export gauche-config)) |
| 238 |
(select-module gauche.config) |
| 239 |
|
| 240 |
(define (gauche-config param) |
| 241 |
(cond [(assoc param *configurations*) => (^p (replace-install-dir (cadr p)))] |
| 242 |
[else (error "unknown configuration parameter name" param)])) |
| 243 |
|
| 244 |
(define (replace-install-dir str) |
| 245 |
(let1 ss (string-split str #\@) |
| 246 |
(if (length<=? ss 1) |
| 247 |
str |
| 248 |
(if-let1 d ((with-module gauche.internal %gauche-runtime-directory)) |
| 249 |
(string-join ss d) |
| 250 |
(error "Couldn't obtain installation directory to complete " str))))) |
| 251 |
|
| 252 |
(define *configurations* |
| 253 |
(quote ( |
| 254 |
@@@COMMAND_LIST@@@ |
| 255 |
))) |
| 256 |
|
| 257 |
EOF |
| 258 |
|
| 259 |
mv ../lib/gauche/config.scm.tmp.$$ ../lib/gauche/config.scm |
| 260 |
|
| 261 |
# Local variables: |
| 262 |
# mode: shell-script |
| 263 |
# end: |