Last active
December 11, 2015 19:19
-
-
Save matze/4648061 to your computer and use it in GitHub Desktop.
Template for C project Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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