Makefile refactoring and cleanup.
[pwl6.git] / rules / nwjs.mk
index 42bbf79..bd5f37d 100644 (file)
@@ -2,30 +2,28 @@
 # domain. To the extent possible under law, the author of this file
 # waives all copyright and related or neighboring rights to it.
 
-.DELETE_ON_ERROR:
-
-include $(dir $(realpath $(lastword $(MAKEFILE_LIST))))programs.mk
+$(call include-once.,programs.mk)
 
 nwjs-platforms := \
        osx-x64.zip osx-ia32.zip \
        linux-x64.tar.gz linux-ia32.tar.gz \
        win-ia32.zip
 
-nwjs-pattern := \
-       $(addprefix nwjs-v%-,$(nwjs-platforms))
+nwjs-pattern := $(addprefix nwjs-v%-,$(nwjs-platforms))
 
 # These are like 30MB, don't download them every time.
 .PRECIOUS: $(nwjs-pattern)
 
 $(nwjs-pattern):
-       mkdir -p $(@D)
-       wget -O $@ http://dl.nwjs.io/v$(*F)/$(@F) || ($(RM) $@ && exit 1)
+       $(MKDIR) '$(@D)'
+       wget -O '$@'.inprogress 'http://dl.nwjs.io/v$(*F)/$(@F)'
+       mv '$@'.inprogress "$@"
 
-nwjs-version ?= 0.10.2
-nwjs-prefix ?= nwjs/
-nwjs-directx = $(addprefix $(nwjs-prefix),d3dcompiler_43.dll d3dcompiler_46.dll)
+nwjs-version ?= 0.12.0
+nwjsdir ?= nwjs/
+nwjs-directx = $(addprefix $(nwjsdir),d3dcompiler_43.dll d3dcompiler_46.dll)
 
-nwjs = $(nwjs-prefix)nwjs-v$(firstword $(value nwjs-version-$1) $(nwjs-version))-$1
+nwjs = $(nwjsdir)nwjs-v$(firstword $(value nwjs-version-$1) $(nwjs-version))-$1
 
 nwjs-archives = $(foreach p,$(nwjs-platforms),$(call nwjs,$(p)))
 
@@ -51,7 +49,7 @@ define nwjs-package-linux
        $(RM) $@
        $(RM) -r $(@:.tar.gz=)
        tar -C $(@D) -xzf $2
-       mkdir -p $(@:.tar.gz=)
+       $(MKDIR) $(@:.tar.gz=)
        mv $(@D)/$(notdir $(2:.tar.gz=)) $(@:.tar.gz=)/nw
        cp -a $1 $(@:.tar.gz=)/nw/package.nw
        cp -a tools/nw-linux-wrapper $(@:.tar.gz=)/`echo $(notdir $1) | sed -E 's/_.+//'`
@@ -67,14 +65,12 @@ endef
 %-linux-x64.tar.gz: %.nw $(call nwjs,linux-x64.tar.gz)
        $(call nwjs-package-linux,$<,$(word 2,$^))
 
-WINE ?= wine
-
 nwjs-icon = $(shell $(UNZIP) -p $1 package.json | grep -Eo '"[^"]+.ico"' -m 1)
 
 define nwjs-package-win
        $(RM) $@
        $(RM) -r $(@:.zip=)
-       if $(UNZIP) -l $2 credits.html > /dev/null; then $(UNZIP) -d $(@D)/$(notdir $(2:.zip=)) $2; else $(UNZIP) -d $(@D) $2; fi
+       $(UNZIP) -d $(@D) $2
        mv $(@D)/$(notdir $(2:.zip=)) $(@:.zip=)
        $(RM) $(@:.zip=)/nwjc.exe
        $(UNZIP) -p $< $(call nwjs-icon,$<) > $(@D)/icon.ico
@@ -94,5 +90,10 @@ endef
 $(nwjs-directx):
        wget -O $@ 'https://github.com/cefsharp/cef-binary/raw/1e51255cf77d267899bf7834768b8774affaad2d/cef_binary_3.y.z_windows32/Release/'$(notdir $@)
 
-$(nwjs-prefix)dxwebsetup.exe:
+$(nwjsdir)dxwebsetup.exe:
        wget -O $@ http://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe
+
+distclean::
+       $(RM) $(nwjs-archives)
+       $(RM) $(nwjs-directx)
+       $(RM) $(nwjsdir)dxwebsetup.exe