mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
✨ feature(Makefile): pretty makefile, added -rdynamic LDFLAG, moved debug warning, added debug Makefile rule
This commit is contained in:
120
Makefile
120
Makefile
@@ -6,96 +6,124 @@
|
|||||||
# By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ #
|
# By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2022/10/04 16:43:41 by maldavid #+# #+# #
|
# Created: 2022/10/04 16:43:41 by maldavid #+# #+# #
|
||||||
# Updated: 2024/01/10 14:20:30 by maldavid ### ########.fr #
|
# Updated: 2024/04/23 20:20:33 by kiroussa ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
NAME = libmlx.so
|
NAME = libmlx.so
|
||||||
|
MAKE = make --no-print-directory
|
||||||
|
|
||||||
SRCS = $(wildcard $(addsuffix /*.cpp, ./src/core))
|
SRCS = $(wildcard $(addsuffix /*.cpp, src/core))
|
||||||
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/platform))
|
SRCS += $(wildcard $(addsuffix /*.cpp, src/platform))
|
||||||
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer))
|
SRCS += $(wildcard $(addsuffix /*.cpp, src/renderer))
|
||||||
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer/**))
|
SRCS += $(wildcard $(addsuffix /*.cpp, src/renderer/**))
|
||||||
|
|
||||||
OBJ_DIR = objs/makefile
|
OBJ_DIR = objs
|
||||||
OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o))
|
OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o))
|
||||||
|
|
||||||
OS = $(shell uname -s)
|
OS = $(shell uname -s)
|
||||||
DEBUG ?= false
|
DEBUG ?= false
|
||||||
TOOLCHAIN ?= clang
|
TOOLCHAIN ?= clang
|
||||||
IMAGES_OPTIMIZED ?= true
|
IMAGES_OPTIMIZED ?= true
|
||||||
FORCE_INTEGRATED_GPU ?= false
|
FORCE_INTEGRATED_GPU ?= false
|
||||||
GRAPHICS_MEMORY_DUMP ?= false
|
GRAPHICS_MEMORY_DUMP ?= false
|
||||||
PROFILER ?= false
|
PROFILER ?= false
|
||||||
|
_ENABLEDFLAGS =
|
||||||
|
|
||||||
MODE = "release"
|
CXX = clang++
|
||||||
|
CXXFLAGS = -std=c++17 -O3 -fPIC -Wall -Wextra -Werror -DSDL_MAIN_HANDLED
|
||||||
CXX = clang++
|
INCLUDES = -I./includes -I./src -I./third_party
|
||||||
|
|
||||||
CXXFLAGS = -std=c++17 -O3 -fPIC -Wall -Wextra -Werror -DSDL_MAIN_HANDLED
|
|
||||||
INCLUDES = -I./includes -I./src -I./third_party
|
|
||||||
|
|
||||||
LDLIBS =
|
|
||||||
|
|
||||||
ifeq ($(TOOLCHAIN), gcc)
|
ifeq ($(TOOLCHAIN), gcc)
|
||||||
CXX = g++
|
CXX = g++
|
||||||
CXXFLAGS += -Wno-error=cpp
|
CXXFLAGS += -Wno-error=cpp
|
||||||
else
|
else
|
||||||
CXXFLAGS += -Wno-error=#warning
|
CXXFLAGS += -Wno-error=#warning
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(OS), Darwin)
|
ifeq ($(OS), Darwin)
|
||||||
LDLIBS += -L /opt/homebrew/lib -lSDL2
|
LDFLAGS += -L /opt/homebrew/lib -lSDL2
|
||||||
CXXFLAGS += -I /opt/homebrew/include
|
CXXFLAGS += -I /opt/homebrew/include
|
||||||
NAME = libmlx.dylib
|
NAME = libmlx.dylib
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(DEBUG), true)
|
ifeq ($(DEBUG), true)
|
||||||
CXXFLAGS += -g -D DEBUG
|
CXXFLAGS += -g3 -D DEBUG
|
||||||
MODE = "debug"
|
LDFLAGS += -rdynamic
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(FORCE_INTEGRATED_GPU), true)
|
ifeq ($(FORCE_INTEGRATED_GPU), true)
|
||||||
CXXFLAGS += -D FORCE_INTEGRATED_GPU
|
_ENABLEDFLAGS += FORCE_INTEGRATED_GPU
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(IMAGES_OPTIMIZED), true)
|
ifeq ($(IMAGES_OPTIMIZED), true)
|
||||||
CXXFLAGS += -D IMAGE_OPTIMIZED
|
_ENABLEDFLAGS += IMAGE_OPTIMIZED
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(GRAPHICS_MEMORY_DUMP), true)
|
ifeq ($(GRAPHICS_MEMORY_DUMP), true)
|
||||||
CXXFLAGS += -D GRAPHICS_MEMORY_DUMP
|
_ENABLEDFLAGS += GRAPHICS_MEMORY_DUMP
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(PROFILER), true)
|
ifeq ($(PROFILER), true)
|
||||||
CXXFLAGS += -D PROFILER
|
_ENABLEDFLAGS += PROFILER
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
CXXFLAGS += $(addprefix -D, $(_ENABLEDFLAGS))
|
||||||
|
|
||||||
RM = rm -rf
|
RM = rm -rf
|
||||||
|
|
||||||
|
_RESET = $(shell tput sgr0)
|
||||||
|
_BOLD = $(shell tput bold)
|
||||||
|
_ITALIC = $(shell tput sitm)
|
||||||
|
_UNDER = $(shell tput smul)
|
||||||
|
_GREEN = $(shell tput setaf 2)
|
||||||
|
_YELLOW = $(shell tput setaf 3)
|
||||||
|
_RED = $(shell tput setaf 1)
|
||||||
|
_GRAY = $(shell tput setaf 8)
|
||||||
|
_PURPLE = $(shell tput setaf 5)
|
||||||
|
|
||||||
|
ifeq ($(DEBUG), true)
|
||||||
|
MODE = $(_RESET)$(_PURPLE)$(_BOLD)Debug$(_RESET)
|
||||||
|
else
|
||||||
|
MODE = $(_RESET)$(_GREEN)$(_BOLD)Release$(_RESET)
|
||||||
|
endif
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: %.cpp
|
$(OBJ_DIR)/%.o: %.cpp
|
||||||
@printf "\033[1;32m[compiling... "$(MODE)" "$(CXX)"]\033[1;00m "$<"\n"
|
@mkdir -p $(dir $@)
|
||||||
|
@printf "$(MODE) $(_GRAY)|$(_RESET) Compiling $(_BOLD)$<$(_RESET) $(_GRAY)$(_ITALIC)($@)$(_RESET)\n"
|
||||||
@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
|
@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
|
||||||
|
|
||||||
all: $(NAME)
|
all: $(NAME)
|
||||||
|
|
||||||
$(NAME): $(OBJ_DIR) $(OBJS)
|
$(NAME): $(OBJS)
|
||||||
@printf "\033[1;32m[linking ... "$(MODE)"]\033[1;00m "$@"\n"
|
@printf "$(MODE) $(_GRAY)|$(_RESET) Linking $(_BOLD)$(NAME)$(_RESET) $(_GRAY)$(_ITALIC)(from ./$(OBJ_DIR)/)$(_RESET)\n"
|
||||||
@$(CXX) -shared -o $(NAME) $(OBJS) $(LDLIBS)
|
@$(CXX) -shared -o $(NAME) $(OBJS) $(LDFLAGS)
|
||||||
@printf "\033[1;32m[build finished]\033[1;00m\n"
|
@printf "$(_BOLD)$(NAME)$(_RESET) compiled $(_GREEN)$(_BOLD)successfully$(_RESET)\n"
|
||||||
|
|
||||||
$(OBJ_DIR):
|
_printbuildinfos:
|
||||||
@mkdir -p $(sort $(addprefix $(OBJ_DIR)/, $(dir $(SRCS))))
|
@printf "$(_RED)$(_BOLD)Warning: $(_RESET)MLX is being compiled in $(MODE) mode.\n"
|
||||||
@printf "\033[1;32m[created objs directory]\033[1;00m\n"
|
@printf "This activates $(_BOLD)Vulkan's validation layers$(_RESET) and $(_BOLD)MLX debug messages$(_RESET), which may impact rendering performances.\n\n"
|
||||||
|
|
||||||
|
@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"
|
||||||
|
|
||||||
|
debug:
|
||||||
|
@$(MAKE) _printbuildinfos DEBUG=true
|
||||||
|
@$(MAKE) all DEBUG=true -j
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@$(RM) $(OBJ_DIR)
|
@$(RM) $(OBJ_DIR)
|
||||||
@printf "\033[1;32m[object files removed]\033[1;00m\n"
|
@printf "Cleaned $(_BOLD)$(OBJ_DIR)$(_RESET)\n"
|
||||||
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
@$(RM) $(NAME)
|
@$(RM) $(NAME)
|
||||||
@printf "\033[1;32m["$(NAME)" removed]\033[1;00m\n"
|
@printf "Cleaned $(_BOLD)$(NAME)$(_RESET)\n"
|
||||||
|
|
||||||
re: fclean all
|
re: fclean all
|
||||||
|
|
||||||
.PHONY: all clean fclean re
|
.PHONY: all clean debug fclean re
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */
|
/* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/20 08:20:07 by maldavid ### ########.fr */
|
/* Updated: 2024/04/23 20:09:14 by kiroussa ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -16,14 +16,6 @@
|
|||||||
#include <renderer/core/render_core.h>
|
#include <renderer/core/render_core.h>
|
||||||
#include <renderer/command/vk_cmd_buffer.h>
|
#include <renderer/command/vk_cmd_buffer.h>
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#ifdef MLX_COMPILER_MSVC
|
|
||||||
#pragma NOTE("MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances")
|
|
||||||
#else
|
|
||||||
#warning "MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
namespace RCore
|
namespace RCore
|
||||||
|
|||||||
Reference in New Issue
Block a user