3.1. Makefile Basics

Example

foo: foo.o helper.o
    gcc -Wall foo.o helper.o -o foo

bar: bar.o helper.o
    gcc -Wall bar.o helper.o -o bar

bar.o: bar.c
    gcc bar.c -c -o bar

foo.o: foo.c foo.h
    gcc -ansi -Wall -c foo.c -o foo.o

Written by Shlomi Fish