diff --git a/.Makefile.swo b/.Makefile.swo new file mode 100644 index 0000000..d86cddc Binary files /dev/null and b/.Makefile.swo differ diff --git a/.Makefile.swp b/.Makefile.swp new file mode 100644 index 0000000..e533034 Binary files /dev/null and b/.Makefile.swp differ diff --git a/.OLDMakefile.swp b/.OLDMakefile.swp deleted file mode 100644 index 8086d06..0000000 Binary files a/.OLDMakefile.swp and /dev/null differ diff --git a/Makefile b/Makefile index 55736c4..f5dc3cc 100644 --- a/Makefile +++ b/Makefile @@ -116,26 +116,36 @@ $(ODIR): # - NAME will execute only for the .c that has been # modified since last creation of NAME # - ranlib is precedeed by a "@" to avoid being print +# - if DEP (libft.h) is modified the library is remade +# - $@ means everything left to ":" +# - $< means first argument right to ":" $(NAME): $(OBJ) $(DEP) ar -rc $@ $< @ranlib $@ -# - this rule depend of the list of files.c and file.h +# - this rule depend of the list of files.c # - if any of these files are more recent than the file # builds/file.o equivalent then the rule will rebuild # this .o file +# - the flag -o is there to put explicit name of the .o +# files since they must be written within a directory +# path (builds/) $(ODIR)/%.o: %.c - $(CC) $(CFLAGS) -c $< + $(CC) $(CFLAGS) -c -o $@ $< +# clean the objects file +# rm is use with it's native path to avoid using an alias clean: /bin/rm -rf $(ODIR) +# clean the objects and executable files fclean: clean /bin/rm -f $(NAME) +# remake the compilation re: fclean all -.PHONY: clean +.PHONY: clean fclean @@ -246,10 +256,9 @@ re: fclean all # si on compile les deux ca marche : # gcc main.c ft_putchar.c -# - - - - - - - - - - - - - - - - - - - - - - - -# les .o : pre-compiler certains fichiers pour -# ne pas les recompiler a chaque fois -# - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - +# les .o : compiler et linker +# - - - - - - - - - - - - - - - # ca fonctionne mais gcc doit a chaque fois recompiler # ft_putchar.c alors qu'il n'est pas modifie, donc on peut @@ -268,11 +277,14 @@ re: fclean all # objet .o qui est deja traduit en langue d'ordinateur # et pret a etre rajoute a la compilation : # -# # gcc -c ft_putchar.c --> donne ft_putchar.o +# # gcc -c ft_putchar.c --> donne ft_putchar.o +# # gcc -c main.c --> donne main.o # -# qu'on peut compiler avec le fichier contenant le main : +# cette etape qui consiste a transformer les fichiers en +# objets .o s'appelle la compilation, il faut ensuite +# linker les objets, ce qui avec gcc se fait simplement : # -# # gcc file.c ft_putchar.o +# # gcc main.o ft_putchar.o # # on va maintenant voir comment faire une libraire qui # contient tous nos fichiers objets @@ -456,20 +468,136 @@ re: fclean all # makefile basique # - - - - - - - - - -# exemple d'un makefilede basic +# exemple d'un makefilede basic qui sert a creer un +# executable pour un programme : # -# # |DECLARATION VARIABLES -# # NAME = libtest.h -# # CC = gcc +# [archtecture] +# # main.c +# # function01.c +# # function02.c +# # header.h +# # Makefile +# +# [Makefile] +# # # DECLARATION VARIABLES +# # +# # NAME = bin_output +# # CC = gcc # # CFLAGS = -I. -c -# # SRCS = example01.c \ -# # example02.c -# # OBJ = $(SRCS:.c=.o) |ecrit les fichiers .c en .o +# # DEPS = header.h +# # SRCS = main.c \ +# # function01.c \ +# # function02.c +# # ODIR = ./builds +# # OBJS = $(addprefix $(ODIR)/, $(SRCS:.c=.o)) # # -# # all: $(NAME) |make execute sa premiere regle NAME -# # $(NAME): $(OBJ) |NAME execute d'abord OBJ -# # ar -rc $@ $< | +# # +# # # RULES TO EXECUTE +# # +# # all: $(ODIR) $(NAME) +# # $(NAME): $(OBJ) +# # ar -rc $@ $< +# # #clean: +# # /bin/rm -rf $(ODIR) +# # fclean: clean +# # /bin/rm -f $(NAME) +# # re: fclean all +# # .PHONY: all clean fclean re # +# apres avoir ecrit "make" dans le terminal le Makefile +# va s'executer et l'architecture du fichier racine sera +# un peu changee : +# +# [archtecture] +# # main.c +# # main.o +# # function01.c +# # function01.o +# # function02.c +# # function02.o +# # header.h +# # Makefile +# # bin_output +# +# +# +# # - "addprefix" is a built-in expansion function used by +# # makefile to perform a transformation on file names, in +# # this case we want to put all the .o files in a +# # subdirectory named "build" +# # - $(SRCS:.c=.o) is a "substitute reference", an +# # abbreviation for the expansion function "patsubst" : +# # $(patsubst %.c,%.o,$(SRCS)) +# OBJ = $(addprefix $(ODIR)/, $(SRCS:.c=.o)) +# +# # - when you write "make" in command line it will execute +# # the first rule wrote in the Makefile, wich is "all" by +# # convention because usually when you type "make" you +# # expect it to build all +# # - it first verify if ODIR is created and if not create +# # it, then it calls NAME to create the library +# all: $(ODIR) $(NAME) +# +# # create the folder where all the .o files will be stored +# $(ODIR): +# mkdir -p $(ODIR) +# +# # - NAME will create the library libft.a +# # - first it checks if any OBJ (files.o) have more recent +# # date of modification than NAME (libft.a), and for each +# # it will execute +# # - $(OBJ) will expand in the list of files.o and each of +# # them will call the rule "$(ODIR)/%.o:" below because it +# # has its exact pattern +# # - NAME will execute only for the .c that has been +# # modified since last creation of NAME +# # - ranlib is precedeed by a "@" to avoid being print +# # - if DEP (libft.h) is modified the library is remade +# # - $@ means everything left to ":" +# # - $< means first argument right to ":" +# $(NAME): $(OBJ) $(DEP) +# ar -rc $@ $< +# @ranlib $@ +# +# # - this rule depend of the list of files.c +# # - if any of these files are more recent than the file +# # builds/file.o equivalent then the rule will rebuild +# # this .o file +# # - the flag -o is there to put explicit name of the .o +# # files since they must be written within a directory +# # path (builds/) +# $(ODIR)/%.o: %.c +# $(CC) $(CFLAGS) -c -o $@ $< +# +# # clean the objects file +# # rm is use with it's native path to avoid using an alias +# clean: +# /bin/rm -rf $(ODIR) +# +# # clean the objects and executable files +# fclean: clean +# /bin/rm -f $(NAME) +# +# # remake the compilation +# re: fclean all +# +# .PHONY: clean fclean + + + + + + + + + + + + + + + + # Make a des built-in pattern rules : # https://www.gnu.org/software/make/manual/html_node/Catalogue-of-Rules.html # par exemple pour construire des .o a partir de .c @@ -532,3 +660,84 @@ re: fclean all # the target, and if so execute the recipes + + +# NAME = fdf +# CC = gcc -g3 +# SRCDIR = srcs +# INCLUDESDIR = includes +# LIBFTDIR = libft +# VPATH = $(INCLUDESDIR) \ +# $(SRCDIR) \ +# $(SRCDIR)/init \ +# $(SRCDIR)/print \ +# $(SRCDIR)/calcul \ +# $(SRCDIR)/projection/isometrique \ +# $(SRCDIR)/projection/parallel \ +# $(SRCDIR)/parser \ +# $(SRCDIR)/loop_and_event +# LIBFT = $(LIBFTDIR)/libft.a +# INCLUDES = fdf.h \ +# init.h \ +# print.h \ +# calcul.h \ +# projection.h \ +# parser.h \ +# loop.h +# SRCS = main.c \ +# create_header.c \ +# create_map.c \ +# color_map.c \ +# color_line.c \ +# color_map_pixel.c \ +# print_3d.c \ +# create_mapping.c \ +# straight_line.c \ +# add_point.c \ +# quadrant_one.c \ +# quadrant_two.c \ +# quadrant_three.c \ +# get_points.c \ +# zoom.c \ +# shift.c \ +# alpha_omega.c \ +# increase_z.c \ +# key_dispatcher.c \ +# set_new_color.c \ +# set_projection.c +# ODIR = objs/ +# OBJS = $(addprefix $(OBJDIR), $(SRCS:.c=.o)) +# INC = -I $(INCLUDESDIR) -I $(LIBFTDIR)/$(INCLUDESDIR) +# all: +# @$(MAKE) -C $(MLX_DIR); +# @$(MAKE) -C $(LIBFTDIR) +# @$(ECHO) "$(FLAGS_COLOR)Compiling with flags $(CFLAGS) $(EOC)" +# @$(MAKE) $(NAME) +# debug: +# @$(MAKE) re DEBUG=1 +# $(LIBFT): +# @$(MAKE) -C $(LIBFTDIR) +# $(NAME): $(LIBFT) $(OBJDIR) $(OBJECTS) +# @$(CC) -o $@ $(OBJECTS) $(CFLAGS) $(LFLAGS) $(MLX_LIB) +# @$(ECHO) "$(OK_COLOR)$(NAME) linked with success !$(EOC)" +# $(OBJDIR): +# @$(MKDIR) $@ +# $(OBJDIR)%.o: $(SRC_DIR)%.c $(INCLUDES) +# @$(CC) -c $< -o $@ $(CFLAGS) +# @$(ECHO) "${COMP_COLOR}$< ${EOC}" +# clean: +# @$(MAKE) clean -C $(MLX_DIR) +# @$(MAKE) clean -C $(LIBFTDIR) +# @$(RM) $(OBJECTS) +# @$(RM) -r $(OBJDIR) && $(ECHO) "${OK_COLOR}Successfully cleaned $(NAME) objects files ${EOC}" +# fclean: clean +# @$(MAKE) fclean -C $(MLX_DIR) +# @$(MAKE) fclean -C $(LIBFTDIR) +# @$(RM) $(NAME) && $(ECHO) "${OK_COLOR}Successfully cleaned $(NAME) ${EOC}" +# re: fclean all +# rere: +# @$(RM) $(OBJECTS) +# @$(RM) -r $(OBJDIR) +# @$(RM) $(BINDIR)/$(NAME) +# @$(MAKE) all +# .PHONY: all clean fclean re debug diff --git a/test/.Makefile.swp b/test/.Makefile.swp deleted file mode 100644 index 8699658..0000000 Binary files a/test/.Makefile.swp and /dev/null differ diff --git a/test/Makefile b/test/Makefile index 6596621..280bff1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,9 +1,33 @@ -SRC = main.c putchar.c transform.c -DEP = test.h -OBJ = $(SRC:.c=.o) +#-------------# +# VARIABLES # +#-------------# +NAME = test +CC = gcc +VPATH = srcs +# HEADERS # +IDIR = includes +_DEPS = test.h +DEPS = $(_DEPS:%.h=$(IDIR)/%.h) +# LIBRAIRIES # +LDIR = ./ +_LIBS = libtest.a +LIBS = $(_LIBS:lib%.a=%) +# FUNCTIONS et OBJETS # +SRCS = main.c #putchar.c transform.c +ODIR = ./builds +OBJS = $(SRCS:%.c=$(ODIR)/%.o) +# OPTIONS de GCC # +CFLAGS = -I$(IDIR) +LFLAGS = -L$(LDIR) -l$(LIBS) -test: $(OBJ) - gcc -I. -o test $(OBJ) -%.o: %.c $(DEP) - gcc -I. -c $< +#---------# +# RULES # +#---------# +all: $(ODIR) $(NAME) +$(NAME): $(OBJS) $(DEPS) + $(CC) $(CFLAGS) -o test $(OBJS) $(LFLAGS) +$(ODIR): + mkdir -p $@ +$(ODIR)/%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< diff --git a/test/main.o b/test/builds/main.o similarity index 100% rename from test/main.o rename to test/builds/main.o diff --git a/test/test.h b/test/includes/test.h similarity index 100% rename from test/test.h rename to test/includes/test.h diff --git a/test/libtest.a b/test/libtest.a index e312c0d..d07faf3 100644 Binary files a/test/libtest.a and b/test/libtest.a differ diff --git a/test/putchar.o b/test/putchar.o deleted file mode 100644 index 824021b..0000000 Binary files a/test/putchar.o and /dev/null differ diff --git a/test/main.c b/test/srcs/main.c similarity index 100% rename from test/main.c rename to test/srcs/main.c diff --git a/test/putchar.c b/test/temp/putchar.c similarity index 100% rename from test/putchar.c rename to test/temp/putchar.c diff --git a/test/transform.c b/test/temp/transform.c similarity index 75% rename from test/transform.c rename to test/temp/transform.c index 36b8f0d..744c097 100644 --- a/test/transform.c +++ b/test/temp/transform.c @@ -2,5 +2,5 @@ int transform(int a) { - return(--a); + return (--a); } diff --git a/test/test b/test/test index b532226..e8415bc 100755 Binary files a/test/test and b/test/test differ diff --git a/test/transform.o b/test/transform.o deleted file mode 100644 index 3c17dae..0000000 Binary files a/test/transform.o and /dev/null differ