Difference between revisions of "Mac OS X:Build from source:Application package"

From Gramps
Jump to: navigation, search
(Structure the Mac OS pages)
 
(revised instructions for Xcode and installing jhbuild, from experience on El Capitan)
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Building GRAMPS from Scratch==
+
==Building Gramps from Scratch==
  
 
Building Gramps from scratch is useful to produce a version not currently available as a binary (for example, a PPC version) or to produce a complete environment for debugging and further development, including debugging of all the C libraries Gramps uses, like gtk.
 
Building Gramps from scratch is useful to produce a version not currently available as a binary (for example, a PPC version) or to produce a complete environment for debugging and further development, including debugging of all the C libraries Gramps uses, like gtk.
  
This is a command-line process. It's not too difficult, but you'll be using Terminal.app, not XCode. Unfortunately, Gtk has so far resisted efforts to get it to successfully cross-compile PPC on Intel or vice-versa, so the whole process must be repeated on machines of each architecture. '''''WebKit will not build on 10.4 (Tiger) or earlier systems, nor will it build against a 10.4 SDK. You must be running 10.5 (Leopard) or newer for this procedure to succeed!'''''
+
This is a command-line process. It's not too difficult, but you'll be using Terminal.app, not XCode. Unfortunately, Gtk has so far resisted efforts to get it to successfully cross-compile PPC on Intel or vice-versa, so the whole process must be repeated on machines of each architecture. '''''N.B. This procedure has not been tested against OS X 10.4 Tiger. Some packages may not be compatible with that very old version of OS X.'''''
+
 
You'll need XCode, Apple's development environment. There's a copy on your OS X distribution DVD, or you can download the latest version from [http://developer.apple.com/technologies/xcode.html Apple], though you must register as a Mac developer. For Lion users, XCode is available for free from the App Store.
+
If you're not familiar with using the unix command line, you might find the frequent use of "~" below puzzling. It refers to the user's home directory (mine is /Users/john; if your name is John, then yours probably is too.) You can use it that way in commands if your current directory is somewhere else.
 +
 
 +
=== Step 1: Install Xcode ===
 +
 
 +
You'll need XCode, Apple's development environment. There's a copy on your OS X distribution DVD, or you can download the latest version from [http://developer.apple.com/technologies/xcode.html Apple], though you must register as a Mac developer. For Lion/Mountain Lion users, XCode is available for free from the App Store.
 +
 
 +
If you try to download Xcode, Apple will probably offer you the latest version of Xcode, irrespective of whether it runs on the version of Mac OS X you are using (Apple probably expects you to upgrade everything to the very latest). You may need to search for an earlier version. For example, as of January 2017, running Mac OS X 10.11 El Capitan it is probably best to use Xcode 7 (e.g. Xcode 7.3.1).
 +
 
 +
If you are running OSX 10.7 Lion or later, you'll need to [https://live.gnome.org/GTK%2B/OSX/Building#Installing_XCode_3_on_XCode_4_systems use Xcode 3]. Building Gramps with Xcode 4.3 or later--which is what is supplied for 10.7 on--produces code that won't run. See https://bugzilla.gnome.org/show_bug.cgi?id=702908 for details.
 +
 
 +
Earlier version of Xcode were delivered as an installer in a disk image (.dmg). Xcode should be installed in the usual way by double clicking on the installer and following the instructions.
 +
 
 +
Later versions of Xcode are delivered as an Application (.app) in a disk image, with instructions to copy this to your Applications folder. You probably need to run the Application to get it to install everything - if you don't, when you go on to the next step it will complain that you haven't agreed to the Xcode licence agreement.
 +
 
 +
=== Step 2: Install jhbuild ===
 +
 
 +
Next, read [http://live.gnome.org/GTK%2B/OSX/Building the build instructions for Gtk-OSX], '''''especially the Prerequisites'''''.  
  
Next, read [http://live.gnome.org/GTK%2B/OSX/Building the build instructions for Gtk-OSX], '''''especially the Prerequisites'''''. Download and run the [http://git.gnome.org/browse/gtk-osx/plain/gtk-osx-build-setup.sh gtk-osx-build-install.sh] script, which will set up jhbuild for you.
+
''It's important that jhbuild is not confused by any existing MacPorts or Fink installation.'' For this reason, it can be convenient to create a new Mac User account and log in to that account if you have either of those installed.
  
''It's important that jhbuild is not confused by any existing MacPorts or Fink installation.'' For this reason, it can be convenient to create a new Mac User account and log in to that account.
+
Download and run the [http://git.gnome.org/browse/gtk-osx/plain/gtk-osx-build-setup.sh gtk-osx-build-install.sh] script, which will set up jhbuild for you. (It is assumed here that you have downloaded gtk-osx-build-install.sh into your home directory, and that you run the following command from there).
  
If you are building for distribution, especially if you are running Snow Leopard on a 64-bit capable machine (Core2Duo, Core i5 or i7, or any Xeon) you should edit the file ~/.jhbuildrc-custom so that the call to <tt>sdk_setup</tt> looks like
+
  sudo sh gtk-osx-build-setup.sh
  setup_sdk(target="10.5", sdk_version="10.5", architectures=["i386"])
 
Lion doesn't support SDKs older than 10.6, so in that case the line should be:
 
  setup_sdk(target="10.6", sdk_version="10.6", architectures=["i386"])
 
(If you're building on a PPC, you don't need to worry about this.)
 
  
If you're not familiar with using the unix command line, you might find the frequent use of "~" below puzzling. It refers to the user's home directory (mine is /Users/john; if your name is John, then yours probably is too.) You can use it that way in commands if your current directory is somewhere else.
+
This may produce a number of warnings but they can be ignored:
 +
Checking out jhbuild (7c8d34736c3804) from git...
 +
Cloning into 'jhbuild'...
 +
remote: Counting objects: 45961, done.
 +
remote: Compressing objects: 100% (12945/12945), done.
 +
remote: Total 45961 (delta 35419), reused 42858 (delta 32831)
 +
Receiving objects: 100% (45961/45961), 10.11 MiB | 1.44 MiB/s, done.
 +
Resolving deltas: 100% (35419/35419), done.
 +
Checking connectivity... done.
 +
Switched to a new branch 'stable'
 +
Installing jhbuild...
 +
-n WARNING: aclocal not available (usually part of package 'autoconf')     
 +
-n WARNING: automake not available (usually part of package 'automake')
 +
-n WARNING: autopoint not available (usually part of package 'gettext')
 +
-n WARNING: pkg-config not available (usually part of package 'pkgconfig')
 +
-n WARNING: yelp-tools not available (usually part of package 'yelp-tools')
 +
-n Configuring jhbuild without autotools
 +
-n Now type `make' to compile jhbuild
 +
Installing jhbuild configuration...
 +
Installing gtk-osx moduleset files...
 +
PATH does not contain /Users/tim/.local/bin, it is recommended that you add that.
 +
Done.
  
 
jhbuild is installed in ~/Source/jhbuild, and produces a binary which appears in ~/.local/bin. You'll want to add ~/.local/bin to your path:
 
jhbuild is installed in ~/Source/jhbuild, and produces a binary which appears in ~/.local/bin. You'll want to add ~/.local/bin to your path:
 
   export PATH=~/.local/bin:$PATH
 
   export PATH=~/.local/bin:$PATH
  
Next, you'll need to get a local copy of the gramps mac configuration stuff from svn (if you already have a gramps svn sandbox, then skip this step and substitute the path to it where appropriate below):
+
Type:
  svn co https://gramps.svn.sourceforge.net/svnroot/gramps/trunk/mac gramps-mac
+
  python
That will make a current copy from the repository in your current directory, which we'll assume to be ~.
+
to check which version of python you have (exit from python by typing crtl-D). For example, you may see (with Mac OS X 10.11 El Capitan):
 +
$ python
 +
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
 +
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
 +
Type "help", "copyright", "credits" or "license" for more information.
 +
>>> ^D
 +
 
 +
This shows you have Python 2.7. As described in [http://live.gnome.org/GTK%2B/OSX/Building the build instructions for Gtk-OSX], if you have a version of Python earlier than 2.5, you have to follow the special instructions to build a Python 2.7 module.
 +
 
 +
Now type:
 +
jhbuild bootstrap
 +
 
 +
=== Step 3: Install Gramps dependencies and Gramps ===
 +
 
  
The Gtk-OSX build instructions are very straightforward, but we need to deviate from them a bit to keep from doing things more than once. Run the following commands from the terminal:
+
==== Gramps 3.4.x ====
  
  jhbuild bootstrap
+
Next, you need a copy of the moduleset file. You *could* just pass the url to jhbuild, but it's easier to download it:
Now we need to build berkeleydb:
+
    curl -o gramps.modules https://raw.githubusercontent.com/gramps-project/gramps/maintenance/gramps34/mac/gramps.modules
  jhbuild --moduleset=~/gramps-mac/gramps.modules build berkeleydb
+
And rebuild python to include the bsddb module (it will notice that we have berkeleydb and do it automatically)
+
That will retrieve the modules file to your current directory, which we'll assume to be ~.  
  jhbuild --moduleset=bootstrap.modules buildone --force python
 
Now we're ready to build everything else:
 
  jhbuild --moduleset=~/gramps-mac/gramps.modules build meta-gtk-osx-bootstrap meta-gtk-osx-core meta-gtk-osx-python gramps
 
  
jhbuild by default puts everything it is building in ~/gtk (controlled by the hidden files ~/.jhbuildrc and ~/.jhbuildrc-custom ). ~/gtk/source contains the downloaded sources, and ~/gtk/inst contains the built libraries and applications. More is built than is needed in the final Gramps application - for example, the build tools are themselves built.
+
The Gtk-OSX build instructions are very straightforward, but we need to deviate from them a bit to keep from doing things more than once. Run the following command from the terminal:
 +
 
 +
  jhbuild --moduleset=~/gramps.modules build meta-gtk-osx-bootstrap berkeleydb python meta-gtk-osx-core meta-gtk-osx-python gramps
 +
 
 +
jhbuild by default puts everything it is building in ~/gtk (controlled by the hidden files ~/.jhbuildrc and ~/.jhbuildrc-custom ). ~/gtk/source contains the downloaded sources, and ~/gtk/inst contains the built libraries and applications.  
 +
Not everything that this procedure builds will be included in the Gramps application bundle; there are some intermediate dependencies and build tools that are necessary for building everything but not required at runtime. ```That doesn't mean that some modules can be skipped.```
  
 
At this point, you can do
 
At this point, you can do
Line 46: Line 94:
  
 
Once you've done this once, you can generally get away with just running  
 
Once you've done this once, you can generally get away with just running  
   jhbuild --moduleset=~/gramps-mac/gramps.modules build meta-gtk-osx-bootstrap meta-gtk-osx-core meta-gtk-osx-python gramps
+
   jhbuild --moduleset=~/gramps-mac/gramps.modules build meta-gtk-osx-core meta-gtk-osx-freetype meta-gtk-osx-python gramps
 
to update everything that has been changed since the previous build. Most of the time nothing will have changed except gramps itself.
 
to update everything that has been changed since the previous build. Most of the time nothing will have changed except gramps itself.
  
If you want to build the svn trunk, you can substitute "gramps-svn" for "gramps". If you want to have both installed, you'll need to set up separate prefixes in .jhbuildrc-custom; gramps doesn't version its installations, so the most recent will overwrite the previous build.
+
==== Gramps 4.x and Git Master ====
  
== Gramps 3.3 and EXIF Editing ==
+
Gramps 4.x is updated to use the Gtk+-3 series for its GUI. This requires a couple of changes.
  
Gramps 3.3.0 introduced a new module, EXIF Editing, which has two tricky dependencies, which JHBuild doesn't know how to handle yet. In order to evade the persnickityness of jhbuild's dependencies, they're given as "soft" dependencies -- you have to add them to your modules list. If you don't, Gramps will still build fine, you'll just get a warning notice about Exiv2 not being installed.
+
Download the modules file for the branch you want to build:
 +
  curl -o gramps.modules https://raw.githubusercontent.com/gramps-project/gramps/maintenance/gramps42/mac/gramps.modules
 +
or
 +
  curl -o gramps.modules https://raw.githubusercontent.com/gramps-project/gramps/master/mac/gramps.modules
  
'''Warning:'''Boost-python will not successfully build with either the 10.6 (Snow Leopard) or 10.7 (Lion) SDKs. With 10.7 it won't build at all; with 10.6, it will build but will crash Python on import. Consequently you can't build EXIF editing using Lion, since earlier SDKs are not available.
+
The list of targets changes to reflect using Gtk+-3:
 +
  jhbuild --moduleset=~/gramps-mac/gramps.modules build meta-gtk-osx-bootstrap meta-gtk-osx-freetype meta-gtk-osx-gtk3 berkeleydb python meta-gtk-osx-python-gtk3 gramps-git
 +
 
 +
If you want to build the latest release tarball rather than the latest check-in, use <tt>gramps</tt> instead of <tt>gramps-git</tt> for the last module--but note that since we don't release from the <tt>master</tt> branch, <tt>gramps.modules</tt> doesn't have a <tt>gramps</tt> module.
 +
 
 +
If you're planning to work on several branches, a single checkout will work: Start with <tt>master</tt>. Gramps is pure python, so once you've got everything built you need repeat this only to update the dependencies. You can quickly switch branches in your git repo with:
 +
  git clean -fdx
 +
  git checkout maintenance/gramps40
 +
  python setup.by build
 +
 
 +
==== .jhbuildrc-custom ====
 +
It's annoying and error-prone to type the long list of modules every time you want to build gramps, so you may want to modify <tt>~/.jhbuildrc-custom</tt> to declare the <tt>moduleset</tt> and <tt>modules</tt> variables. Note that <tt>.jhbuildrc-custom</tt> is a Python file that is loaded and executed by <tt>jhbuild</tt>, so you can make it quite complex. Do beware that defining new global variables will elicit a warning from <tt>jhbuild</tt> so be sure to prefix any top-level variables with '_'.
 +
 
 +
== Gramps 3.x and EXIF Editing ==
 +
 
 +
Gramps 3.3.0 introduced a new module, EXIF Editing, which has two tricky dependencies that JHBuild doesn't know how to handle. Thanks to Gtk+-3, these have been replaced in Gramps-4.0 (and <tt>master</tt>) with a module that JHBuild ''can'' build, so '''these instructions apply only to Gramps-3.4.x'''. In order to evade the persnickityness of jhbuild's dependencies, they're given as "soft" dependencies -- you have to add them to your modules list. If you don't, Gramps will still build fine, you'll just get a warning notice about Exiv2 not being installed.
 +
 
 +
'''Warning:'''Boost-python will not successfully build with either the 10.6 (Snow Leopard) or 10.7 (Lion) SDKs. With 10.7 it won't build at all; with 10.6, it will build but will crash Python on import. Consequently you can't build EXIF editing using Lion or later, since earlier SDKs are not available.
  
 
The first is [http://www.boost.org/libs/python/doc/ Boost-python], a python interface for C++ provided as part of [http://www.boost.org/ Boost]. It uses its own build system, bjam. Since jhbuild doesn't know how to use bjam, it will download the package for you, then error out. Select item 4, "start a shell", and do the following:
 
The first is [http://www.boost.org/libs/python/doc/ Boost-python], a python interface for C++ provided as part of [http://www.boost.org/ Boost]. It uses its own build system, bjam. Since jhbuild doesn't know how to use bjam, it will download the package for you, then error out. Select item 4, "start a shell", and do the following:
Line 73: Line 141:
 
   install_name_tool -id python2.7/site-packages/libexiv2python.dylib $PREFIX/lib/python2.7/site-packages/libexiv2python.dylib
 
   install_name_tool -id python2.7/site-packages/libexiv2python.dylib $PREFIX/lib/python2.7/site-packages/libexiv2python.dylib
 
Quit the shell and pick "2" a few more times to move on to the next module.
 
Quit the shell and pick "2" a few more times to move on to the next module.
 +
 +
=== Webkit ===
 +
Gramps has an optional dependency on WebKit, which is used for the <tt>html-renderer</tt> add-on. If for some reason you want to use this add-on, add <tt>WebKit</tt> to your list of dependencies but be aware that it take a long time to build.
 +
'''''WebKit will not build on 10.4 (Tiger) or earlier systems, nor will it build against a 10.4 SDK. You must be running 10.5 (Leopard) or newer for this procedure to succeed!'''''
  
 
== Bundling ==
 
== Bundling ==
The next step is to create an application bundle. You'll need gtk-mac-bundler, so follow the instructions in the [http://live.gnome.org/GTK%2B/OSX/Bundling Gtk-OSX Wiki] to download and install it.
+
The next step is to create an application bundle. You'll need gtk-mac-bundler, so follow the instructions in the [https://wiki.gnome.org/Projects/GTK%2B/OSX/Bundling Gtk-OSX Wiki] to download and install it.
  
You may need to edit <tt>~/gramps-mac/Info.plist</tt> to update the version number and copyright information.
+
Assuming that your local repository wound up in <tt>~/gtk/src/gramps</tt>:
 +
You may need to edit <tt>~/gtk/src/gramps/mac/Info.plist</tt> to update the version number and copyright information.
  
 
Now open a jhbuild shell and run the bundler:
 
Now open a jhbuild shell and run the bundler:
 
   jhbuild shell
 
   jhbuild shell
   chmod +w $PREFIX/lib/libpython2.6.dylib
+
   chmod +w $PREFIX/lib/libpython2.7.dylib
   gtk-mac-bundler ~/gramps-mac/gramps.bundle
+
   gtk-mac-bundler ~/gtk/src/gramps/mac/gramps.bundle
 
   
 
   
  
Line 95: Line 168:
 
Good Luck!
 
Good Luck!
  
'''Note:''' The 3.1.2 installer left out two files:
+
[[Category:Developers/General]]
#''_strptime.py''. You can get the file from  [http://www.gramps-project.org/bugs/view.php?id=3177 here].
 
#''keysyms.py''. You can get the file from  [http://www.gramps-project.org/bugs/view.php?id=3157 here].
 

Revision as of 17:34, 7 January 2017

Building Gramps from Scratch

Building Gramps from scratch is useful to produce a version not currently available as a binary (for example, a PPC version) or to produce a complete environment for debugging and further development, including debugging of all the C libraries Gramps uses, like gtk.

This is a command-line process. It's not too difficult, but you'll be using Terminal.app, not XCode. Unfortunately, Gtk has so far resisted efforts to get it to successfully cross-compile PPC on Intel or vice-versa, so the whole process must be repeated on machines of each architecture. N.B. This procedure has not been tested against OS X 10.4 Tiger. Some packages may not be compatible with that very old version of OS X.

If you're not familiar with using the unix command line, you might find the frequent use of "~" below puzzling. It refers to the user's home directory (mine is /Users/john; if your name is John, then yours probably is too.) You can use it that way in commands if your current directory is somewhere else.

Step 1: Install Xcode

You'll need XCode, Apple's development environment. There's a copy on your OS X distribution DVD, or you can download the latest version from Apple, though you must register as a Mac developer. For Lion/Mountain Lion users, XCode is available for free from the App Store.

If you try to download Xcode, Apple will probably offer you the latest version of Xcode, irrespective of whether it runs on the version of Mac OS X you are using (Apple probably expects you to upgrade everything to the very latest). You may need to search for an earlier version. For example, as of January 2017, running Mac OS X 10.11 El Capitan it is probably best to use Xcode 7 (e.g. Xcode 7.3.1).

If you are running OSX 10.7 Lion or later, you'll need to use Xcode 3. Building Gramps with Xcode 4.3 or later--which is what is supplied for 10.7 on--produces code that won't run. See https://bugzilla.gnome.org/show_bug.cgi?id=702908 for details.

Earlier version of Xcode were delivered as an installer in a disk image (.dmg). Xcode should be installed in the usual way by double clicking on the installer and following the instructions.

Later versions of Xcode are delivered as an Application (.app) in a disk image, with instructions to copy this to your Applications folder. You probably need to run the Application to get it to install everything - if you don't, when you go on to the next step it will complain that you haven't agreed to the Xcode licence agreement.

Step 2: Install jhbuild

Next, read the build instructions for Gtk-OSX, especially the Prerequisites.

It's important that jhbuild is not confused by any existing MacPorts or Fink installation. For this reason, it can be convenient to create a new Mac User account and log in to that account if you have either of those installed.

Download and run the gtk-osx-build-install.sh script, which will set up jhbuild for you. (It is assumed here that you have downloaded gtk-osx-build-install.sh into your home directory, and that you run the following command from there).

 sudo sh gtk-osx-build-setup.sh

This may produce a number of warnings but they can be ignored:

Checking out jhbuild (7c8d34736c3804) from git...
Cloning into 'jhbuild'...
remote: Counting objects: 45961, done.
remote: Compressing objects: 100% (12945/12945), done.
remote: Total 45961 (delta 35419), reused 42858 (delta 32831)
Receiving objects: 100% (45961/45961), 10.11 MiB | 1.44 MiB/s, done.
Resolving deltas: 100% (35419/35419), done.
Checking connectivity... done.
Switched to a new branch 'stable'
Installing jhbuild...
-n WARNING: aclocal not available (usually part of package 'autoconf')      
-n WARNING: automake not available (usually part of package 'automake')
-n WARNING: autopoint not available (usually part of package 'gettext')
-n WARNING: pkg-config not available (usually part of package 'pkgconfig')
-n WARNING: yelp-tools not available (usually part of package 'yelp-tools')
-n Configuring jhbuild without autotools
-n Now type `make' to compile jhbuild
Installing jhbuild configuration...
Installing gtk-osx moduleset files...
PATH does not contain /Users/tim/.local/bin, it is recommended that you add that.
Done.

jhbuild is installed in ~/Source/jhbuild, and produces a binary which appears in ~/.local/bin. You'll want to add ~/.local/bin to your path:

 export PATH=~/.local/bin:$PATH

Type:

 python

to check which version of python you have (exit from python by typing crtl-D). For example, you may see (with Mac OS X 10.11 El Capitan):

$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D

This shows you have Python 2.7. As described in the build instructions for Gtk-OSX, if you have a version of Python earlier than 2.5, you have to follow the special instructions to build a Python 2.7 module.

Now type:

jhbuild bootstrap

Step 3: Install Gramps dependencies and Gramps

Gramps 3.4.x

Next, you need a copy of the moduleset file. You *could* just pass the url to jhbuild, but it's easier to download it:

   curl -o gramps.modules https://raw.githubusercontent.com/gramps-project/gramps/maintenance/gramps34/mac/gramps.modules

That will retrieve the modules file to your current directory, which we'll assume to be ~.

The Gtk-OSX build instructions are very straightforward, but we need to deviate from them a bit to keep from doing things more than once. Run the following command from the terminal:

 jhbuild --moduleset=~/gramps.modules build meta-gtk-osx-bootstrap berkeleydb python meta-gtk-osx-core meta-gtk-osx-python gramps

jhbuild by default puts everything it is building in ~/gtk (controlled by the hidden files ~/.jhbuildrc and ~/.jhbuildrc-custom ). ~/gtk/source contains the downloaded sources, and ~/gtk/inst contains the built libraries and applications. Not everything that this procedure builds will be included in the Gramps application bundle; there are some intermediate dependencies and build tools that are necessary for building everything but not required at runtime. ```That doesn't mean that some modules can be skipped.```

At this point, you can do

 jhbuild shell
 gramps

at the command line and run gramps. Most everything will work (see the note about spelling dictionaries above).

Once you've done this once, you can generally get away with just running

 jhbuild --moduleset=~/gramps-mac/gramps.modules build meta-gtk-osx-core meta-gtk-osx-freetype meta-gtk-osx-python gramps

to update everything that has been changed since the previous build. Most of the time nothing will have changed except gramps itself.

Gramps 4.x and Git Master

Gramps 4.x is updated to use the Gtk+-3 series for its GUI. This requires a couple of changes.

Download the modules file for the branch you want to build:

 curl -o gramps.modules https://raw.githubusercontent.com/gramps-project/gramps/maintenance/gramps42/mac/gramps.modules

or

 curl -o gramps.modules https://raw.githubusercontent.com/gramps-project/gramps/master/mac/gramps.modules

The list of targets changes to reflect using Gtk+-3:

  jhbuild --moduleset=~/gramps-mac/gramps.modules build meta-gtk-osx-bootstrap meta-gtk-osx-freetype meta-gtk-osx-gtk3 berkeleydb python meta-gtk-osx-python-gtk3 gramps-git

If you want to build the latest release tarball rather than the latest check-in, use gramps instead of gramps-git for the last module--but note that since we don't release from the master branch, gramps.modules doesn't have a gramps module.

If you're planning to work on several branches, a single checkout will work: Start with master. Gramps is pure python, so once you've got everything built you need repeat this only to update the dependencies. You can quickly switch branches in your git repo with:

 git clean -fdx
 git checkout maintenance/gramps40
 python setup.by build

.jhbuildrc-custom

It's annoying and error-prone to type the long list of modules every time you want to build gramps, so you may want to modify ~/.jhbuildrc-custom to declare the moduleset and modules variables. Note that .jhbuildrc-custom is a Python file that is loaded and executed by jhbuild, so you can make it quite complex. Do beware that defining new global variables will elicit a warning from jhbuild so be sure to prefix any top-level variables with '_'.

Gramps 3.x and EXIF Editing

Gramps 3.3.0 introduced a new module, EXIF Editing, which has two tricky dependencies that JHBuild doesn't know how to handle. Thanks to Gtk+-3, these have been replaced in Gramps-4.0 (and master) with a module that JHBuild can build, so these instructions apply only to Gramps-3.4.x. In order to evade the persnickityness of jhbuild's dependencies, they're given as "soft" dependencies -- you have to add them to your modules list. If you don't, Gramps will still build fine, you'll just get a warning notice about Exiv2 not being installed.

Warning:Boost-python will not successfully build with either the 10.6 (Snow Leopard) or 10.7 (Lion) SDKs. With 10.7 it won't build at all; with 10.6, it will build but will crash Python on import. Consequently you can't build EXIF editing using Lion or later, since earlier SDKs are not available.

The first is Boost-python, a python interface for C++ provided as part of Boost. It uses its own build system, bjam. Since jhbuild doesn't know how to use bjam, it will download the package for you, then error out. Select item 4, "start a shell", and do the following:

 cd tools/build/v2
 ./bootstrap.sh --with-toolset=darwin
 ./bjam --prefix="$PREFIX" install
 cd ../../..
 bjam toolset=darwin address-model=32 --prefix=$PREFIX --with-python --cmd-or-prefix=$PYTHON cxxflags="$CXXFLAGS" cflags="$CFLAGS" linkflags="$LDFLAGS" install

Once that's done, quit the shell and select "2" (ignore error) twice to move on to the next library, PyExiv2, which also uses a different build system, SCons. The SCons folks are bright enough to use distutils, which JHBuild can handle, so that gets built and installed for you. JHBuild will stop again after downloading and extracting PyExiv for you, so once again select "4" to start a shell and run the following:

 export CXXFLAGS="$CXXFLAGS -I$PREFIX/include"
 export CFLAGS="$CFLAGS -I$PREFIX/include"
 export LDFLAGS="$LDFLAGS -lpython2.7"
 scons
 scons install
 ln $PREFIX/lib/python2.7/site-packages/libexiv2python.dylib $PREFIX/lib/python2.7/site-packages/libexiv2python.so
 install_name_tool -id python2.7/site-packages/libexiv2python.dylib $PREFIX/lib/python2.7/site-packages/libexiv2python.dylib

Quit the shell and pick "2" a few more times to move on to the next module.

Webkit

Gramps has an optional dependency on WebKit, which is used for the html-renderer add-on. If for some reason you want to use this add-on, add WebKit to your list of dependencies but be aware that it take a long time to build. WebKit will not build on 10.4 (Tiger) or earlier systems, nor will it build against a 10.4 SDK. You must be running 10.5 (Leopard) or newer for this procedure to succeed!

Bundling

The next step is to create an application bundle. You'll need gtk-mac-bundler, so follow the instructions in the Gtk-OSX Wiki to download and install it.

Assuming that your local repository wound up in ~/gtk/src/gramps: You may need to edit ~/gtk/src/gramps/mac/Info.plist to update the version number and copyright information.

Now open a jhbuild shell and run the bundler:

 jhbuild shell
 chmod +w $PREFIX/lib/libpython2.7.dylib
 gtk-mac-bundler ~/gtk/src/gramps/mac/gramps.bundle

You'll have an application bundle named Gramps.app on your desktop.

Packaging

To make an uploadable disk image, create a folder named "Gramps-arch-version", replacing "arch" with either Intel or PPC and "version" with the current version number. Drag your app bundle to this directory. Open your build directory and copy (option-drag) the files "FAQ", "COPYING", "README", and "NEWS" to the Gramps folder you just made. Rename each to have a ".txt" extension so that they're readable with QuickLook. You might also rename COPYING to License.txt so that it's meaning is more clear to users who aren't familiar with the GPL.

Now open Applications>Utilities>Disk Utility and select File>New Image From Folder and select your folder, then approve the name and location. You'll have a dmg ready for distribution.

Good Luck!