diff --git a/.cproject b/.cproject
index 181d6ea..de8d93c 100644
--- a/.cproject
+++ b/.cproject
@@ -67,7 +67,6 @@
make
-
clean
true
true
@@ -75,12 +74,19 @@
make
-
all
true
true
true
+
+ make
+
+ package
+ true
+ true
+ true
+
diff --git a/Makefile b/Makefile
index da23e51..008612c 100644
--- a/Makefile
+++ b/Makefile
@@ -17,20 +17,29 @@
# (at your option) any later version.
#
#******************************************************************************
-OS = $(shell uname -s)
-ifneq (,$(findstring MINGW,$(OS)))
-RES = obj/png2bestpal_stdres.res
-EXEEXT = .exe
+ifneq (,$(findstring Windows,$(OS)))
+ RES = obj/png2bestpal_stdres.res
+ EXEEXT = .exe
+ PKGFMT = zip
+ PKGOS = win
else
-RES =
-EXEEXT =
+ RES =
+ EXEEXT =
+ PKGFMT = tar.gz
+ PKGOS = lin
endif
+
CPP = g++
CC = gcc
WINDRES = windres
DLLTOOL = dlltool
RM = rm -f
+MV = mv -f
+CP = cp -f
MKDIR = mkdir -p
+ECHO = @echo
+TAR = tar
+ZIP = zip
BIN = bin/png2bestpal$(EXEEXT)
LIBS =
@@ -38,6 +47,7 @@ OBJS = \
obj/png2bestpal.o \
$(RES)
+GENSRC = obj/ver_defs.h
LINKOBJ = $(OBJS)
LINKLIB = -static -lpng -lz -lm
INCS =
@@ -55,9 +65,12 @@ WARNFLAGS = -Wall -Wno-sign-compare -Wno-unused-parameter
CXXFLAGS = $(CXXINCS) -std=c++11 -c -fmessage-length=0 $(WARNFLAGS) $(DEPFLAGS) $(OPTFLAGS)
CFLAGS = $(INCS) -c -fmessage-length=0 $(WARNFLAGS) $(DEPFLAGS) $(OPTFLAGS)
LDFLAGS = $(LINKLIB) $(OPTFLAGS) $(DBGFLAGS) $(LINKFLAGS)
-RM = rm -f
-.PHONY: all all-before all-after clean clean-custom
+# load program version
+include version.mk
+VER_STRING = $(VER_MAJOR).$(VER_MINOR).$(VER_RELEASE).$(VER_BUILD)
+
+.PHONY: all all-before all-after clean clean-custom package pkg-before zip tar.gz
all: all-before $(BIN) all-after
@@ -65,30 +78,67 @@ all-before:
$(MKDIR) obj bin
clean: clean-custom
- -${RM} $(OBJS) $(BIN) $(LIBS)
- -@echo ' '
+ -${RM} $(OBJS) $(GENSRC) $(BIN) $(LIBS)
+ -${RM} pkg/*
+ -$(ECHO) ' '
$(BIN): $(OBJS) $(LIBS)
- @echo 'Building target: $@'
+ -$(ECHO) 'Building target: $@'
$(CPP) $(LINKOBJ) -o "$@" $(LDFLAGS)
- @echo 'Finished building target: $@'
- @echo ' '
+ -$(ECHO) 'Finished building target: $@'
+ -$(ECHO) ' '
-obj/%.o: src/%.cpp
- @echo 'Building file: $<'
+obj/%.o: src/%.cpp $(GENSRC)
+ -$(ECHO) 'Building file: $<'
$(CPP) $(CXXFLAGS) -o"$@" "$<"
- @echo 'Finished building: $<'
- @echo ' '
+ -$(ECHO) 'Finished building: $<'
+ -$(ECHO) ' '
-obj/%.o: src/%.c
- @echo 'Building file: $<'
+obj/%.o: src/%.c $(GENSRC)
+ -$(ECHO) 'Building file: $<'
$(CC) $(CFLAGS) -o"$@" "$<"
- @echo 'Finished building: $<'
- @echo ' '
+ -$(ECHO) 'Finished building: $<'
+ -$(ECHO) ' '
-obj/%.res: res/%.rc
- @echo 'Building resource: $<'
+obj/%.res: res/%.rc $(GENSRC)
+ -$(ECHO) 'Building resource: $<'
$(WINDRES) -i "$<" --input-format=rc -o "$@" -O coff
- @echo 'Finished building: $<'
- @echo ' '
+ -$(ECHO) 'Finished building: $<'
+ -$(ECHO) ' '
+
+obj/ver_defs.h: version.mk Makefile
+ $(ECHO) \#define VER_MAJOR $(VER_MAJOR) > "$(@D)/tmp"
+ $(ECHO) \#define VER_MINOR $(VER_MINOR) >> "$(@D)/tmp"
+ $(ECHO) \#define VER_RELEASE $(VER_RELEASE) >> "$(@D)/tmp"
+ $(ECHO) \#define VER_BUILD $(VER_BUILD) >> "$(@D)/tmp"
+ $(ECHO) \#define VER_STRING \"$(VER_STRING)\" >> "$(@D)/tmp"
+ $(ECHO) \#define PACKAGE_SUFFIX \"$(PACKAGE_SUFFIX)\" >> "$(@D)/tmp"
+ $(MV) "$(@D)/tmp" "$@"
+
+package: pkg-before $(PKGFMT)
+
+pkg-before:
+ -${RM} pkg/*
+ $(MKDIR) pkg
+ $(CP) bin/* pkg/
+ $(CP) docs/*_readme.txt pkg/
+
+pkg/%.tar.gz: pkg-before
+ -$(ECHO) 'Creating package: $<'
+ cd $(@D); \
+ $(TAR) --owner=0 --group=0 --exclude=*.tar.gz --exclude=*.zip -zcf "$(@F)" .
+ -$(ECHO) 'Finished creating: $<'
+ -$(ECHO) ' '
+
+tar.gz: pkg/png2bestpal-$(subst .,_,$(VER_STRING))-$(PACKAGE_SUFFIX)-$(PKGOS).tar.gz
+
+pkg/%.zip: pkg-before
+ -$(ECHO) 'Creating package: $<'
+ cd $(@D); \
+ $(ZIP) -x*.tar.gz -x*.zip -9 -r "$(@F)" .
+ -$(ECHO) 'Finished creating: $<'
+ -$(ECHO) ' '
+
+zip: pkg/png2bestpal-$(subst .,_,$(VER_STRING))-$(PACKAGE_SUFFIX)-$(PKGOS).zip
+
#******************************************************************************
diff --git a/docs/png2bestpal_readme.txt b/docs/png2bestpal_readme.txt
new file mode 100644
index 0000000..cc84db5
--- /dev/null
+++ b/docs/png2bestpal_readme.txt
@@ -0,0 +1,11 @@
+
+Best 8bpp palette selector for a series of PNG files (Png2bestPal)
+ Created by Tomasz Lis; GNU General Public License
+----------------------------------------
+usage:
+
+ png2bestpal.exe [options]
+where should be the input BMP file, and [options] are:
+ -v,--verbose Verbose console output mode
+ -m,--palmap Static palette entries mapping file name
+ -o,--output Output PAL file name
diff --git a/src/png2bestpal_version.h b/src/png2bestpal_version.h
index 5e87add..974dc23 100644
--- a/src/png2bestpal_version.h
+++ b/src/png2bestpal_version.h
@@ -20,11 +20,13 @@
#define PNG2BESTPAL_VERSION_H
/* Version definitions */
-#define VER_MAJOR 1
-#define VER_MINOR 0
-#define VER_RELEASE 0
-#define VER_BUILD 1
-#define VER_STRING "1.0.0.1"
+#include "../obj/ver_defs.h"
+//#define VER_MAJOR 1
+//#define VER_MINOR 2
+//#define VER_RELEASE 3
+//#define VER_BUILD 4
+//#define VER_STRING "1.2.3.4"
+
/* Program name, copyrights and file names */
#define PROGRAM_NAME "Png2bestPal"
#define PROGRAM_FULL_NAME "Best 8bpp palette selector for a series of PNG files"
diff --git a/version.mk b/version.mk
new file mode 100644
index 0000000..155de0d
--- /dev/null
+++ b/version.mk
@@ -0,0 +1,5 @@
+VER_MAJOR=1
+VER_MINOR=0
+VER_RELEASE=1
+VER_BUILD=19
+PACKAGE_SUFFIX=devel