Skip to content

Commit

Permalink
First hack at unified version management
Browse files Browse the repository at this point in the history
  • Loading branch information
ronys committed Jun 24, 2016
1 parent ed41717 commit ce6bad7
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 28 deletions.
65 changes: 54 additions & 11 deletions CMakeLists.txt
Expand Up @@ -10,18 +10,55 @@ include(CheckLibraryExists)
include(CheckIncludeFile)

# Version configuration:
# version.mfc for Windows MFC build, version.wx for all the rest
# version file has the following format:
# VER_MAJOR = 3
# VER_MINOR = 39
# VER_REV = 0
# VER_SPECIAL = pre
# where VER_MAJOR and VAR_MINOR are mandatory, and all except
# VER_SPECIAL must be integers

if (WIN32 AND NOT WX_WINDOWS)
set (pwsafe_VERSION_MAJOR 3)
set (pwsafe_VERSION_MINOR 39)
set (pwsafe_REVISION 0)
set (pwsafe_SPECIALBUILD "pre")
set (VERSION_FILE "${PROJECT_SOURCE_DIR}/version.mfc")
else (WIN32 AND NOT WX_WINDOWS)
set (pwsafe_VERSION_MAJOR 0)
set (pwsafe_VERSION_MINOR 98)
set (pwsafe_REVISION 1)
set (pwsafe_SPECIALBUILD "BETA")
set (VERSION_FILE "${PROJECT_SOURCE_DIR}/version.wx")
endif (WIN32 AND NOT WX_WINDOWS)
set (pwsafe_VERSION "${pwsafe_VERSION_MAJOR}.${pwsafe_VERSION_MINOR}.${pwsafe_REVISION}")

if (NOT EXISTS ${VERSION_FILE})
message (FATAL_ERROR "Missing ${VERSION_FILE} - unable to proceed")
endif (NOT EXISTS ${VERSION_FILE})

file ( STRINGS ${VERSION_FILE} VERSION_LIST )

foreach ( VERSION_ITEM IN ITEMS ${VERSION_LIST} )
if (${VERSION_ITEM} MATCHES "^[ ]*VER_MAJOR[ ]*=[ ]*([0-9]+)")
string (REGEX REPLACE ".*=[ ]*([0-9]+)" "\\1"
pwsafe_VERSION_MAJOR ${VERSION_ITEM})
elseif (${VERSION_ITEM} MATCHES "^[ ]*VER_MINOR[ ]*=[ ]*([0-9]+)")
string (REGEX REPLACE ".*=[ ]*([0-9]+)" "\\1"
pwsafe_VERSION_MINOR ${VERSION_ITEM})
elseif (${VERSION_ITEM} MATCHES "^[ ]*VER_REV[ ]*=[ ]*([0-9]+)")
string (REGEX REPLACE ".*=[ ]*([0-9]+)" "\\1"
pwsafe_REVISION ${VERSION_ITEM})
elseif (${VERSION_ITEM} MATCHES "^[ ]*VER_SPECIAL[ ]*=[ ]*(.+)")
string (REGEX REPLACE ".*=[ ]*(.+)" "\\1"
pwsafe_SPECIALBUILD ${VERSION_ITEM})
endif ()
endforeach ( VERSION_ITEM )

if (NOT pwsafe_VERSION_MAJOR)
message (FATAL_ERROR "VER_MAJOR undefined in ${VERSION_FILE} - unable to proceed")
endif (NOT pwsafe_VERSION_MAJOR)
if (NOT pwsafe_VERSION_MINOR)
message (FATAL_ERROR "VER_MINOR undefined in ${VERSION_FILE} - unable to proceed")
endif (NOT pwsafe_VERSION_MINOR)

if (pwsafe_REVISION)
set (pwsafe_VERSION "${pwsafe_VERSION_MAJOR}.${pwsafe_VERSION_MINOR}.${pwsafe_REVISION}")
else ()
set (pwsafe_VERSION "${pwsafe_VERSION_MAJOR}.${pwsafe_VERSION_MINOR}")
endif (pwsafe_REVISION)

# Configurable options:
option (NO_YUBI "Set ON to disable YubiKey support" OFF)
Expand Down Expand Up @@ -302,8 +339,14 @@ endif (NOT WIN32)
## Common:
set (CPACK_PACKAGE_VERSION_MAJOR "${pwsafe_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MAJOR "${pwsafe_VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${pwsafe_REVISION}")
set (CPACK_PACKAGE_VERSION "${pwsafe_VERSION}-${pwsafe_SPECIALBUILD}")
if (pwsafe_REVISION)
set (CPACK_PACKAGE_VERSION_PATCH "${pwsafe_REVISION}")
endif (pwsafe_REVISION)
if (pwsafe_SPECIALBUILD)
set (CPACK_PACKAGE_VERSION "${pwsafe_VERSION}-${pwsafe_SPECIALBUILD}")
else ()
set (CPACK_PACKAGE_VERSION "${pwsafe_VERSION}")
endif (pwsafe_SPECIALBUILD)
set (CPACK_PACKAGE_CONTACT "Rony Shapiro <ronys@pwsafe.org>")
set (CPACK_PACKAGE_VENDOR "Rony Shapiro")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Password Safe is a password database utility.")
Expand Down
17 changes: 9 additions & 8 deletions Makefile.freebsd
@@ -1,17 +1,18 @@

# Toplevel Makefile for Linux build of PasswordSafe
# Toplevel Makefile for FreeBSD build of PasswordSafe

export VER_MAJOR := 0
export VER_MINOR := 98
export VER_REV := 1
export VER_SPECIAL := BETA

# Since we use wxWidgets 3.x, while many distros still provide 2.8
# Since we use wxWidgets 3.x, while some distros still provide 2.8
# The following need to be set to point to the local build of wxWidgets.
# Alternately, you can just set WX_CONFIG in your shell environment
# export WX_CONFIG=$(HOME)/src/wxWidgets-3.0.2/wx-config

# Shouldn't change anything below here
# version numbers are defined in version.wx
include version.wx
export VER_MAJOR
export VER_MINOR
export VER_REV
export VER_SPECIAL


export RELEASENUM := $(VER_MAJOR).$(VER_MINOR)
export RELEASE_SPECIAL := $(VER_SPECIAL)
Expand Down
14 changes: 7 additions & 7 deletions Makefile.linux
@@ -1,18 +1,18 @@

# Toplevel Makefile for Linux build of PasswordSafe

export VER_MAJOR := 0
export VER_MINOR := 98
export VER_REV := 1
export VER_SPECIAL := BETA

# Since we use wxWidgets 3.x, while many distros still provide 2.8
# Since we use wxWidgets 3.x, while some distros still provide 2.8
# The following need to be set to point to the local build of wxWidgets.
# Alternately, you can just set WX_CONFIG in your shell environment
# export WX_CONFIG=$(HOME)/src/wxWidgets-3.0.2/wx-config

# Shouldn't change anything below here

# version numbers are defined in version.wx
include version.wx
export VER_MAJOR
export VER_MINOR
export VER_REV
export VER_SPECIAL
export RELEASENUM := $(VER_MAJOR).$(VER_MINOR)
export RELEASE_SPECIAL := $(VER_SPECIAL)
export RELEASENAME := $(RELEASENUM)$(RELEASE_SPECIAL)
Expand Down
9 changes: 7 additions & 2 deletions Makefile.windows
Expand Up @@ -8,8 +8,13 @@
#
# Oh, this works with GNU make under Cygwin. YMMV on other makes...

RELEASENUM := 3.39
RELEASE_SPECIAL := pre
include version.mfc
ifeq ($(VER_REV),)
RELEASENUM := $(VER_MAJOR).$(VER_MINOR)
else
RELEASENUM := $(VER_MAJOR).$(VER_MINOR).$(VER_REV)
endif
RELEASE_SPECIAL := $(VER_SPECIAL)

RELEASENAME= $(RELEASENUM)$(RELEASE_SPECIAL)

Expand Down
9 changes: 9 additions & 0 deletions version.mfc
@@ -0,0 +1,9 @@
# This file uniquely determines version of Windows/MFC build
# for all build systems
# VER_MAJOR and VAR_MINOR are mandatory, all except VER_SPECIAL must
# be integers

VER_MAJOR = 3
VER_MINOR = 39
#VER_REV = 0
VER_SPECIAL = pre
9 changes: 9 additions & 0 deletions version.wx
@@ -0,0 +1,9 @@
# This file uniquely determines version of Windows/MFC build
# for all build systems
# VER_MAJOR and VAR_MINOR are mandatory, all except VER_SPECIAL must
# be integers

VER_MAJOR = 0
VER_MINOR = 98
VER_REV = 1
VER_SPECIAL = BETA

0 comments on commit ce6bad7

Please sign in to comment.