piscine-bsq/Makefile

93 lines
2.2 KiB
Makefile
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

SRC = \
main.c \
io.c \
parsing.c \
parsing_simple.c \
solution.c \
printing.c \
map_helpers.c \
ft_string.c \
HEADERS = \
parsing.h \
printing.h \
solution.h \
ft_string.h \
OBJDIR = obj
SRCDIR = srcs
INCDIR = includes
CC = cc
LDFLAGS =
CFLAGS = \
-Wall \
-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 test tests run valgrind
all: $(NAME)
clean:
$(RM) $(OBJ)
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)
# @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 = : ;
CYN = : ;
CLR_RST = && : 
run:
@clear
$(CYN) $(VALGRIND_SMALL) ./$(NAME) $(CLR_RST) $(SUCCESS_VALG)
$(YLW) ./$(NAME) $(CLR_RST) $(SUCCESS)
valgrind: re
$(CYN) $(VALGRIND) ./$(NAME) $(CLR_RST) $(SUCCESS_VALG)