Commit 524ac86c authored by jkvis's avatar jkvis

Building multiple test targets

parent ededc38a
INC_LIB = $(shell find .. -name '*.a')
LIB_DIR = $(dir $(INC_LIB))
LIB_NAME = $(notdir $(INC_LIB))
INC_DIR = ../include
INC_DIR = . ../include
SOURCES = $(shell find . -name '*.c')
OBJECTS = $(SOURCES:.c=.o)
DEPS = $(OBJECTS:.o=.d)
TARGET = tests
TARGETS = $(filter ./test_%, $(OBJECTS))
SHARED = $(filter-out $(TARGETS), $(OBJECTS))
CC = gcc
CFLAGS = -march=native -O0 -DDEBUG -ggdb3
......@@ -15,17 +16,16 @@ CPPFLAGS = $(addprefix -I, $(INC_DIR)) -Wall -Wextra -pedantic
.PHONY: all clean run_tests
all: $(TARGET)
all: $(OBJECTS) $(TARGETS:.o=.out)
run_tests: $(TARGET)
@echo running tests...
./$<
run_tests: all
@ - $(foreach T, $(TARGETS:.o=.out), ./$T;)
clean:
rm -f $(OBJECTS) $(DEPS) $(TARGET)
rm -f $(OBJECTS) $(DEPS) $(TARGETS:.o=)
$(TARGET): $(OBJECTS)
$(CC) $(CFLAGS) $(CPPFLAGS) $^ $(addprefix -L, $(LIB_DIR)) $(addprefix -l, $(LIB_NAME:lib%.a=%) $(LIB_NAME:lib%.a=%)) -o $@
$(TARGETS:.o=.out): $(SHARED)
$(CC) $(CFLAGS) $(CPPFLAGS) $(@:.out=.o) $^ $(addprefix -L, $(LIB_DIR)) $(addprefix -l, $(LIB_NAME:lib%.a=%) $(LIB_NAME:lib%.a=%)) -o $@
-include $(DEPS)
......
Markdown is supported
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