78 lines
2.6 KiB
Makefile
78 lines
2.6 KiB
Makefile
|
|
# Project configuration
|
|
EXECUTABLE_NAME = joomer-ftxui-file-browser
|
|
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)
|
|
FTXUI_PATH = ../FTXUI
|
|
LIB_PATHS = -L$(FTXUI_PATH)/build
|
|
INC_DIRS = -I$(FTXUI_PATH)/include
|
|
|
|
# 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
|
|
|
|
# Build type specific flags
|
|
ifeq ($(BUILD_TYPE), debug)
|
|
CPP_DEFINES = -D_DEBUG
|
|
COMMON_FLAGS = $(ARCH_FLAGS)
|
|
COMP_FLAGS = -g -O0 -std=c++17 -Wall
|
|
#LINK_FLAGS = -fvisibility=hidden
|
|
else
|
|
CPP_DEFINES = -DNDEBUG=1
|
|
COMMON_FLAGS = $(ARCH_FLAGS)
|
|
COMP_FLAGS = -O3 -std=c++17 -Wall
|
|
#LINK_FLAGS = -fvisibility=hidden
|
|
endif
|
|
|
|
# Language-specific flags
|
|
CXX = g++
|
|
CXX_FLAGS = $(COMMON_FLAGS)
|
|
LINK_FLAGS = $(LIB_PATHS) #-fvisibility=hidden
|
|
FTXUI_LIB_FLAGS = -lftxui-component -lftxui-dom -lftxui-screen
|
|
|
|
# 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 = -Wl,--start-group $(FTXUI_LIB_FLAGS) -Wl,--end-group
|
|
//LDFLAGS = $(FTXUI_LIB_FLAGS) #$(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-ftxui-file-browser.o as the source of the executable
|
|
OBJECTS = $(OBJ_DIR)/joomer-ftxui-file-browser.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 "Building executables 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) $(LINK_FLAGS) $(LDFLAGS)
|
|
@echo "Building links 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 |