Debian Codegraph @

m4/lib-prefix.m4

raw
1 # lib-prefix.m4 serial 5 (gettext-0.15)
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 dnl
7 dnl SPDX-License-Identifier: FSFULLR
8
9 dnl From Bruno Haible.
10
11 dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
12 dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
13 dnl require excessive bracketing.
14 ifdef([AC_HELP_STRING],
15 [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
16 [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
17
18 dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
19 dnl to access previously installed libraries. The basic assumption is that
20 dnl a user will want packages to use other packages he previously installed
21 dnl with the same --prefix option.
22 dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
23 dnl libraries, but is otherwise very convenient.
24 AC_DEFUN([AC_LIB_PREFIX],
25 [
26 AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
27 AC_REQUIRE([AC_PROG_CC])
28 AC_REQUIRE([AC_CANONICAL_HOST])
29 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
30 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
31 dnl By default, look in $includedir and $libdir.
32 use_additional=yes
33 AC_LIB_WITH_FINAL_PREFIX([
34 eval additional_includedir=\"$includedir\"
35 eval additional_libdir=\"$libdir\"
36 ])
37 AC_LIB_ARG_WITH([lib-prefix],
38 [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
39 --without-lib-prefix don't search for libraries in includedir and libdir],
40 [
41 if test "X$withval" = "Xno"; then
42 use_additional=no
43 else
44 if test "X$withval" = "X"; then
45 AC_LIB_WITH_FINAL_PREFIX([
46 eval additional_includedir=\"$includedir\"
47 eval additional_libdir=\"$libdir\"
48 ])
49 else
50 additional_includedir="$withval/include"
51 additional_libdir="$withval/$acl_libdirstem"
52 fi
53 fi
54 ])
55 if test $use_additional = yes; then
56 dnl Potentially add $additional_includedir to $CPPFLAGS.
57 dnl But don't add it
58 dnl 1. if it's the standard /usr/include,
59 dnl 2. if it's already present in $CPPFLAGS,
60 dnl 3. if it's /usr/local/include and we are using GCC on Linux,
61 dnl 4. if it doesn't exist as a directory.
62 if test "X$additional_includedir" != "X/usr/include"; then
63 haveit=
64 for x in $CPPFLAGS; do
65 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
66 if test "X$x" = "X-I$additional_includedir"; then
67 haveit=yes
68 break
69 fi
70 done
71 if test -z "$haveit"; then
72 if test "X$additional_includedir" = "X/usr/local/include"; then
73 if test -n "$GCC"; then
74 case $host_os in
75 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
76 esac
77 fi
78 fi
79 if test -z "$haveit"; then
80 if test -d "$additional_includedir"; then
81 dnl Really add $additional_includedir to $CPPFLAGS.
82 CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
83 fi
84 fi
85 fi
86 fi
87 dnl Potentially add $additional_libdir to $LDFLAGS.
88 dnl But don't add it
89 dnl 1. if it's the standard /usr/lib,
90 dnl 2. if it's already present in $LDFLAGS,
91 dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
92 dnl 4. if it doesn't exist as a directory.
93 if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
94 haveit=
95 for x in $LDFLAGS; do
96 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
97 if test "X$x" = "X-L$additional_libdir"; then
98 haveit=yes
99 break
100 fi
101 done
102 if test -z "$haveit"; then
103 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
104 if test -n "$GCC"; then
105 case $host_os in
106 linux*) haveit=yes;;
107 esac
108 fi
109 fi
110 if test -z "$haveit"; then
111 if test -d "$additional_libdir"; then
112 dnl Really add $additional_libdir to $LDFLAGS.
113 LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
114 fi
115 fi
116 fi
117 fi
118 fi
119 ])
120
121 dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
122 dnl acl_final_exec_prefix, containing the values to which $prefix and
123 dnl $exec_prefix will expand at the end of the configure script.
124 AC_DEFUN([AC_LIB_PREPARE_PREFIX],
125 [
126 dnl Unfortunately, prefix and exec_prefix get only finally determined
127 dnl at the end of configure.
128 if test "X$prefix" = "XNONE"; then
129 acl_final_prefix="$ac_default_prefix"
130 else
131 acl_final_prefix="$prefix"
132 fi
133 if test "X$exec_prefix" = "XNONE"; then
134 acl_final_exec_prefix='${prefix}'
135 else
136 acl_final_exec_prefix="$exec_prefix"
137 fi
138 acl_save_prefix="$prefix"
139 prefix="$acl_final_prefix"
140 eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
141 prefix="$acl_save_prefix"
142 ])
143
144 dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
145 dnl variables prefix and exec_prefix bound to the values they will have
146 dnl at the end of the configure script.
147 AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
148 [
149 acl_save_prefix="$prefix"
150 prefix="$acl_final_prefix"
151 acl_save_exec_prefix="$exec_prefix"
152 exec_prefix="$acl_final_exec_prefix"
153 $1
154 exec_prefix="$acl_save_exec_prefix"
155 prefix="$acl_save_prefix"
156 ])
157
158 dnl AC_LIB_PREPARE_MULTILIB creates a variable acl_libdirstem, containing
159 dnl the basename of the libdir, either "lib" or "lib64".
160 AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
161 [
162 dnl There is no formal standard regarding lib and lib64. The current
163 dnl practice is that on a system supporting 32-bit and 64-bit instruction
164 dnl sets or ABIs, 64-bit libraries go under $prefix/lib64 and 32-bit
165 dnl libraries go under $prefix/lib. We determine the compiler's default
166 dnl mode by looking at the compiler's library search path. If at least
167 dnl of its elements ends in /lib64 or points to a directory whose absolute
168 dnl pathname ends in /lib64, we assume a 64-bit ABI. Otherwise we use the
169 dnl default, namely "lib".
170 acl_libdirstem=lib
171 searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
172 if test -n "$searchpath"; then
173 acl_save_IFS="${IFS= }"; IFS=":"
174 for searchdir in $searchpath; do
175 if test -d "$searchdir"; then
176 case "$searchdir" in
177 */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
178 *) searchdir=`cd "$searchdir" && pwd`
179 case "$searchdir" in
180 */lib64 ) acl_libdirstem=lib64 ;;
181 esac ;;
182 esac
183 fi
184 done
185 IFS="$acl_save_IFS"
186 fi
187 ])