~bkrpr/bookliberator/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# We may or may not keep this Makefile, as this is a Python project
# and may eventually migrate to some non-Makefile-based Pythonic way
# of doing things.  But for now, 'make dist' builds a release from the
# latest version of Bkrpr in lp:bkrpr.  'make local-dist' will build a
# distribution from the current directory.  Also, 'make deb', 'make
# rpm' and 'make windows' will create install packages for the various
# systems.  'make install' is an alias for 'python setup.py install'

# This Makefile might use some GNU-specific features, so we recommend
# you process it with GNU make in a GNU environment (e.g. one that
# supports 'mkdir -p')

# We use a bit of python to get the current version info from VERSION.
# If this file is missing, it gets generated from the first line of
# the README and the bazaar info.  But if you aren't using bazaar,
# you'll have to set this file by hand.

# If you do not have bazaar installed, 'make dist' will not work, as
# it uses bazaar to download the latest revision.  Use 'make
# local-dist' instead.

# We have an rpm target in this Makefile, but it is completely
# untested, as I haven't had a chance to create an rpm-based distro
# image.

# Theoretically, the deb target will not work except on a Debian or
# Ubuntu machine.  The rpm target, though, should work from even a
# deb-based distro, as it is based on distutils.

SHELL := /bin/sh
PROGRAM := bkrpr
PYTHON := `which python`
BRANCH :=  lp:bkrpr

PY_FILES := setup.py bkrpr.py $(shell find Bkrpr -name '*.py' | xargs)
IMAGES := $(shell find Bkrpr/images -name '*.*')
DOCS := INSTALL.txt LICENSE.txt GPLv3.txt README.txt
DEBIAN_NO_CHANGELOG :=  debian/compat debian/control \
	debian/copyright debian/docs debian/rules
DEBIAN_FILES := debian/changelog $(DEBIAN_NO_CHANGELOG)
PACKAGED_FILES := $(DOCS) $(PY_FILES) $(IMAGES) $(DEBIAN_FILES) Makefile

VERSION := $(shell $(PYTHON) -c "import Bkrpr.utils.dist as dist; print dist.version()")
PWD := $(shell pwd)
DIST_DIR := $(PWD)/dist
DIST_FILE_STUB := $(PROGRAM)-$(VERSION)
TARGZ := $(DIST_DIR)/$(DIST_FILE_STUB).tar.gz
DEB := $(DIST_DIR)/$(PROGRAM)_$(VERSION)_all.deb
WINDOWS := $(DIST_DIR)/$(DIST_FILE_STUB).win32.exe
RPM := $(DIST_DIR)/$(DIST_FILE_STUB)-1.noarch.rpm $(DIST_DIR)/$(DIST_FILE_STUB)-1.src.rpm

BUILD_AREA := $(PWD)/bkrpr-dist-build-area
ORIG := $(BUILD_AREA)/$(DIST_FILE_STUB).orig.tar.gz

BZR := `which bzr`
ifneq ($(strip $(BZR)),)
CHANGELOG := $(BZR) log | $(PYTHON) Bkrpr/utils/bzrlog2dch.py > debian/changelog
else
CHANGELOG = :
BZR := :
endif

MANIFEST = @echo 'Bkrpr/VERSION MANIFEST $(PACKAGED_FILES)' | sed 's/ /\n/g' | sed 's/^\.\///g' > MANIFEST

.PHONY: clean dist local-dist deb windows distclean

dist:
	@mkdir -p dist
	@rm -rf $(BUILD_AREA)
	@$(BZR) branch $(BRANCH) $(BUILD_AREA)
	@cd $(BUILD_AREA) ;\
	make local-dist ;\
	mv dist/* ../dist
	@rm -rf $(BUILD_AREA)
	@#Bkrpr/utils/dist.py

local-dist: $(TARGZ) ;
deb: $(DEB) ;
rpm: $(RPM) ;
windows: $(WINDOWS) ;
all: deb rpm windows ;

install:
	@rm -rf build
	@$(PYTHON) setup.py install

$(RPM): $(PACKAGED_FILES)
	@rm -rf build
	@$(MANIFEST)
	@$(PYTHON) setup.py -q bdist_rpm

$(WINDOWS): $(PACKAGED_FILES)
	@rm -rf build
	@$(MANIFEST)
	@$(PYTHON) setup.py -q bdist_wininst

$(DEB): $(TARGZ) 
	@rm -rf $(BUILD_AREA)
	@mkdir -p $(BUILD_AREA)
	@cp $(TARGZ) $(ORIG)
	@cd $(BUILD_AREA) ;\
	tar -xf $(ORIG);\
	cd $(DIST_FILE_STUB) ;\
	dpkg-buildpackage -us -uc -rfakeroot ;\
	mv $(BUILD_AREA)/$(PROGRAM)_$(VERSION)_all.deb $(DEB)

$(TARGZ): $(PACKAGED_FILES)
	@rm -rf build
	@$(MANIFEST)
	@$(PYTHON) setup.py -q sdist --formats=gztar,zip

debian/copyright: LICENSE.txt
	@cp $(PWD)/LICENSE.txt debian/copyright

debian/changelog: $(DEBIAN_NO_CHANGELOG) $(DOCS) $(PY_FILES) $(IMAGES) 
	@$(CHANGELOG)

distclean:
	@rm -rf dist build MANIFEST Bkrpr/VERSION $(BUILD_AREA) debian/changelog

clean: distclean
	@find . -name '*.pyc' | xargs rm -f