forked from derek-watson/jsUri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
86 lines (65 loc) · 2.06 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
SRC_DIR = src
SPEC_DIR = spec
BUILD_DIR = build
PREFIX = .
DIST_DIR = ${PREFIX}/dist
JS_ENGINE ?= `which node nodejs 2>/dev/null`
LINT = `which jshint 2>/dev/null`
UGLIFY ?= `which uglifyjs 2>/dev/null`
POST_UGLIFY = ${JS_ENGINE} ${BUILD_DIR}/post-uglify.js
BASE_FILES = ${SRC_DIR}/query.js ${SRC_DIR}/uri.js
MODULES = ${SRC_DIR}/intro.js ${BASE_FILES} ${SRC_DIR}/outro.js
VERSION = $(shell cat version.txt | sed ':a;N;$!ba;s/\n/ /g')
REPLACE_VER = sed "s/@VERSION/${VERSION}/"
JSURI = ${DIST_DIR}/jsuri.js
JSURI_MIN = ${DIST_DIR}/jsuri.min.js
JSURI_V = ${DIST_DIR}/jsuri-${VERSION}.js
JSURI_MINV = ${DIST_DIR}/jsuri-${VERSION}.min.js
DATE=$(shell git log -1 --pretty=format:%ad)
PANDOC ?= `which pandoc 2>/dev/null`
README_WIKI = ${DIST_DIR}/README.wiki
all: core
core: dist_dir jsuri min lint v minv readme_wiki
@@echo "jsUri build complete."
dist_dir:
@@mkdir -p ${DIST_DIR}
jsuri:
@@echo 'Building' ${JSURI}
@@cat ${MODULES} | \
sed 's/@DATE/'"${DATE}"'/' | \
sed "s/@VERSION/${VERSION}/" > ${JSURI};
lint: jsuri
@@if test ! -z ${LINT}; then \
echo "Checking jsUri against JSHint..."; \
${LINT} ${JSURI}; \
else \
@@echo "You must have JSHint installed in order to lint jsUri."; \
fi
min: jsuri
@@if test ! -z ${UGLIFY}; then \
echo "Minifying " ${JSURI_MIN}; \
${UGLIFY} ${JSURI} > ${JSURI_MIN}.tmp; \
${POST_UGLIFY} ${JSURI_MIN}.tmp > ${JSURI_MIN}; \
rm -f ${JSURI_MIN}.tmp; \
else \
@@echo "You must have uglifyjs installed in order to minify jsUri."; \
fi
v: jsuri dist_dir
@@echo "Copying ${JSURI} to ${JSURI_V}";
@@cp ${JSURI} ${JSURI_V}
minv: min dist_dir
@@echo "Copying ${JSURI_MIN} to ${JSURI_MINV}";
@@cp ${JSURI_MIN} ${JSURI_MINV}
readme_wiki:
@@if test ! -z ${PANDOC}; then \
echo "Building ${README_WIKI}..."; \
${PANDOC} -f markdown -t mediawiki README.md | \
sed "s/<pre>/\n{{{\n/" | \
sed "s/<\/pre>/\n}}}\n/" \
> ${README_WIKI}; \
else \
@@echo "You must have pandoc installed in order to convert README.md to README.wiki."; \
fi
clean:
@@echo "Removing Distribution directory:" ${DIST_DIR}
@@rm -rf ${DIST_DIR}