Files
42test/libft/Makefile

173 lines
5.6 KiB
Makefile
Raw Permalink Normal View History

2021-10-22 10:26:25 +02:00
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
2021-10-25 10:57:00 +02:00
# By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ #
2021-10-22 10:26:25 +02:00
# +#+#+#+#+#+ +#+ #
2021-10-23 16:41:04 +02:00
# Created: 2021/10/22 09:10:00 by gbaconni #+# #+# #
2021-10-29 17:50:09 +02:00
# Updated: 2021/10/29 17:38:08 by gbaconni ### ########.fr #
2021-10-22 10:26:25 +02:00
# #
# **************************************************************************** #
#
# make all
# make clean
# make fclean
# make re
# make
#
OUT = munit.out
2021-10-23 22:29:53 +02:00
LIBRARY = libft
LIBS = -lft
2021-10-22 10:26:25 +02:00
2021-10-23 22:29:53 +02:00
INCLUDE = munit
HDR = munit.h
2021-10-22 10:26:25 +02:00
SRC = \
2021-10-23 22:29:53 +02:00
munit.c \
$(INCLUDE)/munit.c
2021-10-22 10:26:25 +02:00
CC = gcc
2021-10-23 10:37:02 +02:00
CFLAGS = -Wall -Wextra -Werror
ifeq ($(DEBUG), 1)
CFLAGS += -g -fsanitize=address -O1
endif
2021-10-26 20:50:09 +00:00
ifeq ($(FAST), 1)
CFLAGS += -v -pipe -O3 -ffast-math -fomit-frame-pointer -funroll-loops
endif
ifeq ($(DEBUG), 1)
CFLAGS += -v -g -O1 -fsanitize=address -fsanitize=undefined -fsanitize=signed-integer-overflow
#CFLAGS += -v -g -O1 -fsanitize=address
endif
2021-10-22 10:26:25 +02:00
RM = rm
RMFLAGS = -f
2021-10-24 09:14:03 +02:00
all: compile
2021-10-22 10:26:25 +02:00
2021-10-23 10:37:02 +02:00
debug:
2021-10-24 11:20:36 +02:00
@make -C $(LIBRARY) re DEBUG=1
$(CC) $(CFLAGS) -I$(INCLUDE) $(SRC) -I${LIBRARY} -L${LIBRARY} ${LIBS} -DMUNIT_DISABLE_TIMING=1 -o $(OUT)
fast:
@make -C $(LIBRARY) re FAST=1
$(CC) $(CFLAGS) -I$(INCLUDE) $(SRC) -I${LIBRARY} -L${LIBRARY} ${LIBS} -DMUNIT_DISABLE_TIMING=1 -o $(OUT)
2021-10-23 10:37:02 +02:00
setup:
@echo "Set the location of your libft to:"
@ln -snvf $$(find ~ -mindepth 2 -maxdepth 4 -name libft.a -type f -exec dirname "{}" \; 2>/dev/null | head -n1) libft
@echo ""
2021-10-23 11:13:00 +02:00
@echo "If the above is not the correct location of your libft, use one of the following command to fix it:"
2021-10-25 11:21:34 +02:00
@find ~ -mindepth 2 -maxdepth 4 -name libft.h -type f -exec dirname "{}" \; 2>/dev/null | xargs -I{} echo ln -snvf {} libft
2021-10-23 10:37:02 +02:00
2021-10-22 16:07:10 +02:00
help:
@echo "a: nemequ/µnit"
@echo "b: Tripouille/libftTester"
@echo "c: jtoty/Libftest"
2021-10-23 22:29:53 +02:00
@echo "d: alelievr/libft-unit-test (tests)"
@echo "e: alelievr/libft-unit-test (bench)"
2021-10-27 10:07:58 +02:00
@echo "f: ysoroko/ft_split_tester"
@echo "test: a b c d e f"
2021-10-24 14:33:19 +02:00
@echo "bonus: only test bonuses"
2021-10-22 16:07:10 +02:00
@echo "update: git pull"
2021-10-23 22:29:53 +02:00
_munit:
2021-10-22 10:26:25 +02:00
@./$(OUT) || true
2021-10-23 22:29:53 +02:00
a: update compile _munit
2021-10-23 11:13:00 +02:00
@echo ""
@echo "Summary:"
@./$(OUT) 2>&1 | grep -i -e 'error' -e 'tests successful'|| true
2021-10-22 10:26:25 +02:00
2021-10-23 22:29:53 +02:00
_libftTester:
2021-10-22 15:02:54 +02:00
@grep -q 'update message' libftTester/Makefile && sed -i'.orig' -e 's/update \(message\)/\1/g' libftTester/Makefile || true
@grep -q '/libft$$' libftTester/Makefile || sed -i'.orig' -e 's/^\(PARENT_DIR.*\)/\1\/libft/' libftTester/Makefile || true
2021-10-23 22:29:53 +02:00
b: compile _libftTester
2021-10-22 10:26:25 +02:00
@make -C libftTester m || true
2021-10-23 22:29:53 +02:00
_Libftest:
@patch -d Libftest -p1 --dry-run < Libftest.patch >/dev/null 2>&1 && patch -d Libftest -p1 < Libftest.patch || true
2021-10-24 17:43:39 +02:00
@test -f Libftest/my_config.sh || (cd Libftest && ./grademe.sh -u >/dev/null 2>&1) || true
2021-10-22 21:28:52 +00:00
@grep -q '^PATH_LIBFT=\.\./libft' Libftest/my_config.sh || sed -i'.orig' -e 's/^\(PATH_LIBFT\)=.*/\1=..\/libft/' Libftest/my_config.sh || true
@grep -q "'ft_memccpy'" Libftest/srcs/variables/functions/part_1.sh && sed -i'.orig' -e "/'ft_memccpy'/d" Libftest/srcs/variables/functions/part_1.sh || true
@rm -fr Libftest/tests/Part1_functions/ft_memccpy || true
2021-10-22 10:26:25 +02:00
2021-10-23 22:29:53 +02:00
c: compile _Libftest
2021-10-26 20:50:09 +00:00
@cd Libftest && ./grademe.sh -u -b || true
2021-10-24 01:05:08 +02:00
@echo ""
@echo "For more details do:"
2021-10-24 01:06:19 +02:00
@echo "less Libftest/deepthought"
@echo ""
2021-10-23 22:29:53 +02:00
_libft-unit-test:
@grep -q 'ft_memccpy' libft-unit-test/src/init.c && sed -i'.orig' -e '/ft_memccpy/d' libft-unit-test/src/init.c || true
@grep -q 'ft_memccpy' libft-unit-test/hardcore-mode/hardcore-main.c && sed -i'.orig' -e '/ft_memccpy/d' libft-unit-test/hardcore-mode/hardcore-main.c || true
@grep -q 'test-memccpy' libft-unit-test/Makefile && sed -i'.orig' -e '/test-memccpy/d' libft-unit-test/Makefile || true
@rm -f libft-unit-test/hardcore-mode/test-memccpy.c || true
d: compile _libft-unit-test
2021-10-24 14:33:19 +02:00
@make -C libft-unit-test f | awk 'BEGIN { hide=0 } { if(/\/~~~\\/) hide=1; if(hide!=1) print; }' || true
2021-10-27 11:06:09 +00:00
@rm -f libft/libft.so
2021-10-24 14:33:19 +02:00
@tput init
2021-10-24 01:05:08 +02:00
@echo "For more details do:"
2021-10-24 01:06:19 +02:00
@echo "less libft-unit-test/result.log"
@echo ""
2021-10-22 10:26:25 +02:00
2021-10-24 11:20:36 +02:00
e: fast _libft-unit-test
2021-10-23 22:29:53 +02:00
@make -C libft-unit-test b || true
2021-10-27 10:07:58 +02:00
_FT_SPLIT_TESTER:
2021-10-27 11:03:34 +00:00
@patch -d FT_SPLIT_TESTER -p1 --dry-run < FT_SPLIT_TESTER.patch >/dev/null 2>&1 && patch -d FT_SPLIT_TESTER -p1 < FT_SPLIT_TESTER.patch || true
2021-10-27 10:07:58 +02:00
f: compile _FT_SPLIT_TESTER
@make -C FT_SPLIT_TESTER all || true
test: a b c d e f
2021-10-22 10:26:25 +02:00
2021-10-24 14:33:19 +02:00
bonus: _libftTester _Libftest _libft-unit-test
2021-10-24 17:43:39 +02:00
@make -C libft bonus
2021-10-26 20:50:09 +00:00
@cd Libftest && ./grademe.sh -u -ob || true
2021-10-24 14:33:19 +02:00
@echo ""
@echo "For more details do:"
@echo "less Libftest/deepthought"
@echo ""
2021-10-26 20:50:09 +00:00
@echo ""
@make -C libftTester b || true
@make -C libft-unit-test f | grep -a -B2 -A999 'Bonus part' || true
2021-10-24 14:33:19 +02:00
@echo ""
@echo "For more details do:"
@echo "less libft-unit-test/result.log"
2021-10-26 20:50:09 +00:00
@rm -f libft/libft.so
2021-10-24 14:33:19 +02:00
2021-10-22 11:24:55 +02:00
update:
@git pull
2021-10-22 10:26:25 +02:00
compile:
2021-10-23 22:29:53 +02:00
@make -C $(LIBRARY) all
2021-10-24 07:01:00 +00:00
$(CC) $(CFLAGS) -I$(INCLUDE) $(SRC) -I${LIBRARY} -L${LIBRARY} ${LIBS} -DMUNIT_DISABLE_TIMING=1 -o $(OUT)
2021-10-24 11:20:36 +02:00
2021-10-22 10:26:25 +02:00
clean:
2021-10-24 08:52:11 +02:00
@make -C $(LIBRARY) clean || true
2021-10-22 11:30:53 +02:00
@make -C libftTester clean || true
@make -C libft-unit-test clean || true
2021-10-24 08:52:11 +02:00
fclean: clean
@make -C $(LIBRARY) fclean || true
@make -C libftTester fclean || true
@make -C libft-unit-test fclean || true
2021-10-22 10:26:25 +02:00
@$(RM) $(RMFLAGS) $(OUT)
2021-10-25 06:50:26 +02:00
reset:
@rm -fr Libftest
@rm -fr libft-unit-test
@rm -fr libftTester
2021-10-27 09:56:34 +02:00
@rm -fr FT_SPLIT_TESTER
2021-10-25 06:50:26 +02:00
@rm -fr munit
@git submodule update --init
2021-10-22 10:26:25 +02:00
re: fclean all