Your question's a little confusing but I'll try it out.
Typically, you have a group of C++ source files, for example, x.cpp
and y.cpp
.
The compile phase will take these and create, for example, x.obj
and y.obj
.
The link phase will take these and create a single executable, for example, xy.exe
.
1/ The reason you would have a "del *.obj"
in the batch file is to delete all object files so that the make can recreate them. Make (if you're using intelligent rules in the makefile) will only rebuild things that are needed (an example being that the cpp
file will not be compiled to an obj
file if the current obj
file has a later date than it). Deleting the object file will force a new one to be created.
2/ There doesn't have to be an object file, these are typically created from the c
or cpp
source files. In addition, you can combine compile and link phases so that no object files are created (or are destroyed pretty quickly once they're finished with).
3/ The object file doesn't have to be a cpp
file, but it's usually built from a cpp
file with the same base name.
Update based on comment:
If you want to only specify your application name once, your comments have it like this (I think, the format's not that great as you pointed out):
PATH=C:\BORLAND\BCC55\BIN;%PATH%
APP=MyApp
del *.exe
del *.obj
del *.res
make -f$(APP).mak >err.txt
if exist $(APP).exe goto RUN_EXE
:EDIT_ERR
call notepad.exe err.txt
:RUN_EXE
call $(APP).exe
if exist err.txt delete err.txt :END
I think what you need is:
PATH=C:\BORLAND\BCC55\BIN;%PATH%
set APP=MyApp
del *.exe
del *.obj
del *.res
make -f%APP%.mak >err.txt
if exist %APP%.exe goto :RUN_EXE
:EDIT_ERR
call notepad.exe err.txt
goto :END
:RUN_EXE
call %APP%.exe
if exist err.txt delete err.txt
:END
What you have with your "$(APP)"
substitutions is something that will work inside a makefile, but not inside a cmd file. There you need to use the %APP% variant to get what you want.