2 DEPLOY_DIR=/srv/lmno.games/www
3 DO_NOT_DEPLOY=Makefile deps *.jsx .babelrc .gitignore README
4 DO_NOT_DELETE=flempires
6 REACT_DEPS=react.js react-dom.js
8 deps/react.development.js \
9 deps/react-dom.development.js \
10 deps/react.production.min.js \
11 deps/react-dom.production.min.js
13 JSX_SOURCE=$(wildcard */*.jsx)
14 JS_TARGETS=$(JSX_SOURCE:.jsx=.js)
16 all: $(JS_TARGETS) $(REACT_DEPS)
18 # Execute either of the following to build things:
20 # For a development build:
24 # For a production build:
26 # make LMNO_BUILD=production
28 # Note: To switch between these two, either issue a "make clean"
29 # or otherwise start in a clean source tree (such as a
30 # after a fresh "git clone" or use "git clean -f -x -d).
34 ifeq ($(LMNO_BUILD),production)
35 react.js: deps/react.production.min.js
36 $(call quiet,CP) $^ $@
38 react-dom.js: deps/react-dom.production.min.js
39 $(call quiet,CP) $^ $@
41 export BABEL_ENV=production
43 $(call quiet,BABEL) $^ --out-file $@
45 react.js: deps/react.development.js
46 $(call quiet,CP) $^ $@
48 react-dom.js: deps/react-dom.development.js
49 $(call quiet,CP) $^ $@
51 export BABEL_ENV=development
53 $(call quiet,BABEL) $^ --out-file $@
56 # The user has not set any verbosity, default to quiet mode and inform the
57 # user how to enable verbose compiles.
59 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
60 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$(1) $(or $(2),$@)\n"; $($(word 1, $(1)))
61 WGET_VERBOSE_FLAGS=--quiet
63 # The user has explicitly enabled quiet compilation.
65 quiet = @printf "$(1) $(or $(2),$@)\n"; $($(word 1, $(1)))
66 WGET_VERBOSE_FLAGS=--quiet
68 # Otherwise, print the full command line.
69 quiet ?= $($(word 1, $(1)))
70 WGET_VERBOSE_FLAGS ?= --no-verbose
72 SHA512=sha512sum --strict -c
74 deps: $(REACT_DOWNLOADS)
75 $(call quiet,SHA512) deps/*.sha512
77 DOWNLOAD=wget $(WGET_VERBOSE_FLAGS) -nc -P deps
79 $(call quiet,DOWNLOAD) https://unpkg.com/react@16/umd/$(@:deps/%=%)
80 $(call quiet,SHA512) $(@:%=%.sha512)
83 $(call quiet,DOWNLOAD) https://unpkg.com/react-dom@16/umd/$(@:deps/%=%)
84 $(call quiet,SHA512) $(@:%=%.sha512)
88 git clone . .deploy-source
89 cp deps/*.js .deploy-source/deps
90 make -C .deploy-source deps
91 make -C .deploy-source LMNO_BUILD=production
92 rm -rf .deploy-source/.git
93 (cd .deploy-source; rsync -avz \
94 $(DO_NOT_DEPLOY:%=--exclude=%) \
95 --exclude=$(DO_NOT_DELETE) \
98 ./ $(DEPLOY_HOST):$(DEPLOY_DIR) )