This is the code that i have written in my makefile. For some reason it is not letting me execute the make function. When i type "make findName", i get "make: 'findName' is up to date."
findName: findName.cpp
g++ -g findName.cpp -o findName;
clean:
/bin/rm -f findName *.o
backup:
#tar -zcvf bbrown.assignment4_1.tar.gz *.cpp *.h makeFile readme # will make a tar.gz
tar -cvf bbrown.findName.tar *.cpp *.sh makeFile readme
A message like "make: 'target' is up to date." means that
makehas decided it doesn't need to run any commands, based on the timestamps of files involved. Themakeprogram considers files (and phony targets) to have a tree of prerequisites, and commands associated with creating a file will only be run if the file doesn't exist or has an older timestamp than one of its prerequisites. In big projects, this helps avoid completely rebuilding everything which could take a lot of time, when only a few source files have actually changed:makewill determine which commands are actually needed. But this does require setting up theMakefilewith accurate prerequisites.Your
Makefilespecifies that filefindNamehas one prerequisite:findName.cpp. Ifmakesuccessfully createsfindName, then you do nothing else but just typemakeagain, you'll see the "up to date" message: this is a feature. If you edit and savefindName.cppand then runmake, it should repeat theg++command.But suppose you also have some header files you're including from
findName.cpp, sayfindName.h. If you edit and savefindName.hand then runmake, you'll get "up to date", sincemakedidn't know tofindName.hhas effects onfindName. You would need to add the prerequisite to fix this:There are various ways to automatically deal with header dependencies like that, but they get into more advanced use of
make, and/or using other build tools.