Debian Codegraph @

m4/multiarch.m4

raw
1 # multiarch.m4
2 # serial 9
3 dnl Copyright (C) 2008-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 # Determine whether the compiler is or may be producing universal binaries.
10 #
11 # On Mac OS X 10.5 and later systems, the user can create libraries and
12 # executables that work on multiple system types--known as "fat" or
13 # "universal" binaries--by specifying multiple '-arch' options to the
14 # compiler but only a single '-arch' option to the preprocessor. Like
15 # this:
16 #
17 # ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
18 # CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
19 # CPP="gcc -E" CXXCPP="g++ -E"
20 #
21 # Detect this situation and set APPLE_UNIVERSAL_BUILD accordingly.
22
23 AC_DEFUN_ONCE([gl_MULTIARCH],
24 [
25 dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
26 AC_CACHE_CHECK([whether the compiler produces multi-arch binaries],
27 [gl_cv_c_multiarch],
28 [gl_cv_c_multiarch=no
29 AC_COMPILE_IFELSE(
30 [AC_LANG_SOURCE(
31 [[#ifndef __APPLE_CC__
32 not a universal capable compiler
33 #endif
34 typedef int dummy;
35 ]])],
36 [
37 dnl Check for potential -arch flags. It is not universal unless
38 dnl there are at least two -arch flags with different values.
39 arch=
40 prev=
41 for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
42 if test -n "$prev"; then
43 case $word in
44 i?86 | x86_64 | ppc | ppc64 | arm | arm64)
45 if test -z "$arch" || test "$arch" = "$word"; then
46 arch="$word"
47 else
48 gl_cv_c_multiarch=yes
49 fi
50 ;;
51 esac
52 prev=
53 else
54 if test "x$word" = "x-arch"; then
55 prev=arch
56 fi
57 fi
58 done
59 ])
60 ])
61 if test $gl_cv_c_multiarch = yes; then
62 APPLE_UNIVERSAL_BUILD=1
63 else
64 APPLE_UNIVERSAL_BUILD=0
65 fi
66 AC_SUBST([APPLE_UNIVERSAL_BUILD])
67 ])