mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
🔨 chore: mauvaisfeedback
This commit is contained in:
68
Makefile
68
Makefile
@@ -6,22 +6,14 @@
|
||||
# By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2022/10/04 16:43:41 by maldavid #+# #+# #
|
||||
# Updated: 2024/04/23 20:38:01 by kiroussa ### ########.fr #
|
||||
# Updated: 2024/04/23 22:45:41 by kiroussa ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
NAME = libmlx.so
|
||||
MAKE = make --no-print-directory
|
||||
|
||||
SRCS = $(wildcard $(addsuffix /*.cpp, src/core))
|
||||
SRCS += $(wildcard $(addsuffix /*.cpp, src/platform))
|
||||
SRCS += $(wildcard $(addsuffix /*.cpp, src/renderer))
|
||||
SRCS += $(wildcard $(addsuffix /*.cpp, src/renderer/**))
|
||||
|
||||
OBJ_DIR = objs
|
||||
OBJS := $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o))
|
||||
|
||||
OS := $(shell uname -s)
|
||||
OS ?= $(shell uname -s)
|
||||
DEBUG ?= false
|
||||
TOOLCHAIN ?= clang
|
||||
IMAGES_OPTIMIZED ?= true
|
||||
@@ -30,6 +22,14 @@ GRAPHICS_MEMORY_DUMP ?= false
|
||||
PROFILER ?= false
|
||||
_ENABLEDFLAGS =
|
||||
|
||||
SRCS = $(wildcard $(addsuffix /*.cpp, src/core))
|
||||
SRCS += $(wildcard $(addsuffix /*.cpp, src/platform))
|
||||
SRCS += $(wildcard $(addsuffix /*.cpp, src/renderer))
|
||||
SRCS += $(wildcard $(addsuffix /*.cpp, src/renderer/**))
|
||||
|
||||
OBJ_DIR = objs/make/$(shell echo $(OS) | tr '[:upper:]' '[:lower:]')
|
||||
OBJS := $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o))
|
||||
|
||||
CXX = clang++
|
||||
CXXFLAGS = -std=c++17 -O3 -fPIC -Wall -Wextra -Werror -DSDL_MAIN_HANDLED
|
||||
INCLUDES = -I./includes -I./src -I./third_party
|
||||
@@ -84,44 +84,46 @@ _GRAY := $(shell $(TPUT) setaf 8)
|
||||
_PURPLE := $(shell $(TPUT) setaf 5)
|
||||
|
||||
ifeq ($(DEBUG), true)
|
||||
MODE := $(_RESET)$(_PURPLE)$(_BOLD)Debug$(_RESET)
|
||||
MODE := $(_RESET)$(_PURPLE)$(_BOLD)Debug$(_RESET)$(_PURPLE)
|
||||
else
|
||||
MODE := $(_RESET)$(_GREEN)$(_BOLD)Release$(_RESET)
|
||||
MODE := $(_RESET)$(_GREEN)$(_BOLD)Release$(_RESET)$(_GREEN)
|
||||
endif
|
||||
|
||||
$(OBJ_DIR)/%.o: %.cpp
|
||||
@mkdir -p $(dir $@)
|
||||
@printf "$(MODE) $(_GRAY)|$(_RESET) Compiling $(_BOLD)$<$(_RESET) $(_GRAY)$(_ITALIC)($@)$(_RESET)\n"
|
||||
@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
|
||||
OBJS_TOTAL = $(words $(OBJS))
|
||||
N_OBJS := $(shell find $(OBJ_DIR) -type f -name '*.o' 2>/dev/null | wc -l)
|
||||
OBJS_TOTAL := $(shell echo $(OBJS_TOTAL) - $(N_OBJS) | bc)
|
||||
CURR_OBJ = 0
|
||||
|
||||
all: $(NAME)
|
||||
$(OBJ_DIR)/%.o: %.cpp
|
||||
mkdir -p $(dir $@)
|
||||
$(eval CURR_OBJ=$(shell echo $(CURR_OBJ) + 1 | bc))
|
||||
$(eval PERCENT=$(shell echo $(CURR_OBJ) \* 100 / $(OBJS_TOTAL) | bc))
|
||||
printf "$(_GREEN)($(_BOLD)%3s%%$(_RESET)$(_GREEN)) $(_RESET)Compiling $(_BOLD)$<$(_RESET)\n" "$(PERCENT)"
|
||||
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
all: _printbuildinfos $(NAME)
|
||||
|
||||
$(NAME): $(OBJS)
|
||||
@printf "$(MODE) $(_GRAY)|$(_RESET) Linking $(_BOLD)$(NAME)$(_RESET) $(_GRAY)$(_ITALIC)(from ./$(OBJ_DIR)/)$(_RESET)\n"
|
||||
@$(CXX) -shared -o $(NAME) $(OBJS) $(LDFLAGS)
|
||||
@printf "$(_BOLD)$(NAME)$(_RESET) compiled $(_GREEN)$(_BOLD)successfully$(_RESET)\n"
|
||||
printf "Linking $(_BOLD)$(NAME)$(_RESET)\n"
|
||||
$(CXX) -shared -o $(NAME) $(OBJS) $(LDFLAGS)
|
||||
printf "$(_BOLD)$(NAME)$(_RESET) compiled $(_GREEN)$(_BOLD)successfully$(_RESET)\n"
|
||||
|
||||
_printbuildinfos:
|
||||
@printf "Building $(_BOLD)$(NAME)$(_RESET) in $(_BOLD)$(MODE)$(_RESET) mode\n"
|
||||
@printf "\tOperating System: $(_BOLD)$(OS)$(_RESET)\n"
|
||||
@printf "\tCompiler: $(_BOLD)$(CXX)$(_RESET)\n"
|
||||
@printf "\tEnabled flags: $(_BOLD)$(_ENABLEDFLAGS)$(_RESET)\n"
|
||||
@printf "\tCXXFLAGS: $(_BOLD)$(CXXFLAGS)$(_RESET)\n"
|
||||
@printf "\tINCLUDES: $(_BOLD)$(INCLUDES)$(_RESET)\n"
|
||||
@printf "\tLDFLAGS: $(_BOLD)$(LDFLAGS)$(_RESET)\n"
|
||||
printf "$(_PURPLE)$(_BOLD)MacroLibX $(_RESET)Compiling in $(_BOLD)$(MODE)$(_RESET) mode on $(_BOLD)$(OS)$(_RESET) | Using $(_BOLD)$(CXX)$(_RESET), flags: $(_BOLD)$(_ENABLEDFLAGS)\n"
|
||||
|
||||
debug:
|
||||
@$(MAKE) _printbuildinfos DEBUG=true
|
||||
@$(MAKE) all DEBUG=true -j
|
||||
$(MAKE) all DEBUG=true -j
|
||||
|
||||
clean:
|
||||
@$(RM) $(OBJ_DIR)
|
||||
@printf "Cleaned $(_BOLD)$(OBJ_DIR)$(_RESET)\n"
|
||||
$(RM) $(OBJ_DIR)
|
||||
printf "Cleaned $(_BOLD)$(OBJ_DIR)$(_RESET)\n"
|
||||
|
||||
fclean: clean
|
||||
@$(RM) $(NAME)
|
||||
@printf "Cleaned $(_BOLD)$(NAME)$(_RESET)\n"
|
||||
$(RM) $(NAME)
|
||||
printf "Cleaned $(_BOLD)$(NAME)$(_RESET)\n"
|
||||
|
||||
re: fclean all
|
||||
|
||||
.PHONY: all clean debug fclean re
|
||||
|
||||
.SILENT:
|
||||
|
||||
Reference in New Issue
Block a user