aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 8917d8e1ffad6ec289287fe326bb70c80fe141a2 (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
CC?=gcc
RM:=rm -rf

SRC_DIR:=src
OBJ_DIR:=obj
INC_DIRS=$(addprefix -iquote,include)

PARCINI_SOURCES:=$(wildcard $(SRC_DIR)/*.c)
PARCINI_OBJECTS:=$(PARCINI_SOURCES:%.c=$(OBJ_DIR)/%.o)
BUILD_DIR:=build

test: CFLAGS := -std=c99 -O0 -g -Wall -DDEBUG
test: $(BUILD_DIR) tests/parcini

tests/%: $(OBJ_DIR)/src/tests/%.o $(OBJ_DIR)/src/%.o $(PARCINI_OBJECTS)
	$(CC) $(LDFLAGS) -o $(BUILD_DIR)/$@ $^
	$(BUILD_DIR)/$@

$(OBJ_DIR)/%.o: %.c
	$(CC) -c $(CFLAGS) $(INC_DIRS) -o $@ $<

$(BUILD_DIR):
	mkdir -p $(BUILD_DIR)/tests
	mkdir -p $(OBJ_DIR)/src/tests

clean:
	$(RM) $(OBJ_DIR)
	$(RM) $(BUILD_DIR)

.PHONY: clean test

.PRECIOUS: $(OBJ_DIR)/tests/%.o $(OBJ_DIR)/%.o