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