help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recompile files for different parameters


From: Greg Chicares
Subject: Re: Recompile files for different parameters
Date: Tue, 08 Mar 2011 14:00:53 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7

On 2011-03-08 07:53Z, Matthias Fechner wrote:
> 
> I attached two small c files, a header file and the Makefile.
> 
> Copy it to a directory and execute:
> make
> 
> then execute:
> make debug
> 
> You see, it does not remake the hello.o, but it should because the code 
> changes.

To investigate Mark's suggestion, add this at the top of your makefile:
  MAKEFILE := $(lastword $(MAKEFILE_LIST))
  test.out a.o hello.o: $(MAKEFILE)
All of the gcc output files thus depend on the makefile, so they're all
rebuilt whenever you edit the makefile and run 'make' again. With that
technique, you don't have to remember to 'make clean' after every change
to the makefile.

However, it now appears that you're not editing the makefile in order to
distinguish normal from debug builds. Instead, you have a debug target
with target-specific $(CFLAGS), and you run either 'make' or 'make debug'
without changing the makefile. In that case, you might want to do each
type of build in a separate directory; see this comprehensive paper:
  http://mad-scientist.net/make/multi-arch.html
That way, you can update the debug build to analyze a problem, change
the source accordingly, and then just run 'make' to get a non-debug
version without recompiling code that didn't change.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]