Updating the copy of Google Closure Compiler.
[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}/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 QUNIT_DIR = ${TEST_DIR}/qunit
40
41 JQ_VER = $(shell cat version.txt)
42 VER = sed s/@VERSION/${JQ_VER}/
43
44 DATE=$(shell git log -1 --pretty=format:%ad)
45
46 all: init jquery min lint
47         @@echo "jQuery build complete."
48
49 ${DIST_DIR}:
50         @@mkdir -p ${DIST_DIR}
51
52 ifeq ($(strip $(V)),0)
53 verbose = --quiet
54 else ifeq ($(strip $(V)),1)
55 verbose =
56 else
57 verbose = --verbose
58 endif
59
60 define clone_or_pull
61 -@@if test ! -d $(strip ${1})/.git; then \
62                 echo "Cloning $(strip ${1})..."; \
63                 git clone $(strip ${verbose}) --depth=1 $(strip ${2}) $(strip ${1}); \
64         else \
65                 echo "Pulling $(strip ${1})..."; \
66                 git --git-dir=$(strip ${1})/.git pull $(strip ${verbose}) origin master; \
67         fi
68
69 endef
70
71 init:
72         $(call clone_or_pull, ${QUNIT_DIR}, git://github.com/jquery/qunit.git)
73         $(call clone_or_pull, ${SIZZLE_DIR}, git://github.com/jeresig/sizzle.git)
74
75 jquery: ${JQ}
76 jq: ${JQ}
77
78 ${JQ}: ${MODULES} ${DIST_DIR}
79         @@echo "Building" ${JQ}
80
81         @@cat ${MODULES} | \
82                 sed 's/.function..jQuery...{//' | \
83                 sed 's/}...jQuery..;//' | \
84                 sed 's/Date:./&'"${DATE}"'/' | \
85                 ${VER} > ${JQ};
86
87 ${SRC_DIR}/selector.js: ${SIZZLE_DIR}/sizzle.js
88         @@echo "Building selector code from Sizzle"
89         @@sed '/EXPOSE/r src/sizzle-jquery.js' ${SIZZLE_DIR}/sizzle.js | grep -v window.Sizzle > ${SRC_DIR}/selector.js
90
91 lint: ${JQ}
92         @@echo "Checking jQuery against JSLint..."
93         @@${RHINO} build/jslint-check.js
94
95 min: ${JQ_MIN}
96
97 ${JQ_MIN}: ${JQ}
98         @@echo "Building" ${JQ_MIN}
99
100         @@head -15 ${JQ} > ${JQ_MIN}
101         @@${MINJAR} --js ${JQ} --warning_level QUIET --js_output_file ${JQ_MIN}.tmp
102         @@cat ${JQ_MIN}.tmp >> ${JQ_MIN}
103         @@rm -f ${JQ_MIN}.tmp
104
105 clean:
106         @@echo "Removing Distribution directory:" ${DIST_DIR}
107         @@rm -rf ${DIST_DIR}
108
109         @@echo "Removing built copy of Sizzle"
110         @@rm -f src/selector.js
111
112         @@echo "Removing cloned directories"
113         @@rm -rf test/qunit src/sizzle
114
115 .PHONY: all jquery lint min init jq clean