[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
support for universal binaries on MacOS X (1/6)
From: |
Bruno Haible |
Subject: |
support for universal binaries on MacOS X (1/6) |
Date: |
Thu, 25 Dec 2008 19:25:28 +0100 |
User-agent: |
KMail/1.9.9 |
Hi,
The way to build multi-architecture ("universal"/"fat") binaries on MacOS X
is now documented in the INSTALL file. Yet gnulib does not support it in a
couple of autoconf tests.
To find which autoconf tests are affected, I configured a testdir once for
a 32-bit build (CC="gcc -arch i386") and once for a 64-bit build
(CC="gcc -arch x86_64") and looked at the differences in
- config.status
- config.h
- other generated .h files.
The following modules are affected:
- stdint
- inttypes
- *printf
- mktime
- nanosleep.
I'm committing this patch; it provides the macro to check for a multi-arch
build.
2008-12-25 Bruno Haible <address@hidden>
New module 'multiarch'.
* modules/multiarch: New file.
* m4/multiarch.m4: New file.
================================ modules/multiarch ============================
Description:
Detection of multi-architecture ("universal binary") builds.
Files:
m4/multiarch.m4
Depends-on:
configure.ac:
gl_MULTIARCH
Makefile.am:
Include:
License:
unlimited
Maintainer:
Bruno Haible, autoconf
================================== m4/multiarch.m4 ============================
# multiarch.m4 serial 1
dnl Copyright (C) 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
# Determine whether the compiler is or may be producing universal binaries.
#
# On MacOS X 10.5 and later systems, the user can create libraries and
# executables that work on multiple system types--known as "fat" or
# "universal" binaries--by specifying multiple '-arch' options to the
# compiler but only a single '-arch' option to the preprocessor. Like
# this:
#
# ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
# CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
# CPP="gcc -E" CXXCPP="g++ -E"
#
# Detect this situation and set the macro AA_APPLE_UNIVERSAL_BUILD at the
# beginning of config.h and set APPLE_UNIVERSAL_BUILD accordingly.
AC_DEFUN([gl_MULTIARCH],
[
dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
gl_cv_c_multiarch=no
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE(
[[#ifndef __APPLE_CC__
not a universal capable compiler
#endif
typedef int dummy;
]])],
[
dnl Check for potential -arch flags. It is not universal unless
dnl there are at least two -arch flags with different values.
arch=
prev=
for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
if test -n "$prev"; then
case $word in
i386 | x86_64 | ppc | ppc64)
if test -z "$arch" || test "$arch" = "$word"; then
arch="$word"
else
gl_cv_c_multiarch=yes
fi
;;
esac
prev=
else
if test "x$word" = "x-arch"; then
prev=arch
fi
fi
done
])
if test $gl_cv_c_multiarch = yes; then
AC_DEFINE([AA_APPLE_UNIVERSAL_BUILD], [1],
[Define if the compiler is building for multiple architectures of Apple
platforms at once.])
APPLE_UNIVERSAL_BUILD=1
else
APPLE_UNIVERSAL_BUILD=0
fi
AC_SUBST([APPLE_UNIVERSAL_BUILD])
])
- support for universal binaries on MacOS X (1/6),
Bruno Haible <=