You should check out the following properties of the make and look at the sample below:
- $@ - means the name of the current target file, in this case it corresponds to the value of APP.
- $< - means a single file that is newer than the target on which the target is dependant.
- $? - means a list of files newer than the current target on which the target is dependant.
.SUFFIXES: .cpp.exe
CPP = cl
EXTRAFLAGS =
CPPFLAGS = /Od /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /ZI /TP /errorReport:prompt
FILES = Exercise35
APP = Exercise35.exe
.cpp.exe:
$(CPP) $(EXTRAFLAGS) $(CPPFLAGS) /c $<
all : $(APP)
$(APP) : $(FILES)
$(CPP) $(EXTRAFLAGS) $(CPPFLAGS) $@ $(FILES)
clobber : clean mrproper
clean:
del $(FILES)
mrproper:
del $(APP)
I got this from my old makefile template, notice that the make will appear 'intelligent' and flexible as you can override the flag specifically for debugging/release within the one make file by executing like this
make EXTRAFLAGS="/D _DDEBUG"
This will pass in the extra define into the makefile to include the _DDEBUG
macro, if you wish to build a release, leave out the EXTRAFLAGS on the command line.
Edit:
As per Mike's point-out, I thought it would be useful to include the extra rules so that you can clean the directory with exe's and object code lying around...This was my original template makefile from AIX (which I've used under Linux also...) Thanks Mike for the heads up!
Hope this helps,
Best regards,
Tom.