Skip to content

Instantly share code, notes, and snippets.

@milesrout
Last active November 2, 2017 09:11
Show Gist options
  • Save milesrout/6d1dae191ecea88b2ae5e9ebb3bfc66c to your computer and use it in GitHub Desktop.
Save milesrout/6d1dae191ecea88b2ae5e9ebb3bfc66c to your computer and use it in GitHub Desktop.
TARGET := a.out
PC_DEPS := gl glfw3
PC_CFLAGS := $(shell pkg-config --cflags $(PC_DEPS))
PC_LIBS := $(shell pkg-config --libs $(PC_DEPS))
SRCS := $(shell find src -name *.c)
OBJS := $(SRCS:%=build/%.o)
DEPS := $(OBJS:.o=.d)
INCS := $(addprefix -I,$(shell find ./include -type d))
CFLAGS += $(PC_CFLAGS) $(INCS) -MMD -MP
LDLIBS += $(PC_LIBS)
build/$(TARGET): $(OBJS)
$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDLIBS)
build/%.c.o: %.c
mkdir -p $(dir $@)
$(CC) -c $(CFLAGS) $< -o $@
.PHONY: clean syntastic
clean:
rm build/$(TARGET) $(OBJS) $(DEPS)
syntastic:
echo $(CFLAGS) | tr ' ' '\n' > .syntastic_c_config
-include $(DEPS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment