@@ -26,8 +26,34 @@ BUILD_VERSION_MAJOR := $(or $(ENV_BUILD_VERSION_MAJOR),0)
2626BUILD_VERSION_MINOR := $(or $(ENV_BUILD_VERSION_MINOR ) ,0)
2727BUILD_VERSION_PATCH := $(or $(ENV_BUILD_VERSION_PATCH ) ,0)
2828
29- # Generate version string: "X.Y.Z" if environment vars are set, otherwise "dev"
30- BUILD_VERSION_STR := $(if $(and $(ENV_BUILD_VERSION_MAJOR ) ,$(ENV_BUILD_VERSION_MINOR ) ) ,$(BUILD_VERSION_MAJOR ) .$(BUILD_VERSION_MINOR ) .$(BUILD_VERSION_PATCH ) ,dev)
29+ # Generate version string based on provided environment variables
30+ # - Default fallback is "dev"
31+ # - If ENV_BUILD_VERSION_MAJOR == "dev" and ENV_BUILD_VERSION_MINOR exists → "dev.<minor>"
32+ # - Else if ENV_BUILD_VERSION_MAJOR and ENV_BUILD_VERSION_MINOR exist → "X.Y.Z"
33+ BUILD_VERSION_STR := dev # Default fallback
34+
35+ # Special dev case: major="dev" and minor exists
36+ ifeq ($(ENV_BUILD_VERSION_MAJOR ) ,dev)
37+ ifdef ENV_BUILD_VERSION_MINOR
38+ BUILD_VERSION_STR := $(BUILD_VERSION_MAJOR ) .$(BUILD_VERSION_MINOR )
39+ endif
40+
41+ # Normal semantic version case: major and minor exist
42+ else ifdef ENV_BUILD_VERSION_MAJOR
43+ ifdef ENV_BUILD_VERSION_MINOR
44+ BUILD_VERSION_STR := $(BUILD_VERSION_MAJOR ) .$(BUILD_VERSION_MINOR ) .$(BUILD_VERSION_PATCH )
45+ endif
46+ endif
47+ # End version string generation
48+
49+ # Assign numeric FILEVERSION for Windows .rc file
50+ ifeq ($(or $(filter dev,$(ENV_BUILD_VERSION_MAJOR ) ) ,$(filter dev,$(BUILD_VERSION_STR ) ) ) ,)
51+ # Normal build: use the real version numbers
52+ BUILD_FILEVERSION_RC := $(BUILD_VERSION_MAJOR ) ,$(BUILD_VERSION_MINOR ) ,$(BUILD_VERSION_PATCH ) ,0
53+ else
54+ # Development build: use all 0s
55+ BUILD_FILEVERSION_RC := 0,0,0,0
56+ endif
3157
3258# Alternative: Pass build info as preprocessor definitions instead of build_info.h
3359# Uncomment these lines and remove $(BUILD_INFO_FILE) from compilation prerequisites
@@ -36,16 +62,18 @@ BUILD_VERSION_STR := $(if $(and $(ENV_BUILD_VERSION_MAJOR),$(ENV_BUILD_VERSION_M
3662
3763# Platform-specific configuration
3864ifdef MSYSTEM
39- # Building on Windows (MSYS2/MinGW)
40- PLATFORM := win64
41- TARGET := $(BUILD_DIR)/sqlcw.exe
42- # Boost libraries on Windows use -mt suffix (multi-threaded)
43- LIBS := $(addsuffix -mt, $(addprefix -l,$(BOOST_LIBS)))
65+ # Building on Windows (MSYS2/MinGW)
66+ PLATFORM := win64
67+ TARGET := $(BUILD_DIR ) /sqlcw.exe
68+ # Boost libraries on Windows use -mt suffix (multi-threaded)
69+ LIBS := $(addsuffix -mt, $(addprefix -l,$(BOOST_LIBS ) ) )
70+ WINDRES_OBJECT_FILE := $(OBJ_DIR ) /windres.o
4471else
45- # Building on Linux/Unix
46- PLATFORM := linux_$(shell uname -m)
47- TARGET := $(BUILD_DIR)/sqlcw
48- LIBS := $(addprefix -l,$(BOOST_LIBS))
72+ # Building on Linux/Unix
73+ PLATFORM := linux_$(shell uname -m)
74+ TARGET := $(BUILD_DIR ) /sqlcw
75+ LIBS := $(addprefix -l,$(BOOST_LIBS ) )
76+ WINDRES_OBJECT_FILE :=
4977endif
5078
5179# Phony targets (not actual files)
@@ -86,15 +114,13 @@ $(BUILD_INFO_FILE): | $(BUILD_DIR)
86114 @echo " #define BUILD_VERSION_MINOR $( BUILD_VERSION_MINOR) " >> $(BUILD_INFO_FILE )
87115 @echo " #define BUILD_VERSION_PATCH $( BUILD_VERSION_PATCH) " >> $(BUILD_INFO_FILE )
88116 @echo " #define BUILD_COMPILER \" $( BUILD_COMPILER) \" " >> $(BUILD_INFO_FILE )
117+ @echo " #define BUILD_FILEVERSION_RC $( BUILD_FILEVERSION_RC) " >> $(BUILD_INFO_FILE )
89118 @echo " #endif" >> $(BUILD_INFO_FILE )
90119
91120# Compile Windows resource file (icon, version info, etc.)
92121.build-windres : $(BUILD_INFO_FILE )
93122ifdef MSYSTEM
94- windres -I $(BUILD_DIR) -i $(SRC_DIR)/sqlcw.rc -o $(OBJ_DIR)/windres.o
95- WINDRES_OBJECT_FILE := $(OBJ_DIR ) /windres.o
96- else
97- WINDRES_OBJECT_FILE :=
123+ windres -I $(BUILD_DIR) -i $(SRC_DIR)/sqlcw.rc -o $(WINDRES_OBJECT_FILE)
98124endif
99125
100126# Package application executable and documentation for distribution
0 commit comments