#! /bin/sh set -e # # Generates gauche-config.c, paths_arch.c and lib/gauche/config.scm # # This file is generated from genconfig.in.in by gen-genconfig.scm. # DO NOT EDIT. # host=@host@ xhost=@xhost@ gauche_version=@GAUCHE_VERSION@ case "$xhost" in *mingw*|*winnt*) # On Windows we can't rely on the paths set by configure. # We find the location of the binary and calculate the prefix path # from it instead. The '@' mark will be replaced by the prefix path # at runtime. prefix=@ exec_prefix=@ pathfix='sed -e sx/x\\xg -e sx\\x\\\\xg' pathsep=";" ;; *darwin*-framework) # On MacOSX Framework build, we also calculate the paths at runtime, # so we can make a framework bundle that can be placed anywhere. prefix=@ exec_prefix=@ pathfix="cat" pathsep=":" ;; *) # Standard configured paths prefix=${prefix:-@prefix@} exec_prefix=@exec_prefix@ pathfix="cat" pathsep=":" ;; esac datarootdir=@datarootdir@ # for autoconf 2.60 and later. garchabi=gauche-@GAUCHE_ABI_VERSION@ garchdir=@libdir@/$garchabi gdatadir=@datadir@/$garchabi mandir=`echo @mandir@ | $pathfix` infodir=`echo @infodir@ | $pathfix` gauche_incdir=`echo "$garchdir/$gauche_version/include" | $pathfix` gauche_libdir=`echo "$gdatadir/$gauche_version/lib" | $pathfix` gauche_aclocaldir=`echo "$gdatadir/$gauche_version/" | $pathfix` gauche_archdir=`echo "$garchdir/$gauche_version/$host" | $pathfix` gauche_siteincdir=`echo "$garchdir/site/include" | $pathfix` gauche_sitelibdir=`echo "$gdatadir/site/lib" | $pathfix` gauche_sitearchdir=`echo "$garchdir/site/$host" | $pathfix` gauche_pkgincdir=`echo '${libdir}'"/$garchabi/site/include" | $pathfix` gauche_pkglibdir=`echo '${datadir}'"/$garchabi/site/lib" | $pathfix` gauche_pkgarchdir=`echo '${libdir}'"/$garchabi/site/$host" | $pathfix` gauche_libs="@LIBS@" gauche_configure_args="@GAUCHE_CONFIGURE_ARGS@" arch="$host" # If we search Gauche install path relative to the runtime, the --prefix # argument given to 'configure' is irrelevant. Particulary, if we build # Windows installer, the path given to --prefix is only meaningful for # the host that makes the installer, and it doesn't make sense to show # it to the user (via 'gauche-config --reconfigure', for example). # So we remove the '--prefix' argument from gauche_configure_args. # NB: The following sed script fails if argument of --prefix contains # pathname including spaces. For now, only a limited people builds # Windows installer so we make it so. if [ "$prefix" = "@" ]; then gauche_configure_args=`echo $gauche_configure_args | sed -e "s/'--prefix=[^ ']*'//g" -e 's/--prefix=[^ ]*//g'` fi if [ "$exec_prefix" = "@" ]; then gauche_configure_args=`echo $gauche_configure_args | sed -e "s/'--exec-prefix=[^ ']*'//g" -e 's/--exec-prefix=[^ ]*//g'` fi local_inc="@LOCAL_INC@" local_lib="@LOCAL_LIB@" static_libs="@STATIC_LIBS@" incdirs=`echo $gauche_incdir | sed s/^-I//`${pathsep}`echo $gauche_siteincdir | sed s/^-I//` if [ ! -z "@LOCAL_INCDIRS@" ]; then incdirs="$incdirs${pathsep}@LOCAL_INCDIRS@" fi archdirs=`echo $gauche_archdir | sed s/^-L//`${pathsep}`echo $gauche_sitearchdir | sed s/^-L//` if [ ! -z "@LOCAL_LIBDIRS@" ]; then archdirs="$archdirs${pathsep}@LOCAL_LIBDIRS@" fi cc="@CC@" cpp="@CPP@" default_cflags="@DEFAULT_CFLAGS@" cppflags="@CPPFLAGS@" object_suffix="@OBJEXT@" executable_suffix="@EXEEXT@" rpath_flag="@RPATH_FLAG@" shlib_so_suffix="@SHLIB_SO_SUFFIX@" shlib_so_cflags="@SHLIB_SO_CFLAGS@" shlib_so_ldflags="@SHLIB_SO_LDFLAGS@" shlib_so_libs="@SHLIB_LIBS_FOR_EXT@" shlib_dylib_suffix="@SHLIB_DYLIB_SUFFIX@" shlib_dylib_ldflags="@SHLIB_DYLIB_LDFLAGS@" shlib_main_ldflags="@SHLIB_MAIN_LDFLAGS@" libgauche_so="@LIBGAUCHE_SO@" #============================================================ # gauche-config.c # cat > gauche-config.c.tmp.$$ < /* MinGW needs this before windows.h */ #include #include #endif #include #include #include #include #include #include static void usage (void) { fputs("Usage: gauche-config [option ...]\n" "Multiple options can be given.\n" "\n" "General parameter\n" " -V\n" " The current Gauche version.\n" "\n" "Parameters to compile applications using Gauche\n" " -I\n" " Include path options required to compile programs using Gauche\n" " (Note: This doesn't work if Gauche installation directory\n" " path contains whitespaces. See --incdirs below.)\n" " -L\n" " Library path options required to link programs using Gauche\n" " (Note: This doesn't work if Gauche installation directory\n" " path contains whitespaces. See --archdirs below.)\n" " -l\n" " Link library options required to link programs using Gauche.\n" " --cc\n" " The name of the C compiler used to compile this Gauche.\n" " --cpp\n" " The command to run the C preprocessor.\n" " --ac\n" " The directory that contains Gauche-specific autoconf macros.\n" " --reconfigure\n" " The command line used to configure the current installation.\n" " --arch\n" " The autoconf-style architecture signature (cpu-vendor-kernel-os).\n" " --incdirs\n" " --archdirs\n" " The list of directory names to be looked for include files and\n" " libraries, respectively. Each directory name may be quoted if\n" " it contains whitespaces, and separated by ':' on Unix platforms, or\n" " by ';' on Windows platforms.\n" " --local-incdir\n" " --local-libdir\n" " These are '-I' and '-L' flags for additional local headers/libraries\n" " to search, given by '--with-local' configure flags. Note that those\n" " are also included in '-I', '-L', '--incdirs', and '--archdirs'.\n" "\n" "Parameters to install files\n" " --prefix\n" " The directory prefix set by configure.\n" " --sysincdir\n" " --siteincdir\n" " --pkgincdir\n" " Directories where system|site|package header files of extensions go.\n" " --syslibdir\n" " --sitelibdir\n" " --pkglibdir\n" " Directories where system|site|package scheme files go.\n" " --sysarchdir\n" " --sitearchdir\n" " --pkgarchdir\n" " Directories where system|site|package DSO files go.\n" " --mandir\n" " --infodir\n" " Directories where gauche manpage and info docs are installed.\n" "\n" "Parameters to help building extensions\n" " --object-suffix\n" " The extension of the compiled objects (e.g. 'o' or 'obj').\n" " --executable-suffix\n" " The extension of the executable including a period (empty on Unix systems,\n" " '.exe' on Windows.\n" " --so-suffix\n" " The extension for dynamically loadable (dlopen-able) modules (e.g. 'so').\n" " --so-cflags\n" " Additional CFLAGS to create dynamically loadable modules.\n" " --so-ldflags\n" " Additional LDFLAGS to create dynamically loadable modules.\n" " --so-libs\n" " Additional libraries required to create dynamically loadable modules.\n" " --dylib-suffix\n" " The extension for dynamically linked libraries (as opposed to dlopen()ed)\n" " Usually the same as --so-suffix, but OSX wants 'dylib'.\n" " --dylib-ldflags\n" " LDFLAGS to create dynamically linked libraries.\n" " --rpath-flag\n" " Compiler flag(s) to embed RPATH\n" " --default-cflags\n" " This is the CFLAGS used to compile Gauche, and to be used to compile\n" " extensions as well.\n" " --cppflags\n" " Compiler flag(s) passed to C preprocessor\n" " --static-libs\n" " List of library link flags ('-llib') required to link Gauche statically.\n" " Similar to '-l', but this includes the libraries that are used\n" " for extension modules, and also the static library itself,\n" " that is -lgauche-static-X.X.\n" " --libgauche-so\n" " The base name of dynamically linked libgauche.\n" ,stderr); exit(1); } static struct cmd_rec { const char *cmd; const char *value; } cmds[] = { {"-V", "$gauche_version"}, {"-I", "-I$gauche_incdir"}, {"-L", "-L$gauche_archdir $local_lib"}, {"-l", "-l$garchabi $gauche_libs"}, {"--cc", "$cc"}, {"--cpp", "$cpp"}, {"--ac", "$gauche_aclocaldir"}, {"--reconfigure", "./configure $gauche_configure_args"}, {"--arch", "$arch"}, {"--incdirs", "$incdirs"}, {"--archdirs", "$archdirs"}, {"--local-incdir", "$local_inc"}, {"--local-libdir", "$local_lib"}, {"--prefix", "$prefix"}, {"--sysincdir", "$gauche_incdir"}, {"--siteincdir", "$gauche_siteincdir"}, {"--pkgincdir", "$gauche_pkgincdir"}, {"--syslibdir", "$gauche_libdir"}, {"--sitelibdir", "$gauche_sitelibdir"}, {"--pkglibdir", "$gauche_pkglibdir"}, {"--sysarchdir", "$gauche_archdir"}, {"--sitearchdir", "$gauche_sitearchdir"}, {"--pkgarchdir", "$gauche_pkgarchdir"}, {"--mandir", "$mandir"}, {"--infodir", "$infodir"}, {"--object-suffix", "$object_suffix"}, {"--executable-suffix", "$executable_suffix"}, {"--so-suffix", "$shlib_so_suffix"}, {"--so-cflags", "$shlib_so_cflags"}, {"--so-ldflags", "$shlib_so_ldflags"}, {"--so-libs", "$shlib_so_libs"}, {"--dylib-suffix", "$shlib_dylib_suffix"}, {"--dylib-ldflags", "$shlib_dylib_ldflags"}, {"--rpath-flag", "$rpath_flag"}, {"--default-cflags", "$default_cflags"}, {"--cppflags", "$cppflags"}, {"--static-libs", "$static_libs"}, {"--libgauche-so", "$libgauche_so"}, { NULL, NULL } }; #if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) /* mbs <-> wcs stuff */ #include "win-compat.c" static void errfn(const char *fmt,...); /*definition in paths.c*/ #define SCM_MBS2WCS(s) mbs2wcs(s, FALSE, errfn) #define SCM_WCS2MBS(s) wcs2mbs(s, FALSE, errfn) #else /* !(defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) */ #define SCM_MBS2WCS(s) (s) #define SCM_WCS2MBS(s) (s) #endif /* !(defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) */ #include "paths.c" static int process(const char *arg, int check) { struct cmd_rec *cp = cmds; while (cp->cmd != NULL) { if (strcmp(cp->cmd, arg) == 0) { if (!check) printf("%s\\n", replace_install_dir(cp->value)); return 1; } cp++; } return 0; } int main(int argc, char **argv) { #if (defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) (void)&mbs2wcs; /* suppress unused function warning */ (void)&wcs2mbs; #endif /* (defined(__MINGW32__) || defined(_MSC_VER)) && defined(UNICODE) */ (void)get_libgauche_path(); /* ditto */ if (argc < 2) usage(); if (strcmp(argv[1], "--fixup-extension") == 0) { fprintf(stderr, "(fixup-extension is no longer needed.)\n"); } else { char **av; for (av = argv+1; *av; av++) { if (!process(*av, 1)) usage(); } for (av = argv+1; *av; av++) { process(*av, 0); } } return 0; } EOF mv gauche-config.c.tmp.$$ gauche-config.c #============================================================ # paths_arch.c # cat > paths_arch.c.tmp.$$ < ../lib/gauche/config.scm.tmp.$$ < (^p (replace-install-dir (cadr p)))] [else (error "unknown configuration parameter name" param)])) (define (replace-install-dir str) (let1 ss (string-split str #\@) (if (length<=? ss 1) str (if-let1 d ((with-module gauche.internal %gauche-runtime-directory)) (string-join ss d) (error "Couldn't obtain installation directory to complete " str))))) (define *configurations* (quote ( ("-V" "$gauche_version") ("-I" "-I$gauche_incdir") ("-L" "-L$gauche_archdir $local_lib") ("-l" "-l$garchabi $gauche_libs") ("--cc" "$cc") ("--cpp" "$cpp") ("--ac" "$gauche_aclocaldir") ("--reconfigure" "./configure $gauche_configure_args") ("--arch" "$arch") ("--incdirs" "$incdirs") ("--archdirs" "$archdirs") ("--local-incdir" "$local_inc") ("--local-libdir" "$local_lib") ("--prefix" "$prefix") ("--sysincdir" "$gauche_incdir") ("--siteincdir" "$gauche_siteincdir") ("--pkgincdir" "$gauche_pkgincdir") ("--syslibdir" "$gauche_libdir") ("--sitelibdir" "$gauche_sitelibdir") ("--pkglibdir" "$gauche_pkglibdir") ("--sysarchdir" "$gauche_archdir") ("--sitearchdir" "$gauche_sitearchdir") ("--pkgarchdir" "$gauche_pkgarchdir") ("--mandir" "$mandir") ("--infodir" "$infodir") ("--object-suffix" "$object_suffix") ("--executable-suffix" "$executable_suffix") ("--so-suffix" "$shlib_so_suffix") ("--so-cflags" "$shlib_so_cflags") ("--so-ldflags" "$shlib_so_ldflags") ("--so-libs" "$shlib_so_libs") ("--dylib-suffix" "$shlib_dylib_suffix") ("--dylib-ldflags" "$shlib_dylib_ldflags") ("--rpath-flag" "$rpath_flag") ("--default-cflags" "$default_cflags") ("--cppflags" "$cppflags") ("--static-libs" "$static_libs") ("--libgauche-so" "$libgauche_so") ))) EOF mv ../lib/gauche/config.scm.tmp.$$ ../lib/gauche/config.scm # Local variables: # mode: shell-script # end: