Makefile 2.58 KB
Newer Older
1 2
# export SVN_REPO_BASE=. if you want to use the local version instead of trunk
# from the subversion repository.
3

4
# use something like "VERSION=0.2 make" to override the VERSION on the command line
5 6 7 8
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
9 10
RELEASE_PREFIX ?= pycam-
ARCHIVE_DIR_RELATIVE ?= release-archives
11 12
TMP ?= /tmp
EXPORT_DIR = $(TMP)/$(RELEASE_PREFIX)$(VERSION)
13
EXPORT_FILE_PREFIX = $(EXPORT_DIR)
14 15 16
EXPORT_ZIP = $(EXPORT_FILE_PREFIX).zip
EXPORT_TGZ = $(EXPORT_FILE_PREFIX).tar.gz
EXPORT_WIN32 = $(EXPORT_FILE_PREFIX).win32.exe
17 18 19 20
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
21

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

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

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

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

34 35 36
man: svn_export
	@make -C "$(EXPORT_DIR)/man"

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

43 44 45
create_archive_dir:
	mkdir -p "$(ARCHIVE_DIR)"

46
zip: create_archive_dir man svn_export
47
	cd "$(EXPORT_DIR)"; $(PYTHON_EXE) setup.py sdist --format zip --dist-dir "$(ARCHIVE_DIR)"
48

49
tgz: create_archive_dir man svn_export
50
	cd "$(EXPORT_DIR)"; $(PYTHON_EXE) setup.py sdist --format gztar --dist-dir "$(ARCHIVE_DIR)"
51

52
win32: create_archive_dir man svn_export
53
	# this is a binary release
54
	cd "$(EXPORT_DIR)"; $(PYTHON_EXE) setup.py bdist --format wininst --dist-dir "$(ARCHIVE_DIR)" $(DISTUTILS_PLAT_NAME)
55

56
upload:
57 58 59 60
	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
61