NAME = gol
-VER ?= 0.1.0
+VER ?= 0.2.2
SHELL = /bin/bash
SRCDIR ?= ./src
OBJDIR ?= ./obj
BUILD ?= ./build
-TESTDIR ?= ./test
+TESTDIR ?= ./tests
TESTBIN ?= $(TESTDIR)/bin
BIN ?= $(BUILD)/$(NAME)
HDR ?= $(wildcard $(SRCDIR)/*.h)
OBJ ?= $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRC))
TEST ?= $(wildcard $(TESTDIR)/*.c)
-TESTS ?= $(patsubst $(TESTDIR)/%.c, $(TESTBIN)/%, $(TESTS))
+TESTS ?= $(patsubst $(TESTDIR)/%.c, $(TESTBIN)/%, $(TEST))
TAR ?= $(BUILD)/$(NAME)-$(VERSION).tar.gz
TARSUM ?= $(BUILD)/$(NAME)-$(VERSION)-tar.hash
HASH ?= sha256sum
CFLAGS += -O2 -pipe
WARNINGS ?= -Wall -Wextra -Wpedantic
-CPPFLAGS += -I .
-LDFLAGS += -L .
+CPPFLAGS += -I $(SRCDIR)
+LDFLAGS += -L $(SRCDIR)
LDLIBS +=
FLAGS ?= $(CPPFLAGS) $(CFLAGS) $(WARNINGS) $(LDFLAGS) $(LDLIBS)
$(BIN): $(OBJ)
$(CC) $(OBJ) $(FLAGS) -o $(BIN)
-$(OBJDIR)/%.o: $(SRCDIR)/%.c $(SRCDIR)/$(HDR)
+$(OBJDIR)/%.o: $(SRCDIR)/%.c $(HDR)
$(CC) -c $(FLAGS) $< -o $@
clean:
debug: $(BIN)
$(TESTBIN)/%: $(TESTDIR)/%.c
- $(CC) $(FLAGS) $< $(OBJS) -o $@
+ $(CC) $(FLAGS) $< $(filter-out $(OBJDIR)/$(NAME).o,$(OBJ)) -o $@
test: $(BIN) $(TESTBIN) $(TESTS)
for test in $(TESTS); do ./$$test; done