MacOSX-Framework 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #!/usr/bin/env bash
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
  10. #
  11. # This software is licensed as described in the file COPYING, which
  12. # you should have received as part of this distribution. The terms
  13. # are also available at https://curl.se/docs/copyright.html.
  14. #
  15. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  16. # copies of the Software, and permit persons to whom the Software is
  17. # furnished to do so, under the terms of the COPYING file.
  18. #
  19. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  20. # KIND, either express or implied.
  21. #
  22. ###########################################################################
  23. # This script performs all of the steps needed to build a
  24. # universal binary libcurl.framework for Mac OS X 10.4 or greater.
  25. #
  26. # Hendrik Visage:
  27. # Generalizations added since Snowleopard (10.6) do not include
  28. # the 10.4u SDK.
  29. #
  30. # Also note:
  31. # 10.5 is the *ONLY* SDK that support PPC64 :( -- 10.6 do not have ppc64 support
  32. #If you need to have PPC64 support then change below to 1
  33. PPC64_NEEDED=0
  34. # Apple does not support building for PPC anymore in Xcode 4 and later.
  35. # If you're using Xcode 3 or earlier and need PPC support, then change
  36. # the setting below to 1
  37. PPC_NEEDED=0
  38. # For me the default is to develop for the platform I am on, and if you
  39. #desire compatibility with older versions then change USE_OLD to 1 :)
  40. USE_OLD=0
  41. VERSION=`/usr/bin/sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' include/curl/curlver.h`
  42. FRAMEWORK_VERSION=Versions/Release-$VERSION
  43. #I also wanted to "copy over" the system, and thus the reason I added the
  44. # version to Versions/Release-7.20.1 etc.
  45. # now a simple rsync -vaP libcurl.framework /Library/Frameworks will install it
  46. # and setup the right paths to this version, leaving the system version
  47. # "intact", so you can "fix" it later with the links to Versions/A/...
  48. DEVELOPER_PATH=`xcode-select --print-path`
  49. # Around Xcode 4.3, SDKs were moved from the Developer folder into the
  50. # MacOSX.platform folder
  51. if test -d "$DEVELOPER_PATH/Platforms/MacOSX.platform/Developer/SDKs"; then
  52. SDK_PATH="$DEVELOPER_PATH/Platforms/MacOSX.platform/Developer/SDKs"
  53. else
  54. SDK_PATH="$DEVELOPER_PATH/SDKs";
  55. fi
  56. OLD_SDK=`ls $SDK_PATH|head -1`
  57. NEW_SDK=`ls -r $SDK_PATH|head -1`
  58. if test "0"$USE_OLD -gt 0
  59. then
  60. SDK32=$OLD_SDK
  61. else
  62. SDK32=$NEW_SDK
  63. fi
  64. MACVER=`echo $SDK32|sed -e s/[a-zA-Z]//g -e s/.\$//`
  65. SDK32_DIR=$SDK_PATH/$SDK32
  66. MINVER32='-mmacosx-version-min='$MACVER
  67. if test $PPC_NEEDED -gt 0; then
  68. ARCHES32='-arch i386 -arch ppc'
  69. else
  70. ARCHES32='-arch i386'
  71. fi
  72. if test $PPC64_NEEDED -gt 0
  73. then
  74. SDK64=10.5
  75. ARCHES64='-arch x86_64 -arch ppc64'
  76. SDK64=`ls $SDK_PATH|grep 10.5|head -1`
  77. else
  78. ARCHES64='-arch x86_64'
  79. #We "know" that 10.4 and earlier do not support 64bit
  80. OLD_SDK64=`ls $SDK_PATH|egrep -v "10.[0-4]"|head -1`
  81. NEW_SDK64=`ls -r $SDK_PATH|egrep -v "10.[0-4][^0-9]" | head -1`
  82. if test $USE_OLD -gt 0
  83. then
  84. SDK64=$OLD_SDK64
  85. else
  86. SDK64=$NEW_SDK64
  87. fi
  88. fi
  89. SDK64_DIR=$SDK_PATH/$SDK64
  90. MACVER64=`echo $SDK64|sed -e s/[a-zA-Z]//g -e s/.\$//`
  91. MINVER64='-mmacosx-version-min='$MACVER64
  92. if test ! -z $SDK32; then
  93. echo "----Configuring libcurl for 32 bit universal framework..."
  94. make clean
  95. ./configure --disable-dependency-tracking --disable-static --with-gssapi --with-secure-transport \
  96. CFLAGS="-Os -isysroot $SDK32_DIR $ARCHES32" \
  97. LDFLAGS="-Wl,-syslibroot,$SDK32_DIR $ARCHES32 -Wl,-headerpad_max_install_names" \
  98. CC=$CC
  99. echo "----Building 32 bit libcurl..."
  100. make -j `sysctl -n hw.logicalcpu_max`
  101. echo "----Creating 32 bit framework..."
  102. rm -r libcurl.framework
  103. mkdir -p libcurl.framework/${FRAMEWORK_VERSION}/Resources
  104. cp lib/.libs/libcurl.dylib libcurl.framework/${FRAMEWORK_VERSION}/libcurl
  105. install_name_tool -id @rpath/libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl
  106. /usr/bin/sed -e "s/7\.12\.3/$VERSION/" lib/libcurl.plist >libcurl.framework/${FRAMEWORK_VERSION}/Resources/Info.plist
  107. mkdir -p libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl
  108. cp include/curl/*.h libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl
  109. pushd libcurl.framework
  110. ln -fs ${FRAMEWORK_VERSION}/libcurl libcurl
  111. ln -fs ${FRAMEWORK_VERSION}/Resources Resources
  112. ln -fs ${FRAMEWORK_VERSION}/Headers Headers
  113. cd Versions
  114. ln -fs $(basename "${FRAMEWORK_VERSION}") Current
  115. echo Testing for SDK64
  116. if test -d $SDK64_DIR; then
  117. echo entering...
  118. popd
  119. make clean
  120. echo "----Configuring libcurl for 64 bit universal framework..."
  121. ./configure --disable-dependency-tracking --disable-static --with-gssapi --with-secure-transport \
  122. CFLAGS="-Os -isysroot $SDK64_DIR $ARCHES64" \
  123. LDFLAGS="-Wl,-syslibroot,$SDK64_DIR $ARCHES64 -Wl,-headerpad_max_install_names" \
  124. CC=$CC
  125. echo "----Building 64 bit libcurl..."
  126. make -j `sysctl -n hw.logicalcpu_max`
  127. echo "----Appending 64 bit framework to 32 bit framework..."
  128. cp lib/.libs/libcurl.dylib libcurl.framework/${FRAMEWORK_VERSION}/libcurl64
  129. install_name_tool -id @rpath/libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl64
  130. cp libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl32
  131. pwd
  132. lipo libcurl.framework/${FRAMEWORK_VERSION}/libcurl32 libcurl.framework/${FRAMEWORK_VERSION}/libcurl64 -create -output libcurl.framework/${FRAMEWORK_VERSION}/libcurl
  133. rm libcurl.framework/${FRAMEWORK_VERSION}/libcurl32 libcurl.framework/${FRAMEWORK_VERSION}/libcurl64
  134. fi
  135. pwd
  136. lipo -info libcurl.framework/${FRAMEWORK_VERSION}/libcurl
  137. echo "libcurl.framework is built and can now be included in other projects."
  138. echo "Copy libcurl.framework to your bundle's Contents/Frameworks folder, ~/Library/Frameworks or /Library/Frameworks."
  139. else
  140. echo "Building libcurl.framework requires Mac OS X 10.4 or later with the MacOSX10.4/5/6 SDK installed."
  141. fi