diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2009-03-29 16:03:30 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2009-03-29 16:03:30 +0000 |
commit | 1de70c5fe1e18157efb4a592390ce08534139aa0 (patch) | |
tree | e95068190830febe15dfaab6f0600fb769492706 /Build/source/m4/kpse-cxx-hack.m4 | |
parent | 5b8dcec4983808da1a0b25a4f41435b03370a79f (diff) |
new build system: multiplatform, cxx-runtime-hack, luatex
git-svn-id: svn://tug.org/texlive/trunk@12563 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/m4/kpse-cxx-hack.m4')
-rw-r--r-- | Build/source/m4/kpse-cxx-hack.m4 | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/Build/source/m4/kpse-cxx-hack.m4 b/Build/source/m4/kpse-cxx-hack.m4 new file mode 100644 index 00000000000..94f0eb6cf16 --- /dev/null +++ b/Build/source/m4/kpse-cxx-hack.m4 @@ -0,0 +1,89 @@ +# Public macros for the teTeX / TeX Live (TL) tree. +# Copyright (C) 2009 Peter Breitenlohner <tex-live@tug.org> +# +# This file is free software; the copyright holder +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 0 + +# KPSE_ENABLE_CXX_HACK +# -------------------- +# Provide the configure option '--enable-cxx-runtime-hack'. +AC_DEFUN([KPSE_ENABLE_CXX_HACK], +[AC_ARG_ENABLE([cxx-runtime-hack], + AS_HELP_STRING([--enable-cxx-runtime-hack], + [link C++ runtime statically], + [29]))[]dnl +]) # KPSE_ENABLE_CXX_HACK + +# KPSE_CXX_HACK() +# --------------- +# Try statically linking C++ runtime library (g++ only) +# and define CXX_HACK_LIBS with required flags. +# Since Libtool reshuffles the argument list, we define CXXLD +# as wrapper script appending these flags to g++ as invoked +# by Libtool when linking progams (but not shared libraries). +# +AC_DEFUN([KPSE_CXX_HACK], +[AC_REQUIRE([AC_PROG_CXX])[]dnl +AC_REQUIRE([KPSE_ENABLE_CXX_HACK])[]dnl +cpp_link_hack=false +if test "x$GXX" = xyes && test "x$enable_cxx_runtime_hack" = xyes; then + _KPSE_CXX_HACK +fi +if $cpp_link_hack; then + CXXLD='$(top_builddir)/CXXLD.sh' + CXX_HACK_DEPS=$CXXLD + cxxld_sh="#! ${CONFIG_SHELL-/bin/sh} +# CXXLD.sh. Generated by configure. +set -- $CXX \"\$[]@\" $CXX_HACK_LIBS +echo \"\$[]0:\" \"\$[]@\" +exec \"\$[]@\"" + AC_CONFIG_FILES([CXXLD.sh:Makefile.in], + [echo "$cxxld_sh" >CXXLD.sh; chmod +x CXXLD.sh], + [cxxld_sh='$cxxld_sh']) +else + CXXLD='$(CXX)' +fi +AC_SUBST([CXXLD]) +AC_SUBST([CXX_HACK_DEPS]) +AC_SUBST([CXX_HACK_LIBS]) +]) # KPSE_CXX_HACK + +# _KPSE_CXX_HACK() +# ---------------- +# internal subroutine +m4_define([_KPSE_CXX_HACK], [ +AC_LANG_PUSH([C++]) +AC_CHECK_HEADERS([iostream]) +AC_MSG_CHECKING([for statically linking C++ runtime library]) +AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#ifdef HAVE_IOSTREAM +#include <iostream> +using namespace std; +#else +#include <iostream.h> +#endif]], + [[cout <<"worksok\n";]])]) +flags_try0='-nodefaultlibs -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -lm' +flags_try1='-lgcc_eh -lgcc -lc -lgcc_eh -lgcc' +flags_try2='-lgcc -lc -lgcc' +kpse_save_LIBS=$LIBS +for flags in "$flags_try1" "$flags_try2"; do + LIBS="$kpse_save_LIBS $flags_try0 $flags" + AC_LINK_IFELSE([], + [case `(./conftest$ac_exeext; exit) 2>/dev/null` in + worksok) + cpp_link_hack=true; break;; + esac]) +done +LIBS=$kpse_save_LIBS + +if $cpp_link_hack; then + CXX_HACK_LIBS="$flags_try0 $flags" + AC_MSG_RESULT(ok using $CXX_HACK_LIBS) +else + AC_MSG_RESULT(not supported) +fi +AC_LANG_POP([C++]) +]) # _KPSE_CXX_HACK |