This repository was archived by the owner on Dec 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (76 loc) · 2.59 KB
/
Makefile
File metadata and controls
99 lines (76 loc) · 2.59 KB
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
#******************************************************************************#
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jlagneau <jlagneau@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2015/10/24 07:02:44 by jlagneau #+# #+# #
# Updated: 2017/04/06 08:10:40 by jlagneau ### ########.fr #
# #
#******************************************************************************#
# Variables
NAME = libfts.a
DEB_NAME = libfts_debug.a
OBJS_PATH = .obj/
DEPS_PATH = .dep/
SRCS_PATH = src/
HEAD_PATH = include/
CFLAGS = -f
DEPSFLAGS = -MD "$(DEPS_PATH)$(notdir $(@:.o=.d))"
# Detect OS
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS_DEFINE := $(shell ln -sf define_linux.s depend/define.s)
CFLAGS += elf64
STRPFLAGS += --strip-unneeded
endif
ifeq ($(UNAME_S),Darwin)
OS_DEFINE := $(shell ln -sf define_macosx.s depend/define.s)
CFLAGS += macho64
STRPFLAGS += -x
endif
AR = ar
ARFLAGS = rcs
RM = rm
RMFLAGS = -rf
# Sources files
SRCS := $(shell find src -type f | tr '\n' ' ')
OBJS = $(addprefix $(OBJS_PATH), $(notdir $(SRCS:.s=.o)))
DEPS = $(addprefix $(DEPS_PATH), $(notdir $(SRCS:.s=.d)))
DEB_OBJS = $(addprefix $(OBJS_PATH), $(notdir $(SRCS:.s=_debug.o)))
DEB_DEPS = $(addprefix $(DEPS_PATH), $(notdir $(DEB_OBJS:.o=.d)))
# Phony
.PHONY: all re clean fclean debug redebug test
# Rules
$(NAME): CFLAGS += -Ox
$(NAME): $(OBJS)
$(AR) $(ARFLAGS) $@ $^
ranlib $@
$(DEB_NAME): CFLAGS += -g
$(DEB_NAME): $(DEB_OBJS)
$(AR) $(ARFLAGS) $@ $^
ranlib $@
$(OBJS_PATH)%.o: $(SRCS_PATH)%.s
@mkdir -p $(OBJS_PATH) $(DEPS_PATH)
nasm $(CFLAGS) $(DEPSFLAGS) -o $@ $<
@strip $(STRPFLAGS) $@ -o $@
$(OBJS_PATH)%_debug.o: $(SRCS_PATH)%.s
@mkdir -p $(OBJS_PATH) $(DEPS_PATH)
nasm $(CFLAGS) $(DEPSFLAGS) -o $@ $<
debug: $(DEB_NAME)
redebug: fclean debug
test: $(NAME)
make -C tests
@ln -sf ./tests/test ./test
@ln -sf ./tests/ft_cat.sh ./ft_cat
all: $(NAME)
clean:
make -C tests clean
$(RM) $(RMFLAGS) $(OBJS_PATH) $(DEPS_PATH)
fclean: clean
make -C tests fclean
$(RM) $(RMFLAGS) $(NAME) $(DEB_NAME) ./test ./ft_cat
re: fclean all
-include $(DEPS)
-include $(DEB_DEPS)