-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
58 lines (42 loc) · 939 Bytes
/
Makefile
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
CC ?= gcc
RM ?= rm
CFLAGS = -O0 -std=gnu99 -Wall
LFLAGS =
INC_DIR = include
SRC_DIR = src
TEST_DIR = test
#TEST_SRC = test_resolver.c
LIB =
OBJ =
EXEC = dns_main
TEST =
#Addition FLAGS
CFLAGS += -I $(INC_DIR)
LFLAGS +=
vpath %.c $(SRC_DIR)
ifndef TEST_SRC
TEST_SRC = $(wildcard $(TEST_DIR)/*.c)
else
TEST_SRC := $(addprefix $(TEST_DIR)/, $(TEST_SRC))
endif
TEST = $(patsubst %.c, %.out, $(TEST_SRC))
OBJ_SRC = $(wildcard $(SRC_DIR)/utility/*.c)
OBJ = $(patsubst %.c, %.o, $(OBJ_SRC)) parser.o
#src/dns_main.o
#Debug FLAGS
ifeq ($(strip $(DEBUG)), 1)
CFLAGS += -DDEBUG -g3
endif
.PHONY: all clean
all: $(EXEC)
$(EXEC): $(OBJ)
$(CC) $(CFLAGS) -o $@ $^
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $^
#$(notdir $PATH) can left the file name without dir
%.out: %.c
$(CC) $(CFLAGS) -DDEBUG -g3 -E $^ > tmp
$(CC) $(CFLAGS) -DDEBUG -g3 -o $(notdir $@) $^ $(OBJ)
test: $(OBJ) $(TEST)
clean:
$(RM) -rf $(EXEC) $(OBJ) $(notdir $(TEST))