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