From c3c6147aa5d7ad945ec1c89388037791e9dd63cc Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 24 Oct 2025 21:12:53 +0000 Subject: [PATCH] makefile --- makefile | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 makefile diff --git a/makefile b/makefile new file mode 100644 index 0000000..4b5b728 --- /dev/null +++ b/makefile @@ -0,0 +1,90 @@ + +# Project configuration +EXECUTABLE_NAME = joomer-bella-basic-renderer +PLATFORM = $(shell uname) +BUILD_TYPE ?= release# Default to release build if not specified + +#STB_PATH = $(HOME)/workdir/stb +LINUX_LIB_EXT = so + +# Version configuration (can be overridden) +#DPP_VERSION ?= $(shell find ../DPP/build/library -name "libdpp.so.*.*.*" -type f | head -1 | sed 's/.*libdpp\.so\.//') +BELLA_PATH = $(HOME)/learndir/bella_engine_sdk +#BELLA_BUILD_DIR = $(BELLA_PATH)/build/library +LIB_PATHS = $(BELLA_PATH)/lib +INC_DIRS = -Iinclude -I$(BELLA_PATH)/src +#endif + +#DPP_VERSION := $(or $(DPP_VERSION),10.1.4)# Fallback version if auto-detection fails +#DPP_LINUX_LIB_VERSION_FILE = libdpp.$(LINUX_LIB_EXT).$(DPP_VERSION) +BELLA_LIB_NAME = libdpp.$(LINUX_LIB_EXT) + +# Common paths +OBJ_DIR = obj/$(PLATFORM)/$(BUILD_TYPE) +BIN_DIR = bin/$(PLATFORM)/$(BUILD_TYPE) +OUTPUT_FILE = $(BIN_DIR)/$(EXECUTABLE_NAME) + +CXX = g++ +CXX_FLAGS = $(COMMON_FLAGS) -std=c++17 -Wall -g $(INC_DIRS) + +# Build type specific flags +ifeq ($(BUILD_TYPE), debug) + CPP_DEFINES = -D_DEBUG -DDL_USE_SHARED + COMMON_FLAGS = $(ARCH_FLAGS) $(INCLUDE_PATHS) + COMP_FLAGS = -g -O0 -std=c++17 -Wall + LINK_FLAGS = -fvisibility=hidden +else + CPP_DEFINES = -DNDEBUG=1 -DDL_USE_SHARED + COMMON_FLAGS = $(ARCH_FLAGS) $(INCLUDE_PATHS) + COMP_FLAGS = -O3 -std=c++17 -Wall + LINK_FLAGS = -fvisibility=hidden +endif + +# Language-specific flags +#C_FLAGS = $(COMMON_FLAGS) -std=c17 +#CXX_FLAGS = $(COMMON_FLAGS) -std=c++17 -Wall -g $(INC_DIRS) +CXX = g++ +CXX_FLAGS = $(COMMON_FLAGS) $(INC_DIRS) +LINK_FLAGS = -fvisibility=hidden +BELLA_LIB_FLAGS = -L$(LIB_PATHS) -Wl,-rpath,$(LIB_PATHS) -lbella_engine_sdk + +# Linker directive flags (L for library search path, l for library) +# Need to link against the D++ library and pthread (common for C++ applications with threading) +LDFLAGS = $(BELLA_LIB_FLAGS) #-L$(LIB_PATHS) -ldpp -lpthread -Wl,-rpath='$$ORIGIN' # search for lib in the same place as the executable file + +# List of object files for your executable +# We've changed this back to use joomer-bella-basic-renderer-bot.o as the source of the executable +OBJECTS = $(OBJ_DIR)/joomer-bella-basic-renderer.o + +$(OBJ_DIR)/%.o: %.cpp + @echo "Compiling $< -> $@" + @mkdir -p $(@D) # Ensure the output binary directory exists (e.g., bin/Linux/release/) + $(CXX) -c $(CPP_DEFINES) $(COMP_FLAGS) $(INC_DIRS) $< -o $@ + +# --- Main Target --- +# 'all' is the default target that builds your executable +all: $(OUTPUT_FILE) + @echo "BELLA_PATH: $(BELLA_PATH)" + @echo "Build complete." + + + +# Rule to link the executable: +# It depends on the object files and uses CXX to link them with specified libraries. +$(OUTPUT_FILE): $(OBJECTS) + @echo "Linking $(OUTPUT_FILE)..." + @mkdir -p $(@D) + $(CXX) -o $@ $(OBJECTS) $(LDFLAGS) $(LINK_FLAGS) + @echo "BELLA_PATH: "$(BELLA_PATH) + @echo "Build complete." + + +# --- Clean Target --- +# Removes all generated build files and directories +clean: + @echo "Cleaning build directory..." + $(RM) -r $(BIN_DIR) + $(RM) -r $(OBJ_DIR) + +# .PHONY specifies targets that are not actual files to prevent conflicts with file names +.PHONY: all clean \ No newline at end of file