Clean trailing whitespace from all files.
[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 RHINO ?= java -jar ${BUILD_DIR}/js.jar
11
12 CLOSURE_COMPILER = ${BUILD_DIR}/google-compiler-20100917.jar
13
14 MINJAR ?= java -jar ${CLOSURE_COMPILER}
15
16 BASE_FILES = ${SRC_DIR}/core.js\
17         ${SRC_DIR}/support.js\
18         ${SRC_DIR}/data.js\
19         ${SRC_DIR}/queue.js\
20         ${SRC_DIR}/attributes.js\
21         ${SRC_DIR}/event.js\
22         ${SRC_DIR}/selector.js\
23         ${SRC_DIR}/traversing.js\
24         ${SRC_DIR}/manipulation.js\
25         ${SRC_DIR}/css.js\
26         ${SRC_DIR}/ajax.js\
27         ${SRC_DIR}/xhr.js\
28         ${SRC_DIR}/transports/jsonp.js\
29         ${SRC_DIR}/transports/script.js\
30         ${SRC_DIR}/transports/xhr.js\
31         ${SRC_DIR}/effects.js\
32         ${SRC_DIR}/offset.js\
33         ${SRC_DIR}/dimensions.js
34
35 MODULES = ${SRC_DIR}/intro.js\
36         ${BASE_FILES}\
37         ${SRC_DIR}/outro.js
38
39 JQ = ${DIST_DIR}/jquery.js
40 JQ_MIN = ${DIST_DIR}/jquery.min.js
41
42 SIZZLE_DIR = ${SRC_DIR}/sizzle
43 QUNIT_DIR = ${TEST_DIR}/qunit
44
45 JQ_VER = $(shell cat version.txt)
46 VER = sed "s/@VERSION/${JQ_VER}/"
47
48 DATE=$(shell git log -1 --pretty=format:%ad)
49
50 all: init jquery min lint
51         @@echo "jQuery build complete."
52
53 ${DIST_DIR}:
54         @@mkdir -p ${DIST_DIR}
55
56 ifeq ($(strip $(V)),0)
57 verbose = --quiet
58 else ifeq ($(strip $(V)),1)
59 verbose =
60 else
61 verbose = --verbose
62 endif
63
64 define clone_or_pull
65 -@@if test ! -d $(strip ${1})/.git; then \
66                 echo "Cloning $(strip ${1})..."; \
67                 git clone $(strip ${verbose}) --depth=1 $(strip ${2}) $(strip ${1}); \
68         else \
69                 echo "Pulling $(strip ${1})..."; \
70                 git --git-dir=$(strip ${1})/.git pull $(strip ${verbose}) origin master; \
71         fi
72
73 endef
74
75 init:
76         $(call clone_or_pull, ${QUNIT_DIR}, git://github.com/jquery/qunit.git)
77         $(call clone_or_pull, ${SIZZLE_DIR}, git://github.com/jeresig/sizzle.git)
78
79 jquery: ${JQ}
80 jq: ${JQ}
81
82 ${JQ}: ${MODULES} ${DIST_DIR}
83         @@echo "Building" ${JQ}
84
85         @@cat ${MODULES} | \
86                 sed 's/.function..jQuery...{//' | \
87                 sed 's/}...jQuery..;//' | \
88                 sed 's/@DATE/'"${DATE}"'/' | \
89                 ${VER} > ${JQ};
90
91 ${SRC_DIR}/selector.js: ${SIZZLE_DIR}/sizzle.js
92         @@echo "Building selector code from Sizzle"
93         @@sed '/EXPOSE/r src/sizzle-jquery.js' ${SIZZLE_DIR}/sizzle.js | grep -v window.Sizzle > ${SRC_DIR}/selector.js
94
95 lint: ${JQ}
96         @@echo "Checking jQuery against JSLint..."
97         @@${RHINO} build/jslint-check.js
98
99 min: ${JQ_MIN}
100
101 ${JQ_MIN}: ${JQ}
102         @@echo "Building" ${JQ_MIN}
103
104         @@head -15 ${JQ} > ${JQ_MIN}
105         @@${MINJAR} --js ${JQ} --warning_level QUIET --js_output_file ${JQ_MIN}.tmp
106         @@cat ${JQ_MIN}.tmp >> ${JQ_MIN}
107         @@rm -f ${JQ_MIN}.tmp
108
109 clean:
110         @@echo "Removing Distribution directory:" ${DIST_DIR}
111         @@rm -rf ${DIST_DIR}
112
113         @@echo "Removing built copy of Sizzle"
114         @@rm -f src/selector.js
115
116         @@echo "Removing cloned directories"
117         @@rm -rf test/qunit src/sizzle
118
119 .PHONY: all jquery lint min init jq clean