-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
102 lines (80 loc) · 2.61 KB
/
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: cacharle <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/02/03 04:14:24 by cacharle #+# #+# #
# Updated: 2020/10/10 08:11:22 by cacharle ### ########.fr #
# #
# **************************************************************************** #
RM = rm -f
MAKE = make --no-print-directory
JOBS = 2
DOXYGEN = doxygen
DOXYGEN_FILE = Doxyfile
DOC_DIR = doc
LIBFTDIR = libft
INCLUDEDIR = include
SRCDIR = src
OBJDIR = obj
OBJDIRS = $(shell find $(SRCDIR) -type d | sed 's/src/$(OBJDIR)/')
INCLUDE = $(shell find $(INCLUDEDIR) -name "*.h")
SRC = $(shell find $(SRCDIR) -type f -name "*.c")
OBJ = $(SRC:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
CC = gcc
CCFLAGS = -g -O2 -I$(LIBFTDIR)/include -I$(INCLUDEDIR) -Wall -Wextra #-Werror
LDFLAGS = -L$(LIBFTDIR) -lft
NAME = minishell
.PHONY: all
all: libft_all prebuild
@$(MAKE) -j$(JOBS) allnopre
.PHONY: allnopre
allnopre: $(NAME)
.PHONY: prebuild
prebuild:
@for subdir in $(OBJDIRS); do echo "Making dir $$subdir"; mkdir -p $$subdir; done
$(NAME): $(OBJ)
@echo "Linking: $@"
@$(CC) -o $@ $(OBJ) $(LDFLAGS)
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(INCLUDE)
@echo "Compiling: $@"
@$(CC) $(CCFLAGS) $(MINISHELL_TEST_FLAGS) -c -o $@ $<
.PHONY: clean
clean: libft_clean
@echo "Removing objects"
@$(RM) -r $(OBJDIR)
.PHONY: fclean
fclean: libft_fclean
@echo "Removing objects"
@$(RM) -r $(OBJDIR)
@echo "Removing exectable"
@$(RM) $(NAME)
.PHONY: re
re: fclean all
.PHONY: relocal
relocal:
@echo "Removing objects"
@$(RM) -r $(OBJDIR)
@echo "Removing exectable"
@$(RM) $(NAME)
relocal: all
.PHONY: libft_all
libft_all:
@$(MAKE) -C $(LIBFTDIR) all
.PHONY: libft_clean
libft_clean:
@$(MAKE) -C $(LIBFTDIR) clean
.PHONY: libft_fclean
libft_fclean:
@$(MAKE) -C $(LIBFTDIR) fclean
.PHONY: doc
doc:
mkdir -p tmp
for f in $(SRC) $(INCLUDE) $(shell find libft/src -name "*.c") $(shell find libft/include -name "*.h"); do mkdir -p tmp/`dirname $$f` && sed 's_^/\*$$_/**_' $$f > tmp/$$f; done
$(DOXYGEN) $(DOXYGEN_FILE)
.PHONY: doc_clean
doc_clean:
$(RM) -r $(DOC_DIR)
$(RM) -r tmp