Making an XML bill of materials in GNU Make

[article]

because since the rule for foo didn't have any commands SHELL was not expanded and hence the hack didn't work.   Here's the XML in that case:

<bom>

  <rule target="all">

    <prereq>

      <rule target="foo" />

      <rule target="bar" />

    </prereq>

  </rule>

  <rule target="foo" />

  <rule target="bar" />

</bom>

To workaround this the foo: baz can be modified to include a useful command:

foo: baz ; @true

and the correct results will be generated.

Conclusion

This is a simple technique that can provide useful information from the Make.  It isn't as flexible as some commercial tools that can provide detailed information about the commands run, and even timing information, but as a Makefile debugging aid it's simple to implement and provides insight that hard to obtain otherwise.

About the author

John Graham-Cumming's picture John Graham-Cumming

John Graham-Cumming is Co-Founder at Electric Cloud, Inc . Prior to joining Electric Cloud, John was a Venture Consultant with Accel Partners, VP of Internet Technology at Interwoven, Inc. (IWOV), VP of Engineering at Scriptics Corporation (acquired by Interwoven), and Chief Architect at Optimal Networks, Inc. John holds BA and MA degrees in Mathematics and Computation and a Doctorate in Computer Security from Oxford University. John is the creator of the highly acclaimed open source POPFile project. He also holds two patents in network analysis and has others pending.

AgileConnection is one of the growing communities of the TechWell network.

Featuring fresh, insightful stories, TechWell.com is the place to go for what is happening in software development and delivery.  Join the conversation now!

Upcoming Events

May 04
May 04
May 04
Jun 01