Skip to content

Instantly share code, notes, and snippets.

@matze
Last active December 11, 2015 19:19
Show Gist options
  • Save matze/4648061 to your computer and use it in GitHub Desktop.
Save matze/4648061 to your computer and use it in GitHub Desktop.
Template for C project Makefile
PKGS = glib-2.0
SRC = $(wildcard *.c)
OBJ = $(patsubst %.c,%.o,$(SRC))
BIN = foo
CFLAGS := $(CFLAGS) $(shell pkg-config --cflags $(PKGS))
LDFLAGS := $(LDFLAGS) $(shell pkg-config --libs $(PKGS))
.PHONY: clean
$(BIN): $(OBJ)
$(CC) $(OBJ) $(LDFLAGS) -o $@
%.o: %.c
$(CC) -c $(CFLAGS) -o $@ $<
clean:
rm -f $(OBJ) $(BIN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment