PageRenderTime 27ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/inkscape-0.48.2/packaging/macosx/osx-build.sh

#
Shell | 410 lines | 338 code | 26 blank | 46 comment | 22 complexity | f3d1efe20727bd3c3b93758f4a1c76c2 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. #!/bin/bash
  2. #
  3. # Inkscape compilation and packaging script for Mac OS X
  4. #
  5. # Please see
  6. # http://wiki.inkscape.org/wiki/index.php?title=CompilingMacOsX
  7. # for more complete information
  8. #
  9. # Author:
  10. # Jean-Olivier Irisson <jo.irisson@gmail.com>
  11. # with information from
  12. # Kees Cook
  13. # Michael Wybrow
  14. #
  15. # Copyright (C) 2006-2010
  16. # Released under GNU GPL, read the file 'COPYING' for more information
  17. #
  18. ############################################################
  19. # User modifiable parameters
  20. #----------------------------------------------------------
  21. # Configure flags
  22. CONFFLAGS="--enable-osxapp"
  23. # Libraries prefix (Warning: NO trailing slash)
  24. LIBPREFIX="/opt/local"
  25. # User name on Modevia
  26. MODEVIA_NAME=""
  27. ############################################################
  28. # Help message
  29. #----------------------------------------------------------
  30. help()
  31. {
  32. echo -e "
  33. Compilation script for Inkscape on Mac OS X.
  34. \033[1mUSAGE\033[0m
  35. $0 [options] action[s]
  36. \033[1mACTIONS & OPTIONS\033[0m
  37. \033[1mh,help\033[0m
  38. display this help message
  39. \033[1mu,up,update\033[0m
  40. update an existing checkout from bzr (run bzr pull)
  41. \033[1ma,auto,autogen\033[0m
  42. prepare configure script (run autogen.sh). This is only necessary
  43. for a fresh bzr checkout or after make distclean.
  44. \033[1mc,conf,configure\033[0m
  45. configure the build (run configure). Edit your configuration
  46. options in $0
  47. \033[1m-p,--prefix\033[0m specify install prefix (configure step only)
  48. \033[1mb,build\033[0m
  49. build Inkscape (run make)
  50. \033[1mi,install\033[0m
  51. install the build products locally, inside the source
  52. directory (run make install)
  53. \033[1mp,pack,package\033[0m
  54. package Inkscape in a double clickable .app bundle
  55. \033[1m-s,--strip\033[0m remove debugging information in Inkscape package
  56. \033[1m-py,--with-python\033[0m specify python modules path for inclusion into the app bundle
  57. \033[1md,dist,distrib\033[0m
  58. store Inkscape.app in a disk image (dmg) for distribution
  59. \033[1mf,fat,universal\033[0m
  60. compile inkscape as a universal binary as both i386 and ppc architectures
  61. \033[1mput,upload\033[0m
  62. upload the dmg and the associate info file on Modevia server
  63. \033[1mall\033[0m
  64. do everything (update, configure, build, install, package, distribute)
  65. \033[1mEXAMPLES\033[0m
  66. \033[1m$0 conf build install\033[0m
  67. configure, build and install a dowloaded version of Inkscape in the default
  68. directory, keeping debugging information.
  69. \033[1m$0 u a c b -p ~ i -s -py ~/site-packages/ p d\033[0m
  70. update an bzr checkout, prepare configure script, configure,
  71. build and install Inkscape in the user home directory (~).
  72. Then package Inkscape without debugging information,
  73. with python packages from ~/site-packages/ and prepare
  74. a dmg for distribution."
  75. }
  76. # Parameters
  77. #----------------------------------------------------------
  78. # Paths
  79. HERE=`pwd`
  80. SRCROOT=$HERE/../.. # we are currently in packaging/macosx
  81. # Defaults
  82. if [ "$INSTALLPREFIX" = "" ]
  83. then
  84. INSTALLPREFIX=$SRCROOT/Build/
  85. fi
  86. BZRUPDATE="f"
  87. AUTOGEN="f"
  88. CONFIGURE="f"
  89. BUILD="f"
  90. INSTALL="f"
  91. PACKAGE="f"
  92. DISTRIB="f"
  93. UPLOAD="f"
  94. UNIVERSAL="f"
  95. STRIP=""
  96. PYTHON_MODULES=""
  97. # Parse command line options
  98. #----------------------------------------------------------
  99. while [ "$1" != "" ]
  100. do
  101. case $1 in
  102. h|help)
  103. help
  104. exit 1 ;;
  105. all)
  106. BZRUPDATE="t"
  107. CONFIGURE="t"
  108. BUILD="t"
  109. INSTALL="t"
  110. PACKAGE="t"
  111. DISTRIB="t" ;;
  112. u|up|update)
  113. BZRUPDATE="t" ;;
  114. a|auto|autogen)
  115. AUTOGEN="t" ;;
  116. c|conf|configure)
  117. CONFIGURE="t" ;;
  118. -u|--universal)
  119. UNIVERSAL="t" ;;
  120. b|build)
  121. BUILD="t" ;;
  122. i|install)
  123. INSTALL="t" ;;
  124. p|pack|package)
  125. PACKAGE="t" ;;
  126. d|dist|distrib)
  127. DISTRIB="t" ;;
  128. put|upload)
  129. UPLOAD="t" ;;
  130. -p|--prefix)
  131. INSTALLPREFIX=$2
  132. shift 1 ;;
  133. -s|--strip)
  134. STRIP="-s" ;;
  135. -py|--with-python)
  136. PYTHON_MODULES="$2"
  137. shift 1 ;;
  138. *)
  139. echo "Invalid command line option: $1"
  140. exit 2 ;;
  141. esac
  142. shift 1
  143. done
  144. OSXMINORVER=`/usr/bin/sw_vers | grep ProductVersion | cut -d' ' -f2 | cut -f1-2 -d.`
  145. # Set environment variables
  146. # ----------------------------------------------------------
  147. export LIBPREFIX
  148. # Specific environment variables
  149. # automake seach path
  150. export CPATH="$LIBPREFIX/include"
  151. # configure search path
  152. export CPPFLAGS="-I$LIBPREFIX/include"
  153. # export CPPFLAGS="-I$LIBPREFIX/include -I /System/Library/Frameworks/Carbon.framework/Versions/Current/Headers"
  154. export LDFLAGS="-L$LIBPREFIX/lib"
  155. # compiler arguments
  156. export CFLAGS="-O3 -Wall"
  157. export CXXFLAGS="$CFLAGS"
  158. if [[ "$UNIVERSAL" == "t" ]]
  159. then
  160. MINOSXVER="$OSXMINORVER"
  161. export SDK=/Developer/SDKs/MacOSX${MINOSXVER}.sdk
  162. export CFLAGS="$CFLAGS -isysroot $SDK -arch ppc -arch i386"
  163. export CXXFLAGS="$CFLAGS"
  164. export CONFFLAGS="$CONFFLAGS --disable-dependency-tracking"
  165. fi
  166. # Actions
  167. # ----------------------------------------------------------
  168. if [[ "$BZRUPDATE" == "t" ]]
  169. then
  170. cd $SRCROOT
  171. bzr pull
  172. status=$?
  173. if [[ $status -ne 0 ]]; then
  174. echo -e "\nBZR update failed"
  175. exit $status
  176. fi
  177. cd $HERE
  178. fi
  179. # Fetch some information
  180. REVISION=`bzr version-info 2>/dev/null | grep revno | cut -d' ' -f2`
  181. ARCH=`arch | tr [p,c] [P,C]`
  182. OSXVERSION=`/usr/bin/sw_vers | grep ProductVersion | cut -d' ' -f2`
  183. if [[ "$OSXMINORVER" == "10.3" ]]; then
  184. TARGETNAME="PANTHER"
  185. TARGETVERSION="10.3"
  186. elif [[ "$OSXMINORVER" == "10.4" ]]; then
  187. TARGETNAME="TIGER"
  188. TARGETVERSION="10.4"
  189. elif [[ "$OSXMINORVER" == "10.5" ]]; then
  190. TARGETNAME="LEOPARD+"
  191. TARGETVERSION="10.5+"
  192. fi
  193. TARGETARCH="$ARCH"
  194. if [[ "$UNIVERSAL" == "t" ]]; then
  195. TARGETARCH="UNIVERSAL"
  196. fi
  197. NEWNAME="Inkscape-r$REVISION-$TARGETVERSION-$TARGETARCH"
  198. DMGFILE="$NEWNAME.dmg"
  199. INFOFILE="$NEWNAME-info.txt"
  200. if [[ "$UPLOAD" == "t" ]]
  201. then
  202. # If we are uploading, we are probably building nightlies and don't
  203. # need to build a new one if the repository hasn't changed since the
  204. # last. Hence, if a dmg for this version already exists, then just
  205. # exit here.
  206. if [[ -f "$DMGFILE" ]]; then
  207. echo -e "\nRepository hasn't changed: $DMGFILE already exists."
  208. exit 0
  209. fi
  210. fi
  211. if [[ "$AUTOGEN" == "t" ]]
  212. then
  213. cd $SRCROOT
  214. if [[ "$UNIVERSAL" == "t" ]]
  215. then
  216. # Universal builds have to be built with the option
  217. # --disable-dependency-tracking. So they need to be
  218. # started from scratch each time.
  219. if [[ -f Makefile ]]; then
  220. make distclean
  221. fi
  222. fi
  223. ./autogen.sh
  224. status=$?
  225. if [[ $status -ne 0 ]]; then
  226. echo -e "\nautogen failed"
  227. exit $status
  228. fi
  229. cd $HERE
  230. fi
  231. if [[ "$CONFIGURE" == "t" ]]
  232. then
  233. ALLCONFFLAGS=`echo "$CONFFLAGS --prefix=$INSTALLPREFIX"`
  234. cd $SRCROOT
  235. if [ ! -f configure ]
  236. then
  237. echo "Configure script not found in $SRCROOT. Run '$0 autogen' first"
  238. exit 1
  239. fi
  240. ./configure $ALLCONFFLAGS
  241. status=$?
  242. if [[ $status -ne 0 ]]; then
  243. echo -e "\nConfigure failed"
  244. exit $status
  245. fi
  246. cd $HERE
  247. fi
  248. if [[ "$BUILD" == "t" ]]
  249. then
  250. cd $SRCROOT
  251. make
  252. status=$?
  253. if [[ $status -ne 0 ]]; then
  254. echo -e "\nBuild failed"
  255. exit $status
  256. fi
  257. cd $HERE
  258. fi
  259. if [[ "$INSTALL" == "t" ]]
  260. then
  261. cd $SRCROOT
  262. make install
  263. status=$?
  264. if [[ $status -ne 0 ]]; then
  265. echo -e "\nInstall failed"
  266. exit $status
  267. fi
  268. cd $HERE
  269. fi
  270. if [[ "$PACKAGE" == "t" ]]
  271. then
  272. # Test the existence of required files
  273. if [ ! -e $INSTALLPREFIX/bin/inkscape ]
  274. then
  275. echo "The inkscape executable \"$INSTALLPREFIX/bin/inkscape\" cound not be found."
  276. exit 1
  277. fi
  278. if [ ! -e $SRCROOT/Info.plist ]
  279. then
  280. echo "The file \"$SRCROOT/Info.plist\" could not be found, please re-run configure."
  281. exit 1
  282. fi
  283. # Set python command line option (if PYTHON_MODULES location is not empty, then add the python call to the command line, otherwise, stay empty)
  284. if [[ "$PYTHON_MODULES" != "" ]]; then
  285. PYTHON_MODULES="-py $PYTHON_MODULES"
  286. # TODO: fix this: it does not allow for spaces in the PATH under this form and cannot be quoted
  287. fi
  288. # Create app bundle
  289. ./osx-app.sh $STRIP -b $INSTALLPREFIX/bin/inkscape -p $SRCROOT/Info.plist $PYTHON_MODULES
  290. status=$?
  291. if [[ $status -ne 0 ]]; then
  292. echo -e "\nApplication bundle creation failed"
  293. exit $status
  294. fi
  295. fi
  296. function checkversion {
  297. DEPVER=`pkg-config --modversion $1 2>/dev/null`
  298. if [[ "$?" == "1" ]]; then
  299. DEPVER="Not included"
  300. fi
  301. echo "$DEPVER"
  302. }
  303. if [[ "$DISTRIB" == "t" ]]
  304. then
  305. # Create dmg bundle
  306. ./osx-dmg.sh -p "Inkscape.app"
  307. status=$?
  308. if [[ $status -ne 0 ]]; then
  309. echo -e "\nDisk image creation failed"
  310. exit $status
  311. fi
  312. mv Inkscape.dmg $DMGFILE
  313. # Prepare information file
  314. echo "Build information on `date` for `whoami`:
  315. For OS X Ver $TARGETNAME ($TARGETVERSION)
  316. Architecture $TARGETARCH
  317. Build system information:
  318. OS X Version $OSXVERSION
  319. Architecture $ARCH
  320. MacPorts Ver `port version | cut -f2 -d \ `
  321. GCC `$CXX --version | grep GCC`
  322. Included dependency versions:
  323. GTK `checkversion gtk+-2.0`
  324. GTKmm `checkversion gtkmm-2.4`
  325. Cairo `checkversion cairo`
  326. Cairomm `checkversion cairomm-1.0`
  327. CairoPDF `checkversion cairo-pdf`
  328. Fontconfig `checkversion fontconfig`
  329. Pango `checkversion pango`
  330. LibXML2 `checkversion libxml-2.0`
  331. LibXSLT `checkversion libxslt`
  332. LibSigC++ `checkversion sigc++-2.0`
  333. LibPNG `checkversion libpng`
  334. GSL `checkversion gsl`
  335. ImageMagick `checkversion ImageMagick`
  336. Poppler `checkversion poppler-cairo`
  337. LittleCMS `checkversion lcms`
  338. GnomeVFS `checkversion gnome-vfs-2.0`
  339. LibWPG `checkversion libwpg-0.1`
  340. Configure options:
  341. $CONFFLAGS" > $INFOFILE
  342. if [[ "$STRIP" == "t" ]]; then
  343. echo "Debug info
  344. no" >> $INFOFILE
  345. else
  346. echo "Debug info
  347. yes" >> $INFOFILE
  348. fi
  349. fi
  350. if [[ "$UPLOAD" == "t" ]]
  351. then
  352. # Provide default for user name on modevia
  353. if [[ "$MODEVIA_NAME" == "" ]]; then
  354. MODEVIA_NAME=$USER
  355. fi
  356. # Uploasd file
  357. scp $DMGFILE $INFOFILE "$MODEVIA_NAME"@inkscape.modevia.com:inkscape/docs/macosx-snap/
  358. status=$?
  359. if [[ $status -ne 0 ]]; then
  360. echo -e "\nUpload failed"
  361. exit $status
  362. fi
  363. fi
  364. if [[ "$PACKAGE" == "t" || "$DISTRIB" == "t" ]]; then
  365. # open a Finder window here to admire what we just produced
  366. open .
  367. fi
  368. exit 0