libft_old/Makefile
Willem Haffmans 326f52308e all
2024-07-26 22:32:04 +02:00

63 lines
1.8 KiB
Makefile

# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/07/09 16:25:07 by whaffman #+# #+# #
# Updated: 2024/07/09 17:08:01 by whaffman ### ########.fr #
# #
# **************************************************************************** #
CC = cc
CFLAGS = -Wall -Werror -Wextra
# Add any other static library in the same fashion - 1
# INCLUDE: .h files or .a library folders
# SRC: .c files
SRC_DIR = src
OBJ_DIR = obj
OBJ_SO_DIR = obj_so
INC_DIR = include
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC_FILES))
OBJ_FILES_SO = $(patsubst $(SRC_DIR)/%.c,$(OBJ_SO_DIR)/%.o,$(SRC_FILES))
# Add any other static library in the same fashion - 2
NAME = libft.a
NAME_SO = libft.so
.PHONY: all clean fclean re so
all: $(NAME)
so: $(NAME_SO)
$(NAME): $(OBJ_FILES)
ar rcs $(NAME) $(OBJ_FILES)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
mkdir -p $(OBJ_DIR)
$(CC) $(CFLAGS) -I$(INC_DIR) -O3 -c -o $@ $<
$(NAME_SO): $(OBJ_FILES_SO)
$(CC) -shared -o $(NAME_SO) $(OBJ_FILES_SO)
$(OBJ_SO_DIR)/%.o: $(SRC_DIR)/%.c
mkdir -p $(OBJ_SO_DIR)
$(CC) -fPIC $(CFLAGS) -I$(INC_DIR) -c -o $@ $<
clean:
$(RM) -r $(OBJ_DIR)
$(RM) -r $(OBJ_SO_DIR)
fclean: clean
$(RM) $(NAME)
$(RM) $(NAME_SO)
re: fclean all