I create debian packages using debuild.
In file "debian/control" is described two packages:
Package: app1
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Tool1.
Package: app2
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Tool2.
Both of them should contain the same binaries compiled by one makefile but with different environment variable.
My rules file calls two compilation:
%:
TARGET=S_SS dh $@ -papp1
TARGET=S_TT dh $@ -papp2
A result flow of debuild stages is next:
dh clean -papp1
dh clean -papp2
dh build -papp1
dh build -papp2
dh binary -papp1
dh binary -papp2
It looks like packets are created parallel. Finally binary is overrided by second build.
Is it possible to create rules file in such way that firstly is created app1 and than app2:
dh clean -papp1
dh build -papp1
dh binary -papp1
dh clean -papp2
dh build -papp2
dh binary -papp2
To answer your question: no, it's not possible to change the basic sequence of how packages are build.
The dh-sequencer will run the build-process in stages, such as (very much simplified)
In your current setup, the "build" stage will run two builds (for your two flavours), and once both builds are completed, it will advance to the next stage where it packages all the artifacts into debs.
Now, unfortunately, your 2nd build will just overwrite your 1st build (alternatively it will detect that it already has the binaries in place (not taking the changed envvars into account) and not re-build at all). this is mainly a problem with the build system of the upstream sources (that is: your build system), rather than with the Debian package toolset.
In order to properly build multiple flavours of your package, your build-system should (really) support out-of-tree builds, where you can build all the binaries for one flavour in subdir1/ and all the binaries for another flavour in subdir2/, so the two builds do not interfere.
Then you need to (manually!) instruct
dh
to invoke your buildsystem with the proper flags to use those subdirectories (and a different configuration, obviously).A real-world example of a Debian package (disclaimer: maintained by myself) that builds multiple flavours from the same sources using
dh
can be found here.The upstream build system uses
autotools
(which natively supports out-of-tree builds), and the flavours are distinguished by different configure-flags.The gist is something like this: