Blame gettext-runtime/gnulib-m4/multiarch.m4

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