Appgen best practices - nthallen/monarch GitHub Wiki
Appgen best practices
Driver distribution
The standard directory layout for an experiment looks like:
- src
- TM
- MyExp.spec
- ...
- MyDriver
- MyDriver.cc
- TM
- MyDriver.agm
- ...
- TM
The standard method for building the instrument software is to run
$ make distribution
in src/TM
. We would like to make sure that when we do that we
will be assured of getting the latest updates from MyDriver and
the MyDriver Module. For the most part, appgen takes care of that.
It knows that it must regenerate source files if the templates
have been changed. It does not directly address making sure the
driver itself is up to date.
The driver for the SCoPEx PropMtr has the current
best approach.
The idea is to add the driver executable to the DISTRIB
list, but
also declare it as a .PHONY
target. That seems to prevent make from
trying to build it using default rules.* Then add an explicit rule
to run make in the driver's directory.
DISTRIB = @MODDIR@/../MyDriver
CPPFLAGS = -I @MODDIR@/..
%%
.PHONY : clean-MyDriver @MODDIR@/../MyDriver
@MODDIR@/../MyDriver :
$(MAKE) --directory=@MODDIR@/..
clean-dist : clean-MyDriver
clean-MyDriver :
$(MAKE) --directory=@MODDIR@/.. clean
*I had previously attempted adding the rule without the .PHONY
definition, and make would go ahead and apply a default rule,
seeing a matching .cc file in the driver's directory and assuming
it could build the driver with that alone. That usually fails
because there is more to the driver's build configuration that
is specified in its own Makefile. The .PHONY
definition seems
to be the key to getting this to work reliably.