minishell/tests/Makefile

51 lines
1.1 KiB
Makefile
Raw Normal View History

# make gets confused if a file with the same name exists in the sources, so some
# file are prefixed with test_
rawtests = \
metacharacters \
parse_pipelines \
parse_simple_cmds \
test_env_manip \
word_splitting \
2025-02-13 17:32:51 +01:00
ifeq ($(CFLAGS),)
CFLAGS = -Wall -Wextra -Werror -g
endif
tests = $(addprefix test_,$(rawtests))
run_tests = $(addprefix run_test_,$(rawtests))
test_objs = $(addsuffix .o,$(tests))
2025-02-13 15:17:30 +01:00
objs := $(addprefix ../,$(objs)) testutil.o
all_objs = $(objs) $(test_objs)
deps = $(all_objs:.o=.d)
2025-02-13 15:17:30 +01:00
LDLIBS = \
-lreadline \
-lft
LIBFTDIR = ../libft/
LIBFT = $(LIBFTDIR)libft.a
IFLAGS = -I$(LIBFTDIR)
LINCLUDE = -L$(LIBFTDIR)
.PHONY: run fclean run_test_%
2025-02-13 17:32:51 +01:00
.NOTPARALLEL: run
run: $(run_tests)
2025-02-13 17:32:51 +01:00
@echo "Finished running C tests"
-include $(deps)
%.o: %.c
2025-02-13 15:17:30 +01:00
$(CC) -c $(CFLAGS) $(IFLAGS) -o $*.o $*.c
$(CC) -MM $(CFLAGS) $(IFLAGS) $*.c > $*.d
test_%: %.o $(objs)
2025-02-13 15:17:30 +01:00
$(CC) $(CFLAGS) -o $@ $*.o $(objs) $(LINCLUDE) $(LDLIBS)
run_test_%: test_%
2025-02-13 17:32:51 +01:00
@echo
@echo "====== Now running test: $* ======"
2025-02-13 17:32:51 +01:00
@echo
./test_$*
@echo "====== End of test: $* ======"
fclean:
rm -f $(tests)