summaryrefslogtreecommitdiff
path: root/Makefile
blob: 0bdfd44f0a7af244fb865f9ac7b800bbe2212861 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
CC = gcc
CFLAGS = -g -Wall -Wpedantic
TARGET = parc
BASENM = buffer piece-table
SRC = $(addsuffix .c, $(addprefix src/, $(BASENM)) )
OBJDIR = out
OBJ = $(addsuffix .o, $(addprefix $(OBJDIR)/, $(BASENM)))

HEADERS = $(wildcard src/*.h)

TEST := buffer\
		piece-table-print\
		piece-table-delete\
		piece-table-insert
TEST_FILES = $(addprefix tests/, $(TEST))
TEST_SOURCES = $(addsuffix .c, $(addprefix tests/, $(TEST)))

all: $(TARGET)

$(TARGET): $(OBJ) src/main.c
	@$(CC) $(CFLAGS) $(OBJ) src/main.c -o $(TARGET)

$(OBJ): $(OBJDIR)/%.o: src/%.c $(HEADERS)
	@mkdir -p out
	@$(CC) $(CFLAGS) -o $@ -c $<

clean:
	@rm -f $(TARGET)
	@rm -f out/*
	@rm -rf out/
	@rm -f $(TEST_FILES)

$(TEST_FILES): $(TARGET) $(TEST_SOURCES) $(HEADERS)
	@$(CC) $(CFLAGS) -o $@ $(addsuffix .c, $@) $(OBJ)
	@if ./$@ ; then  echo "PASS: $@";else echo "FAIL: $@ exit value: $$?"; fi

test: $(TEST_FILES)

.PHONY: clean all test