diff --git a/Makefile b/Makefile index 64aaaf8..2d08a64 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PROJECT_NAME = chroma -VERSION = 1.0.0 +VERSION = 1.0.1 # Directories SRCDIR = src @@ -69,7 +69,7 @@ $(INCDIR): @mkdir -p $(INCDIR) # Build main executable -$(TARGET): $(PROTOCOL_HEADERS) $(OBJECTS) | $(BINDIR) +$(TARGET): version-header $(PROTOCOL_HEADERS) $(OBJECTS) | $(BINDIR) @echo " LINK $@" @$(CC) $(OBJECTS) -o $@ $(LDFLAGS) @@ -110,6 +110,16 @@ uninstall: rm -f $(DESTDIR)$(SYSTEMD_INSTALL)/$(PROJECT_NAME).service @echo "Uninstall complete." +# Create version header +version-header: + @echo "Generating version header..." + @echo "#ifndef CHROMA_VERSION_H" > $(INCDIR)/chroma_version.h + @echo "#define CHROMA_VERSION_H" >> $(INCDIR)/chroma_version.h + @echo "" >> $(INCDIR)/chroma_version.h + @echo "#define CHROMA_VERSION \"$(VERSION)\"" >> $(INCDIR)/chroma_version.h + @echo "" >> $(INCDIR)/chroma_version.h + @echo "#endif // CHROMA_VERSION_H" >> $(INCDIR)/chroma_version.h + # Create systemd service file systemd-service: $(SYSTEMD_DIR)/$(PROJECT_NAME).service @@ -140,33 +150,68 @@ test: $(TARGET) @echo "Running tests..." @echo "Tests not implemented yet." +# Version management targets +bump-patch: + @echo "Bumping patch version..." + @$(eval NEW_VERSION := $(shell echo $(VERSION) | awk -F. '{print $$1"."$$2"."$$3+1}')) + @sed -i 's/^VERSION = .*/VERSION = $(NEW_VERSION)/' Makefile + @echo "Version bumped to $(NEW_VERSION)" + +bump-minor: + @echo "Bumping minor version..." + @$(eval NEW_VERSION := $(shell echo $(VERSION) | awk -F. '{print $$1"."$$2+1".0"}')) + @sed -i 's/^VERSION = .*/VERSION = $(NEW_VERSION)/' Makefile + @echo "Version bumped to $(NEW_VERSION)" + +bump-major: + @echo "Bumping major version..." + @$(eval NEW_VERSION := $(shell echo $(VERSION) | awk -F. '{print $$1+1".0.0"}')) + @sed -i 's/^VERSION = .*/VERSION = $(NEW_VERSION)/' Makefile + @echo "Version bumped to $(NEW_VERSION)" + +set-version: + @if [ -z "$(NEW_VER)" ]; then \ + echo "Usage: make set-version NEW_VER=X.Y.Z"; \ + exit 1; \ + fi + @echo "Setting version to $(NEW_VER)..." + @sed -i 's/^VERSION = .*/VERSION = $(NEW_VER)/' Makefile + @echo "Version set to $(NEW_VER)" + # Help target help: @echo "Available targets:" - @echo " all - Build the main executable (default)" + @echo " all - Build main executable (default)" @echo " debug - Build with debug symbols and sanitizers" @echo " static - Build statically linked executable" @echo " check-deps - Check if all dependencies are available" - @echo " install - Install the executable and systemd service" + @echo " install - Install executable and systemd service" @echo " uninstall - Remove installed files" @echo " clean - Remove build artifacts" @echo " distclean - Remove all generated files" @echo " format - Format source code (requires clang-format)" @echo " analyze - Run static analysis (requires cppcheck)" @echo " test - Run tests" + @echo " version-header - Generate version header from Makefile" + @echo " bump-patch - Increment patch version (X.Y.Z+1)" + @echo " bump-minor - Increment minor version (X.Y+1.0)" + @echo " bump-major - Increment major version (X+1.0.0)" + @echo " set-version - Set specific version (use NEW_VER=X.Y.Z)" @echo " help - Show this help message" @echo "" @echo "Examples:" - @echo " make # Build with default settings" - @echo " make debug # Build debug version" - @echo " make PREFIX=/usr install # Install to /usr instead of /usr/local" - @echo " make CC=clang # Use clang instead of gcc" + @echo " make # Build with default settings" + @echo " make debug # Build debug version" + @echo " make PREFIX=/usr install # Install to /usr instead of /usr/local" + @echo " make CC=clang # Use clang instead of gcc" + @echo " make bump-patch # Bump to 1.0.2" + @echo " make set-version NEW_VER=2.0.0 # Set to 2.0.0" # Include dependency files -include $(DEPENDS) # Phony targets -.PHONY: all debug static check-deps install uninstall systemd-service sample-config clean distclean format analyze test help +.PHONY: all debug static check-deps install uninstall systemd-service version-header sample-config clean distclean format analyze test help bump-patch bump-minor bump-major set-version # Print variables print-%: diff --git a/include/chroma.h b/include/chroma.h index 397041f..b49b0b6 100644 --- a/include/chroma.h +++ b/include/chroma.h @@ -12,7 +12,8 @@ #include #include -#define CHROMA_VERSION "1.0.0" +#include "chroma_version.h" + #define MAX_OUTPUTS 16 #define MAX_PATH_LEN 4096 #define CONFIG_FILE_NAME "chroma.conf" diff --git a/include/chroma_version.h b/include/chroma_version.h new file mode 100644 index 0000000..a160ad2 --- /dev/null +++ b/include/chroma_version.h @@ -0,0 +1,6 @@ +#ifndef CHROMA_VERSION_H +#define CHROMA_VERSION_H + +#define CHROMA_VERSION "1.0.1" + +#endif // CHROMA_VERSION_H