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