-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
66 lines (53 loc) · 1.96 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: huaydin <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/12/23 22:14:00 by huaydin #+# #+# #
# Updated: 2022/12/29 23:15:52 by huaydin ### ########.fr #
# #
# **************************************************************************** #
NAME = push_swap
CC = cc
CFLAGS = -Wall -Wextra -Werror -g
LIBFT_DIR = libft
LIBFT = ./libft/libft.a
RM = rm -rf
SRCS = utils.c move.c sort.c main.c
SRC = $(addprefix ./src/,$(SRCS))
OBJ = $(SRC:.c=.o)
all: $(LIBFT) $(NAME)
@echo "Done!"
@echo "To test the program, run 'make test' or 'make test size=10'"
@echo "for example for testing 10 random numbers"
@echo "./push_swap 1 2 3 4 5 6 7 8 9 10"
$(LIBFT):
@make -s -C $(LIBFT_DIR)
$(NAME): $(LIBFT) $(OBJ)
@$(CC) $(CFLAGS) $(OBJ) -o $(NAME) -L./$(LIBFT_DIR) -lft
$(OBJ): $(SRC)
@$(CC) $(CFLAGS) -c $? -I./$(LIBFT_DIR)
@mv *.o src
clean:
@$(RM) src/*.o
@make -s -C $(LIBFT_DIR) clean
fclean: clean
@$(RM) $(NAME)
@make -s -C $(LIBFT_DIR) fclean
re: fclean all clean
.PHONY: all clean fclean test re
OS = $(shell uname)
size ?= 10
ifeq ($(OS),Linux)
CHECKER = valgrind ./push_swap $(ARG) | ./checker_linux $(ARG)
else
CHECKER = ./push_swap $(ARG) | ./checker_Mac $(ARG)
endif
test:
@$(eval ARG = $(shell seq -1000 1000 | shuf -n $(size)))
@echo "Checker result: "
$(CHECKER)
@echo "Instructions count: "
@./push_swap $(ARG) | wc -l