Code

ad7a2eff642fa54627a8047ee83ffc71da416956
[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 and
60     store it in a .dmg image for distribution
61     \033[1m-s,--strip\033[0m    remove debugging information in Inkscape package
62     \033[1m-py,--with-python\033[0m     specify python packages path for inclusion into the dmg image
63         
64 \033[1mEXAMPLES\033[0m
65   \033[1m$0 conf build install\033[0m
66     configure, build and install a dowloaded version of Inkscape in the default
67     directory, keeping debugging information.   
68   \033[1m$0 -p ~ -s -py ~/pyxml/ u a c b i p\033[0m
69     update an svn checkout, prepare configure script, configure,
70     build and install Inkscape in the user home directory.      
71     Then package Inkscape withouth debugging information,
72     with python packages from ~/pyxml/ and prepare it for   
73     distribution."
74 }
76 # Parameters
77 #----------------------------------------------------------
78 # Paths
79 HERE=`pwd`
80 SRCROOT=$HERE/../..             # we are currently in packaging/macosx
82 # Defaults
83 INSTALLPREFIX=$SRCROOT/Build/
84 SVNUPDATE="f"
85 AUTOGEN="f"
86 CONFIGURE="f"
87 BUILD="f"
88 INSTALL="f"
89 PACKAGE="f"
91 STRIP="f"
92 PYTHON="f"
94 # Parse command line options
95 #----------------------------------------------------------
96 while [ "$1" != "" ]
97 do
98         case $1 in
99         h|help)
100                 help 
101                 exit 1 ;;
102         u|up|update)
103                 SVNUPDATE="t" ;;
104         a|auto|autogen)
105                 AUTOGEN="t" ;;
106         c|conf|configure)
107                 CONFIGURE="t" ;;
108         b|build)
109                 BUILD="t" ;;
110         i|install)
111                 INSTALL="t" ;;
112         p|pack|package)
113                 PACKAGE="t" ;;
114         # -p|--prefix)
115                 #INSTALLPREFIX=$2
116                 #shift 1 ;;
117         -s|-strip)
118                 STRIP="t" ;;
119         -py|--with-python)
120                 PYTHON="t" 
121                 PYTHONDIR=$2
122                 shift 1 ;;
123         esac
124         shift 1
125 done
128 # Set environment variables
129 # ----------------------------------------------------------
130 export LIBPREFIX
132 # Specific environment variables
133 #  automake seach path
134 export CPATH="$LIBPREFIX/include"
135 #  configure search path
136 export CPPFLAGS="-I$LIBPREFIX/include"
137 export LDFLAGS="-L$LIBPREFIX/lib"
138 #  compiler arguments
139 export CFLAGS="-O3 -Wall"
140 export CXXFLAGS="$CFLAGS"
141 # add X11 executables and libraries [does not seem to be required now]
142 # export PATH="/usr/X11R6/bin:$PATH"
143 # export LIBRARY_PATH="/usr/X11R6/lib:$LIBPREFIX/lib"
144 # pkgconfig path [does not seem to be required either]
145 # export PKG_CONFIG_PATH="$LIBPREFIX/lib/pkgconfig"
148 # Actions
149 # ----------------------------------------------------------
150 if [[ "$SVNUPDATE" == "t" ]]
151 then
152         cd $SRCROOT
153         svn up
154         cd $HERE
155 fi
157 if [[ "$AUTOGEN" == "t" ]]
158 then
159         cd $SRCROOT
160         ./autogen.sh
161         cd $HERE
162 fi
164 if [[ "$CONFIGURE" == "t" ]]
165 then
166         ALLCONFFLAGS=`echo "$CONFFLAGS --prefix=$INSTALLPREFIX"`
167         cd $SRCROOT
168         ./configure $ALLCONFFLAGS
169         cd $HERE
170 fi
172 if [[ "$BUILD" == "t" ]]
173 then
174         cd $SRCROOT
175         make
176         cd $HERE
177 fi
179 if [[ "$INSTALL" == "t" ]] 
180 then
181         cd $SRCROOT
182         make install
183         cd $HERE
184 fi
186 if [[ "$PACKAGE" == "t" ]]; then
187         if [[ "$STRIP" == "t" ]]; then
188                 STRIPPARAM="-s"
189         else
190                 STRIPPARAM=""
191         fi
192         ./osx-app.sh $STRIPPARAM $INSTALLPREFIX/bin/inkscape $SRCROOT/Info.plist
194         if [[ "$PYTHON" == "t" ]]; then
195                 ./osx-dmg.sh -py "$PYTHONDIR"
196         else
197                 ./osx-dmg.sh
198         fi
200         DATE=`date "+%Y%m%d"`
201         mv Inkscape.dmg Inkscape_$DATE.dmg
202         
203         # Prepare information file
204         INFOFILE=Inkscape_$DATE-info.txt
205         echo "Version information on $DATE for `whoami`:
206         OS X      `/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d \:`
207         DarwinPorts  `port version | cut -f2 -d \ `
208         GCC          `gcc --version | grep GCC`
209         GTK          `pkg-config --modversion gtk+-2.0`
210         GTKmm        `pkg-config --modversion gtkmm-2.4`
211         Cairo        `pkg-config --modversion cairo`
212         Cairomm      `pkg-config --modversion cairomm-1.0`
213         CairoPDF     `pkg-config --modversion cairo-pdf`
214         Pango        `pkg-config --modversion pango`
215 Configure options:
216         $CONFFLAGS" > $INFOFILE
218         if [[ "$STRIP" == "t" ]]; then
219                 echo "Debug info
220         no" >> $INFOFILE
221         else
222                 echo "Debug info
223         yes" >> $INFOFILE
224         fi
225         
226         # open a Finder window here
227         open .
228 fi
230 exit 0