5 PROJECT_NAME = tizen-web-ui-fw
8 PKG_VERSION = $(shell cat packaging/web-ui-fw.spec | grep Version: | sed -e "s@Version:\s*@@" )
11 PATH := $(CURDIR)/build-tools/bin:$(PATH)
14 JSLINT = jslint --sloppy --eqeq --bitwise --forin --nomen --predef jQuery --color --plusplus --browser --jqmspace --regexp --continue
15 COMMON_WIDGET = common
17 OUTPUT_ROOT = $(CURDIR)/build
18 FRAMEWORK_ROOT = ${OUTPUT_ROOT}/${PROJECT_NAME}/${VERSION}
20 LATEST_ROOT = ${OUTPUT_ROOT}/${PROJECT_NAME}/latest
22 JS_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/js
23 JS_LIB_OUTPUT_DIR = ${JS_OUTPUT_ROOT}/src
24 export THEME_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/themes
25 CSS_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/themes/${THEME_NAME}
26 CSS_IMAGES_OUTPUT_DIR = ${CSS_OUTPUT_ROOT}/images
27 WIDGET_CSS_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/widget-css
28 PROTOTYPE_HTML_OUTPUT_DIR = proto-html
30 JS_DIR = $(CURDIR)/src/js
31 WIDGETS_DIR = ${JS_DIR}/widgets
32 THEMES_DIR = $(CURDIR)/src/themes
33 LIBS_DIR = $(CURDIR)/libs
35 COPYING_FILE = $(CURDIR)/COPYING
40 INSTALL_DIR = ${DESTDIR}${PREFIX}
42 FW_JS = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}.js
43 FW_MIN = $(subst .js,.min.js,$(FW_JS))
44 FW_LIB_JS = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}-libs.js
45 FW_LIB_MIN = $(subst .js,.min.js,$(FW_LIB_JS))
47 FW_JS_THEME = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}-${THEME_NAME}-theme.js
48 FW_CSS = ${CSS_OUTPUT_ROOT}/${PROJECT_NAME}-theme.css
49 FW_LIBS_JS = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}-libs.js
50 FW_THEME_CSS_FILE = ${PROJECT_NAME}-theme.css
51 FW_WIDGET_CSS_FILE = ${WIDGET_CSS_OUTPUT_ROOT}/${PROJECT_NAME}-widget.css
53 LIBS_JS_FILES = jquery.easing.1.3.js \
56 globalize/lib/globalize.js \
60 JQUERY_MOBILE_CSS = submodules/jquery-mobile/compiled/jquery.mobile.structure.css \
61 submodules/jquery-mobile/compiled/jquery.mobile.css \
63 JQUERY_MOBILE_IMAGES = submodules/jquery-mobile/css/themes/default/images
65 JQM_VERSION = jquery-mobile-1.2.0
66 JQM_LIB_PATH = $(CURDIR)/libs/js/${JQM_VERSION}
68 JQUERY = jquery-1.8.2.js
69 JQUERY_MIN = $(subst .js,.min.js,$(JQUERY))
71 all: libs_prepare third_party js libs_cleanup themes version version_compat compress
74 # Prepare libs/ build...
75 @@test -d ${LIBS_DIR}.bak && rm -rf ${LIBS_DIR} && mv ${LIBS_DIR}.bak ${LIBS_DIR}; \
76 cp -a ${LIBS_DIR} ${LIBS_DIR}.bak
77 for f in `ls ${LIBS_DIR}/patch/*.patch`; do \
79 echo "Apply patch: $$f"; \
80 cat $$f | patch -p1 -N; \
84 # Cleanup libs/ directory...
85 @@rm -rf ${LIBS_DIR} && mv ${LIBS_DIR}.bak ${LIBS_DIR}
88 # Building jQuery Mobile...
89 cd ${JQM_LIB_PATH} && make js NODE=/usr/bin/node || exit 1; \
90 cp -f ${JQM_LIB_PATH}/compiled/*.js ${JQM_LIB_PATH}/../; \
92 third_party: init jqm globalize
93 # Building third party components...
94 @@cd ${LIBS_DIR}/js; \
95 for f in ${LIBS_JS_FILES}; do \
96 cat $$f >> ${FW_LIB_JS}; \
97 uglifyjs --ascii $$f >> ${FW_LIB_MIN}; \
98 echo "" >> ${FW_LIB_MIN}; \
100 cp ${LIBS_DIR}/js/${JQUERY} ${JS_OUTPUT_ROOT}/jquery.js
101 cp ${LIBS_DIR}/js/${JQUERY_MIN} ${JS_OUTPUT_ROOT}/jquery.min.js
104 # Building JS files...
105 mkdir -p ${JS_LIB_OUTPUT_DIR}; \
106 cp -a ${JS_DIR}/* ${JS_LIB_OUTPUT_DIR}/; \
107 /usr/bin/node $(CURDIR)/tools/moduledep.js -c ${JS_LIB_OUTPUT_DIR} > ${JS_LIB_OUTPUT_DIR}/../depData.json; \
108 find ${JS_LIB_OUTPUT_DIR} -iname '*.js' | sort | \
109 while read JSFILE; do \
110 echo " # Building $$JSFILE"; \
111 sed -i -e '/^\/\/>>excludeStart\(.*\);/,/^\/\/>>excludeEnd\(.*\);/d' $$JSFILE; \
112 if test ${JSLINT_LEVEL} -ge 1; then \
113 ${JSLINT} $$JSFILE; \
114 if test ${JSLINT_LEVEL} -ge 2 -a $$? -ne 0; then \
118 if test "x${INLINE_PROTO}x" = "x1x"; then \
119 echo " $$f (include inline-proto if exists)"; \
120 ./tools/inline-protos.sh $$JSFILE > $$JSFILE.compiled; \
122 mv $$JSFILE.compiled $$JSFILE; \
127 /usr/bin/node $(CURDIR)/tools/moduledep.js -d ${JS_LIB_OUTPUT_DIR} ${JS_LIB_OUTPUT_DIR}/../depData.json >> ${FW_JS}; \
128 cp -a ${JS_DIR}/* ${JQM_LIB_PATH}/js/* ${JS_LIB_OUTPUT_DIR}/; \
129 /usr/bin/node $(CURDIR)/tools/moduledep.js -c ${JS_LIB_OUTPUT_DIR} > ${JS_LIB_OUTPUT_DIR}/../depData.json; \
130 find ${JS_LIB_OUTPUT_DIR} -iname '*.js' | xargs sed -i -e '/^\/\/>>excludeStart\(.*\);/,/^\/\/>>excludeEnd\(.*\);/d';
132 widgets: init third_party globalize
133 # Building widgets...
134 @@ls -l ${WIDGETS_DIR} | grep '^d' | awk '{print $$NF;}' | \
135 while read REPLY; do \
136 echo " # Building widget $$REPLY"; \
137 if test ${JSLINT_LEVEL} -ge 1; then \
138 if test $$REPLY != ${COMMON_WIDGET}; then \
139 for FNAME in ${WIDGETS_DIR}/$$REPLY/js/*.js; do \
141 if test ${JSLINT_LEVEL} -ge 2 -a $$? -ne 0; then \
147 if test "x${INLINE_PROTO}x" = "x1x"; then \
148 ./tools/inline-protos.sh ${WIDGETS_DIR}/$$REPLY >> ${WIDGETS_DIR}/$$REPLY/js/$$REPLY.js.compiled; \
149 cat ${WIDGETS_DIR}/$$REPLY/js/$$REPLY.js.compiled >> ${FW_JS}; \
151 for f in `find ${WIDGETS_DIR}/$$REPLY -iname 'js/*.js' | sort`; do \
153 cat $$f >> ${FW_JS}; \
156 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.js.theme' | sort`; do \
158 cat $$f >> ${FW_JS_THEME}; \
160 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.less' | sort`; do \
162 lessc $$f > $$f.css; \
164 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.css' | sort`; do \
166 cat $$f >> ${FW_CSS}; \
168 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.gif' -or -iname '*.png' -or -iname '*.jpg' | sort`; do \
170 cp $$f ${CSS_IMAGES_OUTPUT_DIR}; \
172 if test "x${INLINE_PROTO}x" != "x1x"; then \
173 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.prototype.html' | sort`; do \
175 cp $$f ${PROTOTYPE_HTML_OUTPUT_DIR}; \
181 # copy globalize libs...
182 cp -a libs/js/globalize/lib/cultures ${FRAMEWORK_ROOT}/js/
185 make -C src/themes || exit $?
188 echo '(function($$){$$.tizen.frameworkData.pkgVersion="$(PKG_VERSION)";}(jQuery));' >> ${FW_JS}
189 echo "$(PKG_VERSION)" > ${FRAMEWORK_ROOT}/../VERSION
191 compress: third_party js themes
192 # Javacript code compressing
193 @@echo " # Compressing...."; \
194 echo '/*' > ${FW_MIN}; \
195 cat ${COPYING_FILE} >> ${FW_MIN}; \
196 echo '*/' >> ${FW_MIN}; \
197 uglifyjs --ascii -nc ${FW_JS} >> ${FW_MIN}; \
199 @@cd ${THEME_OUTPUT_ROOT}; \
200 for csspath in */*.css; do \
201 echo "Compressing $$csspath"; \
202 cleancss -o $${csspath/%.css/.min.css} $$csspath; \
207 # Building documentation...
208 @@hash docco 2>&1 /dev/null || (echo "docco not found. Please see README."; exit 1); \
209 ls -l ${WIDGETS_DIR} | grep '^d' | awk '{print $$NF;}' | \
210 while read REPLY; do \
211 echo " # Building docs for widget $$REPLY"; \
212 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.js' | sort`; do \
213 docco $$f > /dev/null; \
216 cp docs/docco.custom.css docs/docco.css; \
217 cat docs/index.header > docs/index.html; \
218 for f in `find docs -name '*.html' -not -name index.html | sort`; do \
219 echo "<li><a href=\"$$(basename $$f)\">$$(basename $$f .html)</a></li>" >> docs/index.html; \
221 cat docs/index.footer >> docs/index.html
224 version_compat: third_party js
225 # Creating compatible version dirs...
226 for v_compat in ${VERSION_COMPAT}; do \
227 ln -sf ${VERSION} ${FRAMEWORK_ROOT}/../$$v_compat; \
229 ln -sf ${VERSION} ${FRAMEWORK_ROOT}/../latest
232 mkdir -p ${OUTPUT_ROOT}/demos
233 cp -av demos/* ${OUTPUT_ROOT}/demos/
234 cp -f src/template/bootstrap.js ${OUTPUT_ROOT}/demos/gallery/
238 mkdir -p ${INSTALL_DIR}/bin ${INSTALL_DIR}/share/tizen-web-ui-fw/demos/ ${INSTALL_DIR}/share/tizen-web-ui-fw/bin/
239 cp -av ${OUTPUT_ROOT}/tizen-web-ui-fw/* src/template ${INSTALL_DIR}/share/tizen-web-ui-fw/
240 cp -av tools/* ${INSTALL_DIR}/share/tizen-web-ui-fw/bin/
241 cp -av demos/tizen-winsets ${INSTALL_DIR}/share/tizen-web-ui-fw/demos/ && cd ${INSTALL_DIR}/share/tizen-web-ui-fw/demos/tizen-winsets && sed -i -e "s#../../build#../../..#g" *.html
245 # Checking unit test coverage
246 $(CURDIR)/tests/coverage/instrument.sh
250 # Creating tarball...
252 TMPDIR=$$(mktemp -d tarball.XXXXXXXX); \
253 DESTDIR=$${TMPDIR}/${PROJECT_NAME}; \
255 if test "x${DEBUG}x" = "xnox"; then \
258 TARBALL=${PROJECT_NAME}-${VERSION}-`date +%Y%m%d`$${MIN}.tar.gz; \
259 mkdir -p $${DESTDIR}; \
262 ${THEMES_OUTPUT_ROOT}/tizen/${FW_THEME_CSS_FILE} \
263 ${FW_WIDGET_CSS_FILE} \
264 ${THEMES_OUTPUT_ROOT}/tizen/images \
269 hash git 2>&1 /dev/null && touch $${DESTDIR}/$$(git log | head -n 1 | awk '{print $$2;}'); \
273 --exclude='*.less.css' \
274 --exclude='*.js.compiled' \
275 --exclude='submodules/jquery-mobile' \
276 --exclude='${JQUERY}' \
277 -C $${TMPDIR} ${PROJECT_NAME}; \
282 # Removing destination directory...
283 @@rm -rf ${OUTPUT_ROOT}
284 # Remove generated files...
285 @@rm -f `find . -iname *.less.css`
286 @@rm -f `find . -iname *.js.compiled`
290 # Check build environment...
291 @@hash lessc 2>/dev/null || (echo "lessc not found. Please see HACKING."; exit 1); \
294 @@mkdir -p ${JS_OUTPUT_ROOT}
295 @@mkdir -p ${THEME_OUTPUT_ROOT}
296 @@mkdir -p ${CSS_OUTPUT_ROOT}
297 @@mkdir -p ${CSS_IMAGES_OUTPUT_DIR}
298 @@mkdir -p ${PROTOTYPE_HTML_OUTPUT_DIR}