~jgoguen/gablog/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
123
124
#!/usr/bin/make -f
# The MIT License
#
# Copyright (c) 2010 Joel Goguen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

APP_NAME ?= gablog
VERSION ?= 1.0
TMPDIR ?= /tmp

PYTHON_BIN ?= /usr/bin/python2.5
SDK_PATH ?= /opt/google-appengine
BIND_ADDR ?= 127.0.1.1
BIND_PORT ?= 8008
DATASTORE ?= datastore
BLOBSTORE ?= blobstore
HISTORY ?= history

CSSMIN ?= dev/scripts/cssmin.py
JSMIN ?= dev/scripts/jsmin.py

DEV_CLI ?= $(SDK_PATH)/dev_appserver.py --debug --address=$(BIND_ADDR) --port=$(BIND_PORT) --blobstore_path=$(BLOBSTORE) --datastore_path=$(DATASTORE) --history_path=$(HISTORY) --allow_skipped_files --show_mail_body .
UPLOAD_CLI ?= $(SDK_PATH)/appcfg.py

CSS_FILES ?= default/css/style default/css/mobile
JS_FILES ?= default/script/gablog default/script/mobile

serve: clean fortunes.dat
	$(PYTHON_BIN) $(DEV_CLI)

upload: clean fortunes.dat
	$(PYTHON_BIN) $(UPLOAD_CLI) update .

min:
	@echo "Minifying CSS files..."
	$(foreach FILE,$(CSS_FILES),$(shell $(PYTHON_BIN) $(CSSMIN) _resources/$(FILE).debug.css > _resources/$(FILE).css))
	@echo "Minifying JavaScript files..."
	$(foreach FILE,$(JS_FILES),$(shell $(PYTHON_BIN) $(JSMIN) _resources/$(FILE).debug.js > _resources/$(FILE).js))

fortunes.dat: fortunes
	@echo "Generating fortune database"
	@test -f fortunes && $(PYTHON_BIN) dev/scripts/strfile.py fortunes

clean:
	@echo "Removing compiled Python files..."
	$(shell find . -type f -name '*.pyc' -exec rm "{}" \;)

clobber: clean
	@echo "Removing generated release files..."
	@-rm ../$(APP_NAME)-$(VERSION).tgz ../$(APP_NAME)-$(VERSION).zip ../$(APP_NAME)-$(VERSION).tgz.asc ../$(APP_NAME)-$(VERSION).zip.asc ../$(APP_NAME)-$(VERSION).tgz.sha256sum ../$(APP_NAME)-$(VERSION).zip.sha256sum ../README.asc ../CHANGELOG.asc ../README.sha256sum ../CHANGELOG.sha256sum ../README ../CHANGELOG

pkg: clobber min fortunes.dat dir-prep ../$(APP_NAME)-$(VERSION).tgz ../$(APP_NAME)-$(VERSION).zip dir-clean

dir-prep:
	@mkdir ../$(APP_NAME)-$(VERSION)
	@echo "Copying files..."
	@rsync -aqHAXS --exclude=*.pyc --exclude=*.stamp --exclude=.komodotools --exclude=gablog.komodoproject --exclude=datastore --exclude=history --exclude=blobstore * ../$(APP_NAME)-$(VERSION)/

dir-clean:
	@echo "Cleaning files..."
	@rm -rf ../$(APP_NAME)-$(VERSION)/

../$(APP_NAME)-$(VERSION).tgz:
	@echo "Creating tarball..."
	@cd ../;tar zcf $(APP_NAME)-$(VERSION).tgz $(APP_NAME)-$(VERSION)/

../$(APP_NAME)-$(VERSION).zip:
	@echo "Creating ZIP archive..."
	@cd ../;zip -qr $(APP_NAME)-$(VERSION).zip $(APP_NAME)-$(VERSION)/

release: pkg ../$(APP_NAME)-$(VERSION).tgz.asc ../$(APP_NAME)-$(VERSION).zip.asc ../README.asc ../CHANGELOG.asc ../$(APP_NAME)-$(VERSION).tgz.sha256sum ../$(APP_NAME)-$(VERSION).zip.sha256sum ../README.sha256sum ../CHANGELOG.sha256sum

../$(APP_NAME)-$(VERSION).tgz.asc: ../$(APP_NAME)-$(VERSION).tgz
	@echo "Signing $(APP_NAME)-$(VERSION).tgz"
	@cd ../;gpg --armor --sign --detach-sig $(APP_NAME)-$(VERSION).tgz

../$(APP_NAME)-$(VERSION).zip.asc: ../$(APP_NAME)-$(VERSION).zip
	@echo "Signing $(APP_NAME)-$(VERSION).zip"
	@cd ../;gpg --armor --sign --detach-sig $(APP_NAME)-$(VERSION).zip

../README.asc: README
	@echo "Signing README"
	@cp README ../
	@cd ../;gpg --armor --sign --detach-sig README

../CHANGELOG.asc: CHANGELOG
	@echo "Signing CHANGELOG"
	@cp CHANGELOG ../
	@cd ../;gpg --armor --sign --detach-sig CHANGELOG

../$(APP_NAME)-$(VERSION).tgz.sha256sum: ../$(APP_NAME)-$(VERSION).tgz
	@echo "Creating SHA256 checksum for $(APP_NAME)-$(VERSION).tgz"
	@cd ../;sha256sum $(APP_NAME)-$(VERSION).tgz > $(APP_NAME)-$(VERSION).tgz.sha256sum

../$(APP_NAME)-$(VERSION).zip.sha256sum: ../$(APP_NAME)-$(VERSION).zip
	@echo "Creating SHA256 checksum for $(APP_NAME)-$(VERSION).zip"
	@cd ../;sha256sum $(APP_NAME)-$(VERSION).zip > $(APP_NAME)-$(VERSION).zip.sha256sum

../README.sha256sum: ../README
	@echo "Creating SHA256 checksum for README"
	@cd ../;sha256sum README > README.sha256sum

../CHANGELOG.sha256sum: ../CHANGELOG
	@echo "Creating SHA256 checksum for CHANGELOG"
	@cd ../;sha256sum CHANGELOG > CHANGELOG.sha256sum

.PHONY: min upload serve clean dir-prep dir-clean