Moves Deferred-related code into a separate module. Context handling has been simplif...
[jquery.git] / Makefile
1 V ?= 0
2
3 SRC_DIR = src
4 TEST_DIR = test
5 BUILD_DIR = build
6
7 PREFIX = .
8 DIST_DIR = ${PREFIX}/dist
9
10 JS_ENGINE ?= `which node nodejs`
11 COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
12 POST_COMPILER = ${JS_ENGINE} ${BUILD_DIR}/post-compile.js
13
14 BASE_FILES = ${SRC_DIR}/core.js\
15         ${SRC_DIR}/deferred.js\
16         ${SRC_DIR}/support.js\
17         ${SRC_DIR}/data.js\
18         ${SRC_DIR}/queue.js\
19         ${SRC_DIR}/attributes.js\
20         ${SRC_DIR}/event.js\
21         ${SRC_DIR}/selector.js\
22         ${SRC_DIR}/traversing.js\
23         ${SRC_DIR}/manipulation.js\
24         ${SRC_DIR}/css.js\
25         ${SRC_DIR}/ajax.js\
26         ${SRC_DIR}/ajax/jsonp.js\
27         ${SRC_DIR}/ajax/script.js\
28         ${SRC_DIR}/ajax/xhr.js\
29         ${SRC_DIR}/effects.js\
30         ${SRC_DIR}/offset.js\
31         ${SRC_DIR}/dimensions.js
32
33 MODULES = ${SRC_DIR}/intro.js\
34         ${BASE_FILES}\
35         ${SRC_DIR}/outro.js
36
37 JQ = ${DIST_DIR}/jquery.js
38 JQ_MIN = ${DIST_DIR}/jquery.min.js
39
40 SIZZLE_DIR = ${SRC_DIR}/sizzle
41 QUNIT_DIR = ${TEST_DIR}/qunit
42
43 JQ_VER = $(shell cat version.txt)
44 VER = sed "s/@VERSION/${JQ_VER}/"
45
46 DATE=$(shell git log -1 --pretty=format:%ad)
47
48 all: jquery min lint
49         @@echo "jQuery build complete."
50
51 ${DIST_DIR}:
52         @@mkdir -p ${DIST_DIR}
53
54 ifeq ($(strip $(V)),0)
55 verbose = --quiet
56 else ifeq ($(strip $(V)),1)
57 verbose =
58 else
59 verbose = --verbose
60 endif
61
62 define clone_or_pull
63 -@@if test ! -d $(strip ${1})/.git; then \
64                 echo "Cloning $(strip ${1})..."; \
65                 git clone $(strip ${verbose}) --depth=1 $(strip ${2}) $(strip ${1}); \
66         else \
67                 echo "Pulling $(strip ${1})..."; \
68                 git --git-dir=$(strip ${1})/.git pull $(strip ${verbose}) origin master; \
69         fi
70
71 endef
72
73 ${QUNIT_DIR}:
74         $(call clone_or_pull, ${QUNIT_DIR}, git://github.com/jquery/qunit.git)
75
76 ${SIZZLE_DIR}:
77         $(call clone_or_pull, ${SIZZLE_DIR}, git://github.com/jeresig/sizzle.git)
78
79 init: ${QUNIT_DIR} ${SIZZLE_DIR}
80
81 jquery: init ${JQ}
82 jq: init ${JQ}
83
84 ${JQ}: ${MODULES} | ${DIST_DIR}
85         @@echo "Building" ${JQ}
86
87         @@cat ${MODULES} | \
88                 sed 's/.function..jQuery...{//' | \
89                 sed 's/}...jQuery..;//' | \
90                 sed 's/@DATE/'"${DATE}"'/' | \
91                 ${VER} > ${JQ};
92
93 ${SRC_DIR}/selector.js: ${SIZZLE_DIR}/sizzle.js
94         @@echo "Building selector code from Sizzle"
95         @@sed '/EXPOSE/r src/sizzle-jquery.js' ${SIZZLE_DIR}/sizzle.js | grep -v window.Sizzle > ${SRC_DIR}/selector.js
96
97 lint: jquery
98         @@if test ! -z ${JS_ENGINE}; then \
99                 echo "Checking jQuery against JSLint..."; \
100                 ${JS_ENGINE} build/jslint-check.js; \
101         else \
102                 echo "You must have NodeJS installed in order to test jQuery against JSLint."; \
103         fi
104
105 min: ${JQ_MIN}
106
107 ${JQ_MIN}: jquery
108         @@if test ! -z ${JS_ENGINE}; then \
109                 echo "Minifying jQuery" ${JQ_MIN}; \
110                 ${COMPILER} ${JQ} > ${JQ_MIN}.tmp; \
111                 ${POST_COMPILER} ${JQ_MIN}.tmp > ${JQ_MIN}; \
112                 rm -f ${JQ_MIN}.tmp; \
113         else \
114                 echo "You must have NodeJS installed in order to minify jQuery."; \
115         fi
116         
117
118 clean:
119         @@echo "Removing Distribution directory:" ${DIST_DIR}
120         @@rm -rf ${DIST_DIR}
121
122         @@echo "Removing built copy of Sizzle"
123         @@rm -f src/selector.js
124
125         @@echo "Removing cloned directories"
126         @@rm -rf test/qunit src/sizzle
127
128 .PHONY: all jquery lint min init jq clean