-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (49 loc) · 2.15 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
#******************************************************************************#
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: angagnie <angagnie@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2015/12/07 17:38:00 by angagnie #+# #+# #
# Updated: 2021/10/26 21:31:00 by angagnie ### ########.fr #
# #
#******************************************************************************#
# Folders
SOURCE_PATH := src
CACHE_PATH := cache
HEADER_PATH := include
# Files
TARGET_STATIC = libft.a
TARGET_SHARED = libft.so
FILES = $(shell find $(SOURCE_PATH) -name '*.c')
OBJECTS = $(subst $(SOURCE_PATH),$(CACHE_PATH),$(FILES:.c=.o))
DEPFILES = $(OBJECTS:.o=.d)
# Compiler
CFLAGS += --std=gnu99 -Wall -Wextra
CPPFLAGS += -I $(HEADER_PATH)
CPPFLAGS += -Wno-unused-result -Wformat=2
CPPFLAGS += -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition
static: $(TARGET_STATIC)
shared: $(TARGET_SHARED)
all: static shared
include $(wildcard $(DEPFILES))
$(TARGET_STATIC): $(OBJECTS)
$(AR) rcs $@ $^
$(TARGET_SHARED): $(OBJECTS)
$(CC) -shared $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
$(CACHE_PATH)/%.o: $(SOURCE_PATH)/%.c
@mkdir -p $(@D)
$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -c $< -o $@
clean:
$(RM) -r $(CACHE_PATH)
fclean: clean
$(RM) $(TARGET_STATIC) $(TARGET_SHARED)
.PHONY: static shared all clean fclean
local:
@$(MAKE) fclean --no-print-directory
@$(MAKE) fclean -C test
@$(MAKE) fclean -C test/framework
@CFLAGS="-g -O1" $(MAKE) --no-print-directory
@CFLAGS="-g -O1" CPPFLAGS="-I ../../include" $(MAKE) -C test/framework
@CFLAGS="-g -O1" CPPFLAGS="-I ../include -I framework" LDFLAGS="-L .. -L framework" LDLIBS="-lunit -lft" $(MAKE) -C test