PageRenderTime 71ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/imagemagick_compile.sh

https://github.com/fleitz/imagemagick_lib_iphone
Shell | 585 lines | 373 code | 129 blank | 83 comment | 22 complexity | 9d9005ae3e1ed41b11859cb6182eef3d MD5 | raw file
  1. #!/bin/bash
  2. # Author: Claudio Marforio
  3. # e-mail: marforio@gmail.com
  4. # date: 21.03.2011
  5. # Script to make static libraries (jpeg + png + tiff) and ImageMagick
  6. # the libraries will be conbined into i386 + armv6 + armv7 static
  7. # libraries to be used inside an XCODE project for iOS development
  8. # The directory structure has to be:
  9. # ./cross_compile/ImageMagick-VERSION/ <- ImageMagick top directory
  10. # | /IMDelegataes/ <- Some delegates: jpeg + png + tiff
  11. # | |-jpeg-8c/ <- jpeg-8c -- no need to patch it
  12. # | |-libpng-1.4.5 <- png lib -- no need to patch it
  13. # | |-tiff-3.9.4 <- tiff lib -- no need to patch it
  14. # |- ... <- we don't care what's here! :)
  15. # If you don't have this directory structure you can either create it
  16. # or try change around the script
  17. # If everything works correctly you will end up with a folder called
  18. # IMPORT_ME in your working directory (i.e. .) ready to be imported
  19. # into XCode change this line if you want for everything to be
  20. # exported somewhere else
  21. FINAL_DIR=`pwd`/IMPORT_ME/
  22. if [[ $# != 1 ]]; then
  23. echo "imagemagick_compile.sh takes 1 argument: the version of ImageMagick that you want to compile!"
  24. echo "USAGE: imagemagick_compile.sh 6.6.8-5"
  25. exit
  26. fi
  27. IM_VERSION="$1"
  28. IM_DIR="$(pwd)/ImageMagick-$IM_VERSION"
  29. IM_DELEGATES_DIR="${IM_DIR}/IMDelegates/"
  30. if [ -d $IM_DELEGATES_DIR ]; then
  31. :;
  32. else
  33. echo "[INFO] IMDelegates folder not found, copying over"
  34. cp -r "$(pwd)/IMDelegates" "$IM_DIR/IMDelegates"
  35. fi
  36. JPEG_DIR="$IM_DIR/IMDelegates/jpeg-8c"
  37. PNG_DIR="$IM_DIR/IMDelegates/libpng-1.4.5"
  38. TIFF_DIR="$IM_DIR/IMDelegates/tiff-3.9.4"
  39. OUTPUT_FILE="$(pwd)/imagemagick_log_$(date +%s)"
  40. # Architectures and versions
  41. ARCH_SIM="i386"
  42. ARCH_IPHONE="armv7s"
  43. ARCH_IPHONE6="armv7"
  44. GCC_VERSION="4.2.1"
  45. MIN_IPHONE_VERSION="6.0"
  46. IPHONE_SDK_VERSION="6.0"
  47. MACOSX_SDK_VERSION="10.5"
  48. IPHONE="armv7 + armv7s"
  49. # Set this to where you want the libraries to be placed (if dir is not present it will be created):
  50. TARGET_LIB_DIR=$(pwd)/tmp_target
  51. LIB_DIR=$TARGET_LIB_DIR/im_libs
  52. JPEG_LIB_DIR=$TARGET_LIB_DIR/libjpeg
  53. PNG_LIB_DIR=$TARGET_LIB_DIR/libpng
  54. TIFF_LIB_DIR=$TARGET_LIB_DIR/libtiff
  55. IM_LIB_DIR=$TARGET_LIB_DIR/imagemagick
  56. # Set the build directories
  57. mkdir -p $TARGET_LIB_DIR
  58. mkdir -p $LIB_DIR/include/im_config
  59. mkdir -p $LIB_DIR/include/jpeg
  60. mkdir -p $LIB_DIR/include/magick
  61. mkdir -p $LIB_DIR/include/png
  62. mkdir -p $LIB_DIR/include/tiff
  63. mkdir -p $LIB_DIR/include/wand
  64. for i in "jpeg" "png" "tiff"; do
  65. for j in $ARCH_IPHONE $ARCH_IPHONE6 $ARCH_SIM; do
  66. mkdir -p $LIB_DIR/${i}_${j}_dylib
  67. done
  68. done
  69. mkdir -p $JPEG_LIB_DIR
  70. mkdir -p $PNG_LIB_DIR
  71. mkdir -p $TIFF_LIB_DIR
  72. # General folders where you have the iPhone compiler + tools
  73. export DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer"
  74. export SDKROOT="${DEVROOT}/SDKs/iPhoneOS${IPHONE_SDK_VERSION}.sdk"
  75. export MACOSXROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IPHONE_SDK_VERSION}.sdk"
  76. export CLANGROOT="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain"
  77. # Compiler flags and config arguments - IPHONE
  78. COMMON_IPHONE_LDFLAGS="-arch $ARCH_IPHONE -L$SDKROOT/usr/lib/"
  79. COMMON_IPHONE6_LDFLAGS="-arch $ARCH_IPHONE6 -L$SDKROOT/usr/lib/"
  80. COMMON_IPHONE_CFLAGS="-arch $ARCH_IPHONE -miphoneos-version-min=$MIN_IPHONE_VERSION -pipe -Os -isysroot $SDKROOT \
  81. -I$SDKROOT/usr/include -I$SDKROOT/usr/lib/gcc/arm-apple-darwin10/$GCC_VERSION/include/"
  82. COMMON_IPHONE6_CFLAGS="-arch $ARCH_IPHONE6 -miphoneos-version-min=$MIN_IPHONE_VERSION -pipe -Os -isysroot $SDKROOT \
  83. -I$SDKROOT/usr/include -I$SDKROOT/usr/lib/gcc/arm-apple-darwin10/$GCC_VERSION/include/"
  84. COMMON_SIM_LDFLAGS="-L$MACOSXROOT/usr/lib"
  85. COMMON_SIM_CFLAGS="-I$MACOSXROOT/usr/include -I$MACOSXROOT/usr/lib/gcc/i686-apple-darwin10/$GCC_VERSION/include/"
  86. IM_LDFLAGS="-L$LIB_DIR/jpeg_${ARCH_IPHONE}_dylib/ -L$LIB_DIR/png_${ARCH_IPHONE}_dylib/ -L$LIB_DIR/tiff_${ARCH_IPHONE}_dylib/ -L$LIB_DIR"
  87. IM_LDFLAGS6="-L$LIB_DIR/jpeg_${ARCH_IPHONE6}_dylib/ -L$LIB_DIR/png_${ARCH_IPHONE6}_dylib/ -L$LIB_DIR/tiff_${ARCH_IPHONE6}_dylib/ -L$LIB_DIR"
  88. IM_LDFLAGS_SIM="-L$LIB_DIR/jpeg_${ARCH_SIM}_dylib/ -L$LIB_DIR/png_${ARCH_SIM}_dylib/ -L$LIB_DIR/tiff_${ARCH_SIM}_dylib/ -L$LIB_DIR"
  89. IM_IFLAGS="$COMMON_SIM_CFLAGS -I$LIB_DIR/include/jpeg -I$LIB_DIR/include/png -I$LIB_DIR/include/tiff"
  90. ############ HACK ############
  91. # ImageMagick requires this header (crt_externals.h), that doesn't
  92. # exist for the iPhone - Just copying it make things compile/work
  93. if [ -e $SDKROOT/usr/include/crt_externs.h ]; then
  94. :;
  95. else
  96. echo "[INFO] need to copy crt_externals.h for compilation, please enter sudo password"
  97. sudo cp "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IPHONE_SDK_VERSION}.sdk/usr/include/crt_externs.h" \
  98. "$SDKROOT/usr/include/crt_externs.h"
  99. fi
  100. ############ END ############
  101. ###################################
  102. ############ PNG ############
  103. ###################################
  104. function png() {
  105. echo ""
  106. echo "[+ PNG: $1]"
  107. cd $PNG_DIR
  108. LIBPATH_png=libpng14.a
  109. LIBPATH_png_dylib=libpng14.dylib
  110. if [ "$1" == "$IPHONE" ]; then ## ARMV7 ##
  111. U_CC=$CC
  112. U_CFLAGS=$CFLAGS
  113. U_LD=$LD
  114. U_LDFLAGS=$LDFLAGS
  115. U_CPP=$CPP
  116. U_CPPFLAGS=$CPPFLAGS
  117. export LDFLAGS="$COMMON_IPHONE_LDFLAGS"
  118. export CFLAGS="$COMMON_IPHONE_CFLAGS"
  119. echo "[|- CONFIG ${ARCH_IPHONE}]"
  120. ./configure prefix=$PNG_LIB_DIR CC=$CLANGROOT/usr/bin/clang --enable-shared --enable-static \
  121. CC=$CLANGROOT/usr/bin/clang LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin >> $OUTPUT_FILE 2>&1
  122. echo "[|- CC ${ARCH_IPHONE}]"
  123. make -j2 >> $OUTPUT_FILE 2>&1
  124. echo "[|- INSTALL ${ARCH_IPHONE}]"
  125. make install >> $OUTPUT_FILE 2>&1
  126. # cp the static + shared library
  127. cp $PNG_LIB_DIR/lib/$LIBPATH_png $LIB_DIR/libpng.a.$ARCH_IPHONE
  128. cp $PNG_LIB_DIR/lib/$LIBPATH_png_dylib $LIB_DIR/png_${ARCH_IPHONE}_dylib/libpng.dylib
  129. echo "[|- CLEAN ${ARCH_IPHONE}]"
  130. make distclean >> $OUTPUT_FILE 2>&1
  131. ## ARMV6 ##
  132. export LDFLAGS="$COMMON_IPHONE6_LDFLAGS"
  133. export CFLAGS="$COMMON_IPHONE6_CFLAGS"
  134. echo "[|- CONFIG ${ARCH_IPHONE6}]"
  135. ./configure prefix=$PNG_LIB_DIR CC=$CLANGROOT/usr/bin/clang --enable-shared --enable-static \
  136. CC=$CLANGROOT/usr/bin/clang LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin >> $OUTPUT_FILE 2>&1
  137. echo "[|- CC ${ARCH_IPHONE6}]"
  138. make -j2 >> $OUTPUT_FILE 2>&1
  139. make install >> $OUTPUT_FILE 2>&1
  140. # cp the static + shared library
  141. cp $PNG_LIB_DIR/lib/$LIBPATH_png $LIB_DIR/libpng.a.$ARCH_IPHONE6
  142. cp $PNG_LIB_DIR/lib/$LIBPATH_png_dylib $LIB_DIR/png_${ARCH_IPHONE6}_dylib/libpng.dylib
  143. echo "[|- CLEAN ${ARCH_IPHONE6}]"
  144. make distclean >> $OUTPUT_FILE 2>&1
  145. elif [ "$1" == "$ARCH_SIM" ]; then ## INTEL ##
  146. # Set up environment
  147. export CC=$U_CC
  148. export CFLAGS="$COMMON_SIM_CFLAGS -arch $ARCH_SIM"
  149. export LD=$U_LD
  150. export LDFLAGS="$U_LDFLAGS" #export LDFLAGS="$COMMON_SIM_LDFLAGS $U_LDFLAGS"
  151. export CPP=$U_CPP
  152. export CPPFLAGS=$U_CPPFLAGS
  153. echo "[|- CONFIG $ARCH_SIM]"
  154. ./configure prefix=$PNG_LIB_DIR CC=$CLANGROOT/usr/bin/clang --enable-shared --enable-static \
  155. --host=i686-apple-darwin10 >> $OUTPUT_FILE 2>&1
  156. echo "[|- CC $ARCH_SIM]"
  157. make -j2 >> $OUTPUT_FILE 2>&1
  158. make install >> $OUTPUT_FILE 2>&1
  159. # cp the static library
  160. cp $PNG_LIB_DIR/lib/$LIBPATH_png $LIB_DIR/libpng.a.$ARCH_SIM
  161. cp $PNG_LIB_DIR/lib/$LIBPATH_png_dylib $LIB_DIR/png_${ARCH_SIM}_dylib/libpng.dylib
  162. # cp the include/* files
  163. cp $PNG_LIB_DIR/include/libpng14/* $LIB_DIR/include/png/
  164. echo "[|- CLEAN $ARCH_SIM]"
  165. make distclean >> $OUTPUT_FILE 2>&1
  166. echo "[|- COMBINE $ARCH_IPHONE $ARCH_IPHONE6 $ARCH_SIM]"
  167. # combine the static libraries for i386 and arm
  168. $DEVROOT/usr/bin/lipo -arch $ARCH_IPHONE $LIB_DIR/libpng.a.$ARCH_IPHONE \
  169. -arch $ARCH_IPHONE6 $LIB_DIR/libpng.a.$ARCH_IPHONE6 \
  170. -arch $ARCH_SIM $LIB_DIR/libpng.a.$ARCH_SIM -create -output $LIB_DIR/libpng.a
  171. fi
  172. echo "[+ DONE: $1]"
  173. } ## END PNG LIBRARY ##
  174. ###################################
  175. ############ JPEG ############
  176. ###################################
  177. function jpeg() {
  178. echo ""
  179. echo "[+ JPEG: $1]"
  180. cd $JPEG_DIR
  181. LIBPATH_jpeg=libjpeg.a
  182. LIBNAME_jpeg=`basename $LIBPATH_jpeg`
  183. if [ "$1" == "$IPHONE" ]; then ## ARMV7 ##
  184. U_CC=$CC
  185. U_CFLAGS=$CFLAGS
  186. U_LD=$LD
  187. U_LDFLAGS=$LDFLAGS
  188. U_CPP=$CPP
  189. U_CPPFLAGS=$CPPFLAGS
  190. export LDFLAGS="$COMMON_IPHONE_LDFLAGS"
  191. export CFLAGS="$COMMON_IPHONE_CFLAGS"
  192. echo "[|- CONFIG $ARCH_IPHONE]"
  193. ./configure prefix=$JPEG_LIB_DIR --enable-shared --enable-static \
  194. CC=$CLANGROOT/usr/bin/clang LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin >> $OUTPUT_FILE 2>&1
  195. echo "[|- CC $ARCH_IPHONE]"
  196. make -j2 >> $OUTPUT_FILE 2>&1
  197. make install >> $OUTPUT_FILE 2>&1
  198. # cp the static + shared library
  199. cp $JPEG_LIB_DIR/lib/$LIBPATH_jpeg $LIB_DIR/$LIBNAME_jpeg.$ARCH_IPHONE
  200. cp $JPEG_LIB_DIR/lib/libjpeg.dylib $LIB_DIR/jpeg_${ARCH_IPHONE}_dylib/libjpeg.dylib
  201. echo "[|- CLEAN $ARCH_IPHONE]"
  202. make distclean >> $OUTPUT_FILE 2>&1
  203. ## ARMV6 ##
  204. export LDFLAGS="$COMMON_IPHONE6_LDFLAGS"
  205. export CFLAGS="$COMMON_IPHONE6_CFLAGS"
  206. echo "[|- CONFIG $ARCH_IPHONE6]"
  207. ./configure prefix=$JPEG_LIB_DIR --enable-shared --enable-static \
  208. CC=$CLANGROOT/usr/bin/clang LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin >> $OUTPUT_FILE 2>&1
  209. echo "[|- CC $ARCH_IPHONE6]"
  210. make -j2 >> $OUTPUT_FILE 2>&1
  211. make install >> $OUTPUT_FILE 2>&1
  212. # cp the static + shared library
  213. cp $JPEG_LIB_DIR/lib/$LIBPATH_jpeg $LIB_DIR/$LIBNAME_jpeg.$ARCH_IPHONE6
  214. cp $JPEG_LIB_DIR/lib/libjpeg.dylib $LIB_DIR/jpeg_${ARCH_IPHONE6}_dylib/libjpeg.dylib
  215. echo "[|- CLEAN $ARCH_IPHONE6]"
  216. make distclean >> $OUTPUT_FILE 2>&1
  217. elif [ "$1" == "$ARCH_SIM" ]; then ## INTEL ##
  218. # Use default environment
  219. export CC=$U_CC
  220. export CFLAGS="$COMMON_SIM_CFLAGS -arch $ARCH_SIM"
  221. export LD=$U_LD
  222. export LDFLAGS="$U_LDFLAGS" #export LDFLAGS="$COMMON_SIM_LDFLAGS -arch $ARCH_SIM"
  223. export CPP=$U_CPP
  224. export CPPFLAGS=$U_CPPFLAGS
  225. echo "[|- CONFIG $ARCH_SIM]"
  226. ./configure prefix=$JPEG_LIB_DIR CC=$CLANGROOT/usr/bin/clang --enable-shared \
  227. --enable-static --host=i686-apple-darwin10 >> $OUTPUT_FILE 2>&1
  228. echo "[|- CC $ARCH_SIM]"
  229. make -j2 >> $OUTPUT_FILE 2>&1
  230. make install >> $OUTPUT_FILE 2>&1
  231. # cp the static library
  232. cp $JPEG_LIB_DIR/lib/$LIBPATH_jpeg $LIB_DIR/$LIBNAME_jpeg.$ARCH_SIM
  233. cp $JPEG_LIB_DIR/lib/libjpeg.dylib $LIB_DIR/jpeg_${ARCH_SIM}_dylib/libjpeg.dylib
  234. # cp the include/* files
  235. cp $JPEG_LIB_DIR/include/*.h $LIB_DIR/include/jpeg/
  236. echo "[|- CLEAN $ARCH_SIM]"
  237. make distclean >> $OUTPUT_FILE 2>&1
  238. # combine the static libraries for i386 and arm
  239. echo "[|- COMBINE $ARCH_IPHONE $ARCH_IPHONE6 $ARCH_SIM]"
  240. $DEVROOT/usr/bin/lipo -arch $ARCH_IPHONE $LIB_DIR/$LIBNAME_jpeg.$ARCH_IPHONE \
  241. -arch $ARCH_IPHONE6 $LIB_DIR/$LIBNAME_jpeg.$ARCH_IPHONE6 \
  242. -arch $ARCH_SIM $LIB_DIR/$LIBNAME_jpeg.$ARCH_SIM -create -output $LIB_DIR/$LIBNAME_jpeg
  243. fi
  244. echo "[+ DONE: $1]"
  245. } ## END JPEG LIBRARY ##
  246. ###################################
  247. ############# TIFF ##########
  248. ###################################
  249. function tiff() {
  250. echo ""
  251. echo "[+ TIFF: $1]"
  252. cd $TIFF_DIR
  253. LIBPATH_tiff=libtiff.a
  254. LIBNAME_tiff=`basename $LIBPATH_tiff`
  255. if [ "$1" == "$IPHONE" ]; then ## ARM ##
  256. U_CC=$CC
  257. U_CFLAGS=$CFLAGS
  258. U_LD=$LD
  259. U_LDFLAGS=$LDFLAGS
  260. U_CPP=$CPP
  261. U_CPPFLAGS=$CPPFLAGS
  262. export LDFLAGS="$COMMON_IPHONE_LDFLAGS"
  263. export CFLAGS="$COMMON_IPHONE_CFLAGS"
  264. echo "[|- CONFIG $ARCH_IPHONE]"
  265. ./configure prefix=$TIFF_LIB_DIR CC=$CLANGROOT/usr/bin/clang \
  266. LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin --disable-cxx >> $OUTPUT_FILE 2>&1
  267. echo "[|- CC $ARCH_IPHONE]"
  268. make -j2 >> $OUTPUT_FILE 2>&1
  269. make install >> $OUTPUT_FILE 2>&1
  270. # cp the static + shared library
  271. cp $TIFF_LIB_DIR/lib/$LIBPATH_tiff $LIB_DIR/$LIBNAME_tiff.$ARCH_IPHONE
  272. cp $TIFF_LIB_DIR/lib/libtiff.3.dylib $LIB_DIR/tiff_${ARCH_IPHONE}_dylib/libtiff.dylib
  273. echo "[|- CLEAN $ARCH_IPHONE]"
  274. make distclean >> $OUTPUT_FILE 2>&1
  275. ## ARMV6 ##
  276. export LDFLAGS="$COMMON_IPHONE6_LDFLAGS"
  277. export CFLAGS="$COMMON_IPHONE6_CFLAGS"
  278. echo "[|- CONFIG $ARCH_IPHONE6]"
  279. ./configure prefix=$TIFF_LIB_DIR CC=$CLANGROOT/usr/bin/clang \
  280. LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin --disable-cxx >> $OUTPUT_FILE 2>&1
  281. echo "[|- CC $ARCH_IPHONE6]"
  282. make -j2 >> $OUTPUT_FILE 2>&1
  283. make install >> $OUTPUT_FILE 2>&1
  284. # cp the static + shared library
  285. cp $TIFF_LIB_DIR/lib/$LIBPATH_tiff $LIB_DIR/$LIBNAME_tiff.$ARCH_IPHONE6
  286. cp $TIFF_LIB_DIR/lib/libtiff.3.dylib $LIB_DIR/tiff_${ARCH_IPHONE6}_dylib/libtiff.dylib
  287. echo "[|- CLEAN $ARCH_IPHONE6]"
  288. make distclean >> $OUTPUT_FILE 2>&1
  289. elif [ "$1" == "$ARCH_SIM" ]; then ## INTEL ##
  290. # Use default environment
  291. export CC=$U_CC
  292. export CFLAGS="$COMMON_SIM_CFLAGS -arch $ARCH_SIM"
  293. export LD=$U_LD
  294. export LDFLAGS="$U_LDFLAGS" #export LDFLAGS="$COMMON_SIM_LDFLAGS $U_LDFLAGS"
  295. export CPP=$U_CPP
  296. export CPPFLAGS=$U_CPPFLAGS
  297. echo "[|- CONFIG $ARCH_SIM]"
  298. ./configure prefix=$TIFF_LIB_DIR CC=$CLANGROOT/usr/bin/clang --host=i686-apple-darwin10 \
  299. --disable-cxx >> $OUTPUT_FILE 2>&1
  300. echo "[|- CC $ARCH_SIM]"
  301. make -j2 >> $OUTPUT_FILE 2>&1
  302. make install >> $OUTPUT_FILE 2>&1
  303. # cp the static library
  304. cp $TIFF_LIB_DIR/lib/$LIBPATH_tiff $LIB_DIR/$LIBNAME_tiff.$ARCH_SIM
  305. cp $TIFF_LIB_DIR/lib/libtiff.3.dylib $LIB_DIR/tiff_${ARCH_SIM}_dylib/libtiff.dylib
  306. # cp the include/* files
  307. cp $TIFF_LIB_DIR/include/*.h $LIB_DIR/include/tiff/
  308. echo "[|- CLEAN $ARCH_SIM]"
  309. make distclean >> $OUTPUT_FILE 2>&1
  310. # combine the static libraries for i386 and arm
  311. echo "[|- COMBINE $ARCH_IPHONE $ARCH_IPHONE6 $ARCH_SIM]"
  312. $DEVROOT/usr/bin/lipo -arch $ARCH_IPHONE $LIB_DIR/$LIBNAME_tiff.$ARCH_IPHONE \
  313. -arch $ARCH_IPHONE6 $LIB_DIR/$LIBNAME_tiff.$ARCH_IPHONE6 \
  314. -arch $ARCH_SIM $LIB_DIR/$LIBNAME_tiff.$ARCH_SIM -create -output $LIB_DIR/$LIBNAME_tiff
  315. fi
  316. echo "[+ DONE $1]"
  317. } ## END TIFF LIBRARY ##
  318. ###################################
  319. ############ IMAGEMAGICK ####
  320. ###################################
  321. function im() {
  322. echo ""
  323. echo "[+ IM: $1]"
  324. cd $IM_DIR
  325. # static library that will be generated
  326. LIBPATH_static=$IM_LIB_DIR/lib/libMagickCore.a
  327. LIBNAME_static=`basename $LIBPATH_static`
  328. LIBPATH_static2=$IM_LIB_DIR/lib/libMagickWand.a
  329. LIBNAME_static2=`basename $LIBPATH_static2`
  330. if [ "$1" == "$IPHONE" ]; then ## ARM ##
  331. # Save relevant environment
  332. U_CC=$CC
  333. U_CFLAGS=$CFLAGS
  334. U_LD=$LD
  335. U_LDFLAGS=$LDFLAGS
  336. U_CPP=$CPP
  337. U_CPPFLAGS=$CPPFLAGS
  338. export LDFLAGS="$IM_LDFLAGS $COMMON_IPHONE_LDFLAGS"
  339. export CFLAGS="$COMMON_IPHONE_CFLAGS $IM_IFLAGS -DHAVE_J1=0 -DTARGET_OS_IPHONE -DMAGICKCORE_WORDS_BIGENDIAN"
  340. export CXXFLAGS="-Wall -W -D_THREAD_SAFE -DHAVE_J1=0 -DTARGET_OS_IPHONE -DMAGICKCORE_WORDS_BIGENDIAN"
  341. # configure to have the static libraries
  342. echo "[|- CONFIG $ARCH_IPHONE]"
  343. ./configure prefix=$IM_LIB_DIR CC=$CLANGROOT/usr/bin/clang LD=$DEVROOT/usr/bin/ld \
  344. --host=arm-apple-darwin --disable-largefile --with-quantum-depth=8 --without-magick-plus-plus \
  345. --without-perl --without-x --disable-shared --disable-openmp --without-bzlib --without-freetype >> $OUTPUT_FILE 2>&1
  346. # compile ImageMagick
  347. echo "[|- CC $ARCH_IPHONE]"
  348. make -j2 >> $OUTPUT_FILE 2>&1
  349. make install >> $OUTPUT_FILE 2>&1
  350. # copy the CORE + WAND libraries -- ARM version
  351. cp $LIBPATH_static $LIB_DIR/$LIBNAME_static.$ARCH_IPHONE
  352. cp $LIBPATH_static2 $LIB_DIR/$LIBNAME_static2.$ARCH_IPHONE
  353. # clean the ImageMagick build
  354. echo "[| CLEAN $ARCH_IPHONE]"
  355. make distclean >> $OUTPUT_FILE 2>&1
  356. ## ARMV6 ##
  357. export CFLAGS="$COMMON_IPHONE6_CFLAGS $IM_IFLAGS -DHAVE_J1=0 -DTARGET_OS_IPHONE -DMAGICKCORE_WORDS_BIGENDIAN"
  358. export LDFLAGS="$IM_LDFLAGS6 $COMMON_IPHONE6_LDFLAGS"
  359. # configure to have the static libraries
  360. echo "[|- CONFIG $ARCH_IPHONE6]"
  361. ./configure prefix=$IM_LIB_DIR CC=$CLANGROOT/usr/bin/clang LD=$DEVROOT/usr/bin/ld \
  362. --host=arm-apple-darwin --disable-largefile --with-quantum-depth=8 --without-magick-plus-plus \
  363. --without-perl --without-x --disable-shared --disable-openmp --without-bzlib --without-freetype >> $OUTPUT_FILE 2>&1
  364. # compile ImageMagick
  365. echo "[|- CC $ARCH_IPHONE6]"
  366. make -j2 >> $OUTPUT_FILE 2>&1
  367. make install >> $OUTPUT_FILE 2>&1
  368. # copy the CORE + WAND libraries -- ARM version
  369. cp $LIBPATH_static $LIB_DIR/$LIBNAME_static.$ARCH_IPHONE6
  370. cp $LIBPATH_static2 $LIB_DIR/$LIBNAME_static2.$ARCH_IPHONE6
  371. # copy the wand/ + core/ headers
  372. cp $IM_LIB_DIR/include/ImageMagick/magick/* $LIB_DIR/include/magick/
  373. cp $IM_LIB_DIR/include/ImageMagick/wand/* $LIB_DIR/include/wand/
  374. # copy configuration files needed for certain functions
  375. cp $IM_LIB_DIR/etc/ImageMagick/*.xml $LIB_DIR/include/im_config/
  376. cp $IM_LIB_DIR/share/ImageMagick-*/*.xml $LIB_DIR/include/im_config/
  377. # clean the ImageMagick build
  378. echo "[|- CLEAN $ARCH_IPHONE6]"
  379. make distclean >> $OUTPUT_FILE 2>&1
  380. elif [ "$1" == "$ARCH_SIM" ]; then ## INTEL ##
  381. # Use default environment
  382. export CC=$U_CC
  383. export LDFLAGS="-isysroot $MACOSXROOT -mmacosx-version-min=10.6 $IM_LDFLAGS_SIM"
  384. export CFLAGS="-arch $ARCH_SIM -isysroot $MACOSXROOT -mmacosx-version-min=10.6 $IM_IFLAGS -DHAVE_J1=0 -DTARGET_OS_IPHONE -DMAGICKCORE_WORDS_BIGENDIAN"
  385. export LD=$U_LD
  386. export CPP=$U_CPP
  387. export CPPFLAGS="$U_CPPFLAGS $U_LDFLAGS $IM_IFLAGS -DHAVE_J1=0 -DTARGET_OS_IPHONE -DMAGICKCORE_WORDS_BIGENDIAN"
  388. # configure with standard parameters
  389. echo "[|- CONFIG $ARCH_SIM]"
  390. ./configure prefix=$IM_LIB_DIR CC=$CLANGROOT/usr/bin/clang --host=i686-apple-darwin10 \
  391. --disable-largefile --with-quantum-depth=8 --without-magick-plus-plus --without-perl --without-x \
  392. --disable-shared --disable-openmp --without-bzlib --without-freetype --without-threads >> $OUTPUT_FILE 2>&1
  393. # compile ImageMagick
  394. echo "[|- CC $ARCH_SIM]"
  395. make -j2 >> $OUTPUT_FILE 2>&1
  396. make install >> $OUTPUT_FILE 2>&1
  397. # copy the CORE + WAND libraries -- INTEL version
  398. cp $LIBPATH_static $LIB_DIR/$LIBNAME_static.$ARCH_SIM
  399. cp $LIBPATH_static2 $LIB_DIR/$LIBNAME_static2.$ARCH_SIM
  400. # clean the ImageMagick build
  401. echo "[|- CLEAN $ARCH_SIM]"
  402. make distclean >> $OUTPUT_FILE 2>&1
  403. # combine the two generated libraries to be used both in the simulator and in the device
  404. echo "[|- COMBINE (libMagickCore) $ARCH_IPHONE $ARCH_IPHONE6 $ARCH_SIM]"
  405. $DEVROOT/usr/bin/lipo -arch $ARCH_IPHONE $LIB_DIR/$LIBNAME_static.$ARCH_IPHONE \
  406. -arch $ARCH_IPHONE6 $LIB_DIR/$LIBNAME_static.$ARCH_IPHONE6 \
  407. -arch $ARCH_SIM $LIB_DIR/$LIBNAME_static.$ARCH_SIM -create -output $LIB_DIR/$LIBNAME_static
  408. echo "[|- COMBINE (libMagickWand) $ARCH_IPHONE $ARCH_IPHONE6 $ARCH_SIM]"
  409. $DEVROOT/usr/bin/lipo -arch $ARCH_IPHONE $LIB_DIR/$LIBNAME_static2.$ARCH_IPHONE \
  410. -arch $ARCH_IPHONE6 $LIB_DIR/$LIBNAME_static2.$ARCH_IPHONE6 \
  411. -arch $ARCH_SIM $LIB_DIR/$LIBNAME_static2.$ARCH_SIM -create -output $LIB_DIR/$LIBNAME_static2
  412. fi
  413. echo "[+ DONE: IM]"
  414. } ## END IMAGEMAGICK LIBRARY ##
  415. function structure_for_xcode() {
  416. echo ""
  417. echo "[+ XCODE]"
  418. if [ -e $FINAL_DIR ]; then
  419. echo "[|- RM $FINAL_DIR]"
  420. rm -rf "$FINAL_DIR"*
  421. else
  422. echo "[|- MKDIR: $FINAL_DIR]"
  423. mkdir -p "$FINAL_DIR"
  424. fi
  425. echo "[|- CP]"
  426. cp -r ${LIB_DIR}/include/ ${FINAL_DIR}include/
  427. cp $LIB_DIR/*.a "$FINAL_DIR"
  428. echo "[+ DONE: XCODE]"
  429. }
  430. # function used to produce .zips for the ImageMagick ftp site maintained by me (Claudio Marforio)
  431. function zip_for_ftp() {
  432. echo ""
  433. echo "[+ ZIP]"
  434. if [ -e $FINAL_DIR ]; then
  435. tmp_dir="$(pwd)/TMP_IM"
  436. cp -R $FINAL_DIR $tmp_dir
  437. ditto -c -k -rsrc "$tmp_dir" "iOSMagick-${IM_VERSION}-libs.zip" && echo "[|- CREATED W/ libs]"
  438. rm $tmp_dir/libjpeg.a $tmp_dir/libpng.a $tmp_dir/libtiff.a
  439. rm -rf $tmp_dir/include/jpeg/ $tmp_dir/include/png/ $tmp_dir/include/tiff/
  440. ditto -c -k -rsrc "$tmp_dir" "iOSMagick-${IM_VERSION}.zip" && echo "[|- CREATED W/O libs]"
  441. rm -rf $tmp_dir
  442. else
  443. echo "[* ERROR, $FINAL_DIR not present..."
  444. fi
  445. echo "[+ DONE: ZIP]"
  446. }
  447. png "$IPHONE"
  448. png "$ARCH_SIM"
  449. jpeg "$IPHONE"
  450. jpeg "$ARCH_SIM"
  451. tiff "$IPHONE"
  452. tiff "$ARCH_SIM"
  453. im "$IPHONE"
  454. im "$ARCH_SIM"
  455. structure_for_xcode
  456. # zip_for_ftp # used only by me (Claudio Marforio) to upload to the IM ftp :)