Difference between revisions of "CompilingMacOsX"

From Inkscape Wiki
Jump to navigation Jump to search
m (modified title)
(Updated the structure of the document and added some Packaging tips)
Line 10: Line 10:
:http://www.apple.com/downloads/macosx/apple/x11formacosx.html
:http://www.apple.com/downloads/macosx/apple/x11formacosx.html


== Compiling How To ==
= Compiling Inkscape =


<!--'''Note''': You could use the [http://fink.sourceforge.net/pdb/package.php/inkscape Inkscape package] from the [http://fink.sourceforge.net Fink project] to install Inkscape from source but this package is usally older that the precompiled Development Versions and even that the Official Release so this does not seem useful.-->
== Requirements ==
 
To compile Inkscape from source you will need:
'''Requirements''':
*Mac OS X 10.3 of higher
*Mac OS X 10.3 of higher
*A full [http://fink.sourceforge.net/faq/usage-fink.php?phpLang=en#unstable unstable fink] installation
*A full [http://fink.sourceforge.net/faq/usage-fink.php?phpLang=en#unstable unstable fink] installation
Line 20: Line 19:
*A [http://darwinports.opendarwin.org/ DarwinPorts] install if you want to use inkboard.
*A [http://darwinports.opendarwin.org/ DarwinPorts] install if you want to use inkboard.


'''Essential dependencies''':
You need to install software on which Inkscape depends, using Fink and/or DarwinPorts.


These are necessary for Inkscape to compile. In a Terminal type:
'''Essential dependencies'''
They are necessary for Inkscape to compile. In a Terminal type:
<pre>
<pre>
fink install \
fink install \
Line 38: Line 38:
</pre>
</pre>


You need automake 1.8 and not the latest in Fink (1.9.6-1). Fink installs many packages from source so this is usually long.
You need version 1.8 of automake 1.8 (and not 1.9, the latest in Fink). Fink installs many packages from source so this is usually long.


'''Optional dependencies''':
'''Optional dependencies'''


To enable some additional functionality in Inkscape you might want to install:
To enable some additional functionality in Inkscape you might want to install:
* <code>lcms</code> : color management via LittleCMS
* <code>lcms</code> : color management via LittleCMS
* <code>loudmouth-1.0</code> : collaborative whiteboard (only available in DarwinPorts)
* <code>loudmouth >= 1.0</code> : collaborative whiteboard (only available in DarwinPorts)
* <code>boost1.31</code> : auto-organisation of connectors
* <code>boost >= 1.32</code> : auto-organisation of connectors
* <code>gnome-vfs</code>
* <code>gnome-vfs</code>
* <code>gnome-print</code>
* <code>gnome-print</code>
Line 52: Line 52:




'''Setting the build environment''':


Fink hierarchy is not searched for libraries by default. Therefore, before the configuration starts, some environment variables need to be set<!--(taken right out of fink's <code>.info</code> file)-->. In addition, you must make sure that Inkscape is compiled with the compiler that Fink uses, otherwise Inkscape won't link properly. On old 10.3 and 10.4 Fink installs, you compiler is probably gcc-3.3. On fresh 10.4 Fink installs, your compiler is probably gcc-4.0. In addition, to speed up the compilation a bit you could use <code>ccache</code> if you have it installed.
== Setting the build environment ==


The environment variables are presented in bash syntax here. You can create a file named <code>set_env_variables.sh</code> for example and copy/paste this inside:
Fink's hierarchy is not searched for libraries by default. Therefore, before the configuration starts, some environment variables need to be set. The environment variables are presented in bash syntax here. You can create a file named <code>set_env_variables.sh</code> and copy/paste this inside:
<pre>
<pre>
#!/bin/bash
FINK="/sw"
FINK="/sw"
export CFLAGS="-O3 -Wall"
export LIBRARY_PATH="/usr/X11R6/lib:$FINK/lib"
export CXXFLAGS="$CFLAGS"
export CPATH="$FINK/include"
export CPPFLAGS="-I$FINK/include"
export PATH="/usr/X11R6/bin:$PATH"
export LDFLAGS="-L$FINK/lib"
export CPPFLAGS="-I$FINK/include"  
export CPATH="$FINK/include"
export LDFLAGS="-L$FINK/lib"
export PATH="/usr/X11R6/bin:$PATH"
export CFLAGS="-O3 -Wall"
export LIBRARY_PATH="/usr/X11R6/lib:$FINK/lib"
export CXXFLAGS="$CFLAGS"
export PKG_CONFIG_PATH="$FINK/lib/pkgconfig"
export PKG_CONFIG_PATH="$FINK/lib/pkgconfig"
</pre>
</pre>


And add this couple of line to set the compiler:
 
* On 10.3 and fresh Fink installs on 10.4:
In addition, you must make sure that Inkscape is compiled with the compiler version that Fink uses, otherwise Inkscape will not link properly. To determine which compiler to use type:
<pre>
<pre>
export CC="gcc"
 
export CXX="g++"
head -n 5 $FINK/etc/fink.conf | grep "Distribution"
</pre>
</pre>
* With old Fink installs on 10.4:
 
If your fink distribution is 10.4 add:
<pre>
<pre>
export CC="gcc-3.3"
export CC="gcc-4.0"
export CXX="g++-3.3"
export CXX="g++-4.0"
</pre>
</pre>
* With ccache:
to <code>set_env_variables.sh</code>, else (10.3, 10.4-transitional) add:
<pre>
export CC="gcc-3.3"
export CXX="g++-3.3"
</pre>
 
You can also use <code>ccache</code> (<code>fink install ccache</code>) to speed up the compilation a bit. To do so, modify the compiler lines accordingly:
<pre>
<pre>
export CC="ccache gcc-??"
export CC="ccache gcc-??"
export CXX="ccache g++-??"
export CXX="ccache g++-??"
</pre>
</pre>


Then, open a Terminal and, in the directory where you created the file <code>set_env_variables.sh</code>, type:
Eventually, open a Terminal and, in the directory where you created the file <code>set_env_variables.sh</code>, type:
<pre>
<pre>
bash
bash; source set_env_variables.sh
source set_env_variables.sh
</pre>
</pre>


Then you need to build the configure script. Cd to Inkscape's source directory and run:
 
== Configuring ==
 
 
You might need to build the configure script first (if you compile Inkscape for the first time). Cd to Inkscape's source directory and run:
<pre>
<pre>
./autogen.sh
./autogen.sh
</pre>
</pre>


'''Configuring''':
Then run the configure script:
 
Cd to Inkscape's sources directory and type
<pre>
<pre>
./configure --prefix=/path/to/build/products/ --enable-osxapp
./configure --prefix=/path/to/build/products/ --enable-osxapp
</pre>
</pre>


The <code>--prefix</code> option sets the directory where the build products are placed. It must be somewhere you have write access to. The option <code>--enable-osxapp</code> allows you to package Inkscape into an <code>.app</code> bundle in order to access it like a regular OS X application. Remove this option if you only want to build Inskscape, not to package it afterwards. Of course you can add here classic compilation options such as <code>--enable-lcms</code> for color management or <code>--enable-inkboard</code> for whitboard functionality.
The <code>--prefix</code> option sets the directory where the build products are placed. It must be somewhere you have write access to. The option <code>--enable-osxapp</code> allows you to package Inkscape into an <code>.app</code> bundle in order to access it like a regular OS X application. Remove this option if you only want to build Inskscape, not to package it afterwards. Of course you can add here classic configuration options such as <code>--enable-lcms</code> for color management or <code>--enable-inkboard</code> for whitboard functionality.


'''Building''':
== Building ==
Piece of cake:
<pre>
<pre>
make
make
make install
make install
</pre>
</pre>


'''Packaging''':
 
 
= Packaging Inkscape into an .app bundle =
 
 
== Creating the .app and a simple .dmg ==


Assuming that you have used the <code>--enable-osxapp</code> option during <code>configure</code>, the process is fully automatized. You just have to open a Terminal, cd to Inkscape's sources directory and type:
Assuming that you have used the <code>--enable-osxapp</code> option during <code>configure</code>, the process is fully automatized. You just have to open a Terminal, cd to Inkscape's sources directory and type:
<pre>
<pre>
cd packaging
cd packaging
./osx-app.sh /path/to/build/products/bin/inkscape ../Info.plist macosx
./osx-app.sh -s /path/to/build/products/bin/inkscape ../Info.plist macosx
</pre>
</pre>
The <code>-s</code> options produces an app bundle stripped of debugging information (which is therefore smaller). Omit this option if you want to keep debugging info.
Either way, this creates two files in current directory: Inkscape.app that you can copy to your Applications directory and Inkscape.dmg for distribution.


You will end up with two files in current directory: Inkscape.app that you can copy to your Applications directory and Inkscape.dmg for distribution.


-- Kees Cook, Michael Wybrow, Jean-Olivier Irisson
== Creating a more complete .dmg ==


----
Many Mac OS applications are distributed in a dmg with a background picture and some basic installation instructions. In order to distribute Inkscape this way you first need to create an .app bundle of Inkscape as described above. Then you need to create a read-write disc image big enough to contain the app bundle:
<pre>
hdiutil create -size 55m -fs HFS+ -volname "Inkscape" RWinkscape.dmg
</pre>
This step has only to be done once. For next builds you will just have to reattach the image and copy the new Inkscape .app inside it. To attach the disc image, double click the .dmg or use:
<pre>
hdiutil attach RWinkscape.dmg
</pre>
 
 
The second step is to copy everything you need inside the attached disc image (which is available as a white disc icon named "Inskcape" on your Desktop). You need:
*the .app bundle
*an alias to the Applications folder (CTRL+click Applications and select "Make Alias")
*the [http://jo.irisson.free.fr/dropbox/inkscape/background.png background picture]
Finally you need to improve the appearance of the disc image. First you need to set the background image:
*navigate to the attached disc image with the Finder
*switch the Finder to Icon's view (View > as Icons)
*open the View Options window (View > Show View Options)
*check the radio button to select options for "This window only"
*in the "Background" section, select "Picture" and choose the background picture you just copied in the disc image.
You may want to make the background image file invisible to have a cleaner aspect:
<pre>
/Developer/Tools/SetFile -a V /Volumes/Inkscape/background.png
</pre>
The icon of the file should become kind of transparent and you should not see it anymore if you relaunch the Finder.
Enventually, arrange the Finder window as you want people to see it. You may want to hide the Finder brushed metal skin to have a smaller window (click the elongated transparent button in the top right corner of the Finder window), fit the window to the background image, move Inkscape's icon to be next to the arrow (you may need to deselect some presentation options in View > Show View Options) and center the window in your screen.
You should end up with a window looking like [http://jo.irisson.free.fr/dropbox/inkscape/inkscape_distrib.png this].
 
The last step consists in creating a compressed read-only disc image from this read-write disc image:
<pre>
hdiutil detach /Volumes/Inkscape
DATE=`date "+%Y%m%d"`
hdiutil convert -format UDCO -o Inkscape_$DATE.dmg RWinkscape.dmg
</pre>
This creates a smaller disc image with a name like Inkscape_20060424.dmg.


== Enabling python effects ==
== Enabling python effects ==

Revision as of 11:37, 25 April 2006


Before you start

Note that from version 0.42 of Inkscape a Mac OS X package (in .dmg form) will be available for official releases as well as for development versions. Both can be downloaded from Inkscape's downloads page:

http://www.inkscape.org/download.php

Inkscape for Mac OS X is an X client: it runs under the X Windows System. You will need an X Windows Server installed for it to work. For 10.4.x users, X11 can be installed from your installation DVD. For 10.3.x users, you can get Apple's X Server here:

http://www.apple.com/downloads/macosx/apple/x11formacosx.html

Compiling Inkscape

Requirements

To compile Inkscape from source you will need:

You need to install software on which Inkscape depends, using Fink and/or DarwinPorts.

Essential dependencies They are necessary for Inkscape to compile. In a Terminal type:

fink install \
        intltool \
        glib2 glib2-dev glib2-shlibs \
        gtk+2 gtk+2-shlibs gtk+2-dev \
        libpng3 libpng3-shlibs \
        libsigc++2 libsigc++2-shlibs \
        gtkmm2.4 gtkmm2.4-dev gtkmm2.4-shlibs \
        libtool14 libtool14-shlibs \
        libxml2 libxml2-shlibs \
        popt popt-shlibs \
        gc gc-shlibs \
        automake1.8

You need version 1.8 of automake 1.8 (and not 1.9, the latest in Fink). Fink installs many packages from source so this is usually long.

Optional dependencies

To enable some additional functionality in Inkscape you might want to install:

  • lcms : color management via LittleCMS
  • loudmouth >= 1.0 : collaborative whiteboard (only available in DarwinPorts)
  • boost >= 1.32 : auto-organisation of connectors
  • gnome-vfs
  • gnome-print
  • xft2

for each of these you need the developement packages as well (the name ends by -dev)


Setting the build environment

Fink's hierarchy is not searched for libraries by default. Therefore, before the configuration starts, some environment variables need to be set. The environment variables are presented in bash syntax here. You can create a file named set_env_variables.sh and copy/paste this inside:

FINK="/sw"
export CFLAGS="-O3 -Wall"
export CXXFLAGS="$CFLAGS"
export CPPFLAGS="-I$FINK/include"
export LDFLAGS="-L$FINK/lib"
export CPATH="$FINK/include"
export PATH="/usr/X11R6/bin:$PATH"
export LIBRARY_PATH="/usr/X11R6/lib:$FINK/lib"
export PKG_CONFIG_PATH="$FINK/lib/pkgconfig"


In addition, you must make sure that Inkscape is compiled with the compiler version that Fink uses, otherwise Inkscape will not link properly. To determine which compiler to use type:


head -n 5 $FINK/etc/fink.conf | grep "Distribution"

If your fink distribution is 10.4 add:

export CC="gcc-4.0"
export CXX="g++-4.0"

to set_env_variables.sh, else (10.3, 10.4-transitional) add:

export CC="gcc-3.3"
export CXX="g++-3.3"

You can also use ccache (fink install ccache) to speed up the compilation a bit. To do so, modify the compiler lines accordingly:

export CC="ccache gcc-??"
export CXX="ccache g++-??"

Eventually, open a Terminal and, in the directory where you created the file set_env_variables.sh, type:

bash; source set_env_variables.sh


Configuring

You might need to build the configure script first (if you compile Inkscape for the first time). Cd to Inkscape's source directory and run:

./autogen.sh

Then run the configure script:

./configure --prefix=/path/to/build/products/ --enable-osxapp

The --prefix option sets the directory where the build products are placed. It must be somewhere you have write access to. The option --enable-osxapp allows you to package Inkscape into an .app bundle in order to access it like a regular OS X application. Remove this option if you only want to build Inskscape, not to package it afterwards. Of course you can add here classic configuration options such as --enable-lcms for color management or --enable-inkboard for whitboard functionality.

Building

Piece of cake:

make
make install


Packaging Inkscape into an .app bundle

Creating the .app and a simple .dmg

Assuming that you have used the --enable-osxapp option during configure, the process is fully automatized. You just have to open a Terminal, cd to Inkscape's sources directory and type:

cd packaging
./osx-app.sh -s /path/to/build/products/bin/inkscape ../Info.plist macosx

The -s options produces an app bundle stripped of debugging information (which is therefore smaller). Omit this option if you want to keep debugging info.

Either way, this creates two files in current directory: Inkscape.app that you can copy to your Applications directory and Inkscape.dmg for distribution.


Creating a more complete .dmg

Many Mac OS applications are distributed in a dmg with a background picture and some basic installation instructions. In order to distribute Inkscape this way you first need to create an .app bundle of Inkscape as described above. Then you need to create a read-write disc image big enough to contain the app bundle:

hdiutil create -size 55m -fs HFS+ -volname "Inkscape" RWinkscape.dmg

This step has only to be done once. For next builds you will just have to reattach the image and copy the new Inkscape .app inside it. To attach the disc image, double click the .dmg or use:

hdiutil attach RWinkscape.dmg 


The second step is to copy everything you need inside the attached disc image (which is available as a white disc icon named "Inskcape" on your Desktop). You need:

  • the .app bundle
  • an alias to the Applications folder (CTRL+click Applications and select "Make Alias")
  • the background picture

Finally you need to improve the appearance of the disc image. First you need to set the background image:

  • navigate to the attached disc image with the Finder
  • switch the Finder to Icon's view (View > as Icons)
  • open the View Options window (View > Show View Options)
  • check the radio button to select options for "This window only"
  • in the "Background" section, select "Picture" and choose the background picture you just copied in the disc image.

You may want to make the background image file invisible to have a cleaner aspect:

/Developer/Tools/SetFile -a V /Volumes/Inkscape/background.png

The icon of the file should become kind of transparent and you should not see it anymore if you relaunch the Finder. Enventually, arrange the Finder window as you want people to see it. You may want to hide the Finder brushed metal skin to have a smaller window (click the elongated transparent button in the top right corner of the Finder window), fit the window to the background image, move Inkscape's icon to be next to the arrow (you may need to deselect some presentation options in View > Show View Options) and center the window in your screen. You should end up with a window looking like this.

The last step consists in creating a compressed read-only disc image from this read-write disc image:

hdiutil detach /Volumes/Inkscape
DATE=`date "+%Y%m%d"`
hdiutil convert -format UDCO -o Inkscape_$DATE.dmg RWinkscape.dmg 

This creates a smaller disc image with a name like Inkscape_20060424.dmg.

Enabling python effects

Many "effects" in the Effect menu of Inkscape use python as a scripting language. Mac OS X ships with python but not with pyXML which is needed by Inkscape effects. To install it you need to

  1. download the source code from sourceforge
  2. unpack the .tar.gz file
  3. cd into the newly created directory
  4. set the variable MACOSX_DEPLOYMENT_TARGET to the number of your operating system (10.3 for Panther, 10.4 for Tiger. It probably won't work on previous systems). In bash syntax this means typing:
    export MACOSX_DEPLOYMENT_TARGET=10.?
  5. move the python files and build C extensions
    python setup.py build
  6. install (the install is system wide so you need administrator rights)
    sudo python setup.py install
    and type your password.



Interesting links

Some packaging links:

http://freespace.ausgamers.com/2005/02/creating-os-x-application-bundles-step.html

http://java.sun.com/developer/technicalArticles/JavaLP/JavaToMac3/

http://gimp-app.sourceforge.net/gimp.app.howto.txt