aboutsummaryrefslogtreecommitdiff
path: root/m4/lib-prefix.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/lib-prefix.m4')
-rw-r--r--m4/lib-prefix.m4238
1 files changed, 167 insertions, 71 deletions
diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4
index 6851031..c8a0b46 100644
--- a/m4/lib-prefix.m4
+++ b/m4/lib-prefix.m4
@@ -1,18 +1,11 @@
1# lib-prefix.m4 serial 7 (gettext-0.18) 1# lib-prefix.m4 serial 17
2dnl Copyright (C) 2001-2005, 2008-2016 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2005, 2008-2020 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8 8
9dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
10dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
11dnl require excessive bracketing.
12ifdef([AC_HELP_STRING],
13[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
14[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
15
16dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed 9dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
17dnl to access previously installed libraries. The basic assumption is that 10dnl to access previously installed libraries. The basic assumption is that
18dnl a user will want packages to use other packages he previously installed 11dnl a user will want packages to use other packages he previously installed
@@ -32,9 +25,9 @@ AC_DEFUN([AC_LIB_PREFIX],
32 eval additional_includedir=\"$includedir\" 25 eval additional_includedir=\"$includedir\"
33 eval additional_libdir=\"$libdir\" 26 eval additional_libdir=\"$libdir\"
34 ]) 27 ])
35 AC_LIB_ARG_WITH([lib-prefix], 28 AC_ARG_WITH([lib-prefix],
36[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib 29[[ --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], 30 --without-lib-prefix don't search for libraries in includedir and libdir]],
38[ 31[
39 if test "X$withval" = "Xno"; then 32 if test "X$withval" = "Xno"; then
40 use_additional=no 33 use_additional=no
@@ -154,71 +147,174 @@ AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
154]) 147])
155 148
156dnl AC_LIB_PREPARE_MULTILIB creates 149dnl AC_LIB_PREPARE_MULTILIB creates
157dnl - a variable acl_libdirstem, containing the basename of the libdir, either 150dnl - a function acl_is_expected_elfclass, that tests whether standard input
158dnl "lib" or "lib64" or "lib/64", 151dn; has a 32-bit or 64-bit ELF header, depending on the host CPU ABI,
159dnl - a variable acl_libdirstem2, as a secondary possible value for 152dnl - 3 variables acl_libdirstem, acl_libdirstem2, acl_libdirstem3, containing
160dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or 153dnl the basename of the libdir to try in turn, either "lib" or "lib64" or
161dnl "lib/amd64". 154dnl "lib/64" or "lib32" or "lib/sparcv9" or "lib/amd64" or similar.
162AC_DEFUN([AC_LIB_PREPARE_MULTILIB], 155AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
163[ 156[
164 dnl There is no formal standard regarding lib and lib64. 157 dnl There is no formal standard regarding lib, lib32, and lib64.
165 dnl On glibc systems, the current practice is that on a system supporting 158 dnl On most glibc systems, the current practice is that on a system supporting
166 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under 159 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
167 dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine 160 dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. However, on
168 dnl the compiler's default mode by looking at the compiler's library search 161 dnl Arch Linux based distributions, it's the opposite: 32-bit libraries go
169 dnl path. If at least one of its elements ends in /lib64 or points to a 162 dnl under $prefix/lib32 and 64-bit libraries go under $prefix/lib.
170 dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. 163 dnl We determine the compiler's default mode by looking at the compiler's
171 dnl Otherwise we use the default, namely "lib". 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".
172 dnl On Solaris systems, the current practice is that on a system supporting 168 dnl On Solaris systems, the current practice is that on a system supporting
173 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under 169 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
174 dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or 170 dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
175 dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. 171 dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
176 AC_REQUIRE([AC_CANONICAL_HOST]) 172 AC_REQUIRE([AC_CANONICAL_HOST])
177 acl_libdirstem=lib 173 AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT])
178 acl_libdirstem2= 174
179 case "$host_os" in 175 AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf],
180 solaris*) 176 [AC_EGREP_CPP([Extensible Linking Format],
181 dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment 177 [#ifdef __ELF__
182 dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>. 178 Extensible Linking Format
183 dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." 179 #endif
184 dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the 180 ],
185 dnl symlink is missing, so we set acl_libdirstem2 too. 181 [gl_cv_elf=yes],
186 AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], 182 [gl_cv_elf=no])
187 [AC_EGREP_CPP([sixtyfour bits], [ 183 ])
188#ifdef _LP64 184 if test $gl_cv_elf; then
189sixtyfour bits 185 # Extract the ELF class of a file (5th byte) in decimal.
190#endif 186 # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
191 ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) 187 if od -A x < /dev/null >/dev/null 2>/dev/null; then
192 ]) 188 # Use POSIX od.
193 if test $gl_cv_solaris_64bit = yes; then 189 func_elfclass ()
194 acl_libdirstem=lib/64 190 {
195 case "$host_cpu" in 191 od -A n -t d1 -j 4 -N 1
196 sparc*) acl_libdirstem2=lib/sparcv9 ;; 192 }
197 i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; 193 else
198 esac 194 # Use BSD hexdump.
199 fi 195 func_elfclass ()
200 ;; 196 {
201 *) 197 dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "'
202 searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` 198 echo
203 if test -n "$searchpath"; then 199 }
204 acl_save_IFS="${IFS= }"; IFS=":" 200 fi
205 for searchdir in $searchpath; do 201changequote(,)dnl
206 if test -d "$searchdir"; then 202 case $HOST_CPU_C_ABI_32BIT in
207 case "$searchdir" in 203 yes)
208 */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; 204 # 32-bit ABI.
209 */../ | */.. ) 205 acl_is_expected_elfclass ()
210 # Better ignore directories of this form. They are misleading. 206 {
211 ;; 207 test "`func_elfclass | sed -e 's/[ ]//g'`" = 1
212 *) searchdir=`cd "$searchdir" && pwd` 208 }
213 case "$searchdir" in 209 ;;
214 */lib64 ) acl_libdirstem=lib64 ;; 210 no)
215 esac ;; 211 # 64-bit ABI.
216 esac 212 acl_is_expected_elfclass ()
217 fi 213 {
218 done 214 test "`func_elfclass | sed -e 's/[ ]//g'`" = 2
219 IFS="$acl_save_IFS" 215 }
220 fi 216 ;;
221 ;; 217 *)
222 esac 218 # Unknown.
223 test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" 219 acl_is_expected_elfclass ()
220 {
221 :
222 }
223 ;;
224 esac
225changequote([,])dnl
226 else
227 acl_is_expected_elfclass ()
228 {
229 :
230 }
231 fi
232
233 dnl Allow the user to override the result by setting acl_cv_libdirstems.
234 AC_CACHE_CHECK([for the common suffixes of directories in the library search path],
235 [acl_cv_libdirstems],
236 [dnl Try 'lib' first, because that's the default for libdir in GNU, see
237 dnl <https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>.
238 acl_libdirstem=lib
239 acl_libdirstem2=
240 acl_libdirstem3=
241 case "$host_os" in
242 solaris*)
243 dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
244 dnl <https://docs.oracle.com/cd/E19253-01/816-5138/dev-env/index.html>.
245 dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
246 dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
247 dnl symlink is missing, so we set acl_libdirstem2 too.
248 if test $HOST_CPU_C_ABI_32BIT = no; then
249 acl_libdirstem2=lib/64
250 case "$host_cpu" in
251 sparc*) acl_libdirstem3=lib/sparcv9 ;;
252 i*86 | x86_64) acl_libdirstem3=lib/amd64 ;;
253 esac
254 fi
255 ;;
256 *)
257 dnl If $CC generates code for a 32-bit ABI, the libraries are
258 dnl surely under $prefix/lib or $prefix/lib32, not $prefix/lib64.
259 dnl Similarly, if $CC generates code for a 64-bit ABI, the libraries
260 dnl are surely under $prefix/lib or $prefix/lib64, not $prefix/lib32.
261 dnl Find the compiler's search path. However, non-system compilers
262 dnl sometimes have odd library search paths. But we can't simply invoke
263 dnl '/usr/bin/gcc -print-search-dirs' because that would not take into
264 dnl account the -m32/-m31 or -m64 options from the $CC or $CFLAGS.
265 searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \
266 | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
267 if test $HOST_CPU_C_ABI_32BIT != no; then
268 # 32-bit or unknown ABI.
269 if test -d /usr/lib32; then
270 acl_libdirstem2=lib32
271 fi
272 fi
273 if test $HOST_CPU_C_ABI_32BIT != yes; then
274 # 64-bit or unknown ABI.
275 if test -d /usr/lib64; then
276 acl_libdirstem3=lib64
277 fi
278 fi
279 if test -n "$searchpath"; then
280 acl_save_IFS="${IFS= }"; IFS=":"
281 for searchdir in $searchpath; do
282 if test -d "$searchdir"; then
283 case "$searchdir" in
284 */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;;
285 */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;;
286 */../ | */.. )
287 # Better ignore directories of this form. They are misleading.
288 ;;
289 *) searchdir=`cd "$searchdir" && pwd`
290 case "$searchdir" in
291 */lib32 ) acl_libdirstem2=lib32 ;;
292 */lib64 ) acl_libdirstem3=lib64 ;;
293 esac ;;
294 esac
295 fi
296 done
297 IFS="$acl_save_IFS"
298 if test $HOST_CPU_C_ABI_32BIT = yes; then
299 # 32-bit ABI.
300 acl_libdirstem3=
301 fi
302 if test $HOST_CPU_C_ABI_32BIT = no; then
303 # 64-bit ABI.
304 acl_libdirstem2=
305 fi
306 fi
307 ;;
308 esac
309 test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
310 test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem"
311 acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3"
312 ])
313 dnl Decompose acl_cv_libdirstems into acl_libdirstem, acl_libdirstem2, and
314 dnl acl_libdirstem3.
315changequote(,)dnl
316 acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'`
317 acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'`
318 acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'`
319changequote([,])dnl
224]) 320])