2
0

MacOSX-Framework 5.1 KB

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