X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=Makefile;h=74233b0ad221be2a3855440d1b5da92a4dac32f1;hp=cac62148ceba6fd43870edfb4a65b43ddccf2e89;hb=7981f047e7ad9da24f76e6aded3c516c8f2dc563;hpb=7e0909ae536ff9257082815dbcbe17e0cda32b8a diff --git a/Makefile b/Makefile index cac6214..74233b0 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,83 @@ DEPLOY_HOST=lmno.games DEPLOY_DIR=/srv/lmno.games/www -DO_NOT_DEPLOY="Makefile" +DO_NOT_DEPLOY=Makefile deps *.jsx .babelrc .gitignore README DO_NOT_DELETE=flempires +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 + +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 $^ $@ + +%.js: %.jsx + BABEL_ENV=production babeljs $^ --out-file $@ +else +react.js: deps/react.development.js + cp $^ $@ + +react-dom.js: deps/react-dom.development.js + cp $^ $@ + +%.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 + +deps/react-dom.development.js: + wget -nv -nc -P deps https://unpkg.com/react-dom@16/umd/react-dom.development.js + +deps/react.production.min.js: + wget -nv -nc -P deps https://unpkg.com/react@16/umd/react.production.min.js + +deps/react-dom.production.min.js: + wget -nv -nc -P deps https://unpkg.com/react-dom@16/umd/react-dom.production.min.js + deploy: rm -rf .deploy-source git clone . .deploy-source + make -C .deploy-source LMNO_BUILD=production rm -rf .deploy-source/.git (cd .deploy-source; rsync -avz \ - --exclude=$(DO_NOT_DEPLOY) \ + $(DO_NOT_DEPLOY:%=--exclude=%) \ --exclude=$(DO_NOT_DELETE) \ --delete \ --delete-after \ ./ $(DEPLOY_HOST):$(DEPLOY_DIR) ) rm -rf .deploy-source + +clean: + rm -f $(JS_TARGETS) + rm -f $(REACT_DEPS) + rm -f $(REACT_DOWNLOADS)