summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakpu1 <akpu1@inventati.org>2016-06-22 07:23:29 +0200
committerEliot Whalan <ewhal@pantsu.cat>2016-06-22 07:23:29 +0200
commit0d539ff4af4bb62d783d1920abb4158655645398 (patch)
treebb7086343b8c7f6fe14fa8af630b5ee4031f9563
parente0717d467120f25c007bf6a80eb26091ce878d56 (diff)
Significant Makefile improvements (#21)
* Refactored makefile Fixed min-js error; renamed routines inline with make conventions Previously min-js would continually append to the file with `@echo "// @source https://github.com/pomf/pomf/tree/master/static/js" >> ./dist/pomf.min.js`. Fixed so that it overwrites the file whenever it is run now. mkdirs was renamed to installdirs as per makefile conwentions copy was renamed to install for the same reasons Added clean rule Removed install from default target Added DESTDIR,uninstall support Added dist support Replaced static program paths; misc improvements Added missing installdirs target to default target Added npm_dependencies target Properly separated "build" and install targets Modified readme to reflect make install and DESTDIR Modified .travis.yml to reflect make npm_dependencies Reverted to cp for install target, temporarily Ideally this target would use install, but need to work out how to do that properly, For the meantime, cp works. Added missing * to install target Update .travis.yml Fixed bad markdown * Update Makefile * Removed @s cuz ???
-rw-r--r--.travis.yml1
-rw-r--r--Makefile75
-rw-r--r--README.md18
3 files changed, 64 insertions, 30 deletions
diff --git a/.travis.yml b/.travis.yml
index 73bf6c4..d851b4e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,6 @@ install:
- nvm ls-remote
- nvm install stable
- nvm use stable
-- npm install
script:
- make
diff --git a/Makefile b/Makefile
index 2addcd5..96b3118 100644
--- a/Makefile
+++ b/Makefile
@@ -1,31 +1,62 @@
-all: mkdirs swig htmlmin min-css min-js copy
+INSTALL="install"
+TAR="tar"
+GREP="grep"
+NODE="node"
+NPM="npm"
+DESTDIR="./dist"
+PKG_VERSION := $( $(GREP) -Po '(?<="version": ")[^"]*' )
+TMPDIR := $(shell mktemp -d)
+
+all: builddirs npm_dependencies swig htmlmin min-css min-js copy-img copy-php
swig:
- @node node_modules/swig/bin/swig.js render -j dist.json templates/faq.swig > dist/faq.html
- @node node_modules/swig/bin/swig.js render -j dist.json templates/index.swig > dist/index.html
- @node node_modules/swig/bin/swig.js render -j dist.json templates/tools.swig > dist/tools.html
+ $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/faq.swig > $(CURDIR)/build/faq.html
+ $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/index.swig > $(CURDIR)/build/index.html
+ $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/tools.swig > $(CURDIR)/build/tools.html
htmlmin:
- @node node_modules/htmlmin/bin/htmlmin dist/index.html -o dist/index.html
- @node node_modules/htmlmin/bin/htmlmin dist/faq.html -o dist/faq.html
- @node node_modules/htmlmin/bin/htmlmin dist/tools.html -o dist/tools.html
-
-
-mkdirs:
- @mkdir -p ./dist/img
+ $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/index.html -o $(CURDIR)/build/index.html
+ $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/faq.html -o $(CURDIR)/build/faq.html
+ $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/tools.html -o $(CURDIR)/build/tools.html
+installdirs:
+ mkdir -p $(DESTDIR)/ $(DESTDIR)/img $(DESTDIR)/classes $(DESTDIR)/includes
+
min-css:
- @node ./node_modules/.bin/cleancss --s0 ./static/css/pomf.css > ./dist/pomf.min.css
+ $(NODE) ./node_modules/.bin/cleancss --s0 ./static/css/pomf.css > $(CURDIR)/build/pomf.min.css
min-js:
- @echo "// @source https://github.com/pomf/pomf/tree/master/static/js" >> ./dist/pomf.min.js
- @echo "// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat" >> ./dist/pomf.min.js
- @node ./node_modules/.bin/uglifyjs --screw-ie8 ./static/js/app.js >> ./dist/pomf.min.js
- @echo "// @license-end" >> ./dist/pomf.min.js
-
-copy:
- @cp -r ./php/* ./dist/
- @cp ./static/img/*.png ./dist/img
- @cp ./static/img/favicon.ico ./dist/favicon.ico
-
+ echo "// @source https://github.com/pomf/pomf/tree/master/static/js" > $(CURDIR)/build/pomf.min.js
+ echo "// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat" >> $(CURDIR)/build/pomf.min.js
+ $(NODE) ./node_modules/.bin/uglifyjs --screw-ie8 ./static/js/app.js >> $(CURDIR)/build/pomf.min.js
+ echo "// @license-end" >> $(CURDIR)/build/pomf.min.js
+
+copy-img:
+ cp -v ./static/img/*.png $(CURDIR)/build/img/
+ cp -vT ./static/img/favicon.ico $(CURDIR)/build/favicon.ico
+
+copy-php:
+ cp -rv ./php/* $(CURDIR)/build/
+
+install: installdirs
+ cp -rv $(CURDIR)/build/* $(DESTDIR)/
+
+dist:
+ DESTDIR=$(TMPDIR)/pomf-$(PKGVERSION)
+ export DESTDIR
+ install
+ $(TAR) cJf pomf-$(PKG_VERSION).tar.xz $(DESTDIR)
+ rm -rf $(TMPDIR)
+
+clean:
+ rm -rvf $(CURDIR)/node_modules
+ rm -rvf $(CURDIR)/build
+
+uninstall:
+ rm -rvf $(DESTDIR)/
+
+npm_dependencies:
+ $(NPM) install
+builddirs:
+ mkdir -p $(CURDIR)/build $(CURDIR)/build/img $(CURDIR)/build/classes $(CURDIR)/build/includes
diff --git a/README.md b/README.md
index df781f5..6e43462 100644
--- a/README.md
+++ b/README.md
@@ -41,13 +41,17 @@ Node, or NPM. So we'll just assume you already have them all running well.
Assuming you already have Node and NPM working, compilation is easy. Use the
following shell code:
-
- git clone https://github.com/pomf/pomf
- cd pomf/
- npm install
- make
-
-After this, the pomf site is now compressed and set up inside `dist/`.
+```bash
+git clone https://github.com/pomf/pomf
+cd pomf/
+make
+make install
+```
+OR
+```bash
+make install DESTDIR=/desired/path/for/site
+```
+After this, the pomf site is now compressed and set up inside `dist/`, or, if specified, `DESTDIR`.
## Configuring