Building darktable for Apple M1 (ARM64 processor)
I'm trying to build the nightly version of darktable on my Macbook Air M1.
Mac support is lacking and I'd like to test more an give my contribution as a designer and photographer.
There are couple of ways to build darktable for Mac OSX but the easiest one I've found is using Homebrew.
Build instructions are very clear, however I've encountered some issues as my homebrew was already installed on my system.
Clone darktable repository from git
I have a Developer
folder in my system where I tinker with code, but you can use whatever you prefer:
/Users/fabio/Developer
From this folder, clone darktable git repository:
cd ~/Developer
git clone https://github.com/darktable-org/darktable.git
cd darktable
git submodule init
git config submodule.src/tests/integration.update none
git submodule update
Now the source code has been download, let's proceed with the next steps.
Install homebrew
Instructions and prerequisites can be found on official website, ideally use default installation path (/opt/homebrew for arm64, /usr/local for i386).
If homebrew is already installed the first thing to do before building darktable is to update, upgrade and check if there are any issues in the configuration:
brew update
brew upgrade
brew doctor
A couple of fixes were needed in my system that caused errors and headaches during the first compilation attempts.
It's good to check homebrew status BEFORE building darktable.
Install homebrew dependencies
Next step according to the building instructions is to install homebrew dependencies, using the sript inside packagin/macosx:
packaging/macosx/1_install_hb_dependencies.sh
Important: For the app bundle it is required that GraphicsMagick is linked statically, which is not the default by homebrew. To get GraphicsMagick statically linked, open a terminal and perform the following steps:
brew edit graphicsmagick
This opens the graphicsmagick homebrew formula in the editor. Locate and delete the following line:
--with-modules
Reinstall graphicsmagick:
export HOMEBREW_NO_INSTALL_FROM_API=1
brew reinstall --build-from-source graphicsmagick
Now you have a statically linked GraphicsMagick library.
After several attempts I found out that there are some inaccuracies in the installation script.
The first one is related to the tap jsonschema
: at the time I compiled darktable this package is deprecated, and after running brew doctor
it suggested me to remove it because it is deprecated.
==> jsonschema: stable 4.17.3 (bottled), HEAD
Implementation of JSON Schema for Python
https://github.com/python-jsonschema/jsonschema
Deprecated because it cli is deprecated, and will be removed!
The second inaccuracy is that at the end of the build, another library was missing: libtiff.
This library is missing in the 1_install_hb_dependencies.sh
script.
I recommend installing it manually after running the script first to avoid errors:
brew install libtiff
At this point all the dependencies should be there.
Build and install darktable
Inside packaging/macosx/
there 2 scripts that we can use to build darktable.
Option A
Build using the default build.sh, which should work for most use cases
packaging/macosx/2_build_hb_darktable_default.sh
Option B
Build using custom cmake options, edit according to your specific needs/environment
packaging/macosx/2_build_hb_darktable_custom.sh
I used option A and it was all very quick and straightforward.
Create application bundle from build files
This step is to create the application bundle.
If you are an Apple developer and have an account to sign the application, you can optionally provide your developer certificate email/id by defining CODECERT:
export CODECERT="[email protected]" # optional, not required
I don't have a developer account so I skip this step and run directly the following:
packaging/macosx/3_make_hb_darktable_package.sh
At this point, I was able to run darktable from the folder:
open build/macosx/package/darktable.app
Generate DMG image from application bundle
This step is needed to build the dmg if you want to share the application easily:
packaging/macosx/4_make_hb_darktable_dmg.sh
The script will generate a DMG file with this format:
darktable-<current version>+<latest commit>-{arm64|i386}.dmg
Updating from master
From the darktable folder:
git pull origin master
this command will update the repository with the latest darktable version. Then you have to run the same scripts above to build the app and the dmg:
yes | packaging/macosx/2_build_hb_darktable_custom.sh
#to avoid manually confirming each change
packaging/macosx/3_make_hb_darktable_package.sh
packaging/macosx/4_make_hb_darktable_dmg.sh