Initial import.
[yuu.git] / Makefile
1 #!/usr/bin/make -f
2
3 node-webkit-version := 0.10.4
4
5 .DELETE_ON_ERROR:
6 include rules/programs.mk
7 include rules/javascript.mk
8 include rules/icons.mk
9 include rules/git.mk
10 include rules/node-webkit.mk
11 include rules/pngcrush.mk
12
13 .PHONY: all check distclean lint test dist clean serve
14
15 APPLICATION := yuu
16 DISTDIR := build/dist
17 VERSION := $(call git-describe)
18 DISTROOT := $(DISTDIR)/$(APPLICATION)_$(VERSION)
19
20 FIND_FILES := -type f ! -name '.*'
21 FIND_JS := -type f -name '*.js'
22
23 SOURCES := $(shell cd src && find . $(FIND_FILES))
24 MY_SOURCES := $(shell cd src && find . $(FIND_JS) -not -path './ext/*')
25
26 TEST_SOURCES := $(shell find test/spec $(FIND_JS))
27
28 LINT_TARGETS := $(call jshint-stampify,$(MY_SOURCES))
29 TEST_TARGETS := $(call jstest-stampify,$(TEST_SOURCES))
30
31 JSHINTCONFIG := test/jshint.config
32 JSTEST_NODE_PATH := src
33 VPATH := src
34
35 ICONSETS := $(shell find src -type d -name '*.iconset')
36 ICONS := $(ICONSETS:.iconset=.icns) $(ICONSETS:.iconset=.ico)
37
38 IMAGEGZSRC := $(shell find src -type f -name '*.xcf.gz')
39 IMAGESRC := $(shell find src -type f -name '*.xcf')
40 IMAGES := $(IMAGEGZSRC:.xcf.gz=.png) $(IMAGESRC:.xcf=.png)
41
42 BUILT := $(ICONS) $(IMAGES)
43
44 HTTP_SERVER_PORT ?= 8000
45
46 all: check $(BUILT) $(call pngcrush-stampify,$(IMAGES))
47
48 $(DISTDIR):
49 mkdir -p $@
50
51 dist: $(addprefix $(DISTROOT),-src.zip -src.tar.gz .appcache .nw -osx-ia32.zip -osx-x64.zip -linux-ia32.tar.gz -linux-x64.tar.gz -win-ia32.zip)
52
53 test/spec/%.js: %.js
54 touch $@
55
56 lint: $(LINT_TARGETS)
57
58 test: $(TEST_TARGETS)
59
60 check: lint test
61
62 serve: | $(npmbindir)/http-server
63 $(npmbindir)/http-server $(@D) -p $(HTTP_SERVER_PORT) -c-1
64
65 clean:
66 $(RM) $(IMAGES)
67 $(RM) $(ICONS)
68 $(RM) -r build
69
70 distclean: clean
71 $(RM) -r node_modules
72 $(RM) $(node-webkit-archives)
73
74 $(DISTROOT)-src.zip $(DISTROOT)-src.tar.gz: | .git
75 mkdir -p $(@D)
76 $(call git-archive,$@,$(notdir $(DISTROOT))/)
77
78 $(DISTROOT).bare.zip: | .git
79 $(RM) $@
80 $(RM) -r $@.tmp
81 mkdir -p $@.tmp
82 cd src && $(GIT) archive $(call git-describe) . | tar -x -C ../$@.tmp
83 $(MAKE) $(BUILT:src/%=$@.tmp/%)
84 $(RM) $(IMAGESRC:src/%=$@.tmp/%) $(IMAGEGZSRC:src/%=$@.tmp/%)
85 cd $@.tmp && $(ZIP) ../$(@F) -r .
86 $(RM) -r $@.tmp
87
88 %.appcache: %.bare.zip tools/generate-appcache
89 $(RM) -r $@.tmp $@
90 $(UNZIP) -d $@.tmp $<
91 tools/generate-appcache $@.tmp
92 mv $@.tmp $@
93
94 # Python's zipfile module generates zipfiles that node-webkit cannot
95 # read, so delegate to a real zip tool.
96 %.nw: %.bare.zip tools/generate-nw
97 $(RM) -r $@ $@.tmp
98 $(UNZIP) -d $@.tmp $<
99 tools/generate-nw $@.tmp `echo $(*F) | sed -E 's/.+_[^0-9]+//'`
100 cd $@.tmp && $(ZIP) -r ../$(@F) .
101 $(RM) -r $@.tmp