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 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  None Operating System:  Any
Fixed Release:  None Triage 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:

all: myprog

include $(wildcard *.mk)

OBJFILES=file1.o file2.o

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

CFLAGS=-ansi -pedantic

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

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 Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


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

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

    Only logged-in users can vote.




    No changes have been made to this item

    Back to the top

    Powered by Savane 3.3