Architecture-specific features
Many people have asked about making packages behave differently when building on different architectures. For a long time these questions were deferred because of a freeze in the core GAR code. Fortunately for multi-architecture packagers, this need not be an impediment.
GARCH-specific variable contents
The way to set variables based on $(GARCH) is to make use of GNU make's lazy evaluation. Consider the following example:
i386_CONFIGURE_ARGS = -I/usr/i386/include/ ppc_CONFIGURE_ARGS = -I/usr/powerpc/include/ CONFIGURE_ARGS += $($(GARCH)_CONFIGURE_ARGS)
The third line will append the contents of the variable named $(GARCH)_CONFIGURE_ARGS to the end of $(CONFIGURE_ARGS). Consider the possibilities of using this in select cases for $(BUILD_ARGS), $(CFLAGS), or $(LDFLAGS).
GARCH-specific custom rules
Many packages do not rely on the default behavior of the standard rules. Fortunately, dependency names are evaluated in a lazy manner as well:
CONFIGURE_SCRIPTS = custom include ../../gar.mk configure-custom: pre-configure-$(GARCH) $(MAKECOOKIE) pre-configure-i386: cp $(WORKSRC)/Makefile.i386 $(WORKSRC)/Makefile $(MAKECOOKIE) pre-configure-ppc: cp $(WORKSRC)/Makefile.macLinux $(WORKSRC)/Makefile $(MAKECOOKIE)
The example is contrived, but the technique remains useful.
DESTIMG_based_hacks"> DESTIMG-based hacks
This technique works just as well with DESTIMG as it does with GARCH. Thus, one could provide different switches to a package based on what the destination image is. Consider:
main_EXTRASWITCHES = --with-big-feature rootbin_EXTRASWITCHES = --without-big-feature CONFIGURE_ARGS += $($(DESTIMG)_EXTRASWITCHES)
Likewise one could depend on pre-configure-$(DESTIMG) or the like and perform the above trick with custom pre-configure-main and pre-configure-rootbin rules. The two could even be combined, making combinations of switches exist (say) only when building for main and i386.