Makefile example:
Test: Add. O sub. ogcc-O test add. O sub. oadd. o: Add. C test. hgcc-C add. csub. o: sub. C test. hgcc-c sub. c clean: Rm-RF testrm-RF *. O
Format:
Name of the file to be generated (including the suffix): List of dependent files (including the suffix) GCC-O/-C [If an executable file is generated, set the file name here; generate *. o file not needed] list of dependent file names (including suffix names)
Note:
1. If the *. o file is compiled, use gcc-o. If the *. c file is compiled, use gcc-C.
2. *. H files do not need to be compiled in makefile, because. c files call. H files for compilation.
3. Save the content of makefile as a text file named "makefile", and then enter the command "make" in the terminal to execute makefile for compilation.
4. "clean:" Is a tag. If you enter "make clean" in the interrupt, the command after "clean:" is executed (in this example, the generated file is deleted ).
5. rm is the command to delete files, and-RF is the command to force delete files in a series of subfolders.