Makefile rules for bonuses

This commit is contained in:
lalgarra 2025-10-30 19:01:03 +01:00
parent c2cce0985c
commit dca4e515a8

View file

@ -6,7 +6,7 @@
# By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ # # By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2025/10/22 20:41:03 by lalgarra #+# #+# # # Created: 2025/10/22 20:41:03 by lalgarra #+# #+# #
# Updated: 2025/10/30 18:42:43 by lalgarra ### ########.fr # # Updated: 2025/10/30 19:00:00 by lalgarra ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -21,10 +21,6 @@ GNL_SOURCES = get_next_line.c get_next_line_utils.c
SOURCES = $(foreach f, $(GNL_SOURCES), $(LIBDIR)/$f) SOURCES = $(foreach f, $(GNL_SOURCES), $(LIBDIR)/$f)
BONUS_SRC_BN = get_next_line_bonus.c get_next_line_utils_bonus.c
BONUS_SRC = $(foreach f, $(BONUS_SRC_BN), $(LIBDIR)/$f)
CFLAGS += -Wall -Wextra -Werror -g3 -iquote $(LIBDIR) -O0 CFLAGS += -Wall -Wextra -Werror -g3 -iquote $(LIBDIR) -O0
test001: test001.c $(SOURCES) test001: test001.c $(SOURCES)
@ -34,26 +30,39 @@ run_test = printf "==\n test001_01: BUFFER_SIZE=$(1): input$(3) vs output$(3)\n"
$(TIME) ./$(2) input$(3) > output$(3) ;\ $(TIME) ./$(2) input$(3) > output$(3) ;\
diff -s input$(3) output$(3) >> $(4) ; diff -s input$(3) output$(3) >> $(4) ;
test_recipe = $(CC) $(CFLAGS) -D BUFFER_SIZE=$(BUFFER_SIZE) $+ -o $(PRG) ; \
$(foreach i, $(IDXS), $(call run_test, $(BUFFER_SIZE),$(PRG),$i,$@))
PRG = test_bs$(BUFFER_SIZE) PRG = test_bs$(BUFFER_SIZE)
IDXS = 001 002 003 004 005 006 IDXS = 001 002 003 004 005 006
report_01: BUFFER_SIZE = 42 report_01: BUFFER_SIZE = 42
report_01: test001.c $(SOURCES) report_01: test001.c $(SOURCES)
$(CC) $(CFLAGS) -D BUFFER_SIZE=$(BUFFER_SIZE) $+ -o $(PRG) $(call test_recipe)
$(foreach i, $(IDXS), $(call run_test, $(BUFFER_SIZE),$(PRG),$i,$@))
report_02: BUFFER_SIZE = 80 report_02: BUFFER_SIZE = 80
report_02: test001.c $(SOURCES) report_02: test001.c $(SOURCES)
$(CC) $(CFLAGS) -D BUFFER_SIZE=$(BUFFER_SIZE) $+ -o $(PRG) $(call test_recipe)
$(foreach i, $(IDXS), $(call run_test, $(BUFFER_SIZE),$(PRG),$i,$@))
report_03: BUFFER_SIZE = 100000 report_03: BUFFER_SIZE = 100000
report_03: test001.c $(SOURCES) report_03: test001.c $(SOURCES)
$(CC) $(CFLAGS) -D BUFFER_SIZE=$(BUFFER_SIZE) $+ -o $(PRG) $(call test_recipe)
$(foreach i, $(IDXS), $(call run_test, $(BUFFER_SIZE),$(PRG),$i,$@))
report_04: BUFFER_SIZE = 1
report_04: test001.c $(SOURCES)
$(call test_recipe)
BONUS_SRC_BN = get_next_line_bonus.c get_next_line_utils_bonus.c
BONUS_SRC = $(foreach f, $(BONUS_SRC_BN), $(LIBDIR)/$f)
bonus_01: BUFFER_SIZE = 42
bonus_01: test001.c $(BONUS_SRC)
$(call test_recipe)
fclean: fclean:
rm -f test001 test001_01 output* report_* rpt_01 test_bs* rm -f test001 test001_01 output* report_* rpt_01 test_bs* bonus_*
all: report_01 report_02 report_03 all: report_01 report_02 report_03 report_04
re: fclean all re: fclean all