========================= Writing Minimal Makefiles ========================= - Ian! D. Allen - www.idallen.com - www.idallen.com The "make" program has many default rules built-in. Don't duplicate rules that make already knows. Here is a minimal makefile to buld "foo" from "foo.c" and "bar" from "bar.C" (C++): # minimal Makefile, using default rules built-in to "make" # CFLAGS = -g -Wall -Wextra all: foo bar foo: foo.c bar: bar.C Note that no compile or link lines are needed; we use the defaults. The special variable "CFLAGS" is automatically used by "make" as compiler options. A slightly more indirect example (only works for C, not C++ source): # minimal Makefile, using default rules # CFLAGS = -g -Wall -Wextra all: foo foo: foo.o - Blanks and blank lines affect Makefile operation: - target command lines must start with a TAB, not blanks - don't have lines with trailing blanks below a target - separate targets by empty lines - in VIM ":set list" will show tabs and trailing blanks - ":set nolist" to turn it off