multiarch.m4 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # multiarch.m4 serial 7
  2. dnl Copyright (C) 2008-2013 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 Mac OS 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 APPLE_UNIVERSAL_BUILD accordingly.
  19. AC_DEFUN_ONCE([gl_MULTIARCH],
  20. [
  21. dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
  22. gl_cv_c_multiarch=no
  23. AC_COMPILE_IFELSE(
  24. [AC_LANG_SOURCE(
  25. [[#ifndef __APPLE_CC__
  26. not a universal capable compiler
  27. #endif
  28. typedef int dummy;
  29. ]])],
  30. [
  31. dnl Check for potential -arch flags. It is not universal unless
  32. dnl there are at least two -arch flags with different values.
  33. arch=
  34. prev=
  35. for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
  36. if test -n "$prev"; then
  37. case $word in
  38. i?86 | x86_64 | ppc | ppc64)
  39. if test -z "$arch" || test "$arch" = "$word"; then
  40. arch="$word"
  41. else
  42. gl_cv_c_multiarch=yes
  43. fi
  44. ;;
  45. esac
  46. prev=
  47. else
  48. if test "x$word" = "x-arch"; then
  49. prev=arch
  50. fi
  51. fi
  52. done
  53. ])
  54. if test $gl_cv_c_multiarch = yes; then
  55. APPLE_UNIVERSAL_BUILD=1
  56. else
  57. APPLE_UNIVERSAL_BUILD=0
  58. fi
  59. AC_SUBST([APPLE_UNIVERSAL_BUILD])
  60. ])