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