Commit 524ac86c authored by jkvis's avatar jkvis
Browse files

Building multiple test targets

parent ededc38a
INC_LIB = $(shell find .. -name '*.a') INC_LIB = $(shell find .. -name '*.a')
LIB_DIR = $(dir $(INC_LIB)) LIB_DIR = $(dir $(INC_LIB))
LIB_NAME = $(notdir $(INC_LIB)) LIB_NAME = $(notdir $(INC_LIB))
INC_DIR = ../include INC_DIR = . ../include
SOURCES = $(shell find . -name '*.c') SOURCES = $(shell find . -name '*.c')
DEPS = $(OBJECTS:.o=.d) DEPS = $(OBJECTS:.o=.d)
TARGET = tests TARGETS = $(filter ./test_%, $(OBJECTS))
SHARED = $(filter-out $(TARGETS), $(OBJECTS))
CC = gcc CC = gcc
CFLAGS = -march=native -O0 -DDEBUG -ggdb3 CFLAGS = -march=native -O0 -DDEBUG -ggdb3
...@@ -15,17 +16,16 @@ CPPFLAGS = $(addprefix -I, $(INC_DIR)) -Wall -Wextra -pedantic ...@@ -15,17 +16,16 @@ CPPFLAGS = $(addprefix -I, $(INC_DIR)) -Wall -Wextra -pedantic
.PHONY: all clean run_tests .PHONY: all clean run_tests
all: $(TARGET) all: $(OBJECTS) $(TARGETS:.o=.out)
run_tests: $(TARGET) run_tests: all
@echo running tests... @ - $(foreach T, $(TARGETS:.o=.out), ./$T;)
clean: clean:
rm -f $(OBJECTS) $(DEPS) $(TARGET) rm -f $(OBJECTS) $(DEPS) $(TARGETS:.o=)
$(CC) $(CFLAGS) $(CPPFLAGS) $^ $(addprefix -L, $(LIB_DIR)) $(addprefix -l, $(LIB_NAME:lib%.a=%) $(LIB_NAME:lib%.a=%)) -o $@ $(CC) $(CFLAGS) $(CPPFLAGS) $(@:.out=.o) $^ $(addprefix -L, $(LIB_DIR)) $(addprefix -l, $(LIB_NAME:lib%.a=%) $(LIB_NAME:lib%.a=%)) -o $@
-include $(DEPS) -include $(DEPS)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment