Jian Tang's C/C++ E-Log
How to write "makefile" in Linux:
A Guide could be found HERE in Chinese.
- Wildcards: "*","?","[...]" can be used in commands(rm *.o), value of variables(OBJ= *.o, different from OBJ:=$(wildcard *.o), which will expand the value)
- Searching files:
- a special variable "VPATH" provides searching directories for make, paths are seperated by ":"
- another way is to use "vpath" key word: vpath
- Pseudo Object: clean(put ".PHONY : clean" first)
- Multiple Objects: useage of "$@"
- Static Pattern:[targets ...] : [target-pattern] : [prereq-pattern]
Example: - OBJ = foo.o bar.o
- $(OBJ):%.o : %.c
- $(CC) -c $(CFLAGS) %< -o %@
- Automatic Generation of Dependence:generate a "file_name.d" for each "file_name.cc"
Go to Top
Last modified: Mon Sep 14 16:18:28 CDT 2009