Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6662729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:25:17+00:00 2026-05-26T02:25:17+00:00

I have a Makefile with several rules of this form protolist.c: $(PROTOCOLS) Makefile src/genmodtable.sh

  • 0

I have a Makefile with several rules of this form

protolist.c: $(PROTOCOLS) Makefile src/genmodtable.sh
    $(SHELL) $(srcdir)/src/genmodtable.sh \
        $@ $(filter-out %Makefile %genmodtable.sh, $^)

As the name implies, protolist.c winds up containing a list of all the “protocols” defined by the .c files in $(PROTOCOLS). The contents of this file do formally depend on everything in $(PROTOCOLS), the Makefile, and the generator script, but it’s very rare for the file to actually change when one of those .c files is edited. Therefore, genmodtable.sh is coded to not change the timestamp of protolist.c if it’s not going to make any change to its contents. This causes Make to skip rebuilding protolist.o and its dependencies when it’s not really necessary.

That all works fine; the problem is that, because protolist.c now appears to be out of date with respect to its dependencies, Make thinks it has to try to regenerate protolist.c on every run. This isn’t a performance issue — the script is very fast — but it is confusing behavior. I dimly recall an idiom, involving timestamp files, that could be used to stop Make from doing this, but I have not been able to reconstruct it or find it described anywhere. Does anyone know what it is?

(Also if anyone can suggest how to get rid of that silly $(filter-out ...) construct, that would be helpful, as that is the only GNUmakeism in this Makefile.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:25:18+00:00Added an answer on May 26, 2026 at 2:25 am

    This appears similar to an issue with Fortran programming and make, involving the files generated when compiling a module. (Not relevant, other than that is where I picked up how to do this.)

    What you want is have make compare the timestamp of protolist.o to the timestamp of protolist.c, which remains ‘old’, and make the decision to run the recipe for protolist.c, depending on the timestamp of, well, a timestamp file, which gets updated each time the recipe is run.
    In order to make this work, you have to link the two together with an empty rule.

    protolist.o: protolist.c
        [...]
    
    protolist.c: protolist.c.time ;
    
    protolist.c.time: $(PROTOCOLS) Makefile src/genmodtable.sh
        $(SHELL) $(srcdir)/src/genmodtable.sh \
            protolist.c $(filter-out %Makefile %genmodtable.sh, $^)
        touch protolist.c.time
    

    In my own makefiles, I have to declare the timestamp files as prerequisites of the special target .PRECIOUS, to prevent make from deleting them, but I’m using pattern rules; I’m not 100% sure, but I think this isn’t necessary when using explicit rules, like here.

    To avoid the $(filter-out ...) construct, can you not simply replace it with $(PROTOCOLS)?
    (Although, personally, I would stick to Paul’s First Rule of Makefiles: Don’t hassle with writing portable makefiles, use a portable make instead.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several hundred files in a non-flat directory structure. My Makefile lists each
I'm using a makefile to automate some document generation. I have several documents in
I have a Makefile that looks like this CXX = g++ -O2 -Wall all:
I have a large makefile which builds several libraries, installs them, and then keeps
I have a Makefile.am file right now that looks like this: lib_LIBRARIES = foo.a
I have several directories representing subparts of a project, each with its own Makefile.
I have a project with several sources directories : src/A /B /C In each,
So I have this Java project made up of several classes, some external JAR
I have a makefile, which includes several other makefiles, which in turn all add
I have Makefile like this: b: @echo b a: @echo a @make b I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.