🛠️🐜 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.

105 lines
2.5 KiB

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