From dc4cc21e416084a70d32f3772622cc9685c877aa Mon Sep 17 00:00:00 2001 From: mefistotelis Date: Fri, 11 Sep 2015 21:33:16 +0200 Subject: [PATCH] Added making package. Created possibility to build zip or tgz package with compiled executables. Moved version information to version.mk. --- .cproject | 10 ++++- .gitignore | 1 + Makefile | 96 ++++++++++++++++++++++++++++++++----------- src/peresec_version.h | 12 +++--- version.mk | 5 +++ 5 files changed, 94 insertions(+), 30 deletions(-) create mode 100644 version.mk diff --git a/.cproject b/.cproject index 8f134de..737f4bd 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/.gitignore b/.gitignore index fba4e61..bb83041 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /obj /bin +/pkg diff --git a/Makefile b/Makefile index b161b05..542e87c 100644 --- a/Makefile +++ b/Makefile @@ -17,12 +17,16 @@ # (at your option) any later version. # #****************************************************************************** -ifeq ($(OS),Windows_NT) -RES = obj/peresec_stdres.res -EXEEXT = .exe +ifneq (,$(findstring Windows,$(OS))) + RES = obj/peresec_stdres.res + EXEEXT = .exe + PKGFMT = zip + PKGOS = win else -RES = -EXEEXT = + RES = + EXEEXT = + PKGFMT = tar.gz + PKGOS = lin endif CPP = g++ @@ -30,7 +34,12 @@ 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/peresec$(EXEEXT) LIBS = @@ -38,6 +47,7 @@ OBJS = \ obj/peresec.o \ $(RES) +GENSRC = obj/ver_defs.h LINKOBJ = $(OBJS) LINKLIB = INCS = @@ -56,7 +66,11 @@ CXXFLAGS = $(CXXINCS) -c -fmessage-length=0 $(WARNFLAGS) $(DEPFLAGS) $(OPTFLAGS) CFLAGS = $(INCS) -c -fmessage-length=0 $(WARNFLAGS) $(DEPFLAGS) $(OPTFLAGS) LDFLAGS = $(LINKLIB) $(OPTFLAGS) $(DBGFLAGS) $(LINKFLAGS) -.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 @@ -64,30 +78,66 @@ 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: $<' + $(TAR) zcf "$@" pkg + $(ECHO) 'Finished creating: $<' + $(ECHO) ' ' + +tar.gz: pkg/peresec-$(subst .,_,$(VER_STRING))-$(PACKAGE_SUFFIX)-$(PKGOS).tar.gz + +pkg/%.zip: pkg-before + $(ECHO) 'Creating package: $<' + cd $(@D); \ + $(ZIP) -9 -r "$(@F)" . + $(ECHO) 'Finished creating: $<' + $(ECHO) ' ' + +zip: pkg/peresec-$(subst .,_,$(VER_STRING))-$(PACKAGE_SUFFIX)-$(PKGOS).zip + #****************************************************************************** diff --git a/src/peresec_version.h b/src/peresec_version.h index 37ebd90..7cfe1ff 100644 --- a/src/peresec_version.h +++ b/src/peresec_version.h @@ -20,11 +20,13 @@ #define PERESEC_VERSION_H /* Version definitions */ -#define VER_MAJOR 1 -#define VER_MINOR 0 -#define VER_RELEASE 9 -#define VER_BUILD 43 -#define VER_STRING "1.0.9.43" +#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 "PEReSec" #define PROGRAM_FULL_NAME "PE/DLL Rebuilder of Export Section" diff --git a/version.mk b/version.mk new file mode 100644 index 0000000..cb0acff --- /dev/null +++ b/version.mk @@ -0,0 +1,5 @@ +VER_MAJOR=1 +VER_MINOR=0 +VER_RELEASE=9 +VER_BUILD=15 +PACKAGE_SUFFIX=devel