bugmake - Bugs: bug #51495, Notice when a rule changed, so...

 
 

bug #51495: Notice when a rule changed, so target needs rebuilding

Submitted by:  Nadav Har'El <nyh>
Submitted on:  Tue 18 Jul 2017 07:07:31 AM UTC  
 
Severity: 3 - NormalItem Group: Enhancement
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Component Version: NoneOperating System: Any
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 18 Jul 2017 01:46:08 PM UTC, comment #1:

The quick and easy way to accomplish this today is of course to also add the Makefile to the prerequisites of targets. If you don't want every target to be rebuilt when only one rule has changed it is also possible to split the Makefile up into several files with only one rule in each file. Example:

Makefile:
-8<----------------------
all: myprog

include $(wildcard *.mk)
-8<----------------------

link.mk:
-8<----------------------
OBJFILES=file1.o file2.o
LDFLAGS=-lm

myprog: $(OBJFILES) link.mk
gcc -o $@ $(OBJFILES) $(LDFLAGS)
-8<----------------------

compile.mk:
-8<----------------------
CFLAGS=-ansi -pedantic

%.o: %.c compile.mk
gcc -c $(CFLAGS) -o $@ $<
-8<----------------------

Henrik Carlqvist <henca>
Tue 18 Jul 2017 07:07:31 AM UTC, original submission:

It's no secret that in recent years, many alternatives to the classic "make" have come up. Most of them differ from "make" in non-interesting ways, which reflects more on their author's preferences than they are actual improvements. However, there are cases where such alternative build systems actually came up with new ideas which can be adopted by "make" without rewriting it. The idea I propose here comes from the "ninja" build system:

The problem this idea is trying to solve is that sometimes you modify the Makefile and change one or many of the rules (either directly or indirectly by modifying some variable), and running "make" does not rebuild anything because none of the dependency files changed. Sure, one can do "make clean; make". But it's very easy to forget and end up with a broken build.

What ninja does is to keep a file (.ninja_log in the build directory) which lists each of the targets that were built, with a hash of the rule that was used to build it. When building again, we consider a target as outdated not only if one of its dependencies is changed, but also if the target's rule no longer matches the saved hash.

Nadav Har'El <nyh>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by henca (Posted a comment)
  • -unavailable- added by nyh (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup1