X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=Makefile;h=74233b0ad221be2a3855440d1b5da92a4dac32f1;hp=ee69598e27ca527d25bc723cced9f081bd6500c7;hb=7981f047e7ad9da24f76e6aded3c516c8f2dc563;hpb=7df3bbda08d2305fc9149db3adc007bfd1d4bbf5 diff --git a/Makefile b/Makefile index ee69598..74233b0 100644 --- a/Makefile +++ b/Makefile @@ -3,23 +3,54 @@ DEPLOY_DIR=/srv/lmno.games/www DO_NOT_DEPLOY=Makefile deps *.jsx .babelrc .gitignore README DO_NOT_DELETE=flempires -DEPS=deps/react.development.js \ -deps/react-dom.development.js \ -deps/react.production.min.js \ -deps/react-dom.production.min.js +REACT_DEPS=react.js react-dom.js +REACT_DOWNLOADS=\ + deps/react.development.js \ + deps/react-dom.development.js \ + deps/react.production.min.js \ + deps/react-dom.production.min.js -checksums: - sha512sum --strict -c checksums.sha512 +JSX_SOURCE=$(wildcard */*.jsx) +JS_TARGETS=$(JSX_SOURCE:.jsx=.js) + +all: $(JS_TARGETS) $(REACT_DEPS) + +# Execute either of the following to build things: +# +# For a development build: +# +# make +# +# For a production build: +# +# make LMNO_BUILD=production +# +# Note: To switch between these two, either issue a "make clean" +# or otherwise start in a clean source tree (such as a +# after a fresh "git clone" or use "git clean -f -x -d). +# +ifeq ($(LMNO_BUILD),production) +react.js: deps/react.production.min.js + cp $^ $@ + +react-dom.js: deps/react-dom.production.min.js + cp $^ $@ -deps: $(DEPS) checksums +%.js: %.jsx + BABEL_ENV=production babeljs $^ --out-file $@ +else +react.js: deps/react.development.js + cp $^ $@ -dev: deps - cp deps/react.development.js react.js - cp deps/react-dom.development.js react-dom.js +react-dom.js: deps/react-dom.development.js + cp $^ $@ -prod: deps - cp deps/react.production.min.js react.js - cp deps/react-dom.production.min.js react-dom.js +%.js: %.jsx + BABEL_ENV=development babeljs $^ --out-file $@ +endif + +checksums: $(REACT_DOWNLOADS) + sha512sum --strict -c checksums.sha512 deps/react.development.js: wget -nv -nc -P deps https://unpkg.com/react@16/umd/react.development.js @@ -36,7 +67,7 @@ deps/react-dom.production.min.js: deploy: rm -rf .deploy-source git clone . .deploy-source - make -C .deploy-source prod + make -C .deploy-source LMNO_BUILD=production rm -rf .deploy-source/.git (cd .deploy-source; rsync -avz \ $(DO_NOT_DEPLOY:%=--exclude=%) \ @@ -45,3 +76,8 @@ deploy: --delete-after \ ./ $(DEPLOY_HOST):$(DEPLOY_DIR) ) rm -rf .deploy-source + +clean: + rm -f $(JS_TARGETS) + rm -f $(REACT_DEPS) + rm -f $(REACT_DOWNLOADS)