forked from alecmalloc/webserve
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (36 loc) · 968 Bytes
/
Makefile
File metadata and controls
54 lines (36 loc) · 968 Bytes
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
NAME = webserv
BUILD_DIR = ./obj
SRC_DIR = ./src
INCL_DIR = ./inc
LIB =
LIBS = $(addprefix -L, $(LIB))
SRCS = $(filter-out %_bonus.cpp, $(shell find $(SRC_DIR) -name *.cpp))
OBJS = $(subst $(SRC_DIR), $(BUILD_DIR), $(SRCS:.cpp=.o))
BONUS_SRCS = $(shell find $(SRC_DIR) -name *-bonus.cpp))
BONUS_OBJS = $(subst $(SRC_DIR), $(BUILD_DIR), $(BONUS_SRCS:.cpp=.o))
DEPS = $(OBJS:.o=.d)
INC_DIRS = $(shell find $(INCL_DIR) -type d)
INC_FLAGS = $(addprefix -I, $(INC_DIRS))
FOLDERS = uploads session
CC = c++
CPPFLAGS = $(INC_FLAGS) -Wall -Werror -Wextra -MMD -MP -g3 -std=c++98
LD = c++
LDFLAGS = $(LIBS) -g
LINKS =
all: $(NAME) $(FOLDERS)
$(FOLDERS):
mkdir -p $@
$(NAME): $(OBJS)
ifdef $(LIB)
make -C $(LIB)
endif
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LINKS)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
mkdir -p $(@D)
$(CC) $(CPPFLAGS) -c $< -o $@
clean:
$(RM) -r $(BUILD_DIR) $(FOLDERS)
fclean: clean
$(RM) $(NAME)
re: fclean all
.PHONY: clean fclean re all