Code

modified the way -py option is handled to account for spaces in the PATH and avoid...
[inkscape.git] / packaging / macosx / osx-build.sh
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         
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 -p ~ -s -py ~/pyxml/ u a c b i p d\033[0m
70     update an svn checkout, prepare configure script, configure,
71     build and install Inkscape in the user home directory.      
72     Then package Inkscape withouth debugging information,
73     with python packages from ~/pyxml/ and prepare it for   
74     distribution."
75 }
77 # Parameters
78 #----------------------------------------------------------
79 # Paths
80 HERE=`pwd`
81 SRCROOT=$HERE/../..             # we are currently in packaging/macosx
83 # Defaults
84 if [ "$INSTALLPREFIX" = "" ]
85 then
86         INSTALLPREFIX=$SRCROOT/Build/
87 fi
88 SVNUPDATE="f"
89 AUTOGEN="f"
90 CONFIGURE="f"
91 BUILD="f"
92 INSTALL="f"
93 PACKAGE="f"
94 DISTRIB="f"
96 STRIP="f"
97 PYTHON="f"
99 # Parse command line options
100 #----------------------------------------------------------
101 while [ "$1" != "" ]
102 do
103         case $1 in
104         h|help)
105                 help 
106                 exit 1 ;;
107    u|up|update)
108                 SVNUPDATE="t" ;;
109    a|auto|autogen)
110                 AUTOGEN="t" ;;
111         c|conf|configure)
112                 CONFIGURE="t" ;;
113         b|build)
114                 BUILD="t" ;;
115         i|install)
116                 INSTALL="t" ;;
117         p|pack|package)
118                 PACKAGE="t" ;;
119         d|dist|distrib)
120                 DISTRIB="t" ;;
121         # -p|--prefix)
122         #       INSTALLPREFIX=$2
123         #       shift 1 ;;
124         -s|-strip)
125                 STRIP="t" ;;
126         -py|--with-python)
127                 PYTHON="t" 
128                 PYTHONDIR="$2"
129                 shift 1 ;;
130         esac
131         shift 1
132 done
135 # Set environment variables
136 # ----------------------------------------------------------
137 export LIBPREFIX
139 # Specific environment variables
140 #  automake seach path
141 export CPATH="$LIBPREFIX/include"
142 #  configure search path
143 export CPPFLAGS="-I$LIBPREFIX/include"
144 export LDFLAGS="-L$LIBPREFIX/lib"
145 #  compiler arguments
146 export CFLAGS="-O3 -Wall"
147 export CXXFLAGS="$CFLAGS"
148 # add X11 executables and libraries [does not seem to be required now]
149 # export PATH="/usr/X11R6/bin:$PATH"
150 # export LIBRARY_PATH="/usr/X11R6/lib:$LIBPREFIX/lib"
151 # pkgconfig path [does not seem to be required either]
152 # export PKG_CONFIG_PATH="$LIBPREFIX/lib/pkgconfig"
155 # Actions
156 # ----------------------------------------------------------
157 if [[ "$SVNUPDATE" == "t" ]]
158 then
159         cd $SRCROOT
160         svn up
161         status=$?
162         if [[ $status -ne 0 ]]; then
163                 echo -e "\nSVN update failed"
164                 exit $status
165         fi
166         cd $HERE
167 fi
169 if [[ "$AUTOGEN" == "t" ]]
170 then
171         cd $SRCROOT
172         ./autogen.sh
173         status=$?
174         if [[ $status -ne 0 ]]; then
175                 echo -e "\nautogen failed"
176                 exit $status
177         fi
178         cd $HERE
179 fi
181 if [[ "$CONFIGURE" == "t" ]]
182 then
183         ALLCONFFLAGS=`echo "$CONFFLAGS --prefix=$INSTALLPREFIX"`
184         cd $SRCROOT
185         if [ ! -f configure ]
186         then
187                 echo "Configure script not found in $SRCROOT. Run autogen.sh first"
188                 exit 1
189         fi
190         ./configure $ALLCONFFLAGS
191         status=$?
192         if [[ $status -ne 0 ]]; then
193                 echo -e "\nConfigure failed"
194                 exit $status
195         fi
196         cd $HERE
197 fi
199 if [[ "$BUILD" == "t" ]]
200 then
201         cd $SRCROOT
202         make
203         status=$?
204         if [[ $status -ne 0 ]]; then
205                 echo -e "\nBuild failed"
206                 exit $status
207         fi
208         cd $HERE
209 fi
211 if [[ "$INSTALL" == "t" ]] 
212 then
213         cd $SRCROOT
214         make install
215         status=$?
216         if [[ $status -ne 0 ]]; then
217                 echo -e "\nInstall failed"
218                 exit $status
219         fi
220         cd $HERE
221 fi
223 if [[ "$PACKAGE" == "t" ]]
224 then
225         
226         # Detect strip parameter
227         if [[ "$STRIP" == "t" ]]; then
228                 STRIPPARAM="-s"
229         else
230                 STRIPPARAM=""
231         fi
232         
233         # Test the existence of required files
234         if [ ! -e $INSTALLPREFIX/bin/inkscape ]
235         then
236                 echo "The inkscape executable \"$INSTALLPREFIX/bin/inkscape\" cound not be found."
237                 exit 1
238         fi
239         if [ ! -e $SRCROOT/Info.plist ]
240         then
241                 echo "The file \"$SRCROOT/Info.plist\" could not be found, please re-run configure."
242                 exit 1
243         fi
244         
245         # Create app bundle
246         ./osx-app.sh $STRIPPARAM $INSTALLPREFIX/bin/inkscape $SRCROOT/Info.plist
247         status=$?
248         if [[ $status -ne 0 ]]; then
249                 echo -e "\nApplication bundle creation failed"
250                 exit $status
251         fi
252 fi
254 if [[ "$DISTRIB" == "t" ]]
255 then    
256         # Create dmg bundle
257         if [[ "$PYTHON" == "t" ]]; then
258                 ./osx-dmg.sh -py "$PYTHONDIR"
259         else
260                 ./osx-dmg.sh
261         fi
262         status=$?
263         if [[ $status -ne 0 ]]; then
264                 echo -e "\nDisk image creation failed"
265                 exit $status
266         fi
268         DATE=`date "+%Y%m%d"`
269         mv Inkscape.dmg Inkscape_$DATE.dmg
270         
271         # Prepare information file
272 #       INFOFILE=Inkscape_$DATE-info.txt
273 #       echo "Version information on $DATE for `whoami`:
274 #       OS X      `/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d \:`
275 #       DarwinPorts  `port version | cut -f2 -d \ `
276 #       GCC          `gcc --version | grep GCC`
277 #       GTK          `pkg-config --modversion gtk+-2.0`
278 #       GTKmm        `pkg-config --modversion gtkmm-2.4`
279 #       Cairo        `pkg-config --modversion cairo`
280 #       Cairomm      `pkg-config --modversion cairomm-1.0`
281 #       CairoPDF     `pkg-config --modversion cairo-pdf`
282 #       Pango        `pkg-config --modversion pango`
283 # Configure options:
284 #       $CONFFLAGS" > $INFOFILE
285 #       if [[ "$STRIP" == "t" ]]; then
286 #               echo "Debug info
287 #       no" >> $INFOFILE
288 #       else
289 #               echo "Debug info
290 #       yes" >> $INFOFILE
291 #       fi
292         
293         # open a Finder window here
294         open .
295 fi
297 exit 0