From 57f12c91a6b7f535e7b0883dc03743f287852650 Mon Sep 17 00:00:00 2001 From: hugogogo Date: Wed, 9 Jun 2021 15:00:17 +0200 Subject: [PATCH] installation des fichiers --- Makefile | 67 +++++++++++++++++++++++++++++++++++++++++++++ includes/pushswap.h | 48 ++++++++++++++++++++++++++++++++ libft | 1 + srcs/pushswap.c | 0 4 files changed, 116 insertions(+) create mode 100644 Makefile create mode 100644 includes/pushswap.h create mode 120000 libft create mode 100644 srcs/pushswap.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1aaed2f --- /dev/null +++ b/Makefile @@ -0,0 +1,67 @@ + +# - - - - - - - - - - - - - - # name = value \ | .c in srcs/ +# variables names # value | .h in includes/ +# - - - - - - - - - - - - - - # ! name is case sensitive | ! use VPATH only for .c + +NAME = pushswap + +CC = gcc + +VPATH = srcs + +IDIR = ./includes + +_DEPS = +DEPS = $(_DEPS:%.h=$(IDIR)/%.h) +# used to check if a .h has been modify when execute $NAME rule + +LDIR = ./libft +_LIBS = libft.a +LIBS = $(_LIBS:lib%.a=%) + +SRCS = pushswap.c + +ODIR = ./builds +OBJS = $(SRCS:%.c=$(ODIR)/%.o) + +CFLAGS = -I$(IDIR) -g3 -Wall -Wextra -Werror + +LFLAGS = -L$(LDIR) -l$(LIBS) + + + +# - - - - - - - - - - - - - - # target: prerequisites | $@ : target +# rules to execute # recipe | $< : 1st prerequisite +# - - - - - - - - - - - - - - # recipe | $^ : all prerequisites + +all: $(NAME) + +$(NAME): $(ODIR) $(OBJS) $(DEPS) + make -C $(LDIR) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) + +$(ODIR): + mkdir -p $@ + +$(ODIR)/%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +clean: + /bin/rm -f $(OBJS) + +fclean: clean + make fclean -C $(LDIR) + /bin/rm -rf $(ODIR) + /bin/rm -f $(NAME) + /bin/rm -rf a.out a.out.dSYM + +re: fclean all + +leaks: CFLAGS += -fsanitize=address +leaks: clean $(NAME) + +valgrind: clean $(NAME) + valgrind --leak-check=full --show-leak-kinds=all ./$(NAME) + +.PHONY: all clean fclean re gcc + diff --git a/includes/pushswap.h b/includes/pushswap.h new file mode 100644 index 0000000..1b06c5e --- /dev/null +++ b/includes/pushswap.h @@ -0,0 +1,48 @@ + +#ifndef PUSH_SWAP_H +# define PUSH_SWAP_H +# include "libft.h" +// # include "../libft/includes/libft.h" +# include // read(), write(), sleep() +# include // malloc(), free(), exit(), atoi() + + +typedef struct s_list +{ + int n; + struct s_list *next; +} t_list; + +/* +** swap +*/ +int swap(t_list **list); +int sa(); +int sb(); +int ss(); + +/* +** push +*/ +int push(t_list **dst, t_list **src); +int pa(); +int pb(); +int pp(); + +/* +** rotate +*/ +int rotate(t_list **list); +int ra(); +int rb(); +int rr(); + +/* +** reverse rotate +*/ +int reverse_rotate(t_list **list); +int rra(); +int rrb(); +int rrr(); + +#endif diff --git a/libft b/libft new file mode 120000 index 0000000..5634df6 --- /dev/null +++ b/libft @@ -0,0 +1 @@ +../libft \ No newline at end of file diff --git a/srcs/pushswap.c b/srcs/pushswap.c new file mode 100644 index 0000000..e69de29