Blame m4/multiarch.m4

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