Back in 2008, I was working for Ames Labratory developing a cross-platform wxWidgets application called GamessQ. One of the problems with developing on MacOS is that you can’t really test your your application unless it is in a bundle. If you’re doing things the Apple way with XCode, this isn’t a problem because XCodw automatically builds a bundle for you. However, due to the cross-platform nature of the application, I was using Autotools for my build system. I needed to find a way to make Autotools build my bundle.
A MacOS app bundle is just a folder named something.app
containing your executables, loadable resources, and a few meta-data
files in a structured folder hierarchy. The executables, built
libraries, meta-data files, and resources can be easily added to the
bundle by simply giving Autotools the right install paths and running
make install. The real issue is gathering up all of the
external libraries your code is using. Since it’s frequently useful to
delete the entire bundle and rebuild it, I wanted a way to do this
automatically. My solution was a piece of unfortunately painful shell
code that uses the MacOS otool and
install_name_tool utilities to recursively find all library
dependencies that are not installed system-wide and collect them into
the bundle.
Fortunately, GamessQ is distributed under version 3 of the GPL, so you can go look at its source code if you’d like. The app bundling script itself can be found here. There are a few other neat things in GamessQ you may want to check out such as pausing and resuming processes on Windows.