4
0

multiarch.m4 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # multiarch.m4 serial 3
  2. dnl Copyright (C) 2008 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. # Determine whether the compiler is or may be producing universal binaries.
  7. #
  8. # On MacOS X 10.5 and later systems, the user can create libraries and
  9. # executables that work on multiple system types--known as "fat" or
  10. # "universal" binaries--by specifying multiple '-arch' options to the
  11. # compiler but only a single '-arch' option to the preprocessor. Like
  12. # this:
  13. #
  14. # ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
  15. # CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
  16. # CPP="gcc -E" CXXCPP="g++ -E"
  17. #
  18. # Detect this situation and set the macro AA_APPLE_UNIVERSAL_BUILD at the
  19. # beginning of config.h and set APPLE_UNIVERSAL_BUILD accordingly.
  20. AC_DEFUN([gl_MULTIARCH],
  21. [
  22. dnl This AC_REQUIRE is not necessary in theory. It works around a bug in
  23. dnl autoconf <= 2.63: AC_REQUIRE invocations inside AC_REQUIREd macros are
  24. dnl being handled better than AC_REQUIRE invocations inside normally invoked
  25. dnl macros.
  26. AC_REQUIRE([gl_MULTIARCH_BODY])
  27. ])
  28. AC_DEFUN([gl_MULTIARCH_BODY],
  29. [
  30. dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
  31. gl_cv_c_multiarch=no
  32. AC_COMPILE_IFELSE(
  33. [AC_LANG_SOURCE(
  34. [[#ifndef __APPLE_CC__
  35. not a universal capable compiler
  36. #endif
  37. typedef int dummy;
  38. ]])],
  39. [
  40. dnl Check for potential -arch flags. It is not universal unless
  41. dnl there are at least two -arch flags with different values.
  42. arch=
  43. prev=
  44. for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
  45. if test -n "$prev"; then
  46. case $word in
  47. i?86 | x86_64 | ppc | ppc64)
  48. if test -z "$arch" || test "$arch" = "$word"; then
  49. arch="$word"
  50. else
  51. gl_cv_c_multiarch=yes
  52. fi
  53. ;;
  54. esac
  55. prev=
  56. else
  57. if test "x$word" = "x-arch"; then
  58. prev=arch
  59. fi
  60. fi
  61. done
  62. ])
  63. if test $gl_cv_c_multiarch = yes; then
  64. AC_DEFINE([AA_APPLE_UNIVERSAL_BUILD], [1],
  65. [Define if the compiler is building for multiple architectures of Apple platforms at once.])
  66. APPLE_UNIVERSAL_BUILD=1
  67. else
  68. APPLE_UNIVERSAL_BUILD=0
  69. fi
  70. AC_SUBST([APPLE_UNIVERSAL_BUILD])
  71. ])