commit e8094727716877dfe99778b7204ee66127d6b808 Author: tomoron Date: Tue Nov 26 20:14:27 2024 +0100 create Makefile to compile a .so diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..f0c5e8a --- /dev/null +++ b/Makefile @@ -0,0 +1,55 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: tomoron +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2023/07/28 00:35:01 by tomoron #+# #+# # +# Updated: 2024/11/26 16:37:09 by tomoron ### ########.fr # +# # +# **************************************************************************** # + +HOSTTYPE := $(shell uname -m)_$(shell uname -s) + +NAME := libft_malloc_$(HOSTTYPE).so + +CC = cc + +SRCS_NAMES = malloc.c + +SRCS_DIR = srcs + +OBJS_DIR := .objs + +SRCS = $(addprefix $(SRCS_DIR)/, $(SRCS_NAMES)) + +OBJS = $(addprefix $(OBJS_DIR)/, $(SRCS_NAMES:.c=.o)) + +FLAGS = -Wall -Wextra -Werror + +all: libft_malloc.so + +libft_malloc.so: $(NAME) + ln -sf $(NAME) libft_malloc.so + +$(NAME): $(OBJS_DIR) $(OBJS) + $(CC) -shared -o $(NAME) $(OBJS) + +$(OBJS_DIR): + mkdir -p $(OBJS_DIR) + +$(OBJS_DIR)/%.o: $(SRCS_DIR)/%.c + $(CC) -fPIC $(FLAGS) -c $< -o $@ + +clean: + rm -rf $(OBJS_DIR) + +fclean: clean + rm -f $(NAME) + rm -f libft_malloc.so + +re: fclean all + + +.PHONY: clean all re fclean diff --git a/srcs/includes/malloc.h b/srcs/includes/malloc.h new file mode 100644 index 0000000..4f49e88 --- /dev/null +++ b/srcs/includes/malloc.h @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* malloc.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tomoron +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/26 16:38:01 by tomoron #+# #+# */ +/* Updated: 2024/11/26 16:41:22 by tomoron ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef MALLOC_H +# define MALLOC_H + +# ifndef DEBUG +# define DEBUG 1 +# endif + +void *malloc(size_t size) + +#endif diff --git a/srcs/malloc.c b/srcs/malloc.c new file mode 100644 index 0000000..c1c847a --- /dev/null +++ b/srcs/malloc.c @@ -0,0 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* malloc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: tomoron +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/23 17:19:59 by tomoron #+# #+# */ +/* Updated: 2024/11/26 16:42:53 by tomoron ### ########.fr */ +/* */ +/* ************************************************************************** */ + +void *malloc(size_t size) +{ +}