| 1 |
# Public macros for the TeX Live (TL) tree. |
| 2 |
# Copyright (C) 2002 Olaf Weber <[email protected]> |
| 3 |
# Copyright (C) 2009-2014 Peter Breitenlohner <[email protected]> |
| 4 |
# |
| 5 |
# This file is free software; the copyright holders |
| 6 |
# give unlimited permission to copy and/or distribute it, |
| 7 |
# with or without modifications, as long as this notice is preserved. |
| 8 |
|
| 9 |
# serial 0 |
| 10 |
|
| 11 |
# KPSE_ENABLE_CXX_HACK |
| 12 |
# -------------------- |
| 13 |
# Provide the configure option '--enable-cxx-runtime-hack'. |
| 14 |
AC_DEFUN([KPSE_ENABLE_CXX_HACK], |
| 15 |
[AC_ARG_ENABLE([cxx-runtime-hack], |
| 16 |
AS_HELP_STRING([--enable-cxx-runtime-hack], |
| 17 |
[link C++ runtime statically], |
| 18 |
[29]))[]dnl |
| 19 |
]) # KPSE_ENABLE_CXX_HACK |
| 20 |
|
| 21 |
# KPSE_CXX_HACK() |
| 22 |
# --------------- |
| 23 |
# Try statically linking C++ runtime library (g++ only). |
| 24 |
# Since Libtool reshuffles the argument list, we define CXXLD |
| 25 |
# as wrapper script appending these flags to g++ as invoked |
| 26 |
# by Libtool when linking progams (but not shared libraries). |
| 27 |
# |
| 28 |
AC_DEFUN([KPSE_CXX_HACK], |
| 29 |
[AC_REQUIRE([AC_CANONICAL_HOST])[]dnl |
| 30 |
AC_REQUIRE([AC_PROG_CXX])[]dnl |
| 31 |
AC_REQUIRE([KPSE_ENABLE_CXX_HACK])[]dnl |
| 32 |
if test "x$GXX:$enable_cxx_runtime_hack" = xyes:yes; then |
| 33 |
_KPSE_CXX_HACK |
| 34 |
fi |
| 35 |
if test "x$kpse_cv_cxx_hack" = xok; then |
| 36 |
CXXLD='$(top_builddir)/CXXLD.sh' |
| 37 |
cxxld_sh="#! ${CONFIG_SHELL-/bin/sh} |
| 38 |
# CXXLD.sh. Generated by configure. |
| 39 |
set -- $CXX \"\$[]@\" $kpse_cv_cxx_flags |
| 40 |
echo \"\$[]0:\" \"\$[]@\" |
| 41 |
exec \"\$[]@\"" |
| 42 |
AC_CONFIG_COMMANDS([CXXLD.sh], |
| 43 |
[echo "$cxxld_sh" >CXXLD.sh; chmod +x CXXLD.sh], |
| 44 |
[cxxld_sh='$cxxld_sh']) |
| 45 |
else |
| 46 |
CXXLD='$(CXX)' |
| 47 |
fi |
| 48 |
AC_SUBST([CXXLD]) |
| 49 |
]) # KPSE_CXX_HACK |
| 50 |
|
| 51 |
# _KPSE_CXX_HACK() |
| 52 |
# ---------------- |
| 53 |
# Internal subroutine. |
| 54 |
m4_define([_KPSE_CXX_HACK], [ |
| 55 |
AC_LANG_PUSH([C++]) |
| 56 |
AC_CHECK_HEADERS([iostream]) |
| 57 |
AC_CACHE_CHECK([for statically linking C++ runtime library], |
| 58 |
[kpse_cv_cxx_hack], |
| 59 |
[AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#ifdef HAVE_IOSTREAM |
| 60 |
#include <iostream> |
| 61 |
using namespace std; |
| 62 |
#else |
| 63 |
#include <iostream.h> |
| 64 |
#endif]], |
| 65 |
[[cout <<"worksok\n";]])]) |
| 66 |
AS_CASE([$host], |
| 67 |
[*cygwin*], |
| 68 |
[flags_try0='-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic'], |
| 69 |
[flags_try0='-nodefaultlibs -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -lm' |
| 70 |
flags_try1='-lgcc_eh -lgcc -lc -lgcc_eh -lgcc' |
| 71 |
flags_try2='-lgcc -lc -lgcc']) |
| 72 |
kpse_save_LIBS=$LIBS |
| 73 |
cpp_link_hack=false |
| 74 |
for flags in "$flags_try1" "$flags_try2"; do |
| 75 |
LIBS="$kpse_save_LIBS $flags_try0 $flags" |
| 76 |
AC_LINK_IFELSE([], |
| 77 |
[AS_IF([test "x$cross_compiling" = xyes], |
| 78 |
[cpp_link_hack=true; break], |
| 79 |
[AS_CASE([`(./conftest$ac_exeext; exit) 2>/dev/null`], |
| 80 |
[worksok], [cpp_link_hack=true; break])])]) |
| 81 |
done |
| 82 |
LIBS=$kpse_save_LIBS |
| 83 |
if $cpp_link_hack; then |
| 84 |
kpse_cv_cxx_hack=ok |
| 85 |
kpse_cv_cxx_flags="$flags_try0 $flags" |
| 86 |
else |
| 87 |
kpse_cv_cxx_hack="not supported" |
| 88 |
fi]) |
| 89 |
if test "x$kpse_cv_cxx_hack" = xok; then |
| 90 |
AC_MSG_NOTICE([using $kpse_cv_cxx_flags]) |
| 91 |
fi |
| 92 |
AC_LANG_POP([C++]) |
| 93 |
]) # _KPSE_CXX_HACK |