Modifying Makefile to do more writing less
This commit is contained in:
parent
3e47560e13
commit
c2cce0985c
1 changed files with 27 additions and 100 deletions
127
Makefile
127
Makefile
|
|
@ -6,7 +6,7 @@
|
|||
# By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2025/10/22 20:41:03 by lalgarra #+# #+# #
|
||||
# Updated: 2025/10/29 21:20:10 by lalgarra ### ########.fr #
|
||||
# Updated: 2025/10/30 18:42:43 by lalgarra ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -18,115 +18,42 @@ LIBDIR = ../repo_algarra
|
|||
TIME = /usr/bin/time
|
||||
|
||||
GNL_SOURCES = get_next_line.c get_next_line_utils.c
|
||||
SOURCES = $(foreach f, $(GNL_SOURCES), $(LIBDIR)/$f)
|
||||
#OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
#SRCBONUS = test_printf_bonus.c
|
||||
#OBJBONUS = $(SRCBONUS:.c=.o)
|
||||
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
|
||||
|
||||
#%.o: %.c
|
||||
# $(CC) $(CFLAGS) -c -o $*
|
||||
|
||||
test001: test001.c $(SOURCES)
|
||||
$(CC) $(CFLAGS) $+ -o $@
|
||||
|
||||
report_01: test001.c $(SOURCES)
|
||||
$(CC) $(CFLAGS) -D BUFFER_SIZE=42 $+ -o test001_01
|
||||
printf "==\n test001_01: BUFFER_SIZE=42: input001 vs output001\n" >> $@
|
||||
$(TIME) ./test001_01 input001 > output001
|
||||
diff -s input001 output001 >> $@
|
||||
printf "==\n test001_01: BUFFER_SIZE=42: input002 vs output002\n" >> $@
|
||||
$(TIME) ./test001_01 input002 > output002
|
||||
diff -s input002 output002 >> $@
|
||||
printf "==\n test001_01: BUFFER_SIZE=42: input003 vs output003\n" >> $@
|
||||
$(TIME) ./test001_01 input003 > output003
|
||||
diff -s input003 output003 >> $@
|
||||
printf "==\n test001_01: BUFFER_SIZE=42: input004 vs output004\n" >> $@
|
||||
$(TIME) ./test001_01 input004 > output004
|
||||
diff -s input004 output004 >> $@
|
||||
printf "==\n test001_01: BUFFER_SIZE=42: input005 vs output005\n" >> $@
|
||||
$(TIME) ./test001_01 input005 > output005
|
||||
diff -s input005 output005 >> $@
|
||||
printf "==\n test001_01: BUFFER_SIZE=42: input006 vs output006\n" >> $@
|
||||
$(TIME) ./test001_01 input006 > output006
|
||||
diff -s input006 output006 >> $@
|
||||
run_test = printf "==\n test001_01: BUFFER_SIZE=$(1): input$(3) vs output$(3)\n" >> $(4) ;\
|
||||
$(TIME) ./$(2) input$(3) > output$(3) ;\
|
||||
diff -s input$(3) output$(3) >> $(4) ;
|
||||
|
||||
#$(NAME): $(OBJECTS) $(LIBDIR)/libftprintf.a
|
||||
# $(CC) $(CFLAGS) $(OBJECTS) -L$(LIBDIR) -lftprintf -o $(NAME)
|
||||
#
|
||||
#$(LIBDIR)/libftprintf.a:
|
||||
# $(MAKE) -C $(LIBDIR) all
|
||||
#
|
||||
#bonus: $(OBJBONUS)
|
||||
# $(MAKE) -C $(LIBDIR) fclean bonus
|
||||
# $(CC) $(CFLAGS) $(OBJBONUS) -L$(LIBDIR) -lftprintf -o $@
|
||||
#
|
||||
#.PHONY: clean fclean re
|
||||
#
|
||||
#clean:
|
||||
##removes objects (.o)#
|
||||
# rm -f $(OBJECTS) $(OBJBONUS)
|
||||
# $(MAKE) -C $(LIBDIR) clean
|
||||
PRG = test_bs$(BUFFER_SIZE)
|
||||
IDXS = 001 002 003 004 005 006
|
||||
report_01: BUFFER_SIZE = 42
|
||||
report_01: test001.c $(SOURCES)
|
||||
$(CC) $(CFLAGS) -D BUFFER_SIZE=$(BUFFER_SIZE) $+ -o $(PRG)
|
||||
$(foreach i, $(IDXS), $(call run_test, $(BUFFER_SIZE),$(PRG),$i,$@))
|
||||
|
||||
report_02: BUFFER_SIZE = 80
|
||||
report_02: test001.c $(SOURCES)
|
||||
$(CC) $(CFLAGS) -D BUFFER_SIZE=$(BUFFER_SIZE) $+ -o $(PRG)
|
||||
$(foreach i, $(IDXS), $(call run_test, $(BUFFER_SIZE),$(PRG),$i,$@))
|
||||
|
||||
report_03: BUFFER_SIZE = 100000
|
||||
report_03: test001.c $(SOURCES)
|
||||
$(CC) $(CFLAGS) -D BUFFER_SIZE=$(BUFFER_SIZE) $+ -o $(PRG)
|
||||
$(foreach i, $(IDXS), $(call run_test, $(BUFFER_SIZE),$(PRG),$i,$@))
|
||||
|
||||
fclean:
|
||||
rm -f test001 test001_01 output* report_01
|
||||
rm -f test001 test001_01 output* report_* rpt_01 test_bs*
|
||||
|
||||
all: report_01
|
||||
|
||||
#all: $(NAME)
|
||||
## builds all
|
||||
all: report_01 report_02 report_03
|
||||
|
||||
re: fclean all
|
||||
|
||||
#
|
||||
##
|
||||
##CFLAGS += -Wall -Wextra -Werror -g3 -iquote $(LIBDIR) \
|
||||
## -O0
|
||||
##
|
||||
##TESTS := ft_isalpha_test ft_isdigit_test ft_isalnum_test ft_isascii_test \
|
||||
## ft_isprint_test ft_toupper_test ft_tolower_test ft_strlen_test \
|
||||
## ft_memset_test ft_bzero_test ft_memcpy_test ft_calloc_test \
|
||||
## ft_memmove_test ft_strlcpy_test ft_strlcat_test ft_strchr_test \
|
||||
## ft_strrchr_test ft_strncmp_test ft_memcmp_test ft_strnstr_test \
|
||||
## ft_atoi_test ft_substr_test ft_strjoin_test ft_strtrim_test \
|
||||
## ft_split_test
|
||||
##
|
||||
##TESTSBONUS := ft_lstclear_test
|
||||
##
|
||||
##%_test : %_test.c
|
||||
## $(CC) $(CFLAGS) $*_test.c -L$(LIBDIR) -lft -o $*_test
|
||||
##
|
||||
##%_actual.output : %_test
|
||||
## @./$*_test 2>&1 > ./$*_actual.output ;
|
||||
##
|
||||
###alternative command
|
||||
### @script -qc './$*_test &> ./$*_actual.output' 2> ./$*_actual.output 1> /dev/null
|
||||
##
|
||||
##%_report : %_test %_actual.output
|
||||
## -(diff -a $*_expected.output $*_actual.output \
|
||||
## && echo "Test OK") > $*_report
|
||||
##
|
||||
##EXES = $(TESTS)
|
||||
##
|
||||
##ACT_OUTPUTS = $(TESTS:_test=_actual.output)
|
||||
##
|
||||
##ACT_REPORTS = $(TESTS:_test=_report)
|
||||
##
|
||||
##.SECONDARY = $(ACT_REPORTS) $(ACT_OUTPUTS)
|
||||
##
|
||||
### Rule to create a 'report' file with info about the execution of
|
||||
### tests in $(TEST)
|
||||
##report : $(EXES) $(ACT_OUTPUTS) $(ACT_REPORTS)
|
||||
## @rm -f report ;
|
||||
## @$(foreach E, $(TESTS), \
|
||||
## $(eval T = $(subst _test,,$(E))) \
|
||||
## $(eval R = $(subst _test,_report,$(E))) \
|
||||
## echo "=== $(T) ===" >> report ; \
|
||||
## cat $(R) >> report ; \
|
||||
## )
|
||||
##
|
||||
##fclean:
|
||||
## rm -f report $(ACT_REPORTS) $(ACT_OUTPUTS) $(EXES)
|
||||
##
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue