The three most common options for make commands are:
1. -K: Its purpose is to allow the make command to continue execution when errors are found. We can use this option to discover the source files that were not compiled successfully in one operation.
2. -N: Its purpose is to have the make command output the steps that will be performed, rather than actually performing these operations.
3. -F <filename>: Its role is to tell the make command which file to use as the makefile file. If this option is not used, the make command will find the makefile file in the current directory in turn, makefile file.
Makefile file, define the first target as all, and then list the other subordinate targets so that you can explicitly tell the make command which target should be created by default when a specific target is not specified.
1 All:myapp2 #which compiler, the symbol # represents a comment. 3CC =gcc #定义一个宏, referencing with $ (CC)4 #Where to install5Instdir =/usr/local/bin6 #Where is include files kept7INCLUDE = .8#Options forDevelopment9CFLAGS =-g-wall-ANSITen Onemyapp:main.o2. o3. O A$ (CC)-O MyApp main.o2. o3. o #必须以tab键开头, no space - main.o:main.c a.h -$ (CC)-i$ (INCLUDE) $ (CFLAGS)-C MAIN.C the 2. O:2. C a.h b.h c.h -$ (CC)-i$ (INCLUDE) $ (CFLAGS)-C2. C - 3. O:3. C a.h b.h c.h -$ (CC)-i$ (INCLUDE) $ (CFLAGS)-C3. C + - clear: +#rm命令以-The start, meaning that the make command ignores the results of the RM command execution. A-RM Main.0 2. o3. O at Install:myapp - #必须在每行后面添加反斜杠 \, let all these shell script commands be logically on the same line. - #下面这个命令以 @ begins by saying that make does not display the command itself on standard output until the rules are executed. -@if [-D $ (instdir)]; - Then - CP MyApp $ (instdir); inCHOMD a+x $ (instdir)/MyApp; -CHOMD og-w $ (instdir)/MyApp; toEcho"installed in $ (instdir)"; + Else -Echo"Sorry, $ (instdir) does not exit"; theFi
The following three commands:
Make
Make clear
Make install
Makefile writing an instance