build(ASM/make): init the assembly makefile
This commit is contained in:
parent
763682e680
commit
1907e4f2b2
1 changed files with 156 additions and 0 deletions
156
ASM/Makefile
Normal file
156
ASM/Makefile
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Makefile :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||
# Updated: 2026/03/17 15:42:45 by rparodi ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
# Variables
|
||||
|
||||
# Name
|
||||
NAME = DrQuine_ASM
|
||||
|
||||
# Commands
|
||||
AS ?= nasm
|
||||
RM = rm -rf
|
||||
|
||||
# Flags
|
||||
ASFLAGS = -f elf64
|
||||
|
||||
# Directories
|
||||
OBJDIRNAME = ./build
|
||||
|
||||
# Programs
|
||||
COLLEEN = Colleen/Colleen
|
||||
GRACE = Grace/Grace
|
||||
SULLY = Sully/Sully
|
||||
|
||||
# Sources
|
||||
SRC_COLLEEN = Colleen/Colleen.s
|
||||
SRC_GRACE = Grace/Grace.s
|
||||
SRC_SULLY = Sully/Sully.s
|
||||
|
||||
# Objects
|
||||
OBJ_COLLEEN = $(addprefix $(OBJDIRNAME)/,$(SRC_COLLEEN:.s=.o))
|
||||
OBJ_GRACE = $(addprefix $(OBJDIRNAME)/,$(SRC_GRACE:.s=.o))
|
||||
OBJ_SULLY = $(addprefix $(OBJDIRNAME)/,$(SRC_SULLY:.s=.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)
|
||||
@$(AS) $(ASFLAGS) -o $@ $^
|
||||
|
||||
# Compile Grace
|
||||
$(GRACE): $(OBJ_GRACE)
|
||||
@$(AS) $(ASFLAGS) -o $@ $^
|
||||
|
||||
# Compile Sully
|
||||
$(SULLY): $(OBJ_SULLY)
|
||||
@$(AS) $(ASFLAGS) -o $@ $^
|
||||
|
||||
# Clean (make clean)
|
||||
clean:
|
||||
@printf '$(GREY) Removing $(END)$(RED)Objects$(END)\n'
|
||||
@printf '$(GREY) Removing $(END)$(RED)Objects Folder$(END)\n'
|
||||
@find . -name "Sully_*" -delete
|
||||
@$(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: %.s
|
||||
@mkdir -p $(dir $@)
|
||||
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
||||
@$(AS) $(ASFLAGS) -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$(END)\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$(END)\n"
|
||||
@diff $(SRC_COLLEEN) /tmp/test_colleen.c | bat -ldiff
|
||||
|
||||
test_grace: $(GRACE)
|
||||
@$(GRACE)
|
||||
@printf '\n\n\n$(GREY)Output of the $(GOLD)Grace$(END)\n'
|
||||
@bat -plc ./Grace_kid.c
|
||||
@printf "\n$(GREY)Here's the diff between $(GOLD)$(SRC_GRACE) $(GREY)and $(GOLD)Grace_kid.c $(END)\n"
|
||||
@diff $(SRC_GRACE) ./Grace_kid.c | bat -ldiff
|
||||
|
||||
test_sully: $(SULLY)
|
||||
@$(SULLY) > /tmp/test_sully.c
|
||||
@printf '$(GREY)Output of the $(GOLD)Sully$(END)\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$(END)\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'
|
||||
|
||||
debug: ASFLAGS += -g -F dwarf
|
||||
debug: re
|
||||
|
||||
# Phony targets
|
||||
.PHONY: all clean fclean re header footer debug
|
||||
Loading…
Add table
Add a link
Reference in a new issue