🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.5 KiB

  1. #!/bin/sh
  2. #
  3. # Build Universal binaries on Mac OS X, thanks Ryan!
  4. #
  5. # Usage: ./configure CXX="sh clang++-fat.sh" && make && rm -rf arm64 x64
  6. DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
  7. # Intel 64-bit compiler flags (10.7 runtime compatibility)
  8. CLANG_COMPILE_X64="clang++ -arch x86_64 -mmacosx-version-min=10.7 \
  9. -I/usr/local/include"
  10. CLANG_LINK_X64="-mmacosx-version-min=10.7"
  11. # ARM 64-bit compiler flags (11.0 runtime compatibility)
  12. CLANG_COMPILE_ARM64="clang++ -arch arm64 -mmacosx-version-min=11.0 \
  13. -I/usr/local/include"
  14. CLANG_LINK_ARM64="-mmacosx-version-min=11.0"
  15. # Output both Intel and ARM object files
  16. args="$*"
  17. compile=yes
  18. link=yes
  19. while test x$1 != x; do
  20. case $1 in
  21. --version) exec clang++ $1;;
  22. -v) exec clang++ $1;;
  23. -V) exec clang++ $1;;
  24. -print-prog-name=*) exec clang++ $1;;
  25. -print-search-dirs) exec clang++ $1;;
  26. -E) CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 -E"
  27. CLANG_COMPILE_X64="$CLANG_COMPILE_X64 -E"
  28. compile=no; link=no;;
  29. -c) link=no;;
  30. -o) output=$2;;
  31. *.c|*.cc|*.cpp|*.S|*.m|*.mm) source=$1;;
  32. esac
  33. shift
  34. done
  35. if test x$link = xyes; then
  36. CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 $CLANG_LINK_ARM64"
  37. CLANG_COMPILE_X64="$CLANG_COMPILE_X64 $CLANG_LINK_X64"
  38. fi
  39. if test x"$output" = x; then
  40. if test x$link = xyes; then
  41. output=a.out
  42. elif test x$compile = xyes; then
  43. output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
  44. fi
  45. fi
  46. # Compile ARM 64-bit
  47. if test x"$output" != x; then
  48. dir=arm64/`dirname $output`
  49. if test -d $dir; then
  50. :
  51. else
  52. mkdir -p $dir
  53. fi
  54. fi
  55. set -- $args
  56. while test x$1 != x; do
  57. if test -f "arm64/$1" && test "$1" != "$output"; then
  58. arm64_args="$arm64_args arm64/$1"
  59. else
  60. arm64_args="$arm64_args $1"
  61. fi
  62. shift
  63. done
  64. $CLANG_COMPILE_ARM64 $arm64_args || exit $?
  65. if test x"$output" != x; then
  66. cp $output arm64/$output
  67. fi
  68. # Compile Intel 64-bit
  69. if test x"$output" != x; then
  70. dir=x64/`dirname $output`
  71. if test -d $dir; then
  72. :
  73. else
  74. mkdir -p $dir
  75. fi
  76. fi
  77. set -- $args
  78. while test x$1 != x; do
  79. if test -f "x64/$1" && test "$1" != "$output"; then
  80. x64_args="$x64_args x64/$1"
  81. else
  82. x64_args="$x64_args $1"
  83. fi
  84. shift
  85. done
  86. $CLANG_COMPILE_X64 $x64_args || exit $?
  87. if test x"$output" != x; then
  88. cp $output x64/$output
  89. fi
  90. if test x"$output" != x; then
  91. lipo -create -o $output arm64/$output x64/$output
  92. fi