diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 47 |
1 files changed, 24 insertions, 23 deletions
@@ -1,38 +1,39 @@ CC?=gcc -RM:=rm -rf -SRC_DIR:=src -OBJ_DIR:=obj +CFLAGS:=-std=c99 -O0 -g -Wall -DDEBUG + INC_DIRS=$(addprefix -iquote,include) -PARCINI_SOURCES:=$(wildcard $(SRC_DIR)/*.c) -PARCINI_OBJECTS:=$(PARCINI_SOURCES:%.c=$(OBJ_DIR)/%.o) -BUILD_DIR:=build +BUILDIR:=build +OBJDIR:=$(BUILDIR)/obj + +PARCINI_SRCS:=$(wildcard src/*.c) +PARCINI_OBJS:=$(PARCINI_SRCS:%.c=$(OBJDIR)/%.o) -test: CFLAGS := -std=c99 -O0 -g -Wall -DDEBUG -test: $(BUILD_DIR) tests/parcini +ifdef ASAN +CFLAGS+= -fsanitize=address -fno-omit-frame-pointer +endif -tests/%: $(OBJ_DIR)/src/tests/%.o $(PARCINI_OBJECTS) - $(CC) $(LDFLAGS) -o $(BUILD_DIR)/$@ $^ - $(BUILD_DIR)/$@ +test: +test: $(BUILDIR) tests/parcini + +tests/%: $(OBJDIR)/src/tests/%.o $(PARCINI_OBJS) + mkdir -p $(BUILDIR)/$(@D) + $(CC) $(CFLAGS) $(LDFLAGS) -o $(BUILDIR)/$@ $^ + $(BUILDIR)/$@ example: CFLAGS := -std=c99 -O2 -Wall -example: $(OBJ_DIR)/example/example.o $(PARCINI_OBJECTS) - $(CC) $(LDFLAGS) -o $(BUILD_DIR)/example/$@ $^ +example: $(OBJDIR)/example/example.o $(PARCINI_OBJS) + mkdir -p $(@D) + $(CC) $(LDFLAGS) -o $(BUILDIR)/example/$@ $^ -$(OBJ_DIR)/%.o: %.c +$(OBJDIR)/%.o: %.c + mkdir -p $(@D) $(CC) -c $(CFLAGS) $(INC_DIRS) -o $@ $< -$(BUILD_DIR): - mkdir -p $(BUILD_DIR)/tests - mkdir -p $(BUILD_DIR)/example - mkdir -p $(OBJ_DIR)/src/tests - mkdir -p $(OBJ_DIR)/example - clean: - $(RM) $(OBJ_DIR) - $(RM) $(BUILD_DIR) + rm -r $(BUILDIR) .PHONY: clean test -.PRECIOUS: $(OBJ_DIR)/tests/%.o $(OBJ_DIR)/%.o +.PRECIOUS: $(OBJDIR)/tests/%.o $(OBJDIR)/%.o |