Blame gnulib/m4/multiarch.m4

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