build(make): adding the makefile of the project
This commit is contained in:
parent
6ed34984e0
commit
a605101d97
1 changed files with 32 additions and 8 deletions
40
Makefile
40
Makefile
|
|
@ -6,7 +6,7 @@
|
|||
# By: rparodi <marvin@42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||
# Updated: 2025/11/30 20:14:15 by rparodi ### ########.fr #
|
||||
# Updated: 2025/12/06 19:58:12 by rparodi ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
# Name
|
||||
NAME = libasm.a
|
||||
TEST_OUTPUT = test
|
||||
TEST_OUTPUT = result
|
||||
|
||||
# ASM Variables
|
||||
AS ?= nasm
|
||||
|
|
@ -27,6 +27,7 @@ RM = rm -rf
|
|||
CFLAGS = -Werror -Wextra -Wall
|
||||
TEST_FILE = test/main.c
|
||||
INC_DIR = includes
|
||||
LDFLAGS = -L $(shell pwd)/build/
|
||||
CPPFLAGS = $(addprefix -I, $(INC_DIR)) -MMD -MP
|
||||
|
||||
# Objects
|
||||
|
|
@ -34,7 +35,8 @@ OBJDIRNAME = ./build
|
|||
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.s=.o))
|
||||
OBJ_BONUS = $(addprefix $(OBJDIRNAME)/,$(SRC_BONUS:.s=.o))
|
||||
|
||||
SRC = ft_write.s
|
||||
SRC = src/ft_strlen.s \
|
||||
src/ft_strcmp.s
|
||||
|
||||
# Colors
|
||||
GREEN = \033[32m
|
||||
|
|
@ -62,22 +64,29 @@ clean:
|
|||
fclean: clean
|
||||
@printf '$(GREY) Removing $(END)$(RED)Program$(END)\n'
|
||||
@$(RM) $(NAME)
|
||||
@$(RM) $(TEST_OUTPUT)
|
||||
@echo ""
|
||||
|
||||
re: header fclean all
|
||||
|
||||
$(NAME): $(OBJ)
|
||||
@mkdir -p $(OBJDIRNAME)
|
||||
@ar rc $(NAME) $(OBJ)
|
||||
@ranlib $(NAME)
|
||||
@ar rc $(OBJDIRNAME)/$(NAME) $(OBJ)
|
||||
|
||||
$(OBJDIRNAME)/%.o: %.s
|
||||
@mkdir -p $(dir $@)
|
||||
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
||||
@$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
test: $(NAME)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -lasm $(TEST_FILE) -o $(test-lib)
|
||||
test: header $(NAME) run_compile footer
|
||||
|
||||
run: test
|
||||
|
||||
test_compile:
|
||||
@printf '$(GREY) Start $(END)$(GREEN)Testing on $(TEST_OUTPUT)$(END)\n'
|
||||
@$(CC) $(CFLAGS) $(CPPFLAGS) $(TEST_FILE) -o $(TEST_OUTPUT) ./build/libasm.a
|
||||
@echo ""
|
||||
@./result
|
||||
|
||||
header:
|
||||
@clear
|
||||
|
|
@ -108,5 +117,20 @@ footer:
|
|||
@printf "$(GOLD) '\"' '\"'$(END)\n"
|
||||
@printf ' $(GREY)The compilation is$(END) $(GOLD)finished$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
|
||||
|
||||
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;
|
||||
@for file in $(INC_DIR); do \
|
||||
printf " - \"-I"$(shell pwd)"/"$$file"\"\n" >> .clangd; \
|
||||
done
|
||||
@printf "\n" >> ./.clangd
|
||||
@printf '$(GREY) Now parsing settings is set in $(END)$(GREEN)./.clangd$(END)\n'
|
||||
|
||||
|
||||
# Phony
|
||||
.PHONY: all bonus clean fclean re footer header
|
||||
.PHONY: all bonus clean fclean re footer header test run test_compile clangd
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue