-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (68 loc) · 1.74 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
##
## EPITECH PROJECT, 2017
##
## File description:
## makefile
##
NAME = liblstr.so
CC = gcc
ARCHIVER = ar
SRCS = src/lstr.c
SRCS += src/lstr_addch.c
SRCS += src/lstr_append.c
SRCS += src/lstr_concat.c
SRCS += src/lstr_dup.c
SRCS += src/lstr_format.c
SRCS += src/lstr_remove.c
SRCS += src/lstr_replace.c
SRCS += src/lstr_resize.c
SRCS += src/lstr_set.c
SRCS += src/lstr_shift.c
SRCS += src/lstr_shrink_to_fit.c
SRCS += src/lstr_clear.c
SRCS += src/lstr_insert.c
SRCS += src/lstr_erase.c
SRCS += src/lstr_swap.c
SRCS += src/lstr_fd.c
SRCS += src/lstr_file.c
TESTS_SRCS := $(SRCS)
TESTS_SRCS += tests/lblstr_tests.c
OBJS = $(SRCS:.c=.o)
TESTS_OBJS = $(TESTS_SRCS:.c=.o)
RM = rm -f
CFLAGS = -Werror -Wall -Wextra -fPIC -pedantic
CFLAGS += -I ./include
LDFLAGS = -shared
GREEN = '\033[0;32m'
NO_COLOR = '\033[0m'
%.o : %.c
@$ $(CC) $(CFLAGS) -c $< -o $@
@echo "$(CC) $(CFLAGS) -c $< -o $@ ["$(GREEN)"OK"$(NO_COLOR)"]"
.SUFFIXES: .o .c
all: $(NAME)
$(NAME): $(OBJS)
@$ $(CC) $(LDFLAGS) $(OBJS) -o $@
@echo "$(CC) $(LDFLAGS) $(OBJS) -o $@ \
["$(GREEN)"LINKING OK"$(NO_COLOR)"]"
tests_run: $(TESTS_OBJS)
@$ $(CC) -lcriterion $(TESTS_OBJS) -o $@
@echo "$(CC) -lcriterion $(TESTS_OBJS) -o $@ \
["$(GREEN)"LINKING OK"$(NO_COLOR)"]"
./$@
@$(RM) $@
@$(RM) $(TESTS_OBJS)
debug: CFLAGS += -g3
debug: re
clean:
$(RM) $(OBJS)
fclean: clean
$(RM) $(NAME) $(NAME:.so=.a)
re: fclean all
install: re
@cp $(NAME) /usr/lib/$(NAME) 2> /dev/null || \
printf "\033[1m\033[31mError : try sudo make install\033[0m\n" && \
cp include/*.h /usr/include/ 2> /dev/null && \
printf "\033[1m\033[32mLibrary successfull installed !\033[0m\n"
static: $(OBJS)
$(ARCHIVER) rc $(NAME:.so=.a) $(OBJS)
.PHONY: all clean fclean re tests_run debug install static