9ef44cff14af15ef30743069ecfd7bd1f74bd464
[jquery.git] / Makefile
1 SRC_DIR = src
2 TEST_DIR = test
3 BUILD_DIR = build
4
5 PREFIX = .
6 DIST_DIR = ${PREFIX}/dist
7
8 JS_ENGINE ?= `which node nodejs`
9 COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
10 POST_COMPILER = ${JS_ENGINE} ${BUILD_DIR}/post-compile.js
11
12 BASE_FILES = ${SRC_DIR}/core.js\
13         ${SRC_DIR}/deferred.js\
14         ${SRC_DIR}/support.js\
15         ${SRC_DIR}/data.js\
16         ${SRC_DIR}/queue.js\
17         ${SRC_DIR}/attributes.js\
18         ${SRC_DIR}/event.js\
19         ${SRC_DIR}/selector.js\
20         ${SRC_DIR}/traversing.js\
21         ${SRC_DIR}/manipulation.js\
22         ${SRC_DIR}/css.js\
23         ${SRC_DIR}/ajax.js\
24         ${SRC_DIR}/ajax/jsonp.js\
25         ${SRC_DIR}/ajax/script.js\
26         ${SRC_DIR}/ajax/xhr.js\
27         ${SRC_DIR}/effects.js\
28         ${SRC_DIR}/offset.js\
29         ${SRC_DIR}/dimensions.js
30
31 MODULES = ${SRC_DIR}/intro.js\
32         ${BASE_FILES}\
33         ${SRC_DIR}/outro.js
34
35 JQ = ${DIST_DIR}/jquery.js
36 JQ_MIN = ${DIST_DIR}/jquery.min.js
37
38 SIZZLE_DIR = ${SRC_DIR}/sizzle
39
40 JQ_VER = $(shell cat version.txt)
41 VER = sed "s/@VERSION/${JQ_VER}/"
42
43 DATE=$(shell git log -1 --pretty=format:%ad)
44
45 all: update_submodules jquery min lint
46         @@echo "jQuery build complete."
47
48 ${DIST_DIR}:
49         @@mkdir -p ${DIST_DIR}
50
51 jquery: ${JQ}
52
53 ${JQ}: ${MODULES} | ${DIST_DIR}
54         @@echo "Building" ${JQ}
55
56         @@cat ${MODULES} | \
57                 sed 's/.function..jQuery...{//' | \
58                 sed 's/}...jQuery..;//' | \
59                 sed 's/@DATE/'"${DATE}"'/' | \
60                 ${VER} > ${JQ};
61
62 ${SRC_DIR}/selector.js: ${SIZZLE_DIR}/sizzle.js
63         @@echo "Building selector code from Sizzle"
64         @@sed '/EXPOSE/r src/sizzle-jquery.js' ${SIZZLE_DIR}/sizzle.js | grep -v window.Sizzle > ${SRC_DIR}/selector.js
65
66 lint: jquery
67         @@if test ! -z ${JS_ENGINE}; then \
68                 echo "Checking jQuery against JSLint..."; \
69                 ${JS_ENGINE} build/jslint-check.js; \
70         else \
71                 echo "You must have NodeJS installed in order to test jQuery against JSLint."; \
72         fi
73
74 min: ${JQ_MIN}
75
76 ${JQ_MIN}: jquery
77         @@if test ! -z ${JS_ENGINE}; then \
78                 echo "Minifying jQuery" ${JQ_MIN}; \
79                 ${COMPILER} ${JQ} > ${JQ_MIN}.tmp; \
80                 ${POST_COMPILER} ${JQ_MIN}.tmp > ${JQ_MIN}; \
81                 rm -f ${JQ_MIN}.tmp; \
82         else \
83                 echo "You must have NodeJS installed in order to minify jQuery."; \
84         fi
85         
86
87 clean:
88         @@echo "Removing Distribution directory:" ${DIST_DIR}
89         @@rm -rf ${DIST_DIR}
90
91         @@echo "Removing built copy of Sizzle"
92         @@rm -f src/selector.js
93
94 distclean: clean
95         @@echo "Removing submodules"
96         @@rm -rf test/qunit src/sizzle
97
98 # change pointers for submodules and update them to what is specified in jQuery
99 update_submodules:
100         @@if [ -d .git ]; then git submodule update --init --recursive --merge; fi
101
102 # update the submodules to the latest at the most logical branch
103 pull_submodules:
104         @@git submodule foreach "git pull origin \$$(git branch --no-color --contains \$$(git rev-parse HEAD) | grep -v \( | head -1)"
105         @@git submodule summary
106
107 pull: pull_submodules
108         @@git pull ${REMOTE} ${BRANCH}
109
110 .PHONY: all jquery lint min init jq clean