-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (66 loc) · 2.25 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
# **************************************************************************** #
# LE - / #
# / #
# Makefile .:: .:/ . .:: #
# +:+:+ +: +: +:+:+ #
# By: wblondel <[email protected]> +:+ +: +: +:+ #
# #+# #+ #+ #+# #
# Created: 2017/12/04 02:31:10 by wblondel #+# ## ## #+# #
# Updated: 2017/12/04 05:54:12 by wblondel ### #+. /#+ ###.fr #
# / #
# / #
# **************************************************************************** #
# Compiler configuration
#CC= gcc
CFLAGS= -Wall -Wextra -Werror
## Flags for the C preprocessor
CPPFLAGS= -I$(SRC_PATH) -I$(LIB) -I$(INC_PATH)
## Libraries path
LDFLAGS= -L$(LIB)
## Libraries to link into the library
LDLIBS= -lft
NAME=libunit.a
# Project related variables
SRC_PATH = src
INC_PATH = inc
OBJ_PATH = obj
SRC_NAME = suite.c list.c run.c io.c printf.c
OBJ_NAME = $(SRC_NAME:.c=.o)
SRC = $(addprefix $(SRC_PATH)/,$(SRC_NAME))
OBJ = $(addprefix $(OBJ_PATH)/,$(OBJ_NAME))
LIB = libft
HEADER = $(INC_PATH)/libunit.h
# Tracks malloc() and free()
ifdef ALLOCWRAP
LDFLAGS += $(HOME)/lib/alloc_wrap.c -ldl
endif
# Entry point
all: $(NAME)
# Compiles libunit
$(NAME): $(LIB)/$(LIB).a $(OBJ)
ar rc $(NAME) $(OBJ)
ranlib $(NAME)
# Compiles libft/libft.a
# It's a prerequisite to compile libunit
$(LIB)/$(LIB).a:
$(MAKE) -C ./$(LIB)
# Creates obj/ directory
# It's a prerequisite to compile any OBJ
$(OBJ_PATH):
mkdir $@
$(OBJ): | $(OBJ_PATH)
# Compiles all the src/ into obj/
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
ifeq ($(shell $(MAKE) --question -C ./$(LIB) ; echo $$?), 1)
.PHONY: $(LIB)/$(LIB).a
endif
.PHONY: clean
clean:
$(MAKE) -C ./$(LIB) clean
$(RM) -r $(OBJ_PATH)
fclean: clean
$(MAKE) -C ./$(LIB) fclean
$(RM) -r $(NAME) $(NAME).dSYM
re: fclean
$(MAKE) all