The easiest Makefile

zhaozj2021-02-16  100

Name = main

$ (Name) .exe: $ (name) .Obj

$ (Name) .Obj: $ (name) .cpp

Important:

EXE is behind, OBJ is behind. Because NMAKE judge $ (name) .Obj, if not the latest, update the OBJ, then create EXE. Here, the semicolon is called "Target", named "dependent" after the semicolon. This is not the simplest, here is used here. The reference to the macro is $ (). If the macro is a single character, it can not be added ().

Name = main

$ (Name) .exe: $ (name) .Obj

@echo "Link EXE IS OK"

$ (Name) .Obj: $ (name) .cpp

Added @echo "link exe is ok", mainly explaining @ of the usage: do not display itself, so it is displayed:

Link EXE IS OK

Instead of

Echo "Link EX IS OK"

"Link EXE IS OK"

If you exchange $ (Name) .Obj: $ (name) .cpp and $ (name) .exe: $ (name). Obj location, ie

$ (Name) .Obj: $ (name) .cpp

$ (Name) .exe: $ (name) .Obj

EXE will not be compiled, it seems that Nmake only performs the first line, and then do other than the dependency.

转载请注明原文地址:https://www.9cbs.com/read-10983.html

New Post(0)