diff options
Diffstat (limited to 'gl/m4/lib-prefix.m4')
-rw-r--r-- | gl/m4/lib-prefix.m4 | 323 |
1 files changed, 0 insertions, 323 deletions
diff --git a/gl/m4/lib-prefix.m4 b/gl/m4/lib-prefix.m4 deleted file mode 100644 index aefe7f71..00000000 --- a/gl/m4/lib-prefix.m4 +++ /dev/null | |||
@@ -1,323 +0,0 @@ | |||
1 | # lib-prefix.m4 serial 20 | ||
2 | dnl Copyright (C) 2001-2005, 2008-2023 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_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed | ||
10 | dnl to access previously installed libraries. The basic assumption is that | ||
11 | dnl a user will want packages to use other packages he previously installed | ||
12 | dnl with the same --prefix option. | ||
13 | dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate | ||
14 | dnl libraries, but is otherwise very convenient. | ||
15 | AC_DEFUN([AC_LIB_PREFIX], | ||
16 | [ | ||
17 | AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) | ||
18 | AC_REQUIRE([AC_PROG_CC]) | ||
19 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
20 | AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) | ||
21 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) | ||
22 | dnl By default, look in $includedir and $libdir. | ||
23 | use_additional=yes | ||
24 | AC_LIB_WITH_FINAL_PREFIX([ | ||
25 | eval additional_includedir=\"$includedir\" | ||
26 | eval additional_libdir=\"$libdir\" | ||
27 | ]) | ||
28 | AC_ARG_WITH([lib-prefix], | ||
29 | [[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib | ||
30 | --without-lib-prefix don't search for libraries in includedir and libdir]], | ||
31 | [ | ||
32 | if test "X$withval" = "Xno"; then | ||
33 | use_additional=no | ||
34 | else | ||
35 | if test "X$withval" = "X"; then | ||
36 | AC_LIB_WITH_FINAL_PREFIX([ | ||
37 | eval additional_includedir=\"$includedir\" | ||
38 | eval additional_libdir=\"$libdir\" | ||
39 | ]) | ||
40 | else | ||
41 | additional_includedir="$withval/include" | ||
42 | additional_libdir="$withval/$acl_libdirstem" | ||
43 | fi | ||
44 | fi | ||
45 | ]) | ||
46 | if test $use_additional = yes; then | ||
47 | dnl Potentially add $additional_includedir to $CPPFLAGS. | ||
48 | dnl But don't add it | ||
49 | dnl 1. if it's the standard /usr/include, | ||
50 | dnl 2. if it's already present in $CPPFLAGS, | ||
51 | dnl 3. if it's /usr/local/include and we are using GCC on Linux, | ||
52 | dnl 4. if it doesn't exist as a directory. | ||
53 | if test "X$additional_includedir" != "X/usr/include"; then | ||
54 | haveit= | ||
55 | for x in $CPPFLAGS; do | ||
56 | AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) | ||
57 | if test "X$x" = "X-I$additional_includedir"; then | ||
58 | haveit=yes | ||
59 | break | ||
60 | fi | ||
61 | done | ||
62 | if test -z "$haveit"; then | ||
63 | if test "X$additional_includedir" = "X/usr/local/include"; then | ||
64 | if test -n "$GCC"; then | ||
65 | case $host_os in | ||
66 | linux* | gnu* | k*bsd*-gnu) haveit=yes;; | ||
67 | esac | ||
68 | fi | ||
69 | fi | ||
70 | if test -z "$haveit"; then | ||
71 | if test -d "$additional_includedir"; then | ||
72 | dnl Really add $additional_includedir to $CPPFLAGS. | ||
73 | CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" | ||
74 | fi | ||
75 | fi | ||
76 | fi | ||
77 | fi | ||
78 | dnl Potentially add $additional_libdir to $LDFLAGS. | ||
79 | dnl But don't add it | ||
80 | dnl 1. if it's the standard /usr/lib, | ||
81 | dnl 2. if it's already present in $LDFLAGS, | ||
82 | dnl 3. if it's /usr/local/lib and we are using GCC on Linux, | ||
83 | dnl 4. if it doesn't exist as a directory. | ||
84 | if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then | ||
85 | haveit= | ||
86 | for x in $LDFLAGS; do | ||
87 | AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) | ||
88 | if test "X$x" = "X-L$additional_libdir"; then | ||
89 | haveit=yes | ||
90 | break | ||
91 | fi | ||
92 | done | ||
93 | if test -z "$haveit"; then | ||
94 | if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then | ||
95 | if test -n "$GCC"; then | ||
96 | case $host_os in | ||
97 | linux*) haveit=yes;; | ||
98 | esac | ||
99 | fi | ||
100 | fi | ||
101 | if test -z "$haveit"; then | ||
102 | if test -d "$additional_libdir"; then | ||
103 | dnl Really add $additional_libdir to $LDFLAGS. | ||
104 | LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" | ||
105 | fi | ||
106 | fi | ||
107 | fi | ||
108 | fi | ||
109 | fi | ||
110 | ]) | ||
111 | |||
112 | dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, | ||
113 | dnl acl_final_exec_prefix, containing the values to which $prefix and | ||
114 | dnl $exec_prefix will expand at the end of the configure script. | ||
115 | AC_DEFUN([AC_LIB_PREPARE_PREFIX], | ||
116 | [ | ||
117 | dnl Unfortunately, prefix and exec_prefix get only finally determined | ||
118 | dnl at the end of configure. | ||
119 | if test "X$prefix" = "XNONE"; then | ||
120 | acl_final_prefix="$ac_default_prefix" | ||
121 | else | ||
122 | acl_final_prefix="$prefix" | ||
123 | fi | ||
124 | if test "X$exec_prefix" = "XNONE"; then | ||
125 | acl_final_exec_prefix='${prefix}' | ||
126 | else | ||
127 | acl_final_exec_prefix="$exec_prefix" | ||
128 | fi | ||
129 | acl_save_prefix="$prefix" | ||
130 | prefix="$acl_final_prefix" | ||
131 | eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" | ||
132 | prefix="$acl_save_prefix" | ||
133 | ]) | ||
134 | |||
135 | dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the | ||
136 | dnl variables prefix and exec_prefix bound to the values they will have | ||
137 | dnl at the end of the configure script. | ||
138 | AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], | ||
139 | [ | ||
140 | acl_save_prefix="$prefix" | ||
141 | prefix="$acl_final_prefix" | ||
142 | acl_save_exec_prefix="$exec_prefix" | ||
143 | exec_prefix="$acl_final_exec_prefix" | ||
144 | $1 | ||
145 | exec_prefix="$acl_save_exec_prefix" | ||
146 | prefix="$acl_save_prefix" | ||
147 | ]) | ||
148 | |||
149 | dnl AC_LIB_PREPARE_MULTILIB creates | ||
150 | dnl - a function acl_is_expected_elfclass, that tests whether standard input | ||
151 | dn; has a 32-bit or 64-bit ELF header, depending on the host CPU ABI, | ||
152 | dnl - 3 variables acl_libdirstem, acl_libdirstem2, acl_libdirstem3, containing | ||
153 | dnl the basename of the libdir to try in turn, either "lib" or "lib64" or | ||
154 | dnl "lib/64" or "lib32" or "lib/sparcv9" or "lib/amd64" or similar. | ||
155 | AC_DEFUN([AC_LIB_PREPARE_MULTILIB], | ||
156 | [ | ||
157 | dnl There is no formal standard regarding lib, lib32, and lib64. | ||
158 | dnl On most glibc systems, the current practice is that on a system supporting | ||
159 | dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under | ||
160 | dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. However, on | ||
161 | dnl Arch Linux based distributions, it's the opposite: 32-bit libraries go | ||
162 | dnl under $prefix/lib32 and 64-bit libraries go under $prefix/lib. | ||
163 | dnl We determine the compiler's default mode by looking at the compiler's | ||
164 | dnl library search path. If at least one of its elements ends in /lib64 or | ||
165 | dnl points to a directory whose absolute pathname ends in /lib64, we use that | ||
166 | dnl for 64-bit ABIs. Similarly for 32-bit ABIs. Otherwise we use the default, | ||
167 | dnl namely "lib". | ||
168 | dnl On Solaris systems, the current practice is that on a system supporting | ||
169 | dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under | ||
170 | dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or | ||
171 | dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. | ||
172 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
173 | AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT]) | ||
174 | |||
175 | AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf], | ||
176 | [AC_EGREP_CPP([Extensible Linking Format], | ||
177 | [#if defined __ELF__ || (defined __linux__ && defined __EDG__) | ||
178 | Extensible Linking Format | ||
179 | #endif | ||
180 | ], | ||
181 | [gl_cv_elf=yes], | ||
182 | [gl_cv_elf=no]) | ||
183 | ]) | ||
184 | if test $gl_cv_elf = yes; then | ||
185 | # Extract the ELF class of a file (5th byte) in decimal. | ||
186 | # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header | ||
187 | if od -A x < /dev/null >/dev/null 2>/dev/null; then | ||
188 | # Use POSIX od. | ||
189 | func_elfclass () | ||
190 | { | ||
191 | od -A n -t d1 -j 4 -N 1 | ||
192 | } | ||
193 | else | ||
194 | # Use BSD hexdump. | ||
195 | func_elfclass () | ||
196 | { | ||
197 | dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "' | ||
198 | echo | ||
199 | } | ||
200 | fi | ||
201 | # Use 'expr', not 'test', to compare the values of func_elfclass, because on | ||
202 | # Solaris 11 OpenIndiana and Solaris 11 OmniOS, the result is 001 or 002, | ||
203 | # not 1 or 2. | ||
204 | changequote(,)dnl | ||
205 | case $HOST_CPU_C_ABI_32BIT in | ||
206 | yes) | ||
207 | # 32-bit ABI. | ||
208 | acl_is_expected_elfclass () | ||
209 | { | ||
210 | expr "`func_elfclass | sed -e 's/[ ]//g'`" = 1 > /dev/null | ||
211 | } | ||
212 | ;; | ||
213 | no) | ||
214 | # 64-bit ABI. | ||
215 | acl_is_expected_elfclass () | ||
216 | { | ||
217 | expr "`func_elfclass | sed -e 's/[ ]//g'`" = 2 > /dev/null | ||
218 | } | ||
219 | ;; | ||
220 | *) | ||
221 | # Unknown. | ||
222 | acl_is_expected_elfclass () | ||
223 | { | ||
224 | : | ||
225 | } | ||
226 | ;; | ||
227 | esac | ||
228 | changequote([,])dnl | ||
229 | else | ||
230 | acl_is_expected_elfclass () | ||
231 | { | ||
232 | : | ||
233 | } | ||
234 | fi | ||
235 | |||
236 | dnl Allow the user to override the result by setting acl_cv_libdirstems. | ||
237 | AC_CACHE_CHECK([for the common suffixes of directories in the library search path], | ||
238 | [acl_cv_libdirstems], | ||
239 | [dnl Try 'lib' first, because that's the default for libdir in GNU, see | ||
240 | dnl <https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>. | ||
241 | acl_libdirstem=lib | ||
242 | acl_libdirstem2= | ||
243 | acl_libdirstem3= | ||
244 | case "$host_os" in | ||
245 | solaris*) | ||
246 | dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment | ||
247 | dnl <https://docs.oracle.com/cd/E19253-01/816-5138/dev-env/index.html>. | ||
248 | dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." | ||
249 | dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the | ||
250 | dnl symlink is missing, so we set acl_libdirstem2 too. | ||
251 | if test $HOST_CPU_C_ABI_32BIT = no; then | ||
252 | acl_libdirstem2=lib/64 | ||
253 | case "$host_cpu" in | ||
254 | sparc*) acl_libdirstem3=lib/sparcv9 ;; | ||
255 | i*86 | x86_64) acl_libdirstem3=lib/amd64 ;; | ||
256 | esac | ||
257 | fi | ||
258 | ;; | ||
259 | *) | ||
260 | dnl If $CC generates code for a 32-bit ABI, the libraries are | ||
261 | dnl surely under $prefix/lib or $prefix/lib32, not $prefix/lib64. | ||
262 | dnl Similarly, if $CC generates code for a 64-bit ABI, the libraries | ||
263 | dnl are surely under $prefix/lib or $prefix/lib64, not $prefix/lib32. | ||
264 | dnl Find the compiler's search path. However, non-system compilers | ||
265 | dnl sometimes have odd library search paths. But we can't simply invoke | ||
266 | dnl '/usr/bin/gcc -print-search-dirs' because that would not take into | ||
267 | dnl account the -m32/-m31 or -m64 options from the $CC or $CFLAGS. | ||
268 | searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \ | ||
269 | | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` | ||
270 | if test $HOST_CPU_C_ABI_32BIT != no; then | ||
271 | # 32-bit or unknown ABI. | ||
272 | if test -d /usr/lib32; then | ||
273 | acl_libdirstem2=lib32 | ||
274 | fi | ||
275 | fi | ||
276 | if test $HOST_CPU_C_ABI_32BIT != yes; then | ||
277 | # 64-bit or unknown ABI. | ||
278 | if test -d /usr/lib64; then | ||
279 | acl_libdirstem3=lib64 | ||
280 | fi | ||
281 | fi | ||
282 | if test -n "$searchpath"; then | ||
283 | acl_save_IFS="${IFS= }"; IFS=":" | ||
284 | for searchdir in $searchpath; do | ||
285 | if test -d "$searchdir"; then | ||
286 | case "$searchdir" in | ||
287 | */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;; | ||
288 | */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;; | ||
289 | */../ | */.. ) | ||
290 | # Better ignore directories of this form. They are misleading. | ||
291 | ;; | ||
292 | *) searchdir=`cd "$searchdir" && pwd` | ||
293 | case "$searchdir" in | ||
294 | */lib32 ) acl_libdirstem2=lib32 ;; | ||
295 | */lib64 ) acl_libdirstem3=lib64 ;; | ||
296 | esac ;; | ||
297 | esac | ||
298 | fi | ||
299 | done | ||
300 | IFS="$acl_save_IFS" | ||
301 | if test $HOST_CPU_C_ABI_32BIT = yes; then | ||
302 | # 32-bit ABI. | ||
303 | acl_libdirstem3= | ||
304 | fi | ||
305 | if test $HOST_CPU_C_ABI_32BIT = no; then | ||
306 | # 64-bit ABI. | ||
307 | acl_libdirstem2= | ||
308 | fi | ||
309 | fi | ||
310 | ;; | ||
311 | esac | ||
312 | test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" | ||
313 | test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem" | ||
314 | acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3" | ||
315 | ]) | ||
316 | dnl Decompose acl_cv_libdirstems into acl_libdirstem, acl_libdirstem2, and | ||
317 | dnl acl_libdirstem3. | ||
318 | changequote(,)dnl | ||
319 | acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'` | ||
320 | acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'` | ||
321 | acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'` | ||
322 | changequote([,])dnl | ||
323 | ]) | ||