Jian Tang's C/C++ E-Log

   Jian Tang's HOME       E-Log HOME       JAVA       Shell       Matlab   

How to write "makefile" in Linux:

A Guide could be found HERE in Chinese.

  1. Wildcards: "*","?","[...]" can be used in commands(rm *.o), value of variables(OBJ= *.o, different from OBJ:=$(wildcard *.o), which will expand the value)
  2. Searching files:
  3. Pseudo Object: clean(put ".PHONY : clean" first)
  4. Multiple Objects: useage of "$@"
  5. Static Pattern:[targets ...] : [target-pattern] : [prereq-pattern]
    OBJ = foo.o bar.o
    $(OBJ):%.o : %.c
    $(CC) -c $(CFLAGS) %< -o %@
  6. 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