Blame m4/multiarch.m4

Packit 8f70b4
# multiarch.m4 serial 7
Packit 8f70b4
dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
Packit 8f70b4
dnl This file is free software; the Free Software Foundation
Packit 8f70b4
dnl gives unlimited permission to copy and/or distribute it,
Packit 8f70b4
dnl with or without modifications, as long as this notice is preserved.
Packit 8f70b4
Packit 8f70b4
# Determine whether the compiler is or may be producing universal binaries.
Packit 8f70b4
#
Packit 8f70b4
# On Mac OS X 10.5 and later systems, the user can create libraries and
Packit 8f70b4
# executables that work on multiple system types--known as "fat" or
Packit 8f70b4
# "universal" binaries--by specifying multiple '-arch' options to the
Packit 8f70b4
# compiler but only a single '-arch' option to the preprocessor.  Like
Packit 8f70b4
# this:
Packit 8f70b4
#
Packit 8f70b4
#     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
Packit 8f70b4
#                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
Packit 8f70b4
#                 CPP="gcc -E" CXXCPP="g++ -E"
Packit 8f70b4
#
Packit 8f70b4
# Detect this situation and set APPLE_UNIVERSAL_BUILD accordingly.
Packit 8f70b4
Packit 8f70b4
AC_DEFUN_ONCE([gl_MULTIARCH],
Packit 8f70b4
[
Packit 8f70b4
  dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
Packit 8f70b4
  gl_cv_c_multiarch=no
Packit 8f70b4
  AC_COMPILE_IFELSE(
Packit 8f70b4
    [AC_LANG_SOURCE(
Packit 8f70b4
      [[#ifndef __APPLE_CC__
Packit 8f70b4
         not a universal capable compiler
Packit 8f70b4
        #endif
Packit 8f70b4
        typedef int dummy;
Packit 8f70b4
      ]])],
Packit 8f70b4
    [
Packit 8f70b4
     dnl Check for potential -arch flags.  It is not universal unless
Packit 8f70b4
     dnl there are at least two -arch flags with different values.
Packit 8f70b4
     arch=
Packit 8f70b4
     prev=
Packit 8f70b4
     for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
Packit 8f70b4
       if test -n "$prev"; then
Packit 8f70b4
         case $word in
Packit 8f70b4
           i?86 | x86_64 | ppc | ppc64)
Packit 8f70b4
             if test -z "$arch" || test "$arch" = "$word"; then
Packit 8f70b4
               arch="$word"
Packit 8f70b4
             else
Packit 8f70b4
               gl_cv_c_multiarch=yes
Packit 8f70b4
             fi
Packit 8f70b4
             ;;
Packit 8f70b4
         esac
Packit 8f70b4
         prev=
Packit 8f70b4
       else
Packit 8f70b4
         if test "x$word" = "x-arch"; then
Packit 8f70b4
           prev=arch
Packit 8f70b4
         fi
Packit 8f70b4
       fi
Packit 8f70b4
     done
Packit 8f70b4
    ])
Packit 8f70b4
  if test $gl_cv_c_multiarch = yes; then
Packit 8f70b4
    APPLE_UNIVERSAL_BUILD=1
Packit 8f70b4
  else
Packit 8f70b4
    APPLE_UNIVERSAL_BUILD=0
Packit 8f70b4
  fi
Packit 8f70b4
  AC_SUBST([APPLE_UNIVERSAL_BUILD])
Packit 8f70b4
])