From 8f8f91994ec2380b875ac3eead4b4b36dac0726c Mon Sep 17 00:00:00 2001 From: Sergio <147100454+sdevsantiago@users.noreply.github.com> Date: Thu, 31 Jul 2025 03:22:38 +0200 Subject: [PATCH] Initial commit --- .gitignore | 58 ++++++++++++++ LICENSE | 39 +++++++++ Makefile | 201 +++++++++++++++++++++++++++++++++++++++++++++++ docs/.gitkeep | 0 include/.gitkeep | 0 src/.gitkeep | 0 6 files changed, 298 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 docs/.gitkeep create mode 100644 include/.gitkeep create mode 100644 src/.gitkeep diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..df504bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +# Build path +build/ + +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +# debug information files +*.dwo diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a3ae27d --- /dev/null +++ b/LICENSE @@ -0,0 +1,39 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# LICENSE :+: :+: :+: # +# +:+ +:+ +:+ # +# By: sede-san +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2025/07/30 20:22:21 by sede-san #+# #+# # +# Updated: 2025/07/30 20:22:21 by sede-san ### ########.fr # +# # +# **************************************************************************** # + +This is a free work delivered for educational purposes during the main course +at 42 <42.fr>. + +You are free to use, modify, and share this software. Contributions, +suggestions, and pull requests are welcome! Feel free to contact me if you want +to share thoughts. + +In jurisdictions that recognize copyright laws, the author(s) of this software +dedicate any and all copyright interest in the software to the public domain. +This dedication is made for the benefit of the public at large and to the +detriment of our heirs and successors. We intend this dedication to be an overt +act of relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +If the Unlicense public domain dedication is not valid in your jurisdiction, +you may use this software under the terms of the Creative Commons Zero v1.0 +Universal (CC0 1.0) License: + +https://creativecommons.org/publicdomain/zero/1.0/legalcode + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fe5a4e3 --- /dev/null +++ b/Makefile @@ -0,0 +1,201 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: sede-san make DEBUG=1 +DFLAGS = -g3 +ifeq ($(DEBUG), 1) + CFLAGS += $(DFLAGS) +endif + +# Make command with no-print-directory flag +MAKE += --no-print-directory + +# ***************************** Style variables ****************************** # + +# Define color codes +RED = \033[0;31m +GREEN = \033[0;32m +YELLOW = \033[0;33m +BLUE = \033[0;34m +RESET = \033[0m # No Color + +# Emojis +EMOJI_BROOM = ๐Ÿงน +EMOJI_CHECK = โœ… +EMOJI_CROSS = โŒ +EMOJI_WRENCH = ๐Ÿ”ง +EMOJI_BOX = ๐Ÿ“ฆ + +# ****************************** Source files ******************************** # + +# Source files path +SRC_PATH = src + +# Source files +SRC = \ + + +# Include path +INCLUDE_PATH = ./include + +# ****************************** Object files ******************************** # + +# Object files path +OBJS_PATH = build + +# Source files and destination paths +OBJS = $(SRC:$(SRC_PATH)/%.c=$(OBJS_PATH)/%.o) + +# Compile as object files +$(OBJS_PATH)/%.o: $(SRC_PATH)/%.c + @mkdir -p $(@D) + @$(CC) $(CFLAGS) -c $< -o $@ $(HEADERS) + @echo "$< compiled" + +# ********************************* Rules ************************************ # + +# Compile all +all: lib $(NAME) +.PHONY: all + +# Compile project +$(NAME): $(OBJS) + @echo "$(YELLOW)$(EMOJI_BOX) Linking...$(RESET)" + @$(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $(NAME) + @echo "$(GREEN)$(EMOJI_CHECK) Linked.$(RESET)" + +# Clean object files +clean: + @echo "$(RED)$(EMOJI_BROOM) Cleaning object files...$(RESET)" + @rm -rf $(OBJS_PATH) + @echo "$(GREEN)$(EMOJI_CHECK) Object files cleaned.$(RESET)" +.PHONY: clean + +# Clean object files and binaries +fclean: clean + @echo "$(RED)$(EMOJI_BROOM) Cleaning binaries...$(RESET)" + @rm -f $(NAME) + @if [ -d $(LIBFT_PATH) ]; then \ + $(MAKE) -C $(LIBFT_PATH) fclean; \ + fi + @if [ -d $(GNL_PATH) ]; then \ + $(MAKE) -C $(GNL_PATH) fclean; \ + fi + @echo "$(GREEN)$(EMOJI_CHECK) Binaries cleaned.$(RESET)" +.PHONY: fclean + +# Recompile +re: fclean all +.PHONY: re + +# ********************************* Libraries ******************************** # + +# Compile libraries +lib: + @$(MAKE) libft + @$(MAKE) ft_printf + @$(MAKE) get_next_line +.PHONY: lib + +# Compile file with libraries +# LIBS = $(GNL_BIN) $(LIBFT_BIN) $(PRINTF_BIN) + +# Libraries path +LIB_PATH = lib + +# ** Libft ** # + +LIBFT = Libft +LIBFT_REPO = https://github.com/sdevsantiago/Libft.git +LIBFT_PATH = $(LIB_PATH)/$(LIBFT) +LIBFT_INCLUDE_PATH = $(LIBFT_PATH) +LIBFT_BIN = $(LIBFT_PATH)/libft.a + +libft: + @if [ ! -d $(LIBFT_PATH) ]; then \ + echo "$(YELLOW)$(EMOJI_WRENCH) Cloning $(LIBFT)...$(RESET)"; \ + git clone $(LIBFT_REPO) $(LIBFT_PATH); \ + rm -rf $(LIBFT_PATH)/.git; \ + echo "$(GREEN)$(EMOJI_CHECK) $(LIBFT) cloned...$(RESET)"; \ + fi + @if [ ! -f $(LIBFT_BIN) ]; then \ + echo "$(YELLOW)$(EMOJI_WRENCH) Compiling $(LIBFT)...$(RESET)"; \ + $(MAKE) -C $(LIBFT_PATH) all bonus clean; \ + echo "$(GREEN)$(EMOJI_CHECK) $(LIBFT) compiled.$(RESET)"; \ + else \ + echo "$(GREEN)$(EMOJI_CHECK) $(LIBFT) already compiled.$(RESET)"; \ + fi +.PHONY: libft + +# ** ft_printf ** # + +PRINTF = ft_printf +PRINTF_REPO = https://github.com/sdevsantiago/ft_printf.git +PRINTF_PATH = $(LIB_PATH)/$(PRINTF) +PRINTF_INCLUDE_PATH = $(PRINTF_PATH) +PRINTF_BIN = $(PRINTF_PATH)/libftprintf.a + +ft_printf: + @if [ ! -d $(PRINTF_PATH) ]; then \ + echo "$(YELLOW)$(EMOJI_WRENCH) Cloning $(PRINTF)...$(RESET)"; \ + git clone $(PRINTF_REPO) $(PRINTF_PATH); \ + rm -rf $(PRINTF_PATH)/.git; \ + echo "$(GREEN)$(EMOJI_CHECK) $(PRINTF) cloned...$(RESET)"; \ + fi + @if [ ! -f $(PRINTF_BIN) ]; then \ + echo "$(YELLOW)$(EMOJI_WRENCH) Compiling $(PRINTF)...$(RESET)"; \ + $(MAKE) -C $(PRINTF_PATH) all bonus clean; \ + echo "$(GREEN)$(EMOJI_CHECK) $(PRINTF) compiled.$(RESET)"; \ + else \ + echo "$(GREEN)$(EMOJI_CHECK) $(PRINTF) already compiled.$(RESET)"; \ + fi +.PHONY: ft_printf + +# ** get_next_line ** # + +GNL = get_next_line +GNL_REPO = https://github.com/sdevsantiago/get_next_line.git +GNL_PATH = $(LIB_PATH)/$(GNL) +GNL_INCLUDE_PATH = $(GNL_PATH) +GNL_BIN = $(GNL_PATH)/get_next_line.a + +get_next_line: + @if [ ! -d $(GNL_PATH) ]; then \ + echo "$(YELLOW)$(EMOJI_WRENCH) Cloning $(GNL)...$(RESET)"; \ + git clone $(GNL_REPO) $(GNL_PATH); \ + rm -rf $(GNL_PATH)/.git; \ + echo "$(GREEN)$(EMOJI_CHECK) $(GNL) cloned...$(RESET)"; \ + fi + @if [ ! -f $(GNL_BIN) ]; then \ + echo "$(YELLOW)$(EMOJI_WRENCH) Compiling $(GNL)...$(RESET)"; \ + $(MAKE) -C $(GNL_PATH) all clean; \ + echo "$(GREEN)$(EMOJI_CHECK) $(GNL) compiled.$(RESET)"; \ + else \ + echo "$(GREEN)$(EMOJI_CHECK) $(GNL) already compiled.$(RESET)"; \ + fi +.PHONY: get_next_line diff --git a/docs/.gitkeep b/docs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/include/.gitkeep b/include/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/.gitkeep b/src/.gitkeep new file mode 100644 index 0000000..e69de29