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