summaryrefslogtreecommitdiff
path: root/Makefile
blob: 7cc379895f73a98e449806f04c9f9353e54fe8ee (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
#sort_stack Copyright (C) 2026 yctct
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <https://www.gnu.org/licenses/>.

# Programme name
NAME = $(BIN)/push_swap

# Directories
SRC_DIR = ./src
LIB_DIR = ./lib
BUILD_DIR = ./build
BIN = ./bin

# Sources files and object files
SRCS = $(addprefix $(SRC_DIR)/, \
main.c \
push.c \
rotate.c \
rrotate.c \
rotate_stacks.c \
swap.c \
sort_two.c \
sort_three.c \
sort_five.c \
sort.c \
helper.c \
ft_lstmin.c \
ft_lstmax.c \
pstack.c \
free.c \
errors.c) 
OBJS = $(SRCS:%.c=$(BUILD_DIR)/%.o)

# Libraries
LIB = lib/libft.a
DEPS = include/push_swap.h

# Compiler and flags
#FLAGS = -Wextra -Werror -Wall -g -fsanitize=address
FLAGS = -Wextra -Werror -Wall -g

# Rules
$(BUILD_DIR)/%.o:%.c $(DEPS)
	mkdir -p $(dir $@)
	$(CC) -c -o $@ $< $(FLAGS)

$(NAME): $(OBJS) $(LIB)
	mkdir -p $(dir $@)
	$(CC) -o $@ $^ $(FLAGS)

$(LIB):
	$(MAKE) -C $(LIB_DIR)

all: $(NAME)

# Cleaning
.PHONY: clean fclean re

clean:
	rm -rf $(BUILD_DIR)
	$(MAKE) -C $(LIB_DIR) clean
fclean: clean
	$(MAKE) -C $(LIB_DIR) fclean
	rm -f  $(NAME)

re: fclean all