MS_makefile_template
资源名称:CppPrimer.rar [点击查看]
上传用户:qdkongtiao
上传日期:2022-06-29
资源大小:356k
文件大小:2k
源码类别:
书籍源码
开发平台:
Visual C++
- #MS compiler: options
- # -c compile but do not link
- # -GX Enable exception handling
- # -nologo suppresses copyright notice
- # -o name the output file
- # -Za disables language extensions
- CPP = cl
- CPPFLAGS = -GX -O -Za -nologo $(LOCFLAGS)
- # Some programs include headers defined in earlier chapters
- # LOCFLAGS used to set tell the compiler where to find a
- # header that is not in the same directory as the source file itself
- # LOCFLAGS will be set in directory level makefiles as needed
- LOCFLAGS =
- # An additional option is required to compile code using
- # runtime type information (covered in chapter 18).
- # See the makefile in directory 18
- ####### To compile without using a makefile
- # To compile an object file from a source file you could execute
- # cl -GX -O -Za -nologo -c filename.cpp # produces filename.obj
- # To compile an executable file from an object file, you would execute
- # cl -GX -O -Za -nologo filename.obj # produces filename.exe
- # To compile an executable file from a source file, you would execute
- # cl -GX -O -Za -nologo filename.cpp # produces filename.exe
- #######
- # each subdirectory contains a Makefile that lists the executable
- # files that can be made in that directory. That list is assigned
- # to the make macro named $OBJECTS
- # This rule says that the make target named "all" depends on those
- # files. Executing "nmake all" in a subdirectory will cause make
- # to build each .exe file listed in that subdirectory's makefile
- all: $(OBJECTS)
- # rule that says how to make a .obj object file from a .cpp source file
- # for a given source file in a given directory you could compile it
- # into an object file by executing "nmake filename.obj"
- # $< and $@ are macros defined by make
- # $< refers to the file being processed (i.e., compiled or linked)
- # $@ refers to the generated file
- .cpp.obj:
- $(CPP) $(CPPFLAGS) -c $< -o $@
- # rule that says how to make a .exe executable file from a .obj object file
- .obj.exe:
- $(CPP) $(CPPFLAGS) $< -o $@
- # target to clean up the object files and any core files
- # executing "nmake clean" in a subdirectory will remove all
- # files named core or any file ending in .obj, or .stackdump
- clean:
- del *.obj core *.stackdump
- # target to remove executable files as well as object and core files
- clobber: clean
- del *.exe