-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
43 lines (30 loc) · 867 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
NAME = simplehttpserver
CC = gcc
# MMD Genera los ficheros de dependencia .d
# MP los agrega como PHONY
# con estas dos flags, controlamos los relinks y recompilaciones innecesarias.
CFLAGS = -Wall -Werror -Wextra -MMD -MP
OBJ_DIR = ./obj
SRC_DIR = ./src
INC_DIR = ./hdrs
SERVER_SRC = server.c \
test.c
SERVER_OBJS = $(patsubst %.c,${OBJ_DIR}/%.o,${SERVER_SRC})
SERVER_DEPS = $(patsubst %.c,${OBJ_DIR}/%.d,${SERVER_SRC})
ifdef CSANITIZE
CFLAGS += -fsanitize=address -fsanitize=leak
endif
all: $(NAME)
$(NAME): $(SERVER_OBJS)
$(CC) $(CFLAGS) $(SERVER_OBJS) -o $(NAME)
$(OBJ_DIR)/%.o : ${SRC_DIR}/%.c Makefile
@mkdir -p ${OBJ_DIR}
$(CC) $(CFLAGS) -c $< -I${INC_DIR} -o $@
clean:
rm -rf ${OBJ_DIR}
fclean: clean
rm -rf ${NAME}
re: fclean all
#include de los ficheros de dependencias.
-include ${SERVER_DEPS}
.PHONY: all clean fclean re