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
make
has decided it doesn't need to run any commands, based on the timestamps of files involved. Themake
program 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:make
will determine which commands are actually needed. But this does require setting up theMakefile
with accurate prerequisites.Your
Makefile
specifies that filefindName
has one prerequisite:findName.cpp
. Ifmake
successfully createsfindName
, then you do nothing else but just typemake
again, you'll see the "up to date" message: this is a feature. If you edit and savefindName.cpp
and 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.h
and then runmake
, you'll get "up to date", sincemake
didn't know tofindName.h
has 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.