Makefile???
This commit is contained in:
parent
ef28991e7c
commit
56a46c0bb0
43
Makefile
43
Makefile
|
@ -11,7 +11,7 @@ SRC = \
|
|||
|
||||
HEADERS = ft_bsq.h
|
||||
|
||||
OBJDIR = srcs
|
||||
OBJDIR = obj
|
||||
SRCDIR = srcs
|
||||
INCDIR = includes
|
||||
|
||||
|
@ -22,18 +22,20 @@ CFLAGS = \
|
|||
-Wextra \
|
||||
-Werror \
|
||||
-I$(INCDIR) \
|
||||
-fcolor-diagnostics \
|
||||
|
||||
_OBJ = $(SRC:.c=.o)
|
||||
OBJ = $(addprefix $(OBJDIR)/,$(_OBJ))
|
||||
DEPS = $(addprefix $(INCDIR)/,$(HEADERS))
|
||||
|
||||
RM = /bin/rm -f
|
||||
RMDIR = /bin/rmdir
|
||||
|
||||
.DEFAULT_GOAL = all
|
||||
|
||||
NAME ?= bsq
|
||||
|
||||
.PHONY: re fclean clean all
|
||||
.PHONY: re fclean clean all test tests run valgrind
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
|
@ -42,11 +44,46 @@ clean:
|
|||
|
||||
fclean: clean
|
||||
$(RM) $(NAME)
|
||||
@$(RMDIR) $(OBJDIR) 2>/dev/null || true
|
||||
|
||||
re: fclean all
|
||||
|
||||
$(NAME): $(OBJ)
|
||||
$(CC) $(LDFLAGS) $^ -o $@
|
||||
|
||||
$(OBJ): | $(OBJDIR)
|
||||
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(DEPS)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
@norminette $< >/dev/null || { printf '\033[101;37m%s\033[m\n' "!Norminette Failed>>>"; norminette $<; printf '\033[101;37m%s\033[m\n' "<<<Norminette Failed!"; exit 1; }
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR):
|
||||
@mkdir -p $@
|
||||
|
||||
tests: test valgrind
|
||||
|
||||
test: re run fclean
|
||||
|
||||
SUCCESS_MSG = printf '\n\033[102;30m --- %s --- \033[m\n\n' "Test passed!"
|
||||
FAIL_MSG = printf '\n\033[101;37m --- %s --- \033[m\n\n' "Test failed!"
|
||||
SUCCESS_MSG_VALG = printf '\n\033[102;30m --- %s --- \033[m\n\n' "Valgrind ran without errors!"
|
||||
FAIL_MSG_VALG = printf '\n\033[101;37m --- %s --- \033[m\n\n' "Valgrind Failed!"
|
||||
SUCCESS = && $(SUCCESS_MSG) || $(FAIL_MSG)
|
||||
SUCCESS_VALG = && $(SUCCESS_MSG_VALG) || $(FAIL_MSG_VALG)
|
||||
FAIL = && $(FAIL_MSG) || $(SUCCESS_MSG)
|
||||
VALGRIND = valgrind --leak-check=full --error-exitcode=1
|
||||
VALGRIND_SMALL = 2>/dev/null 1>&2 valgrind --error-exitcode=1
|
||||
# The following 3 lines intentionally contain non-printable characters, namely
|
||||
# the escape character \x1b. It is soley for the color-coding. If you use this Makefile,
|
||||
# either download/copy this file or select/copy the text directly and lose the colors.
|
||||
YLW = : [33m;
|
||||
CYN = : [36m;
|
||||
CLR_RST = && : [m
|
||||
|
||||
run:
|
||||
@clear
|
||||
$(CYN) $(VALGRIND_SMALL) ./$(NAME) $(CLR_RST) $(SUCCESS_VALG)
|
||||
$(YLW) ./$(NAME) $(CLR_RST) $(SUCCESS)
|
||||
|
||||
valgrind: re
|
||||
$(CYN) $(VALGRIND) ./$(NAME) ./assets/subject.map ./assets/full.map $(CLR_RST) $(SUCCESS_VALG)
|
||||
|
|
Loading…
Reference in New Issue