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)
15 JSLINT = jslint --sloppy --eqeq --bitwise --forin --nomen --predef jQuery --color --plusplus --browser --jqmspace --regexp --continue
16 COMMON_WIDGET = common
18 OUTPUT_ROOT = $(CURDIR)/build
19 FRAMEWORK_ROOT = ${OUTPUT_ROOT}/${PROJECT_NAME}/${VERSION}
21 LATEST_ROOT = ${OUTPUT_ROOT}/${PROJECT_NAME}/latest
23 JS_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/js
24 JS_LIB_OUTPUT_DIR = ${JS_OUTPUT_ROOT}/src
25 export THEME_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/themes
26 CSS_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/themes/${THEME_NAME}
27 CSS_IMAGES_OUTPUT_DIR = ${CSS_OUTPUT_ROOT}/images
28 WIDGET_CSS_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/widget-css
29 PROTOTYPE_HTML_OUTPUT_DIR = proto-html
31 JS_DIR = $(CURDIR)/src/js
32 WIDGETS_DIR = ${JS_DIR}/widgets
33 THEMES_DIR = $(CURDIR)/src/themes
34 LIBS_DIR = $(CURDIR)/libs
36 COPYING_FILE = $(CURDIR)/COPYING
41 INSTALL_DIR = ${DESTDIR}${PREFIX}
43 FW_JS = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}.js
44 FW_MIN = $(subst .js,.min.js,$(FW_JS))
45 FW_LIB_JS = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}-libs.js
46 FW_LIB_MIN = $(subst .js,.min.js,$(FW_LIB_JS))
48 FW_JS_THEME = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}-${THEME_NAME}-theme.js
49 FW_CSS = ${CSS_OUTPUT_ROOT}/${PROJECT_NAME}-theme.css
50 FW_LIBS_JS = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}-libs.js
51 FW_THEME_CSS_FILE = ${PROJECT_NAME}-theme.css
52 FW_WIDGET_CSS_FILE = ${WIDGET_CSS_OUTPUT_ROOT}/${PROJECT_NAME}-widget.css
54 LIBS_JS_FILES = jquery.easing.1.3.js \
57 globalize/lib/globalize.js \
61 JQUERY_MOBILE_CSS = submodules/jquery-mobile/compiled/jquery.mobile.structure.css \
62 submodules/jquery-mobile/compiled/jquery.mobile.css \
64 JQUERY_MOBILE_IMAGES = submodules/jquery-mobile/css/themes/default/images
66 JQM_VERSION = jquery-mobile-1.2.0
67 JQM_LIB_PATH = $(CURDIR)/libs/js/${JQM_VERSION}
69 JQUERY = jquery-1.8.2.js
70 JQUERY_MIN = $(subst .js,.min.js,$(JQUERY))
72 all: libs_prepare third_party js libs_cleanup themes version version_compat compress
75 # Prepare libs/ build...
76 @@test -d ${LIBS_DIR}.bak && rm -rf ${LIBS_DIR} && mv ${LIBS_DIR}.bak ${LIBS_DIR}; \
77 cp -a ${LIBS_DIR} ${LIBS_DIR}.bak
78 for f in `ls ${LIBS_DIR}/patch/*.patch`; do \
80 echo "Apply patch: $$f"; \
81 cat $$f | patch -p1 -N; \
85 # Cleanup libs/ directory...
86 @@rm -rf ${LIBS_DIR} && mv ${LIBS_DIR}.bak ${LIBS_DIR}
89 # Building jQuery Mobile...
90 cd ${JQM_LIB_PATH} && make js NODE=/usr/bin/node || exit 1; \
91 cp -f ${JQM_LIB_PATH}/compiled/*.js ${JQM_LIB_PATH}/../; \
93 third_party: init jqm globalize
94 # Building third party components...
95 @@cd ${LIBS_DIR}/js; \
96 for f in ${LIBS_JS_FILES}; do \
97 cat $$f >> ${FW_LIB_JS}; \
98 uglifyjs --ascii $$f >> ${FW_LIB_MIN}; \
99 echo "" >> ${FW_LIB_MIN}; \
101 cp ${LIBS_DIR}/js/${JQUERY} ${JS_OUTPUT_ROOT}/jquery.js
102 cp ${LIBS_DIR}/js/${JQUERY_MIN} ${JS_OUTPUT_ROOT}/jquery.min.js
105 # Building JS files...
106 mkdir -p ${JS_LIB_OUTPUT_DIR}; \
107 cp -a ${JS_DIR}/* ${JS_LIB_OUTPUT_DIR}/; \
108 ${NODE} $(CURDIR)/tools/moduledep.js -c ${JS_LIB_OUTPUT_DIR} > ${JS_LIB_OUTPUT_DIR}/../depData.json; \
109 find ${JS_LIB_OUTPUT_DIR} -iname '*.js' | sort | \
110 while read JSFILE; do \
111 echo " # Building $$JSFILE"; \
112 sed -i -e '/^\/\/>>excludeStart\(.*\);/,/^\/\/>>excludeEnd\(.*\);/d' $$JSFILE; \
113 if test ${JSLINT_LEVEL} -ge 1; then \
114 ${JSLINT} $$JSFILE; \
115 if test ${JSLINT_LEVEL} -ge 2 -a $$? -ne 0; then \
119 if test "x${INLINE_PROTO}x" = "x1x"; then \
120 echo " $$f (include inline-proto if exists)"; \
121 ./tools/inline-protos.sh $$JSFILE > $$JSFILE.compiled; \
123 mv $$JSFILE.compiled $$JSFILE; \
128 ${NODE} $(CURDIR)/tools/moduledep.js -d ${JS_LIB_OUTPUT_DIR} ${JS_LIB_OUTPUT_DIR}/../depData.json >> ${FW_JS}; \
129 cp -a ${JS_DIR}/* ${JQM_LIB_PATH}/js/* ${JS_LIB_OUTPUT_DIR}/; \
130 ${NODE} $(CURDIR)/tools/moduledep.js -c ${JS_LIB_OUTPUT_DIR} > ${JS_LIB_OUTPUT_DIR}/../depData.json; \
131 find ${JS_LIB_OUTPUT_DIR} -iname '*.js' | xargs sed -i -e '/^\/\/>>excludeStart\(.*\);/,/^\/\/>>excludeEnd\(.*\);/d';
133 widgets: init third_party globalize
134 # Building widgets...
135 @@ls -l ${WIDGETS_DIR} | grep '^d' | awk '{print $$NF;}' | \
136 while read REPLY; do \
137 echo " # Building widget $$REPLY"; \
138 if test ${JSLINT_LEVEL} -ge 1; then \
139 if test $$REPLY != ${COMMON_WIDGET}; then \
140 for FNAME in ${WIDGETS_DIR}/$$REPLY/js/*.js; do \
142 if test ${JSLINT_LEVEL} -ge 2 -a $$? -ne 0; then \
148 if test "x${INLINE_PROTO}x" = "x1x"; then \
149 ./tools/inline-protos.sh ${WIDGETS_DIR}/$$REPLY >> ${WIDGETS_DIR}/$$REPLY/js/$$REPLY.js.compiled; \
150 cat ${WIDGETS_DIR}/$$REPLY/js/$$REPLY.js.compiled >> ${FW_JS}; \
152 for f in `find ${WIDGETS_DIR}/$$REPLY -iname 'js/*.js' | sort`; do \
154 cat $$f >> ${FW_JS}; \
157 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.js.theme' | sort`; do \
159 cat $$f >> ${FW_JS_THEME}; \
161 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.less' | sort`; do \
163 lessc $$f > $$f.css; \
165 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.css' | sort`; do \
167 cat $$f >> ${FW_CSS}; \
169 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.gif' -or -iname '*.png' -or -iname '*.jpg' | sort`; do \
171 cp $$f ${CSS_IMAGES_OUTPUT_DIR}; \
173 if test "x${INLINE_PROTO}x" != "x1x"; then \
174 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.prototype.html' | sort`; do \
176 cp $$f ${PROTOTYPE_HTML_OUTPUT_DIR}; \
182 # copy globalize libs...
183 cp -a libs/js/globalize/lib/cultures ${FRAMEWORK_ROOT}/js/
186 make -C src/themes || exit $?
189 echo '(function($$){$$.tizen.frameworkData.pkgVersion="$(PKG_VERSION)";}(jQuery));' >> ${FW_JS}
190 echo "$(PKG_VERSION)" > ${FRAMEWORK_ROOT}/../VERSION
192 compress: third_party js themes
193 # Javacript code compressing
194 @@echo " # Compressing...."; \
195 echo '/*' > ${FW_MIN}; \
196 cat ${COPYING_FILE} >> ${FW_MIN}; \
197 echo '*/' >> ${FW_MIN}; \
198 uglifyjs --ascii -nc ${FW_JS} >> ${FW_MIN}; \
200 @@cd ${THEME_OUTPUT_ROOT}; \
201 for csspath in */*.css; do \
202 echo "Compressing $$csspath"; \
203 cleancss -o $${csspath/%.css/.min.css} $$csspath; \
208 # Building documentation...
209 @@hash docco 2>&1 /dev/null || (echo "docco not found. Please see README."; exit 1); \
210 ls -l ${WIDGETS_DIR} | grep '^d' | awk '{print $$NF;}' | \
211 while read REPLY; do \
212 echo " # Building docs for widget $$REPLY"; \
213 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.js' | sort`; do \
214 docco $$f > /dev/null; \
217 cp docs/docco.custom.css docs/docco.css; \
218 cat docs/index.header > docs/index.html; \
219 for f in `find docs -name '*.html' -not -name index.html | sort`; do \
220 echo "<li><a href=\"$$(basename $$f)\">$$(basename $$f .html)</a></li>" >> docs/index.html; \
222 cat docs/index.footer >> docs/index.html
225 version_compat: third_party js
226 # Creating compatible version dirs...
227 for v_compat in ${VERSION_COMPAT}; do \
228 ln -sf ${VERSION} ${FRAMEWORK_ROOT}/../$$v_compat; \
230 ln -sf ${VERSION} ${FRAMEWORK_ROOT}/../latest
233 mkdir -p ${OUTPUT_ROOT}/demos
234 cp -av demos/* ${OUTPUT_ROOT}/demos/
235 cp -f src/template/bootstrap.js ${OUTPUT_ROOT}/demos/gallery/
239 mkdir -p ${INSTALL_DIR}/bin ${INSTALL_DIR}/share/tizen-web-ui-fw/demos/ ${INSTALL_DIR}/share/tizen-web-ui-fw/bin/
240 cp -av ${OUTPUT_ROOT}/tizen-web-ui-fw/* src/template ${INSTALL_DIR}/share/tizen-web-ui-fw/
241 cp -av tools/* ${INSTALL_DIR}/share/tizen-web-ui-fw/bin/
242 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
246 # Checking unit test coverage
247 $(CURDIR)/tests/coverage/instrument.sh
251 # Creating tarball...
253 TMPDIR=$$(mktemp -d tarball.XXXXXXXX); \
254 DESTDIR=$${TMPDIR}/${PROJECT_NAME}; \
256 if test "x${DEBUG}x" = "xnox"; then \
259 TARBALL=${PROJECT_NAME}-${VERSION}-`date +%Y%m%d`$${MIN}.tar.gz; \
260 mkdir -p $${DESTDIR}; \
263 ${THEMES_OUTPUT_ROOT}/tizen/${FW_THEME_CSS_FILE} \
264 ${FW_WIDGET_CSS_FILE} \
265 ${THEMES_OUTPUT_ROOT}/tizen/images \
270 hash git 2>&1 /dev/null && touch $${DESTDIR}/$$(git log | head -n 1 | awk '{print $$2;}'); \
274 --exclude='*.less.css' \
275 --exclude='*.js.compiled' \
276 --exclude='submodules/jquery-mobile' \
277 --exclude='${JQUERY}' \
278 -C $${TMPDIR} ${PROJECT_NAME}; \
283 # Removing destination directory...
284 @@rm -rf ${OUTPUT_ROOT}
285 # Remove generated files...
286 @@rm -f `find . -iname *.less.css`
287 @@rm -f `find . -iname *.js.compiled`
291 # Check build environment...
292 @@hash lessc 2>/dev/null || (echo "lessc not found. Please see HACKING."; exit 1); \
295 @@mkdir -p ${JS_OUTPUT_ROOT}
296 @@mkdir -p ${THEME_OUTPUT_ROOT}
297 @@mkdir -p ${CSS_OUTPUT_ROOT}
298 @@mkdir -p ${CSS_IMAGES_OUTPUT_DIR}
299 @@mkdir -p ${PROTOTYPE_HTML_OUTPUT_DIR}