# **************************************************************************** # # # # ::: :::::::: # # Makefile :+: :+: :+: # # +:+ +:+ +:+ # # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # # Updated: 2026/01/30 22:16:49 by rparodi ### ########.fr # # # # **************************************************************************** # # Variables # Name NAME = DrQuine_C # Commands CC ?= cc RM = rm -rf # Flags CFLAGS = -Werror -Wall -Wextra # Directories OBJDIRNAME = ./build # Programs COLLEEN = Colleen/Colleen GRACE = Grace/Grace SULLY = Sully/Sully # Sources SRC_COLLEEN = Colleen/Colleen.c SRC_GRACE = Grace/Grace.c SRC_SULLY = Sully/Sully.c # Objects OBJ_COLLEEN = $(addprefix $(OBJDIRNAME)/,$(SRC_COLLEEN:.c=.o)) OBJ_GRACE = $(addprefix $(OBJDIRNAME)/,$(SRC_GRACE:.c=.o)) OBJ_SULLY = $(addprefix $(OBJDIRNAME)/,$(SRC_SULLY:.c=.o)) # Colors GREEN = \033[32m GREY = \033[0;90m RED = \033[0;31m GOLD = \033[38;5;220m END = \033[0m # Rules # All (make all) all: header $(NAME) footer # Exercices ex0: $(COLLEEN) ex1: $(GRACE) ex2: $(SULLY) # Dependences for all $(NAME): $(COLLEEN) $(GRACE) $(SULLY) # Compile Colleen $(COLLEEN): $(OBJ_COLLEEN) @$(CC) $(CFLAGS) -o $@ $^ # Compile Grace $(GRACE): $(OBJ_GRACE) @$(CC) $(CFLAGS) -o $@ $^ # Compile Sully $(SULLY): $(OBJ_SULLY) @$(CC) $(CFLAGS) -o $@ $^ # 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) $(COLLEEN) $(GRACE) $(SULLY) @echo "" # Restart (make re) re: header fclean all # Creating the objects $(OBJDIRNAME)/%.o: %.c @mkdir -p $(dir $@) @printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n' @$(CC) $(CFLAGS) -c -o $@ $< test: test_colleen test_grace test_sully test_colleen: $(COLLEEN) @clear @rm -rf /tmp/test_colleen.c @$(COLLEEN) > /tmp/test_colleen.c @printf '$(GREY)Output of the $(GOLD)Colleen$(RESET)\n' @bat -plc /tmp/test_colleen.c @printf '\n$(GREY)Here's the diff between $(GOLD)$(SRC_COLLEEN) $(GREY)and $(GOLD)/tmp/test_colleen.c$(RESET)\n' @diff $(SRC_COLLEEN) /tmp/test_colleen.c | bat -ldiff test_grace: $(GRACE) @$(GRACE) > /tmp/test_grace.c @printf '\n\n\n$(GREY)Output of the $(GOLD)Grace$(RESET)\n' @bat -plc /tmp/test_grace.c @printf '\n$(GREY)Here's the diff between $(GOLD)$(SRC_GRACE) $(GREY)and $(GOLD)/tmp/test_grace.c$(RESET)\n' @diff $(SRC_GRACE) /tmp/test_grace | bat -ldiff test_sully: $(SULLY) @$(SULLY) > /tmp/test_sully.c @printf '$(GREY)Output of the $(GOLD)Sully$(RESET)\n' @bat -plc /tmp/test_sully.c @printf '\n$(GREY)Here's the diff between $(GOLD)$(SRC_SULLY) $(GREY)and $(GOLD)/tmp/test_sully.c$(RESET)\n' @diff $(SRC_SULLY) /tmp/test_sully | bat -ldiff # Header header: @printf '\n\n' @printf '$(GOLD) ******* ****** ******* $(END)\n' @printf '$(GOLD) ****** *** ******* $(END)\n' @printf '$(GOLD) ******* * ******* $(END)\n' @printf '$(GOLD) ****** ******* $(END)\n' @printf '$(GOLD) ******* ******* $(END)\n' @printf '$(GOLD) ******************* ******* * $(END)\n' @printf '$(GOLD) ******************* ******* *** $(END)\n' @printf '$(GOLD) ****** ******* ****** $(END)\n' @printf '$(GOLD) ****** $(END)\n' @printf '$(GOLD) ****** $(END)\n' @printf '$(GREY) Made by rparodi$(END)\n\n' # Footer footer: @printf "\n" @printf "$(GOLD) ,_ _,$(END)\n" @printf "$(GOLD) | \\___//|$(END)\n" @printf "$(GOLD) |=6 6=|$(END)\n" @printf "$(GOLD) \\=._Y_.=/$(END)\n" @printf "$(GOLD) ) \` ( ,$(END)\n" @printf "$(GOLD) / \\ (('$(END)\n" @printf "$(GOLD) | | ))$(END)\n" @printf "$(GOLD) /| | | |\\_//$(END)\n" @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' tmux: @tmux new-session -d -s $(NAME) @tmux send-keys -t $(NAME):0 'vim' C-m @tmux split-window -h -t $(NAME):0 @tmux resize-pane -t $(NAME):0.0 -x 70 @tmux new-window -t $(NAME):1 -n 'lazygit' @tmux send-keys -t $(NAME):1 'lazygit' C-m @tmux select-window -t $(NAME):0 @tmux attach-session -t $(NAME) clangd: @printf "CompileFlags:\n" > ./.clangd @printf " Add:\n" >> ./.clangd @printf " - \"-xc\"\n" >> ./.clangd @for FLAG in $(CFLAGS); do \ printf " - \"$$FLAG\"\n" >> ./.clangd; \ done @printf " - \"-I"$(shell pwd)"/\"\n" >> ./.clangd @printf "\n" >> ./.clangd @printf '$(GREY) Now parsing settings is set in $(END)$(GREEN)./.clangd$(END)\n' # Phony targets .PHONY: all clean fclean re clangd tmux header footer