Makefile for CGI program using SQLite library I am developing a CGI program in C on Linux using gcc, GNU make and the SQLite library. How does my makefile look?

# Automatic Variables
# $@ file name of target
# $&lt; name of the first prerequisite
# $? name  of all prerequisites newer than target
# $^ names of all prerequisites
# Pattern rule example - complile object files from prerequisites
# %.o: %.c
#   $(CC) -c $(CFLAGS) $&lt; -o $@ 
#
# Predefined Variables  
# CC compiler, default gcc
# CFLAGS compiler flags
# LDFLAGS linker flags such as -L (extra directories searched for -l)
# LDLIBS libaries such as -lfoo

CC=gcc
CFLAGS=-ansi -pedantic -Wall -Wextra -O2
LDLIBS=-ldl -lpthread
# directory of SQLite library
SQLITEDIR=sqlite

sqlfun.cgi: sqlfuncgi.o sqlite3.o
    $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)

sqlite3.o: $(SQLITEDIR)/sqlite3.c
    $(CC) -o $@ $^ -c -Os 

sqlfuncgi.o: sqlfuncgi.c
    $(CC) -o $@ $^ -c $(CFLAGS) 

.PHONY: clean test
clean:
    rm -f sqlfun.cgi *.o

test:
    clear
    cppcheck --enable=all --inconclusive --std=c89 sqlfuncgi.c
    valgrind --leak-check=yes ./sqlfun.cgi test
First impressions
This is clear and easy to read, and follows conventions well.

Use more built-ins
You can use more of Make's built-in rules.  For example, this rule can be omitted entirely:
sqlfuncgi.o: sqlfuncgi.c
    $(CC) -o $@ $^ -c $(CFLAGS)

If you add $(SQLITEDIR) to the VPATH, the sqlite3.o rule becomes simply
sqlite3.o: CFLAGS += -Os

And the link rule can use the built-in LINK.c variable:
sqlfun.cgi: sqlfuncgi.o sqlite3.o
    $(LINK.c) -o $@ $^  $(LDLIBS)


Special targets
Good use of .PHONY.  We probably also want .DELETE_ON_ERROR to ensure that if any command fails, its partially-written outputs don't hang around and appear to be made

Portability improvement
We can use Make's predefined $(RM) in place of rm -f.