Landing pull request 511. Adding a little Makefile jQuery sizing utility to easily...
[jquery.git] / Makefile
blob59f63bdd9b60760ca59fda2da136789741abd55b
1 SRC_DIR = src
2 TEST_DIR = test
3 BUILD_DIR = build
5 PREFIX = .
6 DIST_DIR = ${PREFIX}/dist
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
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
31 MODULES = ${SRC_DIR}/intro.js\
32 ${BASE_FILES}\
33 ${SRC_DIR}/outro.js
35 JQ = ${DIST_DIR}/jquery.js
36 JQ_MIN = ${DIST_DIR}/jquery.min.js
38 SIZZLE_DIR = ${SRC_DIR}/sizzle
40 JQ_VER = $(shell cat version.txt)
41 VER = sed "s/@VERSION/${JQ_VER}/"
43 DATE=$(shell git log -1 --pretty=format:%ad)
45 all: update_submodules core
47 core: jquery min lint size
48 @@echo "jQuery build complete."
50 ${DIST_DIR}:
51 @@mkdir -p ${DIST_DIR}
53 jquery: ${JQ}
55 ${JQ}: ${MODULES} | ${DIST_DIR}
56 @@echo "Building" ${JQ}
58 @@cat ${MODULES} | \
59 sed 's/.function..jQuery...{//' | \
60 sed 's/}...jQuery..;//' | \
61 sed 's/@DATE/'"${DATE}"'/' | \
62 ${VER} > ${JQ};
64 ${SRC_DIR}/selector.js: ${SIZZLE_DIR}/sizzle.js
65 @@echo "Building selector code from Sizzle"
66 @@sed '/EXPOSE/r src/sizzle-jquery.js' ${SIZZLE_DIR}/sizzle.js | grep -v window.Sizzle > ${SRC_DIR}/selector.js
68 lint: jquery
69 @@if test ! -z ${JS_ENGINE}; then \
70 echo "Checking jQuery against JSLint..."; \
71 ${JS_ENGINE} build/jslint-check.js; \
72 else \
73 echo "You must have NodeJS installed in order to test jQuery against JSLint."; \
76 size: jquery min
77 @@if test ! -z ${JS_ENGINE}; then \
78 gzip -c ${JQ_MIN} > ${JQ_MIN}.gz; \
79 wc -c ${JQ} ${JQ_MIN} ${JQ_MIN}.gz | ${JS_ENGINE} ${BUILD_DIR}/sizer.js; \
80 rm ${JQ_MIN}.gz; \
81 else \
82 echo "You must have NodeJS installed in order to size jQuery."; \
85 min: jquery ${JQ_MIN}
87 ${JQ_MIN}: ${JQ}
88 @@if test ! -z ${JS_ENGINE}; then \
89 echo "Minifying jQuery" ${JQ_MIN}; \
90 ${COMPILER} ${JQ} > ${JQ_MIN}.tmp; \
91 ${POST_COMPILER} ${JQ_MIN}.tmp > ${JQ_MIN}; \
92 rm -f ${JQ_MIN}.tmp; \
93 else \
94 echo "You must have NodeJS installed in order to minify jQuery."; \
97 clean:
98 @@echo "Removing Distribution directory:" ${DIST_DIR}
99 @@rm -rf ${DIST_DIR}
101 @@echo "Removing built copy of Sizzle"
102 @@rm -f src/selector.js
104 distclean: clean
105 @@echo "Removing submodules"
106 @@rm -rf test/qunit src/sizzle
108 # change pointers for submodules and update them to what is specified in jQuery
109 # --merge doesn't work when doing an initial clone, thus test if we have non-existing
110 # submodules, then do an real update
111 update_submodules:
112 @@if [ -d .git ]; then \
113 if git submodule status | grep -q -E '^-'; then \
114 git submodule update --init --recursive; \
115 else \
116 git submodule update --init --recursive --merge; \
117 fi; \
120 # update the submodules to the latest at the most logical branch
121 pull_submodules:
122 @@git submodule foreach "git pull \$$(git config remote.origin.url)"
123 @@git submodule summary
125 pull: pull_submodules
126 @@git pull ${REMOTE} ${BRANCH}
128 .PHONY: all jquery lint min clean distclean update_submodules pull_submodules pull core