1 # lib-prefix.m4 serial 2 (gettext-0.12)
2 dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License. As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
11 dnl AC_LIB_ARG_WITH is similar to AC_ARG_WITH except that it doesn't
12 dnl require excessive bracketing.
13 AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])
15 dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
16 dnl to access previously installed libraries. The basic assumption is that
17 dnl a user will want packages to use other packages he previously installed
18 dnl with the same --prefix option.
19 dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
20 dnl libraries, but is otherwise very convenient.
21 AC_DEFUN([AC_LIB_PREFIX],
23 AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
24 AC_REQUIRE([AC_PROG_CC])
25 AC_REQUIRE([AC_CANONICAL_HOST])
26 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
27 dnl By default, look in $includedir and $libdir.
29 AC_LIB_WITH_FINAL_PREFIX([
30 eval additional_includedir=\"$includedir\"
31 eval additional_libdir=\"$libdir\"
33 AC_LIB_ARG_WITH([lib-prefix],
34 [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
35 --without-lib-prefix don't search for libraries in includedir and libdir],
37 if test "X$withval" = "Xno"; then
40 if test "X$withval" = "X"; then
41 AC_LIB_WITH_FINAL_PREFIX([
42 eval additional_includedir=\"$includedir\"
43 eval additional_libdir=\"$libdir\"
46 additional_includedir="$withval/include"
47 additional_libdir="$withval/lib"
51 if test $use_additional = yes; then
52 dnl Potentially add $additional_includedir to $CPPFLAGS.
54 dnl 1. if it's the standard /usr/include,
55 dnl 2. if it's already present in $CPPFLAGS,
56 dnl 3. if it's /usr/local/include and we are using GCC on Linux,
57 dnl 4. if it doesn't exist as a directory.
58 if test "X$additional_includedir" != "X/usr/include"; then
60 for x in $CPPFLAGS; do
61 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
62 if test "X$x" = "X-I$additional_includedir"; then
67 if test -z "$haveit"; then
68 if test "X$additional_includedir" = "X/usr/local/include"; then
69 if test -n "$GCC"; then
75 if test -z "$haveit"; then
76 if test -d "$additional_includedir"; then
77 dnl Really add $additional_includedir to $CPPFLAGS.
78 CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
83 dnl Potentially add $additional_libdir to $LDFLAGS.
85 dnl 1. if it's the standard /usr/lib,
86 dnl 2. if it's already present in $LDFLAGS,
87 dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
88 dnl 4. if it doesn't exist as a directory.
89 if test "X$additional_libdir" != "X/usr/lib"; then
92 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
93 if test "X$x" = "X-L$additional_libdir"; then
98 if test -z "$haveit"; then
99 if test "X$additional_libdir" = "X/usr/local/lib"; then
100 if test -n "$GCC"; then
106 if test -z "$haveit"; then
107 if test -d "$additional_libdir"; then
108 dnl Really add $additional_libdir to $LDFLAGS.
109 LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
117 dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
118 dnl acl_final_exec_prefix, containing the values to which $prefix and
119 dnl $exec_prefix will expand at the end of the configure script.
120 AC_DEFUN([AC_LIB_PREPARE_PREFIX],
122 dnl Unfortunately, prefix and exec_prefix get only finally determined
123 dnl at the end of configure.
124 if test "X$prefix" = "XNONE"; then
125 acl_final_prefix="$ac_default_prefix"
127 acl_final_prefix="$prefix"
129 if test "X$exec_prefix" = "XNONE"; then
130 acl_final_exec_prefix='${prefix}'
132 acl_final_exec_prefix="$exec_prefix"
134 acl_save_prefix="$prefix"
135 prefix="$acl_final_prefix"
136 eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
137 prefix="$acl_save_prefix"
140 dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
141 dnl variables prefix and exec_prefix bound to the values they will have
142 dnl at the end of the configure script.
143 AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
145 acl_save_prefix="$prefix"
146 prefix="$acl_final_prefix"
147 acl_save_exec_prefix="$exec_prefix"
148 exec_prefix="$acl_final_exec_prefix"
150 exec_prefix="$acl_save_exec_prefix"
151 prefix="$acl_save_prefix"