CC = gcc CFLAGS = -Wall -Wextra -std=c11 -g -fwrapv LDFLAGS = -lsqlite3 TARGETS = tomsg_server .PHONY: all clean remake # Clear all implicit suffix rules .SUFFIXES: # Don't delete intermediate files .SECONDARY: all: $(TARGETS) clean: rm -f $(TARGETS) *.o *.sql.h remake: clean $(MAKE) all $(TARGETS): $(patsubst %.c,%.o,$(wildcard *.c)) $(CC) -o $@ $^ $(LDFLAGS) %.o: %.c $(wildcard *.h) $(patsubst %.sql,%.sql.h,$(wildcard *.sql)) $(CC) $(CFLAGS) -c -o $@ $< %.sql.h: %.sql xxd -i $^ $@