MacOSX-Framework 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. # For me the default is to develop for the platform I am on, and if you
  14. #desire compatibility with older versions then change USE_OLD to 1 :)
  15. USE_OLD=0
  16. VERSION=`/usr/bin/sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' include/curl/curlver.h`
  17. FRAMEWORK_VERSION=Versions/Release-$VERSION
  18. #I also wanted to "copy over" the system, and thus the reason I added the
  19. # version to Versions/Release-7.20.1 etc.
  20. # now a simple rsync -vaP libcurl.framework /Library/Frameworks will install it
  21. # and setup the right paths to this version, leaving the system version
  22. # "intact", so you can "fix" it later with the links to Versions/A/...
  23. OLD_SDK=`ls /Developer/SDKs|head -1`
  24. NEW_SDK=`ls -r /Developer/SDKs|head -1`
  25. if test "0"$USE_OLD -gt 0
  26. then
  27. SDK32=$OLD_SDK
  28. else
  29. SDK32=$NEW_SDK
  30. fi
  31. MACVER=`echo $SDK32|sed -e s/[a-zA-Z]//g -e s/.\$//`
  32. SDK32_DIR='/Developer/SDKs/'$SDK32
  33. MINVER32='-mmacosx-version-min='$MACVER
  34. ARCHES32='-arch i386 -arch ppc'
  35. if test $PPC64_NEEDED -gt 0
  36. then
  37. SDK64=10.5
  38. ARCHES64='-arch x86_64 -arch ppc64'
  39. SDK64=`ls /Developer/SDKs|grep 10.5|head -1`
  40. else
  41. ARCHES64='-arch x86_64'
  42. #We "know" that 10.4 and earlier do not support 64bit
  43. OLD_SDK64=`ls /Developer/SDKs|egrep -v "10.[0-4]"|head -1`
  44. NEW_SDK64=`ls -r /Developer/SDKs|egrep -v "10.[0-4]"|head -1`
  45. if test $USE_OLD -gt 0
  46. then
  47. SDK64=$OLD_SDK64
  48. else
  49. SDK64=$NEW_SDK64
  50. fi
  51. fi
  52. SDK64_DIR='/Developer/SDKs/'$SDK64
  53. MACVER64=`echo $SDK64|sed -e s/[a-zA-Z]//g -e s/.\$//`
  54. MINVER64='-mmacosx-version-min='$MACVER64
  55. if test ! -z $SDK32; then
  56. echo "----Configuring libcurl for 32 bit universal framework..."
  57. make clean
  58. ./configure --disable-dependency-tracking --disable-static --with-gssapi \
  59. CFLAGS="-Os -isysroot $SDK32_DIR $ARCHES32 $MINVER32" \
  60. LDFLAGS="-Wl,-syslibroot,$SDK32_DIR $ARCHES32 $MINVER32 -Wl,-headerpad_max_install_names" \
  61. CC=$CC
  62. echo "----Building 32 bit libcurl..."
  63. make
  64. echo "----Creating 32 bit framework..."
  65. rm -r libcurl.framework
  66. mkdir -p libcurl.framework/${FRAMEWORK_VERSION}/Resources
  67. cp lib/.libs/libcurl.dylib libcurl.framework/${FRAMEWORK_VERSION}/libcurl
  68. install_name_tool -id @executable_path/../Frameworks/libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl
  69. /usr/bin/sed -e "s/7\.12\.3/$VERSION/" lib/libcurl.plist >libcurl.framework/${FRAMEWORK_VERSION}/Resources/Info.plist
  70. mkdir -p libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl
  71. cp include/curl/*.h libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl
  72. pushd libcurl.framework
  73. ln -fs ${FRAMEWORK_VERSION}/libcurl libcurl
  74. ln -fs ${FRAMEWORK_VERSION}/Resources Resources
  75. ln -fs ${FRAMEWORK_VERSION}/Headers Headers
  76. cd Versions
  77. ln -fs ${FRAMEWORK_VERSION} Current
  78. echo TEsting for SDK64
  79. if test -d $SDK64_DIR; then
  80. echo entering...
  81. popd
  82. make clean
  83. echo "----Configuring libcurl for 64 bit universal framework..."
  84. ./configure --disable-dependency-tracking --disable-static --with-gssapi \
  85. CFLAGS="-Os -isysroot $SDK64_DIR $ARCHES64 $MINVER64" \
  86. LDFLAGS="-Wl,-syslibroot,$SDK64_DIR $ARCHES64 $MINVER64 -Wl,-headerpad_max_install_names" \
  87. CC=$CC
  88. echo "----Building 64 bit libcurl..."
  89. make
  90. echo "----Appending 64 bit framework to 32 bit framework..."
  91. cp lib/.libs/libcurl.dylib libcurl.framework/${FRAMEWORK_VERSION}/libcurl64
  92. install_name_tool -id @executable_path/../Frameworks/libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl64
  93. cp libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl32
  94. pwd
  95. lipo libcurl.framework/${FRAMEWORK_VERSION}/libcurl32 libcurl.framework/${FRAMEWORK_VERSION}/libcurl64 -create -output libcurl.framework/${FRAMEWORK_VERSION}/libcurl
  96. rm libcurl.framework/${FRAMEWORK_VERSION}/libcurl32 libcurl.framework/${FRAMEWORK_VERSION}/libcurl64
  97. cp libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl/curlbuild.h libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl/curlbuild32.h
  98. cp include/curl/curlbuild.h libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl/curlbuild64.h
  99. cat >libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl/curlbuild.h <<EOF
  100. #ifdef __LP64__
  101. #include "curl/curlbuild64.h"
  102. #else
  103. #include "curl/curlbuild32.h"
  104. #endif
  105. EOF
  106. fi
  107. pwd
  108. lipo -info libcurl.framework/${FRAMEWORK_VERSION}/libcurl
  109. echo "libcurl.framework is built and can now be included in other projects."
  110. echo "Copy libcurl.framework to your bundle's Contents/Frameworks folder, ~/Library/Frameworks or /Library/Frameworks."
  111. else
  112. echo "Building libcurl.framework requires Mac OS X 10.4 or later with the MacOSX10.4/5/6 SDK installed."
  113. fi