Skip to content

Commit

Permalink
Added making package.
Browse files Browse the repository at this point in the history
Created possibility to build zip or tgz package with compiled executables.
Moved version information to version.mk.
  • Loading branch information
mefistotelis committed Sep 11, 2015
1 parent 9701a68 commit dc4cc21
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 30 deletions.
10 changes: 8 additions & 2 deletions .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,26 @@
<buildTargets>
<target name="clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="all" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="package" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>package</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
</buildTargets>
</storageModule>
</cproject>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/obj
/bin
/pkg
96 changes: 73 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,37 @@
# (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++
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 =
OBJS = \
obj/peresec.o \
$(RES)

GENSRC = obj/ver_defs.h
LINKOBJ = $(OBJS)
LINKLIB =
INCS =
Expand All @@ -56,38 +66,78 @@ 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

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

#******************************************************************************
12 changes: 7 additions & 5 deletions src/peresec_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions version.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
VER_MAJOR=1
VER_MINOR=0
VER_RELEASE=9
VER_BUILD=15
PACKAGE_SUFFIX=devel

0 comments on commit dc4cc21

Please sign in to comment.