1 # lib-prefix.m4 serial 4 (gettext-0.14.2)
2 dnl Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
10 dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
11 dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
12 dnl require excessive bracketing.
13 ifdef([AC_HELP_STRING],
14 [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
15 [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
17 dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
18 dnl to access previously installed libraries. The basic assumption is that
19 dnl a user will want packages to use other packages he previously installed
20 dnl with the same --prefix option.
21 dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
22 dnl libraries, but is otherwise very convenient.
23 AC_DEFUN([AC_LIB_PREFIX],
25 AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
26 AC_REQUIRE([AC_PROG_CC])
27 AC_REQUIRE([AC_CANONICAL_HOST])
28 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
29 dnl By default, look in $includedir and $libdir.
31 AC_LIB_WITH_FINAL_PREFIX([
32 eval additional_includedir=\"$includedir\"
33 eval additional_libdir=\"$libdir\"
35 AC_LIB_ARG_WITH([lib-prefix],
36 [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
37 --without-lib-prefix don't search for libraries in includedir and libdir],
39 if test "X$withval" = "Xno"; then
42 if test "X$withval" = "X"; then
43 AC_LIB_WITH_FINAL_PREFIX([
44 eval additional_includedir=\"$includedir\"
45 eval additional_libdir=\"$libdir\"
48 additional_includedir="$withval/include"
49 additional_libdir="$withval/lib"
53 if test $use_additional = yes; then
54 dnl Potentially add $additional_includedir to $CPPFLAGS.
56 dnl 1. if it's the standard /usr/include,
57 dnl 2. if it's already present in $CPPFLAGS,
58 dnl 3. if it's /usr/local/include and we are using GCC on Linux,
59 dnl 4. if it doesn't exist as a directory.
60 if test "X$additional_includedir" != "X/usr/include"; then
62 for x in $CPPFLAGS; do
63 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
64 if test "X$x" = "X-I$additional_includedir"; then
69 if test -z "$haveit"; then
70 if test "X$additional_includedir" = "X/usr/local/include"; then
71 if test -n "$GCC"; then
73 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
77 if test -z "$haveit"; then
78 if test -d "$additional_includedir"; then
79 dnl Really add $additional_includedir to $CPPFLAGS.
80 CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
85 dnl Potentially add $additional_libdir to $LDFLAGS.
87 dnl 1. if it's the standard /usr/lib,
88 dnl 2. if it's already present in $LDFLAGS,
89 dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
90 dnl 4. if it doesn't exist as a directory.
91 if test "X$additional_libdir" != "X/usr/lib"; then
94 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
95 if test "X$x" = "X-L$additional_libdir"; then
100 if test -z "$haveit"; then
101 if test "X$additional_libdir" = "X/usr/local/lib"; then
102 if test -n "$GCC"; then
108 if test -z "$haveit"; then
109 if test -d "$additional_libdir"; then
110 dnl Really add $additional_libdir to $LDFLAGS.
111 LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
119 dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
120 dnl acl_final_exec_prefix, containing the values to which $prefix and
121 dnl $exec_prefix will expand at the end of the configure script.
122 AC_DEFUN([AC_LIB_PREPARE_PREFIX],
124 dnl Unfortunately, prefix and exec_prefix get only finally determined
125 dnl at the end of configure.
126 if test "X$prefix" = "XNONE"; then
127 acl_final_prefix="$ac_default_prefix"
129 acl_final_prefix="$prefix"
131 if test "X$exec_prefix" = "XNONE"; then
132 acl_final_exec_prefix='${prefix}'
134 acl_final_exec_prefix="$exec_prefix"
136 acl_save_prefix="$prefix"
137 prefix="$acl_final_prefix"
138 eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
139 prefix="$acl_save_prefix"
142 dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
143 dnl variables prefix and exec_prefix bound to the values they will have
144 dnl at the end of the configure script.
145 AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
147 acl_save_prefix="$prefix"
148 prefix="$acl_final_prefix"
149 acl_save_exec_prefix="$exec_prefix"
150 exec_prefix="$acl_final_exec_prefix"
152 exec_prefix="$acl_save_exec_prefix"
153 prefix="$acl_save_prefix"