
# Toplevel Makefile for Linux build of PasswordSafe


# 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

# 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).$(VER_REV)
export RELEASE_SPECIAL := $(VER_SPECIAL)
export RELEASENAME := $(RELEASENUM)$(RELEASE_SPECIAL)

.PHONY:    all tar signatures \
	sha1sums upload upload-sf upload-src-sf upload-github git-tag I18N \
	help

RELEASEDIR := ./Releases/

PKG_BASE := pwsafe
SRC_TGZ = $(PKG_BASE)-$(RELEASENAME)-src.tgz

MKDIR := mkdir -p
RM := /bin/rm -rf
GIT := git
GZIP := gzip
ECHO := /bin/echo
TAR := /usr/bin/tar

GPG := /usr/bin/gpg
GPG_SIGN := $(GPG) --detach-sign --default-key $(GPG_KEY)
SIGN_CMD := $(foreach file, $(wildcard $(RELEASEDIR)/*$(RELEASENAME)*), $(GPG_SIGN) $(file); )

SHA1SUM := /usr/bin/sha1sum
SF_UPLOAD_CMD := /usr/bin/rsync -avP -e ssh
SF_UPLOAD_DST := $(SF_UPLOAD_ROOT)/Linux-BETA/$(RELEASENUM)
RELTAG = wx$(subst .,_,$(RELEASENAME))

export CPPFLAGS += -std=c++11

all:
	@echo "Toplevel make is no longer supported for building Linux versions of PasswordSafe. Please use cmake as described in README.LINUX.DEVELOPERS.md"



tar:
	@$(MKDIR)  $(RELEASEDIR)
	@$(GIT) archive --format=tar.gz \
	--prefix=$(PKG_BASE)-$(RELEASENAME)/ \
	-o $(RELEASEDIR)/$(SRC_TGZ) \
	$(RELEASENAME)

# Following needed because GitHub creates its own tar.gz and .zip files for a release
# and we need to verify those before signing them
cmpsrc-github: tar
	(cd $(RELEASEDIR); $(TAR) xzf $(SRC_TGZ) && \
	../Misc/sighlp_cmp.py -f ChangeLog -f pwsafe.pot -f version.h -v 1 -s $(RELEASENAME).zip \
												https://github.com/pwsafe/pwsafe/archive/$(RELEASENAME).zip \
	                      $(PKG_BASE)-$(RELEASENAME)/ && $(GPG_SIGN) $(RELEASENAME).zip; \
	../Misc/sighlp_cmp.py -f ChangeLog -f pwsafe.pot -f version.h -v 1 -s $(RELEASENAME).tar.gz \
												https://github.com/pwsafe/pwsafe/archive/$(RELEASENAME).tar.gz \
												$(PKG_BASE)-$(RELEASENAME)/ && $(GPG_SIGN) $(RELEASENAME).tar.gz)

	(cd $(RELEASEDIR); $(RM) $(RELEASENAME).zip $(RELEASENAME).tar.gz &&	$(RM) -rf $(PKG_BASE)-$(RELEASENAME))
	@echo "GitHub source signature files ready to upload from $(RELEASEDIR)"

sha1sums:
	(cd $(RELEASEDIR); $(SHA1SUM) *$(RELEASENAME)*)

signatures:
	$(SIGN_CMD)

upload: upload-sf upload-src-sf upload-github

upload-sf:
	$(SF_UPLOAD_CMD) \
	$(wildcard $(RELEASEDIR)/passwordsafe-*$(RELEASENAME)*) \
	$(wildcard $(RELEASEDIR)/pwsafe-*$(RELEASENAME)*) \
	$(SF_UPLOAD_DST)

upload-github:
	@echo $@ TBD

# Uploading source is a separate target as we only want to do this once,
# as opposed to uploading the compiled package, which we need to do per distro.
upload-src-sf:
	$(SF_UPLOAD_CMD) \
	$(wildcard $(RELEASEDIR)/pwsafe-*$(RELEASENAME)-src*) \
	$(SF_UPLOAD_DST)

git-tag:
	$(GIT) tag -u $(GPG_KEY) -m "tag wx $(RELEASENAME) release" $(RELEASENAME)

I18N:
	$(MAKE) -C src/ui/wxWidgets/I18N mos

help:
	$(MAKE) -C help


# Local variables:
# mode: makefile
# End:
