Makefile 2.52 KB
Newer Older
1 2
# BEWARE: this makefile is solely used for preparing a release - it is not useful for compiling/installing the program

3
# use something like "VERSION=0.2 make" to override the VERSION on the command line
4 5 6 7
VERSION ?= $(shell sed -n "s/^.*[\t ]*VERSION[\t ]*=[\t ]*[\"']\([^\"']*\)[\"'].*/\1/gp" src/pycam/__init__.py)
SVN_REPO_BASE ?= $(shell svn info --xml 2>/dev/null | grep "^<url>" | cut -f 2 -d ">" | cut -f 1 -d "<")
SVK_REPO_BASE ?= $(shell LANG= svk info | grep "^Depot Path:" | cut -f 3- -d " ")
REPO_TAGS ?= https://pycam.svn.sourceforge.net/svnroot/pycam/tags
8 9
RELEASE_PREFIX ?= pycam-
ARCHIVE_DIR_RELATIVE ?= release-archives
10 11
TMP ?= /tmp
EXPORT_DIR = $(TMP)/$(RELEASE_PREFIX)$(VERSION)
12
EXPORT_FILE_PREFIX = $(EXPORT_DIR)
13 14 15
EXPORT_ZIP = $(EXPORT_FILE_PREFIX).zip
EXPORT_TGZ = $(EXPORT_FILE_PREFIX).tar.gz
EXPORT_WIN32 = $(EXPORT_FILE_PREFIX).win32.exe
16 17 18 19
PYTHON_EXE ?= python
# check if the local version of python's distutils support "--plat-name"
# (introduced in python 2.6)
DISTUTILS_PLAT_NAME = $(shell $(PYTHON_EXE) setup.py --help build_ext | grep -q -- "--plat-name" && echo "--plat-name win32")
lode_leroy's avatar
lode_leroy committed
20

21 22
# turn the destination directory into an absolute path
ARCHIVE_DIR := $(shell pwd)/$(ARCHIVE_DIR_RELATIVE)
lode_leroy's avatar
lode_leroy committed
23

24
.PHONY: zip tgz win32 clean dist svn_export upload create_archive_dir
lode_leroy's avatar
lode_leroy committed
25

26
dist: zip tgz win32
27 28
	@# remove the tmp directory when everything is done
	@rm -rf "$(EXPORT_DIR)"
lode_leroy's avatar
lode_leroy committed
29

30 31 32 33
clean:
	@rm -rf "$(EXPORT_DIR)"

svn_export: clean
34 35 36 37
	@if svn info &>/dev/null;\
		then svn export --quiet "$(SVN_REPO_BASE)" "$(EXPORT_DIR)";\
		else svk co "$(SVK_REPO_BASE)" "$(EXPORT_DIR)";\
	fi
38

39 40 41 42
create_archive_dir:
	mkdir -p "$(ARCHIVE_DIR)"

zip: create_archive_dir svn_export
43
	cd "$(EXPORT_DIR)"; $(PYTHON_EXE) setup.py sdist --format zip --dist-dir "$(ARCHIVE_DIR)"
44

45
tgz: create_archive_dir svn_export
46
	cd "$(EXPORT_DIR)"; $(PYTHON_EXE) setup.py sdist --format gztar --dist-dir "$(ARCHIVE_DIR)"
47

48
win32: create_archive_dir svn_export
49
	# this is a binary release
50
	cd "$(EXPORT_DIR)"; $(PYTHON_EXE) setup.py bdist --format wininst --dist-dir "$(ARCHIVE_DIR)" $(DISTUTILS_PLAT_NAME)
51

52
upload:
53 54 55 56
	svn cp "$(SVN_REPO_BASE)" "$(REPO_TAGS)/release-$(VERSION)" -m "tag release $(VERSION)"
	svn import "$(ARCHIVE_DIR)/$(EXPORT_ZIP)" "$(REPO_TAGS)/archives/$(EXPORT_ZIP)" -m "added released zip file for version $(VERSION)"
	svn import "$(ARCHIVE_DIR)/$(EXPORT_TGZ)" "$(REPO_TAGS)/archives/$(EXPORT_TGZ)" -m "added released tgz file for version $(VERSION)"
	svn import "$(ARCHIVE_DIR)/$(EXPORT_WIN32)" "$(REPO_TAGS)/archives/$(EXPORT_WIN32)" -m "added released win32 installer for version $(VERSION)"
lode_leroy's avatar
lode_leroy committed
57