explication makefil en cours
This commit is contained in:
BIN
.Makefile.swo
Normal file
BIN
.Makefile.swo
Normal file
Binary file not shown.
BIN
.Makefile.swp
Normal file
BIN
.Makefile.swp
Normal file
Binary file not shown.
BIN
.OLDMakefile.swp
BIN
.OLDMakefile.swp
Binary file not shown.
249
Makefile
249
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
|
||||
|
||||
Binary file not shown.
@@ -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 $@ $<
|
||||
|
||||
|
||||
BIN
test/libtest.a
BIN
test/libtest.a
Binary file not shown.
BIN
test/putchar.o
BIN
test/putchar.o
Binary file not shown.
@@ -2,5 +2,5 @@
|
||||
|
||||
int transform(int a)
|
||||
{
|
||||
return(--a);
|
||||
return (--a);
|
||||
}
|
||||
BIN
test/transform.o
BIN
test/transform.o
Binary file not shown.
Reference in New Issue
Block a user