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 $@
46 react.js: deps/react.development.js
47 $(call quiet,CP) $^ $@
49 react-dom.js: deps/react-dom.development.js
50 $(call quiet,CP) $^ $@
52 export BABEL_ENV=development
54 $(call quiet,BABEL) $^ --out-file $@
58 # The user has not set any verbosity, default to quiet mode and inform the
59 # user how to enable verbose compiles.
61 quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
62 quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$(1) $(or $(2),$@)\n"; $($(word 1, $(1)))
63 WGET_VERBOSE_FLAGS=--quiet
65 # The user has explicitly enabled quiet compilation.
67 quiet = @printf "$(1) $(or $(2),$@)\n"; $($(word 1, $(1)))
68 WGET_VERBOSE_FLAGS=--quiet
70 # Otherwise, print the full command line.
71 quiet ?= $($(word 1, $(1)))
72 WGET_VERBOSE_FLAGS ?= --no-verbose
74 SHA512=sha512sum --strict -c
76 deps: $(REACT_DOWNLOADS)
77 $(call quiet,SHA512) deps/*.sha512
79 DOWNLOAD=wget $(WGET_VERBOSE_FLAGS) -nc -P deps
81 $(call quiet,DOWNLOAD) https://unpkg.com/react@16/umd/$@
82 $(call quiet,SHA512) $(patsubst %,%.sha512,$@)
86 git clone . .deploy-source
87 cp deps/*.js .deploy-source/deps
88 make -C .deploy-source deps
89 make -C .deploy-source LMNO_BUILD=production
90 rm -rf .deploy-source/.git
91 (cd .deploy-source; rsync -avz \
92 $(DO_NOT_DEPLOY:%=--exclude=%) \
93 --exclude=$(DO_NOT_DELETE) \
96 ./ $(DEPLOY_HOST):$(DEPLOY_DIR) )