Update note about Safari, demo location.
[yuu.git] / rules / node-webkit.mk
1 # This is free and unencumbered software released into the public
2 # domain. To the extent possible under law, the author of this file
3 # waives all copyright and related or neighboring rights to it.
4
5 .DELETE_ON_ERROR:
6
7 include $(dir $(realpath $(lastword $(MAKEFILE_LIST))))programs.mk
8
9 node-webkit-platforms := \
10 osx-x64.zip osx-ia32.zip \
11 linux-x64.tar.gz linux-ia32.tar.gz \
12 win-ia32.zip
13
14 node-webkit-pattern := \
15 $(addprefix node-webkit-v%-,$(node-webkit-platforms))
16
17 # These are like 30MB, don't download them every time.
18 .PRECIOUS: $(node-webkit-pattern)
19
20 $(node-webkit-pattern):
21 mkdir -p $(@D)
22 wget -O $@.tmp http://dl.node-webkit.org/v$(*F)/$(@F)
23 mv $@.tmp $@
24
25 node-webkit-version ?= 0.10.2
26 node-webkit-prefix ?= node-webkit/
27 node-webkit-directx = $(addprefix $(node-webkit-prefix),d3dcompiler_43.dll d3dcompiler_46.dll)
28
29 node-webkit = $(node-webkit-prefix)node-webkit-v$(firstword $(value node-webkit-version-$1) $(node-webkit-version))-$1
30
31 node-webkit-archives = \
32 $(foreach p,$(node-webkit-platforms),$(call node-webkit,$(p)))
33
34 define node-webkit-package-osx
35 $(RM) $@
36 $(RM) -r $(@:.zip=)
37 $(UNZIP) -d $(@D) $2
38 mv $(@D)/$(notdir $(2:.zip=)) $(@:.zip=)
39 tools/generate-osx-app $(@:.zip=) $1
40 $(RM) $(@:.zip=)/nwsnapshot
41 mv $(@:.zip=)/credits.html $(@:.zip=)/node-webkit\ credits.html
42 cd $(@D) && $(ZIP) -r $(@F) $(@F:.zip=)
43 $(RM) -r $(@:.zip=)
44 endef
45
46 %-osx-ia32.zip: %.nw $(call node-webkit,osx-ia32.zip)
47 $(call node-webkit-package-osx,$<,$(word 2,$^))
48
49 %-osx-x64.zip: %.nw $(call node-webkit,osx-x64.zip)
50 $(call node-webkit-package-osx,$<,$(word 2,$^))
51
52 define node-webkit-package-linux
53 $(RM) $@
54 $(RM) -r $(@:.tar.gz=)
55 tar -C $(@D) -xzf $2
56 mkdir -p $(@:.tar.gz=)
57 mv $(@D)/$(notdir $(2:.tar.gz=)) $(@:.tar.gz=)/nw
58 cp -a $1 $(@:.tar.gz=)/nw/package.nw
59 cp -a tools/nw-linux-wrapper $(@:.tar.gz=)/`echo $(notdir $1) | sed -E 's/_.+//'`
60 $(RM) $(@:.tar.gz=)/nw/nwsnapshot
61 mv $(@:.tar.gz=)/nw/credits.html $(@:.tar.gz=)/nw/node-webkit\ credits.html
62 tar -czf $@ -C $(@D) $(@F:.tar.gz=)
63 $(RM) -r $(@:.tar.gz=)
64 endef
65
66 %-linux-ia32.tar.gz: %.nw $(call node-webkit,linux-ia32.tar.gz)
67 $(call node-webkit-package-linux,$<,$(word 2,$^))
68
69 %-linux-x64.tar.gz: %.nw $(call node-webkit,linux-x64.tar.gz)
70 $(call node-webkit-package-linux,$<,$(word 2,$^))
71
72 WINE ?= wine
73
74 node-webkit-icon = $(shell $(UNZIP) -p $1 package.json | grep -Eo '"[^"]+.ico"' -m 1)
75
76 define node-webkit-package-win
77 $(RM) $@
78 $(RM) -r $(@:.zip=)
79 if $(UNZIP) -l $2 credits.html > /dev/null; then $(UNZIP) -d $(@D)/$(notdir $(2:.zip=)) $2; else $(UNZIP) -d $(@D) $2; fi
80 mv $(@D)/$(notdir $(2:.zip=)) $(@:.zip=)
81 $(RM) $(@:.zip=)/nwsnapshot.exe
82 $(UNZIP) -p $< $(call node-webkit-icon,$<) > $(@D)/icon.ico
83 $(WINE) tools/rcedit.exe $(@:.zip=)/nw.exe --set-icon $(@D)/icon.ico
84 $(RM) $(@D)/icon.ico
85 mv $(@:.zip=)/credits.html $(@:.zip=)/node-webkit\ credits.html
86 cp -a $< $(@:.zip=)/package.nw
87 cp -a $(node-webkit-directx) $(@:.zip=)
88 mv $(@:.zip=)/nw.exe $(@:.zip=)/`echo $(notdir $1) | sed -E 's/_.+/.exe/'`
89 cd $(@D) && $(ZIP) -r $(@F) $(@F:.zip=)
90 $(RM) -r $(@:.zip=)
91 endef
92
93 %-win-ia32.zip: %.nw $(call node-webkit,win-ia32.zip) $(node-webkit-directx)
94 $(call node-webkit-package-win,$<,$(word 2,$^))
95
96 $(node-webkit-directx):
97 mkdir -p $(@D)
98 wget -O $@.tmp 'https://github.com/cefsharp/cef-binary/raw/1e51255cf77d267899bf7834768b8774affaad2d/cef_binary_3.y.z_windows32/Release/'$(@F)
99 mv $@.tmp $@
100
101 $(node-webkit-prefix)dxwebsetup.exe:
102 mkdir -p $(@D)
103 wget -O $@.tmp http://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe
104 mv $@.tmp $@