1*75f6d617Schristos# lib-prefix.m4 serial 1 (gettext-0.11) 2*75f6d617Schristosdnl Copyright (C) 2001-2002 Free Software Foundation, Inc. 3*75f6d617Schristosdnl This file is free software, distributed under the terms of the GNU 4*75f6d617Schristosdnl General Public License. As a special exception to the GNU General 5*75f6d617Schristosdnl Public License, this file may be distributed as part of a program 6*75f6d617Schristosdnl that contains a configuration script generated by Autoconf, under 7*75f6d617Schristosdnl the same distribution terms as the rest of that program. 8*75f6d617Schristos 9*75f6d617Schristosdnl From Bruno Haible. 10*75f6d617Schristos 11*75f6d617Schristosdnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed 12*75f6d617Schristosdnl to access previously installed libraries. The basic assumption is that 13*75f6d617Schristosdnl a user will want packages to use other packages he previously installed 14*75f6d617Schristosdnl with the same --prefix option. 15*75f6d617Schristosdnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate 16*75f6d617Schristosdnl libraries, but is otherwise very convenient. 17*75f6d617SchristosAC_DEFUN([AC_LIB_PREFIX], 18*75f6d617Schristos[ 19*75f6d617Schristos AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) 20*75f6d617Schristos AC_REQUIRE([AC_PROG_CC]) 21*75f6d617Schristos AC_REQUIRE([AC_CANONICAL_HOST]) 22*75f6d617Schristos AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 23*75f6d617Schristos dnl By default, look in $includedir and $libdir. 24*75f6d617Schristos use_additional=yes 25*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([ 26*75f6d617Schristos eval additional_includedir=\"$includedir\" 27*75f6d617Schristos eval additional_libdir=\"$libdir\" 28*75f6d617Schristos ]) 29*75f6d617Schristos AC_ARG_WITH([lib-prefix], 30*75f6d617Schristos[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib 31*75f6d617Schristos --without-lib-prefix don't search for libraries in includedir and libdir], 32*75f6d617Schristos[ 33*75f6d617Schristos if test "X$withval" = "Xno"; then 34*75f6d617Schristos use_additional=no 35*75f6d617Schristos else 36*75f6d617Schristos if test "X$withval" = "X"; then 37*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([ 38*75f6d617Schristos eval additional_includedir=\"$includedir\" 39*75f6d617Schristos eval additional_libdir=\"$libdir\" 40*75f6d617Schristos ]) 41*75f6d617Schristos else 42*75f6d617Schristos additional_includedir="$withval/include" 43*75f6d617Schristos additional_libdir="$withval/lib" 44*75f6d617Schristos fi 45*75f6d617Schristos fi 46*75f6d617Schristos]) 47*75f6d617Schristos if test $use_additional = yes; then 48*75f6d617Schristos dnl Potentially add $additional_includedir to $CPPFLAGS. 49*75f6d617Schristos dnl But don't add it 50*75f6d617Schristos dnl 1. if it's the standard /usr/include, 51*75f6d617Schristos dnl 2. if it's already present in $CPPFLAGS, 52*75f6d617Schristos dnl 3. if it's /usr/local/include and we are using GCC on Linux, 53*75f6d617Schristos dnl 4. if it doesn't exist as a directory. 54*75f6d617Schristos if test "X$additional_includedir" != "X/usr/include"; then 55*75f6d617Schristos haveit= 56*75f6d617Schristos for x in $CPPFLAGS; do 57*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 58*75f6d617Schristos if test "X$x" = "X-I$additional_includedir"; then 59*75f6d617Schristos haveit=yes 60*75f6d617Schristos break 61*75f6d617Schristos fi 62*75f6d617Schristos done 63*75f6d617Schristos if test -z "$haveit"; then 64*75f6d617Schristos if test "X$additional_includedir" = "X/usr/local/include"; then 65*75f6d617Schristos if test -n "$GCC"; then 66*75f6d617Schristos case $host_os in 67*75f6d617Schristos linux*) haveit=yes;; 68*75f6d617Schristos esac 69*75f6d617Schristos fi 70*75f6d617Schristos fi 71*75f6d617Schristos if test -z "$haveit"; then 72*75f6d617Schristos if test -d "$additional_includedir"; then 73*75f6d617Schristos dnl Really add $additional_includedir to $CPPFLAGS. 74*75f6d617Schristos CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" 75*75f6d617Schristos fi 76*75f6d617Schristos fi 77*75f6d617Schristos fi 78*75f6d617Schristos fi 79*75f6d617Schristos dnl Potentially add $additional_libdir to $LDFLAGS. 80*75f6d617Schristos dnl But don't add it 81*75f6d617Schristos dnl 1. if it's the standard /usr/lib, 82*75f6d617Schristos dnl 2. if it's already present in $LDFLAGS, 83*75f6d617Schristos dnl 3. if it's /usr/local/lib and we are using GCC on Linux, 84*75f6d617Schristos dnl 4. if it doesn't exist as a directory. 85*75f6d617Schristos if test "X$additional_libdir" != "X/usr/lib"; then 86*75f6d617Schristos haveit= 87*75f6d617Schristos for x in $LDFLAGS; do 88*75f6d617Schristos AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) 89*75f6d617Schristos if test "X$x" = "X-L$additional_libdir"; then 90*75f6d617Schristos haveit=yes 91*75f6d617Schristos break 92*75f6d617Schristos fi 93*75f6d617Schristos done 94*75f6d617Schristos if test -z "$haveit"; then 95*75f6d617Schristos if test "X$additional_libdir" = "X/usr/local/lib"; then 96*75f6d617Schristos if test -n "$GCC"; then 97*75f6d617Schristos case $host_os in 98*75f6d617Schristos linux*) haveit=yes;; 99*75f6d617Schristos esac 100*75f6d617Schristos fi 101*75f6d617Schristos fi 102*75f6d617Schristos if test -z "$haveit"; then 103*75f6d617Schristos if test -d "$additional_libdir"; then 104*75f6d617Schristos dnl Really add $additional_libdir to $LDFLAGS. 105*75f6d617Schristos LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" 106*75f6d617Schristos fi 107*75f6d617Schristos fi 108*75f6d617Schristos fi 109*75f6d617Schristos fi 110*75f6d617Schristos fi 111*75f6d617Schristos]) 112*75f6d617Schristos 113*75f6d617Schristosdnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, 114*75f6d617Schristosdnl acl_final_exec_prefix, containing the values to which $prefix and 115*75f6d617Schristosdnl $exec_prefix will expand at the end of the configure script. 116*75f6d617SchristosAC_DEFUN([AC_LIB_PREPARE_PREFIX], 117*75f6d617Schristos[ 118*75f6d617Schristos dnl Unfortunately, prefix and exec_prefix get only finally determined 119*75f6d617Schristos dnl at the end of configure. 120*75f6d617Schristos if test "X$prefix" = "XNONE"; then 121*75f6d617Schristos acl_final_prefix="$ac_default_prefix" 122*75f6d617Schristos else 123*75f6d617Schristos acl_final_prefix="$prefix" 124*75f6d617Schristos fi 125*75f6d617Schristos if test "X$exec_prefix" = "XNONE"; then 126*75f6d617Schristos acl_final_exec_prefix='${prefix}' 127*75f6d617Schristos else 128*75f6d617Schristos acl_final_exec_prefix="$exec_prefix" 129*75f6d617Schristos fi 130*75f6d617Schristos acl_save_prefix="$prefix" 131*75f6d617Schristos prefix="$acl_final_prefix" 132*75f6d617Schristos eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" 133*75f6d617Schristos prefix="$acl_save_prefix" 134*75f6d617Schristos]) 135*75f6d617Schristos 136*75f6d617Schristosdnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the 137*75f6d617Schristosdnl variables prefix and exec_prefix bound to the values they will have 138*75f6d617Schristosdnl at the end of the configure script. 139*75f6d617SchristosAC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], 140*75f6d617Schristos[ 141*75f6d617Schristos acl_save_prefix="$prefix" 142*75f6d617Schristos prefix="$acl_final_prefix" 143*75f6d617Schristos acl_save_exec_prefix="$exec_prefix" 144*75f6d617Schristos exec_prefix="$acl_final_exec_prefix" 145*75f6d617Schristos $1 146*75f6d617Schristos exec_prefix="$acl_save_exec_prefix" 147*75f6d617Schristos prefix="$acl_save_prefix" 148*75f6d617Schristos]) 149