GAR: Automating Entire OS Builds
Suppose you want to perform a configure step, but there is no actual program or script associated with that step. For example, you could conceivably want to run a series of shell commands to create a configuration file. Simply pick a file associated with the configure step (or ``none'' if there isn't one) and set your CONFIGURE_SCRIPTS to that. Then write a configure- rule to handle that file (or ``configure-none'' if you used ``none'').
For example, look at the way the traceroute package (Gavron's Traceroute) performs its build step. There was no Makefile, so the maintainer had to provide a method for the compilation commands to be run semi-manually. So the BUILD_SCRIPTS is set to the .c file, and a build- rule for that file is created:
BUILD_SCRIPTS = $(WORKSRC)/traceroute.c build-$(WORKSRC)/traceroute.c: mkdir -p $(COOKIEDIR)/build-$(WORKSRC) $(CC) $(CFLAGS) -o $(WORKSRC)/traceroute \ $(WORKSRC)/traceroute.c -lresolv -lm $(MAKECOOKIE) include ../../gar.mk
This is in fact similar to the way that the default rules are defined in the GAR libraries. For example, here is how the library handles Makefiles as BUILD_SCRIPTS:
build-%/Makefile: mkdir -p $(COOKIEDIR)/build-$* $(BUILD_ENV) $(MAKE) -C $* $(BUILD_ARGS)In make, the % is a wildcard (matching) character when used in the name of a rule, and the $* variable holds whatever it matched. This means that if we told the system to build using work/robotfindskitten-1.0/Makefile, then $* would be set to work/robotfindskitten-1.0 when this rule is run.
The GAR library takes advantage of many of the advanced features of GNU make and is written with the strengths of make in mind. This has been advantageous for a number of reasons. Namely, the size of the GAR library files is a few hundred lines. The BSD Ports libraries are written more like shell scripts and weigh in at several thousand lines.
In addition, the pattern-and-rule handling of package-specific build features fits the realm of make nicely. Also, make has facilities that help avoid redundant behavior. If a package has been installed, running make install will cause it to quickly run through the seven steps, verifying that it had already performed them. To force a package to rebuild from scratch, the make clean target is provided.
GAR provides many features that are not present in most binary package systems, such as dpkg or RPM. This makes user customization of compiles much easier and allows you to rebuild your whole system with whatever optimization flags you choose. The software GAR builds can all be put in /usr/local, for example. The software can also be installed to a scratch directory or secondary volume for later packaging into a complete OS image.
GAR has largely been a product of the LNX-BBC Project, but has also been adopted by many GNOME developers as a means for building the latest CVS build of GNOME from scratch. For more information on the LNX-BBC Project and the GAR system, visit http://lnx-bbc.org/. If you have any specific questions about GAR, feel free to ask on the lnx-bbc-devel list at http://zork.net/mailman/listinfo/lnx-bbc-devel/.
Nick Moffitt is a free software enthusiast in San Francisco, California where he maintains a multiuser community shell server. He is a member of the LNX-BBC Project and maintains GAR, nwall and the popular game of robotfindskitten. When he's not building software projects in make or m4, he prefers the more conventional Scheme and Python languages.
|Red Hat Enterprise Linux 7.1 beta available on IBM Power Platform||Jan 23, 2015|
|Designing with Linux||Jan 22, 2015|
|Wondershaper—QOS in a Pinch||Jan 21, 2015|
|Ideal Backups with zbackup||Jan 19, 2015|
|Non-Linux FOSS: Animation Made Easy||Jan 14, 2015|
|Internet of Things Blows Away CES, and it May Be Hunting for YOU Next||Jan 12, 2015|
- Designing with Linux
- Wondershaper—QOS in a Pinch
- Red Hat Enterprise Linux 7.1 beta available on IBM Power Platform
- Ideal Backups with zbackup
- Internet of Things Blows Away CES, and it May Be Hunting for YOU Next
- Slow System? iotop Is Your Friend
- New Products
- Non-Linux FOSS: Animation Made Easy
- diff -u: What's New in Kernel Development
- Hats Off to Mozilla
Editorial Advisory Panel
Thank you to our 2014 Editorial Advisors!
- Jeff Parent
- Brad Baillio
- Nick Baronian
- Steve Case
- Chadalavada Kalyana
- Caleb Cullen
- Keir Davis
- Michael Eager
- Nick Faltys
- Dennis Frey
- Philip Jacob
- Jay Kruizenga
- Steve Marquez
- Dave McAllister
- Craig Oda
- Mike Roberts
- Chris Stark
- Patrick Swartz
- David Lynch
- Alicia Gibb
- Thomas Quinlan
- Carson McDonald
- Kristen Shoemaker
- Charnell Luchich
- James Walker
- Victor Gregorio
- Hari Boukis
- Brian Conner
- David Lane