Revert "Makefile???"

This reverts commit 56a46c0bb0.
This commit is contained in:
Andrei Pago 2023-04-05 20:14:23 +02:00
parent 56a46c0bb0
commit 54da1d608e
1 changed files with 3 additions and 40 deletions

View File

@ -11,7 +11,7 @@ SRC = \
HEADERS = ft_bsq.h
OBJDIR = obj
OBJDIR = srcs
SRCDIR = srcs
INCDIR = includes
@ -22,20 +22,18 @@ 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 test tests run valgrind
.PHONY: re fclean clean all
all: $(NAME)
@ -44,46 +42,11 @@ 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)
@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) ./assets/subject.map ./assets/full.map $(CLR_RST) $(SUCCESS_VALG)
$(CC) $(CFLAGS) -c $< -o $@