Thread: how gnu make tells if file's been changed?

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    64

    how gnu make tells if file's been changed?

    I am writing a program to test if the file has been modified recently, and am thinking about how to implement it.

    To know if a file has been changed, there has to be a reference to compared. My primitive idea was to check the modified stamp and the accessed stamp of the file, if they were not the same, probabaly the file has been changed. But after some experiments, it was not like what I supposed.

    I also thought to keep a copy of the file, so I could compare the time stamps between them, but if the volume of the files were large, that certainly causes some overhead.

    As I know, GNU make only compile those source files that have been modified. How does it do to tell if a file's changed or not?

    thanks.

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    AFAIK it compares the timestamp of the source file to the object file. If the source file is newer than the object file, it rebuilds it.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    All versions of Make uses file modification time to determine which is newer/older. [This is sometimes a problem if your file lives on a drive that is shared between machines, and the time on the machines aren't in sync].

    Note also that a target file that doesn't exist is treated as "really old".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Establishing 'make clean' with GNU make
    By Jesdisciple in forum C Programming
    Replies: 9
    Last Post: 04-11-2009, 09:10 AM
  2. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 02:47 AM
  3. GNU make - generating dynamic dependencies
    By OriginalCopy in forum Linux Programming
    Replies: 0
    Last Post: 05-15-2008, 10:41 AM
  4. Using c++ standards
    By subdene in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2002, 09:15 AM
  5. creating make files
    By Unregistered in forum Linux Programming
    Replies: 4
    Last Post: 09-22-2001, 01:58 AM