Changeset 2659


Ignore:
Timestamp:
Dec 1, 2012 1:33:08 PM (7 years ago)
Author:
stefan
Message:

add --enable-static-standardlibs to add flags like --static-libgcc/stdc++/gfortran to LDFLAGS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/coin.m4

    r2618 r2659  
    303303[AC_REQUIRE([AC_COIN_PROG_CC]) #Let's try if that overcomes configuration problem with VC++ 6.0
    304304AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
     305AC_REQUIRE([AC_COIN_ENABLE_STATICSTDLIBS])
    305306AC_LANG_PUSH(C++)
    306307
     
    576577esac
    577578
     579# check whether to add flag for static linking against standard libraries to LDFLAGS
     580if test x$use_static_standardlibs != xno ; then
     581  case $build in
     582    *-mingw*)
     583      static_standardlib_flag=-static
     584      ;;
     585    *)
     586      static_standardlib_flag=-static-libstdc++
     587      ;;
     588  esac
     589  case " $LDFLAGS " in
     590    *" $static_standardlib_flag "* ) ;;
     591    *)
     592    AC_MSG_CHECKING([whether linking with $static_standardlib_flag works])
     593    coin_save_LDFLAGS="$LDFLAGS"
     594    LDFLAGS="$LDFLAGS $static_standardlib_flag"
     595    AC_LINK_IFELSE(
     596      [AC_LANG_PROGRAM(, [int i=0;])],
     597      [AC_MSG_RESULT(yes)],
     598      [AC_MSG_RESULT(no)
     599       LDFLAGS="$coin_save_LDFLAGS"
     600       if test $use_static_standardlibs = yes ; then
     601         AC_MSG_ERROR([failed to link with $static_standardlib_flag])
     602       fi
     603      ])
     604    ;;
     605  esac
     606fi
     607
    578608AC_LANG_POP(C++)
    579609]) # AC_COIN_PROG_CXX
     
    691721
    692722###########################################################################
     723#                   COIN_ENABLE_STATICSTDLIBS                             #
     724###########################################################################
     725
     726# This macro defines the --enable-static-standardlibs flag and determines
     727# its default value according to the setting of --enable-shared.
     728# That is, if static libraries are build, then we also try to link against
     729# static standard libraries, unless the corresponding flags do not work.
     730
     731AC_DEFUN([AC_COIN_ENABLE_STATICSTDLIBS],
     732[
     733
     734# check whether to add flags for static linking against standard libraries
     735AC_ARG_ENABLE([static-standardlibs],
     736  [AC_HELP_STRING([--enable-static-standardlibs],
     737                  [whether to link against static standard libraries (libgcc, libgfortran, libstdc++)])],
     738  [case "$enableval" in
     739     no | yes | auto ) ;;
     740     *)
     741       AC_MSG_ERROR([invalid argument for --enable-static-standardlibs: $enableval]) ;;
     742   esac
     743   use_static_standardlibs=$enableval],
     744  [if test $enable_shared = yes ; then
     745     use_static_standardlibs = no
     746   else
     747     use_static_standardlibs = auto
     748   fi
     749  ]
     750)
     751
     752]);
     753
     754###########################################################################
    693755#                             COIN_PROG_CC                                #
    694756###########################################################################
     
    702764[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
    703765AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
     766AC_REQUIRE([AC_COIN_ENABLE_STATICSTDLIBS])
    704767AC_LANG_PUSH(C)
    705768
     
    912975    CFLAGS="$OPT_CFLAGS"
    913976  fi
     977
    914978else
    915979  CFLAGS="$CFLAGS $ADD_CFLAGS $CDEFS"
     
    9721036esac
    9731037
     1038# check whether to add flags for static linking against standard libraries to LDFLAGS
     1039if test x$use_static_standardlibs != xno ; then
     1040  case $build in
     1041    *-mingw*)
     1042      static_standardlib_flag=-static
     1043      ;;
     1044    *)
     1045      static_standardlib_flag=-static-libgcc
     1046      ;;
     1047  esac
     1048  case " $LDFLAGS " in
     1049    *" $static_standardlib_flag "* ) ;;
     1050    *)
     1051    AC_MSG_CHECKING([whether linking with $static_standardlib_flag works])
     1052    coin_save_LDFLAGS="$LDFLAGS"
     1053    LDFLAGS="$LDFLAGS $static_standardlib_flag"
     1054    AC_LINK_IFELSE(
     1055      [AC_LANG_PROGRAM(, [int i=0;])],
     1056      [AC_MSG_RESULT(yes)],
     1057      [AC_MSG_RESULT(no)
     1058       LDFLAGS="$coin_save_LDFLAGS"
     1059       if test $use_static_standardlibs = yes ; then
     1060         AC_MSG_ERROR([failed to link with $static_standardlib_flag])
     1061       fi
     1062      ])
     1063    ;;
     1064  esac
     1065fi
     1066
    9741067AC_LANG_POP(C)
    9751068]) # AC_COIN_PROG_CC
     
    9861079[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
    9871080AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
     1081AC_REQUIRE([AC_COIN_ENABLE_STATICSTDLIBS])
    9881082AC_REQUIRE([AC_COIN_PROG_CC])
    9891083AC_REQUIRE([AC_COIN_F77_COMPS])
     
    11331227    FFLAGS="$OPT_FFLAGS"
    11341228  fi
     1229
    11351230else
    11361231  FFLAGS="$FFLAGS $ADD_FFLAGS"
     
    11861281    ;;
    11871282esac
     1283
     1284# check whether to add flag for static linking against standard libraries to LDFLAGS
     1285if test x$use_static_standardlibs != xno ; then
     1286  case $build in
     1287    *-mingw*)
     1288      static_standardlib_flag=-static
     1289      ;;
     1290    *)
     1291      static_standardlib_flag=-static-libgfortran
     1292      ;;
     1293  esac
     1294  case " $LDFLAGS " in
     1295    *" $static_standardlib_flag "* ) ;;
     1296    *)
     1297    AC_MSG_CHECKING([whether linking with $static_standardlib_flag works])
     1298    coin_save_LDFLAGS="$LDFLAGS"
     1299    LDFLAGS="$LDFLAGS $static_standardlib_flag"
     1300    AC_LINK_IFELSE(
     1301      [AC_LANG_PROGRAM(,[      integer i])],
     1302      [AC_MSG_RESULT(yes)],
     1303      [AC_MSG_RESULT(no)
     1304       LDFLAGS="$coin_save_LDFLAGS"
     1305       if test $use_static_standardlibs = yes ; then
     1306         AC_MSG_ERROR([failed to link with $static_standardlib_flag])
     1307       fi
     1308      ])
     1309    ;;
     1310  esac
     1311fi
    11881312
    11891313AC_LANG_POP([Fortran 77])
Note: See TracChangeset for help on using the changeset viewer.