[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: outputting which dependencies triggered a target action
From: |
Shawn Halpenny |
Subject: |
Re: outputting which dependencies triggered a target action |
Date: |
Fri, 19 Aug 2005 16:22:59 -0400 |
On 8/19/05, Noel Yap <address@hidden> wrote:
> Is there an option less verbose than --debug that outputs which dependencies
> triggered a target action?
You just gave me a great idea to add to my build system. Here's
roughly how I went about it.
For my build system, all compilation+linkage rules are generated
dynamically based on variables' values in some set of makefiles; I
have one function that generates a compile rule and one function that
generates a link rule, for any combination of linker/compiler options,
source files, etc. I mention this because it's easy for me to add
this to any project I currently build; if you have a bunch of rules
you want prereq information for, you'll need to adapt this solution.
The key is to use the $? (which prerequisites caused this target to
run) and $| (order-only prerequisites) variables. I changed the rules
for my compile+link rule generation functions to do basically this:
ifneq ($(PREREQS),)
@echo $@: $? \| $|
else
@<generic link/compile rule cmds>
endif
This works because the if*/endif stuff is parsed before function
definitions are parsed, so if I set PREREQS=1 on the cmd line, the
only thing the rules can do is output the prereqs lists. Without
defining PREREQs everything builds normally.
This was really cool. Thanks for the idea!