makefile class finish
This commit is contained in:
727
Makefile
727
Makefile
@@ -2,108 +2,120 @@
|
|||||||
# variables names #
|
# variables names #
|
||||||
# - - - - - - - - - #
|
# - - - - - - - - - #
|
||||||
|
|
||||||
# each variable will expand in its value when used
|
NAME = libft.a
|
||||||
|
CC = gcc
|
||||||
|
VPATH = srcs
|
||||||
|
|
||||||
NAME = libft.a
|
IDIR = includes
|
||||||
DEP = libft.h
|
_DEP = libft.h
|
||||||
CC = gcc
|
DEPS = $(_DEP:%.h=$(IDIR)/%.h)
|
||||||
CFLAGS = -Wall -Wextra -Werror -I. -c
|
# - $(_DEP:%.h=$(IDIR)/%.h) is a built-in function called
|
||||||
SRCS = ft_atoi.c \
|
# a "substitute reference", an abbreviation for the
|
||||||
ft_bzero.c \
|
|
||||||
ft_isalnum.c \
|
|
||||||
ft_isalpha.c \
|
|
||||||
ft_isascii.c \
|
|
||||||
ft_isdigit.c \
|
|
||||||
ft_isprint.c \
|
|
||||||
ft_memccpy.c \
|
|
||||||
ft_memchr.c \
|
|
||||||
ft_memcmp.c \
|
|
||||||
ft_memcpy.c \
|
|
||||||
ft_memmove.c \
|
|
||||||
ft_memset.c \
|
|
||||||
ft_strcat.c \
|
|
||||||
ft_strchr.c \
|
|
||||||
ft_strcmp.c \
|
|
||||||
ft_strcpy.c \
|
|
||||||
ft_strdup.c \
|
|
||||||
ft_strlcat.c \
|
|
||||||
ft_strlen.c \
|
|
||||||
ft_strncat.c \
|
|
||||||
ft_strncmp.c \
|
|
||||||
ft_strncpy.c \
|
|
||||||
ft_strnstr.c \
|
|
||||||
ft_strrchr.c \
|
|
||||||
ft_strstr.c \
|
|
||||||
ft_tolower.c \
|
|
||||||
ft_toupper.c \
|
|
||||||
\
|
|
||||||
ft_itoa.c \
|
|
||||||
ft_memalloc.c \
|
|
||||||
ft_memdel.c \
|
|
||||||
ft_putchar.c \
|
|
||||||
ft_putchar_fd.c \
|
|
||||||
ft_putendl.c \
|
|
||||||
ft_putendl_fd.c \
|
|
||||||
ft_putnbr.c \
|
|
||||||
ft_putnbr_fd.c \
|
|
||||||
ft_putstr.c \
|
|
||||||
ft_putstr_fd.c \
|
|
||||||
ft_strclr.c \
|
|
||||||
ft_strdel.c \
|
|
||||||
ft_strequ.c \
|
|
||||||
ft_striter.c \
|
|
||||||
ft_striteri.c \
|
|
||||||
ft_strjoin.c \
|
|
||||||
ft_strmap.c \
|
|
||||||
ft_strmapi.c \
|
|
||||||
ft_strnequ.c \
|
|
||||||
ft_strnew.c \
|
|
||||||
ft_strsplit.c \
|
|
||||||
ft_strsub.c \
|
|
||||||
ft_strtrim.c \
|
|
||||||
\
|
|
||||||
ft_lstnew.c \
|
|
||||||
ft_lstdelone.c \
|
|
||||||
ft_lstdel.c \
|
|
||||||
ft_lstadd.c \
|
|
||||||
ft_lstiter.c \
|
|
||||||
ft_lstmap.c \
|
|
||||||
\
|
|
||||||
ft_any.c \
|
|
||||||
ft_atoibase.c \
|
|
||||||
ft_convertbase.c \
|
|
||||||
ft_foreach.c \
|
|
||||||
ft_issort.c \
|
|
||||||
ft_arraymap.c \
|
|
||||||
ft_putnbrbase.c \
|
|
||||||
ft_strmultisplit.c
|
|
||||||
ODIR = ./builds
|
|
||||||
|
|
||||||
# - $(SRCS:%.c=$(ODIR)/%.o) is a built-in function called a
|
|
||||||
# "substitute reference", an abbreviation for the
|
|
||||||
# expansion function "patsubst" :
|
# expansion function "patsubst" :
|
||||||
# $(patsubst %.c,$(ODIR)/%.o,$(SRCS))
|
# $(patsubst %.h,$(IDIR)/%.h,$(_DEP))
|
||||||
|
# $(patsubst pattern,replacement,text)
|
||||||
# - % match everything, the value of the first % in
|
# - % match everything, the value of the first % in
|
||||||
# "replacement" is replaced by the text matched by the
|
# "replacement" is replaced by the text matched by the
|
||||||
# first one in "pattern", it only works for the firsts
|
# first % in "pattern", it only works for the firsts
|
||||||
|
|
||||||
|
CFLAGS = -I$(IDIR)
|
||||||
|
CFLAGS += -Wall -Wextra -Werror
|
||||||
|
|
||||||
|
SRCS = ft_atoi.c \
|
||||||
|
ft_bzero.c \
|
||||||
|
ft_isalnum.c \
|
||||||
|
ft_isalpha.c \
|
||||||
|
ft_isascii.c \
|
||||||
|
ft_isdigit.c \
|
||||||
|
ft_isprint.c \
|
||||||
|
ft_memccpy.c \
|
||||||
|
ft_memchr.c \
|
||||||
|
ft_memcmp.c \
|
||||||
|
ft_memcpy.c \
|
||||||
|
ft_memmove.c \
|
||||||
|
ft_memset.c \
|
||||||
|
ft_strcat.c \
|
||||||
|
ft_strchr.c \
|
||||||
|
ft_strcmp.c \
|
||||||
|
ft_strcpy.c \
|
||||||
|
ft_strdup.c \
|
||||||
|
ft_strlcat.c \
|
||||||
|
ft_strlen.c \
|
||||||
|
ft_strncat.c \
|
||||||
|
ft_strncmp.c \
|
||||||
|
ft_strncpy.c \
|
||||||
|
ft_strnstr.c \
|
||||||
|
ft_strrchr.c \
|
||||||
|
ft_strstr.c \
|
||||||
|
ft_tolower.c \
|
||||||
|
ft_toupper.c \
|
||||||
|
\
|
||||||
|
ft_itoa.c \
|
||||||
|
ft_memalloc.c \
|
||||||
|
ft_memdel.c \
|
||||||
|
ft_putchar.c \
|
||||||
|
ft_putchar_fd.c \
|
||||||
|
ft_putendl.c \
|
||||||
|
ft_putendl_fd.c \
|
||||||
|
ft_putnbr.c \
|
||||||
|
ft_putnbr_fd.c \
|
||||||
|
ft_putstr.c \
|
||||||
|
ft_putstr_fd.c \
|
||||||
|
ft_strclr.c \
|
||||||
|
ft_strdel.c \
|
||||||
|
ft_strequ.c \
|
||||||
|
ft_striter.c \
|
||||||
|
ft_striteri.c \
|
||||||
|
ft_strjoin.c \
|
||||||
|
ft_strmap.c \
|
||||||
|
ft_strmapi.c \
|
||||||
|
ft_strnequ.c \
|
||||||
|
ft_strnew.c \
|
||||||
|
ft_strsplit.c \
|
||||||
|
ft_strsub.c \
|
||||||
|
ft_strtrim.c \
|
||||||
|
\
|
||||||
|
ft_lstnew.c \
|
||||||
|
ft_lstdelone.c \
|
||||||
|
ft_lstdel.c \
|
||||||
|
ft_lstadd.c \
|
||||||
|
ft_lstiter.c \
|
||||||
|
ft_lstmap.c \
|
||||||
|
\
|
||||||
|
ft_any.c \
|
||||||
|
ft_atoibase.c \
|
||||||
|
ft_convertbase.c \
|
||||||
|
ft_foreach.c \
|
||||||
|
ft_issort.c \
|
||||||
|
ft_arraymap.c \
|
||||||
|
ft_putnbrbase.c \
|
||||||
|
ft_strmultisplit.c
|
||||||
|
ODIR = ./builds
|
||||||
OBJ = $(SRCS:%.c=$(ODIR)/%.o)
|
OBJ = $(SRCS:%.c=$(ODIR)/%.o)
|
||||||
|
|
||||||
|
|
||||||
# - - - - - - - - - - - #
|
# - - - - - - - - - - - #
|
||||||
# rules to execute #
|
# rules to execute #
|
||||||
# - - - - - - - - - - - #
|
# - - - - - - - - - - - #
|
||||||
|
|
||||||
|
|
||||||
|
all: $(ODIR) $(NAME)
|
||||||
# - when you write "make" in command line it will execute
|
# - when you write "make" in command line it will execute
|
||||||
# the first rule wrote in the Makefile, wich is "all" by
|
# the first rule wrote in the Makefile, wich is "all" by
|
||||||
# convention because usually when you type "make" you
|
# convention because usually when you type "make" you
|
||||||
# expect it to build all
|
# expect it to build all
|
||||||
# - it first verify if ODIR is created and if not create
|
# - it first verify if ODIR is created and if not create
|
||||||
# it, then it calls NAME to create the library
|
# it, then it calls NAME to create the library
|
||||||
all: $(ODIR) $(NAME)
|
|
||||||
|
|
||||||
# create the folder where all the .o files will be stored
|
|
||||||
$(ODIR):
|
$(ODIR):
|
||||||
mkdir -p $(ODIR)
|
mkdir -p $(ODIR)
|
||||||
|
# create the folder where all the .o files will be stored
|
||||||
|
|
||||||
|
|
||||||
|
$(NAME): $(OBJS) $(DEPS)
|
||||||
|
ar -rc $@ $(OBJS)
|
||||||
|
@ranlib $@
|
||||||
# - NAME will create the library libft.a
|
# - NAME will create the library libft.a
|
||||||
# - first it checks if any OBJ (files.o) have more recent
|
# - first it checks if any OBJ (files.o) have more recent
|
||||||
# date of modification than NAME (libft.a), and for each
|
# date of modification than NAME (libft.a), and for each
|
||||||
@@ -115,12 +127,12 @@ $(ODIR):
|
|||||||
# modified since last creation of NAME
|
# modified since last creation of NAME
|
||||||
# - ranlib is precedeed by a "@" to avoid being print
|
# - ranlib is precedeed by a "@" to avoid being print
|
||||||
# - if DEP (libft.h) is modified the library is remade
|
# - if DEP (libft.h) is modified the library is remade
|
||||||
# - $@ means everything left to ":"
|
# - $@ means name of the rule
|
||||||
# - $< means first argument right to ":"
|
# - $< means first argument right to ":"
|
||||||
$(NAME): $(OBJ) $(DEP)
|
|
||||||
ar -rc $@ $<
|
|
||||||
@ranlib $@
|
|
||||||
|
|
||||||
|
|
||||||
|
$(ODIR)/%.o: %.c
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
# - this rule depend of the list of files.c
|
# - this rule depend of the list of files.c
|
||||||
# - if any of these files are more recent than the file
|
# - if any of these files are more recent than the file
|
||||||
# builds/file.o equivalent then the rule will rebuild
|
# builds/file.o equivalent then the rule will rebuild
|
||||||
@@ -128,22 +140,55 @@ $(NAME): $(OBJ) $(DEP)
|
|||||||
# - the flag -o is there to put explicit name of the .o
|
# - the flag -o is there to put explicit name of the .o
|
||||||
# files since they must be written within a directory
|
# files since they must be written within a directory
|
||||||
# path (builds/)
|
# 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:
|
clean:
|
||||||
/bin/rm -rf $(ODIR)
|
/bin/rm -rf $(ODIR)
|
||||||
|
# clean the objects file
|
||||||
|
# rm is use with its native path to avoid using an alias
|
||||||
|
|
||||||
|
|
||||||
# clean the objects and executable files
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
/bin/rm -f $(NAME)
|
/bin/rm -f $(NAME)
|
||||||
|
# clean the objects and executable files
|
||||||
|
|
||||||
|
|
||||||
# remake the compilation
|
|
||||||
re: fclean all
|
re: fclean all
|
||||||
|
# remake the compilation
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean fclean re all
|
.PHONY: clean fclean re all
|
||||||
|
# all rules that are not names of a file are declared to
|
||||||
|
# be phony so that makefile knows he has to execute them
|
||||||
|
# even if a file name similarly exist and would prevent
|
||||||
|
# the rule to execute because it has not been changed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -155,27 +200,26 @@ re: fclean all
|
|||||||
# explication complete etapes par etapes depuis le debut #
|
# explication complete etapes par etapes depuis le debut #
|
||||||
# ------------------------------------------------------ #
|
# ------------------------------------------------------ #
|
||||||
|
|
||||||
## SOMMAIRE [140 G]
|
## 1 - compiler avec gcc [25 gj]
|
||||||
## 1 - compiler avec gcc [161 G]
|
# compiler un programme [29 gj]
|
||||||
# compiler un programme... [165 G]
|
# compiler en plusieurs fichiers [54 gj]
|
||||||
# compiler en plusieurs fichiers... [190 G]
|
# les .o : compiler et linker [102 gj]
|
||||||
# les .o : pre-compiler... [238 G]
|
|
||||||
|
|
||||||
## 2 - creer une librairie [272 G]
|
## 2 - creer une librairie [135 gj]
|
||||||
# ar rc [276 G]
|
# ar rc [139 gj]
|
||||||
# ar rc en plusieurs fois [301 G]
|
# ar rc en plusieurs fois [164 gj]
|
||||||
# ranlib [322 G]
|
# ranlib [185 gj]
|
||||||
|
|
||||||
## 3 - fichiers .h [335 G]
|
## 3 - fichiers .h [198 gj]
|
||||||
# a quoi sert un header []
|
# a quoi sert un header [202 gj]
|
||||||
# ecrire un header []
|
# ecrire un header [229 gj]
|
||||||
# comment ca se compile []
|
# comment ca se compile [273 gj]
|
||||||
|
|
||||||
## 4 - ecrire un make file... []
|
## 4 - ecrire un make file [305 gj]
|
||||||
# makefile basique []
|
# basic makefile [309 gj]
|
||||||
# ne pas tout recompiler... []
|
# makefile with subdirectories [462 gj]
|
||||||
# fichiers .o dans un dossier... []
|
# makefile making another makefile [583 gj]
|
||||||
# make un autre makefile []
|
# makefile for a library [690 gj]
|
||||||
|
|
||||||
## ----------------------
|
## ----------------------
|
||||||
## 1 - compiler avec gcc
|
## 1 - compiler avec gcc
|
||||||
@@ -357,7 +401,6 @@ re: fclean all
|
|||||||
# - - - - - - - - - - - -
|
# - - - - - - - - - - - -
|
||||||
# a quoi sert un header
|
# a quoi sert un header
|
||||||
# - - - - - - - - - - - -
|
# - - - - - - - - - - - -
|
||||||
|
|
||||||
# si on utilise une librairie c'est parce qu'on peut avoir
|
# si on utilise une librairie c'est parce qu'on peut avoir
|
||||||
# souvent besoin des memes fonctions dans un programme
|
# souvent besoin des memes fonctions dans un programme
|
||||||
# mais si a chaque fois qu'on utilise une fonction de la
|
# mais si a chaque fois qu'on utilise une fonction de la
|
||||||
@@ -435,10 +478,10 @@ re: fclean all
|
|||||||
#
|
#
|
||||||
# par exemple pour l'architecture de dossier suivante :
|
# par exemple pour l'architecture de dossier suivante :
|
||||||
#
|
#
|
||||||
# # file
|
# # file/
|
||||||
# # -> main.c
|
# # main.c
|
||||||
# # -> ft_putchar.c
|
# # ft_putchar.c
|
||||||
# # -> libtest.h
|
# # libtest.h
|
||||||
#
|
#
|
||||||
# il faut ecrire :
|
# il faut ecrire :
|
||||||
#
|
#
|
||||||
@@ -496,19 +539,19 @@ re: fclean all
|
|||||||
# # #---------#
|
# # #---------#
|
||||||
# # all: $(ODIR) $(NAME)
|
# # all: $(ODIR) $(NAME)
|
||||||
# # $(NAME): $(OBJS) $(DEPS)
|
# # $(NAME): $(OBJS) $(DEPS)
|
||||||
# # $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS)
|
# # $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS)
|
||||||
# # %.o: %.c
|
# # %.o: %.c
|
||||||
# # $(CC) $(CFLAGS) -c -o $@ $<
|
# # $(CC) $(CFLAGS) -c -o $@ $<
|
||||||
# # clean:
|
# # clean:
|
||||||
# # /bin/rm -rf $(ODIR)
|
# # /bin/rm -rf $(ODIR)
|
||||||
# # fclean: clean
|
# # fclean: clean
|
||||||
# # /bin/rm -f $(NAME)
|
# # /bin/rm -f $(NAME)
|
||||||
# # re: fclean all
|
# # re: fclean all
|
||||||
# # .PHONY: all clean fclean re
|
# # .PHONY: all clean fclean re
|
||||||
#
|
#
|
||||||
# # prompt "make" execute the first rule ("all")
|
# # prompt "make" execute the first rule ("all")
|
||||||
#
|
#
|
||||||
# [archtecture]
|
# [architecture]
|
||||||
# # main.c
|
# # main.c
|
||||||
# # main.o
|
# # main.o
|
||||||
# # function01.c
|
# # function01.c
|
||||||
@@ -627,7 +670,7 @@ re: fclean all
|
|||||||
#
|
#
|
||||||
# have multiples .a files
|
# have multiples .a files
|
||||||
#
|
#
|
||||||
# [archtecture]
|
# [architecture]
|
||||||
# # srcs/
|
# # srcs/
|
||||||
# # main.c
|
# # main.c
|
||||||
# # function01.c
|
# # function01.c
|
||||||
@@ -670,21 +713,21 @@ re: fclean all
|
|||||||
# # #---------#
|
# # #---------#
|
||||||
# # all: $(ODIR) $(NAME)
|
# # all: $(ODIR) $(NAME)
|
||||||
# # $(NAME): $(OBJS) $(DEPS)
|
# # $(NAME): $(OBJS) $(DEPS)
|
||||||
# # $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS)
|
# # $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS)
|
||||||
# # $(ODIR):
|
# # $(ODIR):
|
||||||
# # mkdir -p $@
|
# # mkdir -p $@
|
||||||
# # $(ODIR)/%.o: %.c
|
# # $(ODIR)/%.o: %.c
|
||||||
# # $(CC) $(CFLAGS) -c -o $@ $<
|
# # $(CC) $(CFLAGS) -c -o $@ $<
|
||||||
# # clean:
|
# # clean:
|
||||||
# # /bin/rm -rf $(ODIR)
|
# # /bin/rm -rf $(ODIR)
|
||||||
# # fclean: clean
|
# # fclean: clean
|
||||||
# # /bin/rm -f $(NAME)
|
# # /bin/rm -f $(NAME)
|
||||||
# # re: fclean all
|
# # re: fclean all
|
||||||
# # .PHONY: all clean fclean re
|
# # .PHONY: all clean fclean re
|
||||||
#
|
#
|
||||||
# # prompt "make" execute the first rule ("all")
|
# # prompt "make" execute the first rule ("all")
|
||||||
#
|
#
|
||||||
# [archtecture]
|
# [architecture]
|
||||||
# # srcs/
|
# # srcs/
|
||||||
# # main.c
|
# # main.c
|
||||||
# # function01.c
|
# # function01.c
|
||||||
@@ -692,21 +735,30 @@ re: fclean all
|
|||||||
# # includes/
|
# # includes/
|
||||||
# # header01.h
|
# # header01.h
|
||||||
# # header02.h
|
# # header02.h
|
||||||
# # builds/
|
# # builds/ ++
|
||||||
# # main.o
|
# # main.o ++
|
||||||
# # function01.o
|
# # function01.o ++
|
||||||
# # function02.o
|
# # function02.o ++
|
||||||
# # libtest.a
|
# # libtest.a
|
||||||
# # liboption.a
|
# # liboption.a
|
||||||
# # Makefile
|
# # Makefile
|
||||||
# # program_test
|
# # program_test ++
|
||||||
|
#
|
||||||
|
# -----
|
||||||
|
#
|
||||||
|
# VPATH = srcs
|
||||||
|
#
|
||||||
|
# build-in variable VPATH is a list of directories where
|
||||||
|
# makefile looks for files that it doesn't find in the
|
||||||
|
# first place, so it let you easily put .c files into
|
||||||
|
# subdirectories
|
||||||
#
|
#
|
||||||
# -----
|
# -----
|
||||||
#
|
#
|
||||||
# LIBS = $(_LIBS:lib%.a=%)
|
# LIBS = $(_LIBS:lib%.a=%)
|
||||||
#
|
#
|
||||||
# from "libtest.a" abd "liboption.a" it creates "test"
|
# from "libtest.a" and "liboption.a" it creates "test"
|
||||||
# and option
|
# and "option"
|
||||||
#
|
#
|
||||||
# as said, the value of the % in "replacement" is
|
# as said, the value of the % in "replacement" is
|
||||||
# replaced with the text matched by the % in "pattern"
|
# replaced with the text matched by the % in "pattern"
|
||||||
@@ -720,253 +772,200 @@ re: fclean all
|
|||||||
#
|
#
|
||||||
# -----
|
# -----
|
||||||
#
|
#
|
||||||
# all: $(ODIR) $(NAME)
|
|
||||||
# $(ODIR):
|
|
||||||
# mkdir -p $@
|
|
||||||
#
|
|
||||||
# ALL call the rull ODIR wich verify if the objects files
|
|
||||||
# directory already exist and if not, create it
|
|
||||||
#
|
|
||||||
# -----
|
|
||||||
#
|
|
||||||
# $(NAME): $(OBJS) $(DEPS)
|
# $(NAME): $(OBJS) $(DEPS)
|
||||||
# $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS)
|
# $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS)
|
||||||
#
|
#
|
||||||
# NAME depends on OBJS and DEPS, so if any .o or any .h
|
# NAME depends on OBJS and DEPS, so if any .o or any .h
|
||||||
# have more recent date of modification NAME will execute
|
# have more recent date of modification NAME will execute
|
||||||
# only for them
|
# again only for them
|
||||||
|
|
||||||
|
# - - - - - - - - - - - - - - - - -
|
||||||
|
# makefile making another makefile
|
||||||
|
# - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
# compiling a makefile with compiling another makefile in
|
||||||
|
# a subdirectory wich contain the library used by the
|
||||||
|
# roots makefile
|
||||||
|
#
|
||||||
|
# [architecture]
|
||||||
|
# # srcs/
|
||||||
|
# # main.c
|
||||||
|
# # function01.c
|
||||||
|
# # function02.c
|
||||||
|
# # includes/
|
||||||
|
# # header01.h
|
||||||
|
# # header02.h
|
||||||
|
# # libtest/
|
||||||
|
# # Makefile
|
||||||
|
# # header_lib.h
|
||||||
|
# # function_lib01.c
|
||||||
|
# # function_lib02.c
|
||||||
|
# # libtest.a
|
||||||
|
# # Makefile
|
||||||
|
#
|
||||||
|
# # #-------------#
|
||||||
|
# # # VARIABLES #
|
||||||
|
# # #-------------#
|
||||||
|
# # NAME = program_test
|
||||||
|
# # CC = gcc
|
||||||
|
# # VPATH = srcs
|
||||||
|
# #
|
||||||
|
# # IDIR = includes
|
||||||
|
# # _DEPS = header01.h \
|
||||||
|
# # header02.h
|
||||||
|
# # DEPS = $(_DEPS:%.h=$(IDIR)/%.h)
|
||||||
|
# #
|
||||||
|
# # LDIR = ./libtest/
|
||||||
|
# # _LIBS = libtest.a \
|
||||||
|
# # LIBS = $(_LIBS:lib%.a=%)
|
||||||
|
# #
|
||||||
|
# # SRCS = main.c \
|
||||||
|
# # function01.c
|
||||||
|
# # function02.c
|
||||||
|
# # ODIR = ./builds
|
||||||
|
# # OBJS = $(SRCS:%.c=$(ODIR)/%.o)
|
||||||
|
# #
|
||||||
|
# # CFLAGS = -I$(IDIR)
|
||||||
|
# # LFLAGS = -L$(LDIR) -l$(LIBS)
|
||||||
|
# #
|
||||||
|
# # #---------#
|
||||||
|
# # # RULES #
|
||||||
|
# # #---------#
|
||||||
|
# # all: $(ODIR) $(NAME)
|
||||||
|
# # $(NAME): $(OBJS) $(DEPS)
|
||||||
|
# # make -C $(LDIR)
|
||||||
|
# # $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS)
|
||||||
|
# # $(ODIR):
|
||||||
|
# # mkdir -p $@
|
||||||
|
# # $(ODIR)/%.o: %.c
|
||||||
|
# # $(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
# # clean:
|
||||||
|
# # make clean -C $(LDIR)
|
||||||
|
# # /bin/rm -rf $(ODIR)
|
||||||
|
# # fclean: clean
|
||||||
|
# # make fclean -C $(LDIR)
|
||||||
|
# # /bin/rm -f $(NAME)
|
||||||
|
# # re: fclean all
|
||||||
|
# # .PHONY: all clean fclean re
|
||||||
|
#
|
||||||
|
# # prompt "make" execute the first rule ("all")
|
||||||
|
#
|
||||||
|
# [archtecture]
|
||||||
|
# # srcs/
|
||||||
|
# # main.c
|
||||||
|
# # function01.c
|
||||||
|
# # function02.c
|
||||||
|
# # includes/
|
||||||
|
# # header01.h
|
||||||
|
# # header02.h
|
||||||
|
# # builds/ ++
|
||||||
|
# # main.o ++
|
||||||
|
# # function01.o ++
|
||||||
|
# # function02.o ++
|
||||||
|
# # libtest/
|
||||||
|
# # Makefile
|
||||||
|
# # header_lib.h
|
||||||
|
# # function_lib01.c
|
||||||
|
# # function_lib02.c
|
||||||
|
# # libtest.a
|
||||||
|
# # Makefile
|
||||||
|
# # program_test ++
|
||||||
#
|
#
|
||||||
# -----
|
# -----
|
||||||
#
|
#
|
||||||
# clean:
|
# make -C $(LDIR)
|
||||||
# /bin/rm -rf $(ODIR)
|
|
||||||
#
|
#
|
||||||
# "make clean" suppress all the .o files
|
# make -C <path>
|
||||||
|
#
|
||||||
|
# the -C option says to makefile it should first go to the
|
||||||
|
# path location and then do "make"
|
||||||
|
#
|
||||||
|
# it's similar to :
|
||||||
|
#
|
||||||
|
# rule:
|
||||||
|
# cd $(LDIR) && make
|
||||||
|
#
|
||||||
|
|
||||||
|
# - - - - - - - - - - - -
|
||||||
|
# makefile for a library
|
||||||
|
# - - - - - - - - - - - -
|
||||||
|
|
||||||
|
#
|
||||||
|
# exemple of a makefile used not for a compilation into a
|
||||||
|
# binary executable, but to create a library
|
||||||
|
#
|
||||||
|
# [architecture]
|
||||||
|
# # srcs/
|
||||||
|
# # function01.c
|
||||||
|
# # function02.c
|
||||||
|
# # includes/
|
||||||
|
# # header.h
|
||||||
|
# # Makefile
|
||||||
|
#
|
||||||
|
# # #-------------#
|
||||||
|
# # # VARIABLES #
|
||||||
|
# # #-------------#
|
||||||
|
# # NAME = libtest.a
|
||||||
|
# # CC = gcc
|
||||||
|
# # VPATH = srcs
|
||||||
|
# #
|
||||||
|
# # IDIR = includes
|
||||||
|
# # _DEPS = header.h
|
||||||
|
# # DEPS = $(_DEPS:%.h=$(IDIR)/%.h)
|
||||||
|
# #
|
||||||
|
# # SRCS = function01.c \
|
||||||
|
# # function02.c
|
||||||
|
# # ODIR = ./builds
|
||||||
|
# # OBJS = $(SRCS:%.c=$(ODIR)/%.o)
|
||||||
|
# #
|
||||||
|
# # CFLAGS = -I$(IDIR)
|
||||||
|
# #
|
||||||
|
# # #---------#
|
||||||
|
# # # RULES #
|
||||||
|
# # #---------#
|
||||||
|
# # all: $(ODIR) $(NAME)
|
||||||
|
# # $(NAME): $(OBJS) $(DEP)
|
||||||
|
# # ar -rc $@ $(OBJS)
|
||||||
|
# # @ranlib $@
|
||||||
|
# # $(ODIR):
|
||||||
|
# # mkdir -p $@
|
||||||
|
# # $(ODIR)/%.o: %.c
|
||||||
|
# # $(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
# # clean:
|
||||||
|
# # /bin/rm -rf $(ODIR)
|
||||||
|
# # fclean: clean
|
||||||
|
# # /bin/rm -f $(NAME)
|
||||||
|
# # re: fclean all
|
||||||
|
# # .PHONY: all clean fclean re
|
||||||
|
#
|
||||||
|
# # prompt "make" execute the first rule ("all")
|
||||||
|
#
|
||||||
|
# [archtecture]
|
||||||
|
# # srcs/
|
||||||
|
# # function01.c
|
||||||
|
# # function02.c
|
||||||
|
# # includes/
|
||||||
|
# # header.h
|
||||||
|
# # builds/
|
||||||
|
# # function01.o
|
||||||
|
# # function02.o
|
||||||
|
# # libtest.a
|
||||||
|
# # Makefile
|
||||||
#
|
#
|
||||||
# -----
|
# -----
|
||||||
#
|
#
|
||||||
|
# NAME = libtest.a
|
||||||
#
|
#
|
||||||
|
# name is now the name of the library to be built
|
||||||
#
|
#
|
||||||
|
# -----
|
||||||
#
|
#
|
||||||
|
# @ranlib $@
|
||||||
#
|
#
|
||||||
#
|
# @ tells makefile not to show the line in prompt
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - -
|
|
||||||
# makefile qui make un autre makefile
|
|
||||||
# - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - -
|
|
||||||
# makefile pour une librairie
|
|
||||||
# - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # create the folder where all the .o files will be stored
|
|
||||||
# $(ODIR):
|
|
||||||
# mkdir -p $(ODIR)
|
|
||||||
#
|
#
|
||||||
# # - NAME will create the library libft.a
|
# THE END
|
||||||
# # - first it checks if any OBJ (files.o) have more recent
|
# enjoy, futur me
|
||||||
# # 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
|
|
||||||
# qui sont utilisees par défaut si les variables
|
|
||||||
# sont bien nomee (genre CC ou CFLAGS)
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
# ne pas tout recompiler a la moindre modification
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - -
|
|
||||||
# mettre les fichiers .o dans un dossier
|
|
||||||
# - - - - - - - - - - - - - - - - - - - -
|
|
||||||
|
|
||||||
# - - - - - - - - - - - -
|
|
||||||
# make un autre makefile
|
|
||||||
# - - - - - - - - - - - -
|
|
||||||
|
|
||||||
#
|
|
||||||
# cependant si on veut mettre les fichiers .o dans un
|
|
||||||
# sous-fichier BUILDS il n'y a pas de built-in pattern
|
|
||||||
# il faut donc l'ecrire nous-meme :
|
|
||||||
#
|
|
||||||
# # NAME = libtest.h
|
|
||||||
# # CC = gcc
|
|
||||||
# # CFLAGS = -I.
|
|
||||||
# # SRCS = example01.c \
|
|
||||||
# # example02.c
|
|
||||||
# # ODIR = ./builds
|
|
||||||
# # OBJS = $(addprefix $(ODIR)/, $(SRCS:.c=.o))
|
|
||||||
# #
|
|
||||||
# # all: $(NAME)
|
|
||||||
# # $(NAME): $(OBJS)
|
|
||||||
# # ar -rc $@ $<
|
|
||||||
# #
|
|
||||||
# # $(ODIR)/%.o : %.c
|
|
||||||
# # $(COMPILE.c) -o $@ $<
|
|
||||||
#
|
|
||||||
# cette regle est appellee par $(OBJS) puisque
|
|
||||||
# cette variable appelle la regle $(ODIR/file.o)
|
|
||||||
#
|
|
||||||
# COMPILE est une built-in variable qui execute
|
|
||||||
# les regles CC et CFLAGS avec l'option -c
|
|
||||||
#
|
|
||||||
# % = "tout"
|
|
||||||
# $@ = "la valeur a gauche de :"
|
|
||||||
# $< = "la premiere valeur a droite de :"
|
|
||||||
# $^ = "toutes les valeurs a droite de :"
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# shape of a rule :
|
|
||||||
#
|
|
||||||
# target: prerequisites
|
|
||||||
# recipe
|
|
||||||
#
|
|
||||||
# before executing its recipes, makefile verify if any of
|
|
||||||
# the prerequisites has been more recently modify than
|
|
||||||
# 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
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ LDIR = ./
|
|||||||
_LIBS = libtest.a
|
_LIBS = libtest.a
|
||||||
LIBS = $(_LIBS:lib%.a=%)
|
LIBS = $(_LIBS:lib%.a=%)
|
||||||
# FUNCTIONS et OBJETS #
|
# FUNCTIONS et OBJETS #
|
||||||
SRCS = main.c to_uppercase.c #putchar.c transform.c
|
SRCS = main.c to_uppercase.c putchar.c transform.c
|
||||||
ODIR = ./builds
|
ODIR = ./builds
|
||||||
OBJS = $(SRCS:%.c=$(ODIR)/%.o)
|
OBJS = $(SRCS:%.c=$(ODIR)/%.o)
|
||||||
# OPTIONS de GCC #
|
# OPTIONS de GCC #
|
||||||
@@ -24,8 +24,10 @@ LFLAGS = -L$(LDIR) -l$(LIBS)
|
|||||||
# RULES #
|
# RULES #
|
||||||
#---------#
|
#---------#
|
||||||
all: $(ODIR) $(NAME)
|
all: $(ODIR) $(NAME)
|
||||||
|
#$(NAME): $(OBJS) $(DEPS)
|
||||||
|
# $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS)
|
||||||
$(NAME): $(OBJS) $(DEPS)
|
$(NAME): $(OBJS) $(DEPS)
|
||||||
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS)
|
ar rc $@ $(OBJS)
|
||||||
$(ODIR):
|
$(ODIR):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
$(ODIR)/%.o: %.c
|
$(ODIR)/%.o: %.c
|
||||||
|
|||||||
Binary file not shown.
BIN
test/builds/putchar.o
Normal file
BIN
test/builds/putchar.o
Normal file
Binary file not shown.
Binary file not shown.
BIN
test/builds/transform.o
Normal file
BIN
test/builds/transform.o
Normal file
Binary file not shown.
BIN
test/libtest.a
BIN
test/libtest.a
Binary file not shown.
6
test/srcs/putchar.c
Normal file
6
test/srcs/putchar.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
void ft_putchar(char c)
|
||||||
|
{
|
||||||
|
write(1, &c, 1);
|
||||||
|
}
|
||||||
6
test/srcs/transform.c
Normal file
6
test/srcs/transform.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
int transform(int a)
|
||||||
|
{
|
||||||
|
return (--a);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user