CFLAGS = -Wall -std=gnu99 -O CC = gcc LDLIBS = -lm # link with math library default: out-hello.txt out-echo.txt out-math.txt out-hello.txt: hello ./hello > out-hello.txt out-echo.txt: Makefile echo 'hello' > $@ # $@ here is actually the target: out-echo.txt hello: hello.o $(CC) $(CFLAGS) hello.o -o hello hello.o: hello.c $(CC) $(CFLAGS) -c $< -o $@ # here $< is the first ingredient: hello.c .PHONEY:clean # clean is not a file but a phoney target clean: rm -f out*.txt *.o find . -type f -executable -delete out-math.txt: math # math is built automaticall with built-in rules ./math > $@ test: @echo '$$(CC)=' $(CC) @echo '$$(CFLAGS)=' $(CFLAGS) @echo 'CFLAGS=' CFLAGS