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