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 2006
16 # Licensed under GNU General Public License
17 #
19 ############################################################
21 # User modifiable parameters
22 #----------------------------------------------------------
23 # Configure flags
24 CONFFLAGS="--disable-static --enable-shared --enable-osxapp"
25 # Libraries prefix
26 LIBPREFIX="/opt/local"
28 ############################################################
30 # Help message
31 #----------------------------------------------------------
32 help()
33 {
35 echo -e "
36 Compilation script for Inkscape on Mac OS X.
38 \033[1mUSAGE\033[0m
39 $0 [options] action[s]
41 \033[1mACTIONS & OPTIONS\033[0m
42 \033[1mh,help\033[0m
43 display this help message
44 \033[1mu,up,update\033[0m
45 update an existing checkout from svn (run svn up)
46 \033[1ma,auto,autogen\033[0m
47 prepare configure script (run autogen.sh). This is only necessary
48 for a fresh svn checkout or after make distclean.
49 \033[1mc,conf,configure\033[0m
50 configure the build (run configure). Edit your configuration
51 options in $0
52 \033[1m-p,--prefix\033[0m specify install prefix (configure step only)
53 \033[1mb,build\033[0m
54 build Inkscape (run make)
55 \033[1mi,install\033[0m
56 install the build products locally, inside the source
57 directory (run make install)
58 \033[1mp,pack,package\033[0m
59 package Inkscape in a double clickable .app bundle
60 \033[1m-s,--strip\033[0m remove debugging information in Inkscape package
61 \033[1md,dist,distrib\033[0m
62 store Inkscape.app in a disk image (dmg) for distribution
63 \033[1m-py,--with-python\033[0m specify python packages path for inclusion into the dmg image
64 \033[1mall\033[0m
65 do everything (update, configure, build, install, package, distribute)
67 \033[1mEXAMPLES\033[0m
68 \033[1m$0 conf build install\033[0m
69 configure, build and install a dowloaded version of Inkscape in the default
70 directory, keeping debugging information.
71 \033[1m$0 u a c b -p ~ i -s p -py ~/pyxml/ d\033[0m
72 update an svn checkout, prepare configure script, configure,
73 build and install Inkscape in the user home directory (~).
74 Then package Inkscape withouth debugging information,
75 with python packages from ~/pyxml/ and prepare a dmg for
76 distribution."
77 }
79 # Parameters
80 #----------------------------------------------------------
81 # Paths
82 HERE=`pwd`
83 SRCROOT=$HERE/../.. # we are currently in packaging/macosx
85 # Defaults
86 if [ "$INSTALLPREFIX" = "" ]
87 then
88 INSTALLPREFIX=$SRCROOT/Build/
89 fi
90 SVNUPDATE="f"
91 AUTOGEN="f"
92 CONFIGURE="f"
93 BUILD="f"
94 INSTALL="f"
95 PACKAGE="f"
96 DISTRIB="f"
98 STRIP="f"
99 PYTHON="f"
101 # Parse command line options
102 #----------------------------------------------------------
103 while [ "$1" != "" ]
104 do
105 case $1 in
106 h|help)
107 help
108 exit 1 ;;
109 all)
110 SVNUPDATE="t"
111 AUTOGEN="t"
112 CONFIGURE="t"
113 BUILD="t"
114 INSTALL="t"
115 PACKAGE="t"
116 DISTRIB="t" ;;
117 u|up|update)
118 SVNUPDATE="t" ;;
119 a|auto|autogen)
120 AUTOGEN="t" ;;
121 c|conf|configure)
122 CONFIGURE="t" ;;
123 b|build)
124 BUILD="t" ;;
125 i|install)
126 INSTALL="t" ;;
127 p|pack|package)
128 PACKAGE="t" ;;
129 d|dist|distrib)
130 DISTRIB="t" ;;
131 -p|--prefix)
132 INSTALLPREFIX=$2
133 shift 1 ;;
134 -s|-strip)
135 STRIP="t" ;;
136 -py|--with-python)
137 PYTHON="t"
138 PYTHONDIR="$2"
139 shift 1 ;;
140 esac
141 shift 1
142 done
145 # Set environment variables
146 # ----------------------------------------------------------
147 export LIBPREFIX
149 # Specific environment variables
150 # automake seach path
151 export CPATH="$LIBPREFIX/include"
152 # configure search path
153 export CPPFLAGS="-I$LIBPREFIX/include"
154 export LDFLAGS="-L$LIBPREFIX/lib"
155 # compiler arguments
156 export CFLAGS="-O3 -Wall"
157 export CXXFLAGS="$CFLAGS"
158 # add X11 executables and libraries [does not seem to be required now]
159 # export PATH="/usr/X11R6/bin:$PATH"
160 # export LIBRARY_PATH="/usr/X11R6/lib:$LIBPREFIX/lib"
161 # pkgconfig path [does not seem to be required either]
162 # export PKG_CONFIG_PATH="$LIBPREFIX/lib/pkgconfig"
165 # Actions
166 # ----------------------------------------------------------
167 if [[ "$SVNUPDATE" == "t" ]]
168 then
169 cd $SRCROOT
170 svn up
171 status=$?
172 if [[ $status -ne 0 ]]; then
173 echo -e "\nSVN update failed"
174 exit $status
175 fi
176 cd $HERE
177 fi
179 if [[ "$AUTOGEN" == "t" ]]
180 then
181 cd $SRCROOT
182 ./autogen.sh
183 status=$?
184 if [[ $status -ne 0 ]]; then
185 echo -e "\nautogen failed"
186 exit $status
187 fi
188 cd $HERE
189 fi
191 if [[ "$CONFIGURE" == "t" ]]
192 then
193 ALLCONFFLAGS=`echo "$CONFFLAGS --prefix=$INSTALLPREFIX"`
194 cd $SRCROOT
195 if [ ! -f configure ]
196 then
197 echo "Configure script not found in $SRCROOT. Run autogen.sh first"
198 exit 1
199 fi
200 ./configure $ALLCONFFLAGS
201 status=$?
202 if [[ $status -ne 0 ]]; then
203 echo -e "\nConfigure failed"
204 exit $status
205 fi
206 cd $HERE
207 fi
209 if [[ "$BUILD" == "t" ]]
210 then
211 cd $SRCROOT
212 make
213 status=$?
214 if [[ $status -ne 0 ]]; then
215 echo -e "\nBuild failed"
216 exit $status
217 fi
218 cd $HERE
219 fi
221 if [[ "$INSTALL" == "t" ]]
222 then
223 cd $SRCROOT
224 make install
225 status=$?
226 if [[ $status -ne 0 ]]; then
227 echo -e "\nInstall failed"
228 exit $status
229 fi
230 cd $HERE
231 fi
233 if [[ "$PACKAGE" == "t" ]]
234 then
236 # Detect strip parameter
237 if [[ "$STRIP" == "t" ]]; then
238 STRIPPARAM="-s"
239 else
240 STRIPPARAM=""
241 fi
243 # Test the existence of required files
244 if [ ! -e $INSTALLPREFIX/bin/inkscape ]
245 then
246 echo "The inkscape executable \"$INSTALLPREFIX/bin/inkscape\" cound not be found."
247 exit 1
248 fi
249 if [ ! -e $SRCROOT/Info.plist ]
250 then
251 echo "The file \"$SRCROOT/Info.plist\" could not be found, please re-run configure."
252 exit 1
253 fi
255 # Create app bundle
256 ./osx-app.sh $STRIPPARAM $INSTALLPREFIX/bin/inkscape $SRCROOT/Info.plist
257 status=$?
258 if [[ $status -ne 0 ]]; then
259 echo -e "\nApplication bundle creation failed"
260 exit $status
261 fi
262 fi
264 if [[ "$DISTRIB" == "t" ]]
265 then
266 REVISION=`head -n 4 ../../.svn/entries | tail -n 1`
267 ARCH=`arch | tr [p,c] [P,C]`
268 NEWNAME="Inkscape-$REVISION-$ARCH"
269 DMGFILE="$NEWNAME.dmg"
270 INFOFILE="$NEWNAME-info.txt"
272 # Create dmg bundle
273 if [[ "$PYTHON" == "t" ]]; then
274 ./osx-dmg.sh -py "$PYTHONDIR"
275 else
276 ./osx-dmg.sh
277 fi
278 status=$?
279 if [[ $status -ne 0 ]]; then
280 echo -e "\nDisk image creation failed"
281 exit $status
282 fi
284 mv Inkscape.dmg $DMGFILE
286 # Prepare information file
287 echo "Version information on $DATE for `whoami`:
288 OS X `/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d \:`
289 Architecture $ARCH
290 DarwinPorts `port version | cut -f2 -d \ `
291 GCC `gcc --version | grep GCC`
292 GTK `pkg-config --modversion gtk+-2.0`
293 GTKmm `pkg-config --modversion gtkmm-2.4`
294 Cairo `pkg-config --modversion cairo`
295 Cairomm `pkg-config --modversion cairomm-1.0`
296 CairoPDF `pkg-config --modversion cairo-pdf`
297 Pango `pkg-config --modversion pango`
298 Configure options:
299 $CONFFLAGS" > $INFOFILE
300 if [[ "$STRIP" == "t" ]]; then
301 echo "Debug info
302 no" >> $INFOFILE
303 else
304 echo "Debug info
305 yes" >> $INFOFILE
306 fi
308 # open a Finder window here
309 open .
310 fi
312 exit 0