create Makefile to compile a .so
This commit is contained in:
55
Makefile
Executable file
55
Makefile
Executable file
@ -0,0 +1,55 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# ::: :::::::: #
|
||||||
|
# Makefile :+: :+: :+: #
|
||||||
|
# +:+ +:+ +:+ #
|
||||||
|
# By: tomoron <marvin@42.fr> +#+ +:+ +#+ #
|
||||||
|
# +#+#+#+#+#+ +#+ #
|
||||||
|
# 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
|
22
srcs/includes/malloc.h
Normal file
22
srcs/includes/malloc.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* malloc.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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
|
15
srcs/malloc.c
Normal file
15
srcs/malloc.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* malloc.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/11/23 17:19:59 by tomoron #+# #+# */
|
||||||
|
/* Updated: 2024/11/26 16:42:53 by tomoron ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
void *malloc(size_t size)
|
||||||
|
{
|
||||||
|
}
|
Reference in New Issue
Block a user