installation des fichiers
This commit is contained in:
67
Makefile
Normal file
67
Makefile
Normal file
@@ -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
|
||||
|
||||
48
includes/pushswap.h
Normal file
48
includes/pushswap.h
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
#ifndef PUSH_SWAP_H
|
||||
# define PUSH_SWAP_H
|
||||
# include "libft.h"
|
||||
// # include "../libft/includes/libft.h"
|
||||
# include <unistd.h> // read(), write(), sleep()
|
||||
# include <stdlib.h> // 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
|
||||
0
srcs/pushswap.c
Normal file
0
srcs/pushswap.c
Normal file
Reference in New Issue
Block a user