[haiku-3rdparty-dev] Re: Makefile-Engine with multiple, dependant targets

  • From: Pete Goodeve <pete.goodeve@xxxxxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Wed, 5 Oct 2016 18:48:02 -0700

On Tue, Oct 04, 2016 at 11:05:23AM +0200, Stefano Ceccherini wrote:

Hi.
Is it possible to use the makefile-engine to create more complex build
setup ?
I have this need:

My project needs to build a tool which generate an header file, and then
the main project (which requires that header file) needs to be built.
Is there a way to express this with the makefile-engine ?
Thanks.

Damn you... (:-))  Setting more puzzles I can't resist taking a crack at!!

It is possible, but it is SO easy to get lost (:-/) I did -- many times...

First, you have to put your rules *after* the makefile-engine include,
as the main target is in the engine.  If you satisfy a rule before the
engine, it just thinks it's done, and quits.  'make' itself takes care
of doing things in the right order, so the header will get built before
the main project is compiled.

You also have to make sure you put in necessary dependencies,
because those set up by the engine don't take into account added
needs.  For example, if your source includes a header that doesn't yet
exist, the mkdepend command in the engine just ignores that header.

To test this, I set up a trivial source file that included 'MyHeader.h',
but instead I supplied 'MyHeader.src' to be copied to the actual header.
To get things to compile, the end of the makefile looks like this:

  ....
  ## include the makefile-engine
  include /boot/develop/etc/makefile-engine

  HeaderTest.cpp : MyHeader.h

  MyHeader.h : MyHeader.src
        cp MyHeader.src MyHeader.h

The "HeaderTest.cpp : MyHeader.h" line supplies the dependency
that would otherwise be missing.  The last two lines are of course
the actual action rule.

That's probably expandable to whatever you need to do.
Hope it helps.

        -- Pete --

Other related posts: