After making a mistake of replying to a post from 2010 (the link to it: What does it mean to 'touch' a target in make? ), i would like to understand something as a new student for C programming language, who recently learned about the makefile, make command an so on. i've got a question on class about what does the make -t
command do, and why should i use it (or not, for the matter).
i understand that make -t
only create the files (the relevant ones, from my makefile commands and full script). but why should i ever use it?
i mean, if it is just creating me the files, without actually doing anything with it - why bother?
(I'm using Ubuntu 20.04.4 LTS, gcc for compiling, and writing my code in C language)
CodePudding user response:
As mentioned in comments you should pretty much never use this.
It is "useful" in very limited situations such as: you know for a fact that your entire build is is correct and up to date, then something happens such that the timestamps on your files get all messed up. Maybe some tool went in and tweaked a comment in every file (maybe something changed the copyright year in every file), or maybe you copied the build tree somewhere but forgot to preserve the modification time, or whatever.
Then you can run make -t
to "bring back" the relative timestamps of your files so that make understands everything is up to date, without actually building anything.
Back in the day when builds were a lot slower and there were more opportunities to mess up timestamps maybe this was more useful.
These days it's better to just run make
without -t
: yes you'll have to rebuild a bunch of files but it's much safer than assuring make
you know that everything is up to date, when you might be wrong.