BUILDDIR := build SRCDIR := src FLAGS = -Wall -Wextra -g -O3 LD_CXXFLAGS = SRC := $(wildcard $(SRCDIR)/*.c) OBJ = $(filter-out $(BUILDDIR)/main.o, $(SRC:$(SRCDIR)/%.c=$(BUILDDIR)/%.o)) $(BUILDDIR)/main: $(SRCDIR)/main.c $(OBJ) $(CC) $^ -o $@ $(FLAGS) $(LD_FLAGS) $(BUILDDIR)/%.o: $(SRCDIR)/%.c $(SRCDIR)/include/%.h $(CC) -c $< -o $@ $(FLAGS)