Please grab a coffee or a beer, and feel free to dive in when ready. Answers to 1, 2, 3 follow, with further discussion below.
- The pkg target invokes a make file in macosx/build. This is what I am updating to use pkgbuild and productbuild rather than package maker.
2a) By CI to you mean Continuous Integration? I build from the cloned repo on my MacBook and found that I need to start with autogen.sh, which employs the GNU tools. These are not part of macOS or the Command Line Tools. I do not use Homebrew or MacPorts. The make file scripts in macosx/prebuild provided the template for downloading and installing the GNU Tools on the Mac.
2b) I am not sure what all the dependencies built in the old macosx/prebuild/Makefile.* are for, (fontconfig, pango, cairo, gdlib,…), and if Quartz is sufficient for macOS deployments of Graphviz, then the Makefile can stop with the GNU tools (and Bison).
- I could update the pkg target directly in Makefile.am by pulling over what I put in the macosx/build make file. The macosx/build make file has targets to
- write a PATH directive for /usr/local/graphviz/bin to /etc/paths.d/graphviz
- define a postinstall script to run dot -c
- pkgbuild Graphviz to deploy to /usr/local/graphviz
- xcodebuild the objective-c Graphiz app
- pkgbuild Graphviz.app to deploy to /Applications
- productbuild to assemble this all into a single installer package
Further discussion:
Anyway, I perhaps have ventured a bit into the weeds here. May I offer how I got here, and hopefully you can get me back on track.
For several years I have used Graphviz dot to render SVG of process diagrams, after discovering how Go used dot to diagram CPU and memory usage. I built Graphviz from source on my Mac using the instructions at https://graphviz.org/download/source/. The only requirement for this build is to install the macOS Command Line Tools.
My first possible detour is related to the Graphviz.app. Is this app still relevant? If so, please refer to Note 1 below. Otherwise, perhaps all this code can be removed from the repo.
The old make files in macosx/prebuild install the GNU tools, so I set about writing a “gnutools.mk” to download and install the GNU tools to streamline my workflow for building Graphviz from the repo.
The make files in macosx/prebuild led me on my second possible detour. These make files install a number of other Graphviz dependencies with which I am unfamiliar. If these dependencies are useful for the macOS version of Graphviz, see Note 2.
In the macosx/build make files the obsolete package maker tool is used to create an installer for macOS. This is where I focused on the update to use pkgbuild and productbuild. This is the make file that Makefile.am references to build the installer package with the make -C flag. If updating the pkg target to invoke pkgbuild and productbuild directly is the goal, please see Note 3. Finally, see Note 4 regarding signing of installer packages.
As an aside, I have also been exploring how to build Graphviz with CMake. (you helped me with the LIBZ/ZLIB naming issue). I believe that this would preclude the need for the GNU tools. CMake also supports CPack which may also facilitate the packaging.
Thank you.
Note 1:
Last spring I happened to notice the macosx folder and the old Objective-C code for a Graphviz.app. I rewrote this code using Xcode to update it for newer capabilities of Objective-C such as ARC, and to resolve compiler and deprecation warnings and errors. It became a substantial rewrite, including a few changes to the Quartz plugin to add HEIC support.
As I was making these code changes, I started to wonder whether this would be of utility to anyone else. So I cloned the Gitlab repo and started building from that. In my experience, to build from the repo I need to start with the autogen.sh script. Starting the build with this script calls for installing the GNU tools, as well as Bison, as the Bison installed with the Command Line Tools is too old.
So at that point, I was installing the GNU tools, building Graphviz --with-quartz, then opening the macosx/graphviz.xcodeproj in Xcode, and building the app in Xcode.
Note 2:
I updated macosx/prebuild/Makefile-packages-incl to reference the latest versions of the GNU tools and other dependencies and created two prebuild make files for macOS: gnutools.mk for the GNU tools and dependencies.mk for the additional dependencies. I named these with a .mk extension so that VSCode recognizes them for syntax highlighting.
Note 3:
The new macosx/build/Makefile uses xcodebuild, pkgbuild, and productbuild to create an installer package. It also builds Graphviz. In this way, the package contains everything for a deployment. It drops all of Graphviz into /usr/local/graphviz (to isolate it from /usr/local), creates an /etc/paths.d/graphviz file to add /usr/local/graphviz/bin to the PATH, and installs the Graphviz.app into /Applications. In this way, a user can download the package and run the installer, Theoretically then, Graphviz could even be distributed through the Mac App store.
I build Graphviz from the macosx/build/Makefile with a staging location for --prefix and DESTDIR for the embedded install targets. This may seem a bit involved, but in this way the installer package can all be assembled from a staging location rather than from /usr/local. The installer itself then deploys into /usr/local/graphviz
I deploy to /usr/local/graphviz to make it easier for me to rerun the builds without having to selectively remove all the Graphviz deployed files. By using a staging location, one can build the package without inadvertently populating it with other files the developer may have in /usr/local.
Note 4:
To distribute a macOS installer package requires that it be signed with an Apple Developer installer enabled account. I am not an Apple Developer and I do not work for a company that could provide a vetted Apple Developer signature.
| smattr
October 23 |
I’m still unclear what the goal is here. Specifically what’s throwing me off:
- Why are you building the GNU tools from source? Graphviz doesn’t modify these in any way, so you should be able to use pre-built versions of all this. See commit a832ad72d437e13aad82a46581117cbfc822c4af in the Graphviz repo. The scripts this commit removed show a much simpler path to obtaining all these tools.
- Similarly, why are you building the Graphviz dependencies from source? We’ve never done that in CI.
- Why do you need a separate Makefile? I’m still not following why you cannot replace the
pkg
target in the existing top level Makefile.am.
You can also probably get away without “sonoma” in paths too. I don’t know much about macOS versions, but in recent times we’ve never tried to support anything other than the latest macOS.
zosmac:
how much utility is there to build Graphviz with additional dependencies beyond what Quartz and dot provide?
I’ll have to leave this to others to comment.