Fix: Makefile doesn't relink
This commit is contained in:
parent
89d1381121
commit
c40eae3699
2 changed files with 112 additions and 86 deletions
112
shcat_c/Makefile
112
shcat_c/Makefile
|
|
@ -6,47 +6,12 @@
|
||||||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||||
# Updated: 2024/04/28 17:24:41 by maiboyer ### ########.fr #
|
# Updated: 2024/04/28 17:36:57 by maiboyer ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
||||||
# Variables
|
|
||||||
|
|
||||||
# Name
|
|
||||||
NAME = minishell
|
|
||||||
LIBDIRNAME = libft
|
|
||||||
SRCDIRNAME = sources
|
|
||||||
|
|
||||||
# Commands
|
|
||||||
CC = cc
|
|
||||||
RM = rm -rf
|
|
||||||
|
|
||||||
# Objdir
|
# Objdir
|
||||||
OBJDIRNAME = ./objects
|
OBJDIRNAME = ./objects
|
||||||
# Flags
|
|
||||||
CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD -lreadline -L$(OBJDIRNAME) -lme -lgmr -I./includes -I./stdme/includes -I./parser_src/includes
|
|
||||||
|
|
||||||
# Sources
|
|
||||||
LIB = ./libft/ft_bzero.c \
|
|
||||||
./libft/ft_calloc.c \
|
|
||||||
./libft/ft_memset.c \
|
|
||||||
./libft/ft_split.c \
|
|
||||||
./libft/ft_strcmp.c \
|
|
||||||
./libft/ft_strdup.c \
|
|
||||||
./libft/ft_strlcpy.c \
|
|
||||||
./libft/ft_strjoin.c \
|
|
||||||
./libft/ft_strlen.c
|
|
||||||
|
|
||||||
SRC = ./sources/ft_cmd.c \
|
|
||||||
./sources/ft_echo.c \
|
|
||||||
./sources/ft_exit.c \
|
|
||||||
./sources/ft_pwd.c \
|
|
||||||
./sources/main.c
|
|
||||||
|
|
||||||
# Objects
|
|
||||||
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o))
|
|
||||||
LIB_OBJ = $(addprefix $(OBJDIRNAME)/,$(LIB:.c=.o))
|
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
GREEN = \033[32m
|
GREEN = \033[32m
|
||||||
|
|
@ -58,47 +23,15 @@ END = \033[0m
|
||||||
# Rules
|
# Rules
|
||||||
|
|
||||||
# All (make all)
|
# All (make all)
|
||||||
all: header $(NAME) footer
|
all:
|
||||||
|
@$(MAKE) --no-print-directory header OBJDIRNAME=$(OBJDIRNAME)
|
||||||
|
@$(MAKE) --no-print-directory -f./Minishell.mk OBJDIRNAME=$(OBJDIRNAME)
|
||||||
|
@$(MAKE) --no-print-directory footer OBJDIRNAME=$(OBJDIRNAME)
|
||||||
|
|
||||||
# Bonus (make bonus)
|
bonus:
|
||||||
bonus: header $(OBJ) $(LIB_OBJ) footer
|
@$(MAKE) --no-print-directory header OBJDIRNAME=$(OBJDIRNAME)
|
||||||
@mkdir -p $(OBJDIRNAME)
|
@$(MAKE) --no-print-directory -f./Minishell.mk OBJDIRNAME=$(OBJDIRNAME) bonus
|
||||||
@mkdir -p $(OBJDIRNAME)/$(LIBDIRNAME)
|
@$(MAKE) --no-print-directory footer OBJDIRNAME=$(OBJDIRNAME)
|
||||||
@mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME)
|
|
||||||
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
|
||||||
@printf '$(GREY) Be Carefull ur in $(END)$(GREEN)Debug Mode$(END)\n'
|
|
||||||
@cc $(CFLAGS) -D DEBUG=42 -o $(NAME) $(OBJ)
|
|
||||||
|
|
||||||
# Clean (make clean)
|
|
||||||
clean:
|
|
||||||
@printf '$(GREY) Removing $(END)$(RED)Objects$(END)\n'
|
|
||||||
@printf '$(GREY) Removing $(END)$(RED)Objects Folder$(END)\n'
|
|
||||||
@$(RM) $(OBJDIRNAME)
|
|
||||||
|
|
||||||
# Clean (make fclean)
|
|
||||||
fclean: clean
|
|
||||||
@printf '$(GREY) Removing $(END)$(RED)Program$(END)\n'
|
|
||||||
@$(RM) $(NAME)
|
|
||||||
@echo ""
|
|
||||||
|
|
||||||
# Restart (make re)
|
|
||||||
re: header
|
|
||||||
$(MAKE) fclean
|
|
||||||
$(MAKE) all
|
|
||||||
|
|
||||||
# Dependences for all
|
|
||||||
$(NAME): $(OBJ) $(LIB_OBJ) $(OBJDIRNAME)/libme.a $(OBJDIRNAME)/libgmr.a
|
|
||||||
@mkdir -p $(OBJDIRNAME)
|
|
||||||
@mkdir -p $(OBJDIRNAME)/$(LIBDIRNAME)
|
|
||||||
@mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME)
|
|
||||||
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
|
||||||
@cc $(CFLAGS) -o $(NAME) $(OBJ) $(LIB_OBJ)
|
|
||||||
|
|
||||||
# Creating the objects
|
|
||||||
$(OBJDIRNAME)/%.o: %.c
|
|
||||||
@mkdir -p $(dir $@)
|
|
||||||
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
|
||||||
@cc $(CFLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
header:
|
header:
|
||||||
|
|
@ -131,19 +64,26 @@ footer:
|
||||||
@printf "$(GOLD) '\"' '\"'$(END)\n"
|
@printf "$(GOLD) '\"' '\"'$(END)\n"
|
||||||
@printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
|
@printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
|
||||||
|
|
||||||
$(OBJDIRNAME)/libme.a:
|
|
||||||
@$(MAKE) --no-print-directory -C ./stdme/ LIB_NAME="$(realpath ./$(stdme))/" "BUILD_DIR=$(shell realpath ./$(OBJDIRNAME))" libme.a
|
|
||||||
|
|
||||||
$(OBJDIRNAME)/libgmr.a:
|
|
||||||
@$(MAKE) --no-print-directory -C ./parser/ LIB_NAME="$(realpath ./$(stdme))/" "BUILD_DIR=$(shell realpath ./$(OBJDIRNAME))" libgmr.a
|
|
||||||
|
|
||||||
|
|
||||||
pull:
|
pull:
|
||||||
@printf "$(GREEN)Pulling Submodules$(END)\n"
|
@printf "$(GREEN)Pulling Submodules$(END)\n"
|
||||||
@git submodule init
|
@git submodule init
|
||||||
@git submodule update
|
@git submodule update
|
||||||
|
|
||||||
# Phony
|
# Clean (make clean)
|
||||||
.PHONY: all bonus clean fclean re $(OBJDIRNAME)/libme.a $(OBJDIRNAME)/libgmr.a
|
clean:
|
||||||
|
@printf '$(GREY) Removing $(END)$(RED)Objects$(END)\n'
|
||||||
|
@printf '$(GREY) Removing $(END)$(RED)Objects Folder$(END)\n'
|
||||||
|
@$(RM) -r $(OBJDIRNAME)
|
||||||
|
|
||||||
-include ${OBJ:.o=.d}
|
# Clean (make fclean)
|
||||||
|
fclean: clean
|
||||||
|
@printf '$(GREY) Removing $(END)$(RED)Program$(END)\n'
|
||||||
|
@$(RM) $(NAME)
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
# Restart (make re)
|
||||||
|
re: header
|
||||||
|
@$(MAKE) --no-print-directory fclean
|
||||||
|
@$(MAKE) --no-print-directory all
|
||||||
|
# phony
|
||||||
|
.PHONY: all bonus clean fclean re
|
||||||
|
|
|
||||||
86
shcat_c/Minishell.mk
Normal file
86
shcat_c/Minishell.mk
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# ::: :::::::: #
|
||||||
|
# Minishell.mk :+: :+: :+: #
|
||||||
|
# +:+ +:+ +:+ #
|
||||||
|
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
||||||
|
# +#+#+#+#+#+ +#+ #
|
||||||
|
# Created: 2024/04/28 17:28:30 by maiboyer #+# #+# #
|
||||||
|
# Updated: 2024/04/28 17:36:20 by maiboyer ### ########.fr #
|
||||||
|
# #
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
|
||||||
|
OBJDIRNAME ?=
|
||||||
|
|
||||||
|
# Flags
|
||||||
|
CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD -lreadline -L$(OBJDIRNAME) -lme -lgmr -I./includes -I./stdme/includes -I./parser_src/includes
|
||||||
|
|
||||||
|
# Sources
|
||||||
|
LIB = ./libft/ft_bzero.c \
|
||||||
|
./libft/ft_calloc.c \
|
||||||
|
./libft/ft_memset.c \
|
||||||
|
./libft/ft_split.c \
|
||||||
|
./libft/ft_strcmp.c \
|
||||||
|
./libft/ft_strdup.c \
|
||||||
|
./libft/ft_strlcpy.c \
|
||||||
|
./libft/ft_strjoin.c \
|
||||||
|
./libft/ft_strlen.c
|
||||||
|
|
||||||
|
SRC = ./sources/ft_cmd.c \
|
||||||
|
./sources/ft_echo.c \
|
||||||
|
./sources/ft_exit.c \
|
||||||
|
./sources/ft_pwd.c \
|
||||||
|
./sources/main.c
|
||||||
|
|
||||||
|
# Name
|
||||||
|
NAME = minishell
|
||||||
|
LIBDIRNAME = libft
|
||||||
|
SRCDIRNAME = sources
|
||||||
|
|
||||||
|
# Commands
|
||||||
|
CC = cc
|
||||||
|
RM = rm -rf
|
||||||
|
|
||||||
|
# Objects
|
||||||
|
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o))
|
||||||
|
LIB_OBJ = $(addprefix $(OBJDIRNAME)/,$(LIB:.c=.o))
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
GREEN = \033[32m
|
||||||
|
GREY = \033[0;90m
|
||||||
|
RED = \033[0;31m
|
||||||
|
GOLD = \033[38;5;220m
|
||||||
|
END = \033[0m
|
||||||
|
|
||||||
|
all: $(NAME)
|
||||||
|
|
||||||
|
# Bonus (make bonus)
|
||||||
|
bonus: $(OBJ) $(LIB_OBJ) $(OBJDIRNAME)/libme.a $(OBJDIRNAME)/libgmr.a
|
||||||
|
@mkdir -p $(OBJDIRNAME)
|
||||||
|
@mkdir -p $(OBJDIRNAME)/$(LIBDIRNAME)
|
||||||
|
@mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME)
|
||||||
|
@printf '$(GREY) Be Carefull ur in $(END)$(GREEN)Debug Mode$(END)\n'
|
||||||
|
@cc $(CFLAGS) -D DEBUG=42 -o $(NAME) $(OBJ)
|
||||||
|
|
||||||
|
# Dependences for all
|
||||||
|
$(NAME): $(OBJ) $(LIB_OBJ) $(OBJDIRNAME)/libme.a $(OBJDIRNAME)/libgmr.a
|
||||||
|
@mkdir -p $(OBJDIRNAME)
|
||||||
|
@mkdir -p $(OBJDIRNAME)/$(LIBDIRNAME)
|
||||||
|
@mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME)
|
||||||
|
@cc $(CFLAGS) -o $(NAME) $(OBJ) $(LIB_OBJ)
|
||||||
|
|
||||||
|
# Creating the objects
|
||||||
|
$(OBJDIRNAME)/%.o: %.c
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
||||||
|
@cc $(CFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
$(OBJDIRNAME)/libme.a:
|
||||||
|
@$(MAKE) --no-print-directory -C ./stdme/ LIB_NAME="$(realpath ./$(stdme))/" "BUILD_DIR=$(shell realpath ./$(OBJDIRNAME))" libme.a
|
||||||
|
|
||||||
|
$(OBJDIRNAME)/libgmr.a:
|
||||||
|
@$(MAKE) --no-print-directory -C ./parser/ LIB_NAME="$(realpath ./$(stdme))/" "BUILD_DIR=$(shell realpath ./$(OBJDIRNAME))" libgmr.a
|
||||||
|
|
||||||
|
-include ${OBJ:.o=.d}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue