progressbar: event trigger correctly
[platform/framework/web/web-ui-fw.git] / Makefile
1 SHELL := /bin/bash
2
3 ## Project setting
4 DEBUG ?= yes
5 PROJECT_NAME = tizen-web-ui-fw
6 VERSION = 0.2
7 VERSION_COMPAT =
8 PKG_VERSION = $(shell cat packaging/web-ui-fw.spec | grep Version: | sed -e "s@Version:\s*@@" )
9 THEME_NAME = default
10
11 PATH := $(CURDIR)/build-tools/bin:$(PATH)
12
13 JSLINT_LEVEL = 1
14 JSLINT = jslint --sloppy --eqeq --bitwise --forin --nomen --predef jQuery --color --plusplus --browser --jqmspace --regexp --continue
15 COMMON_WIDGET = common
16 INLINE_PROTO = 1
17 OUTPUT_ROOT = $(CURDIR)/build
18 FRAMEWORK_ROOT = ${OUTPUT_ROOT}/${PROJECT_NAME}/${VERSION}
19
20 LATEST_ROOT = ${OUTPUT_ROOT}/${PROJECT_NAME}/latest
21
22 JS_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/js
23 export THEME_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/themes
24 CSS_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/themes/${THEME_NAME}
25 CSS_IMAGES_OUTPUT_DIR = ${CSS_OUTPUT_ROOT}/images
26 WIDGET_CSS_OUTPUT_ROOT = ${FRAMEWORK_ROOT}/widget-css
27 PROTOTYPE_HTML_OUTPUT_DIR = proto-html
28
29 WIDGETS_DIR = $(CURDIR)/src/widgets
30
31 THEMES_DIR = $(CURDIR)/src/themes
32 LIBS_DIR = $(CURDIR)/libs
33
34 COPYING_FILE = $(CURDIR)/COPYING
35
36 DESTDIR ?=
37
38 PREFIX ?= /usr
39 INSTALL_DIR = ${DESTDIR}${PREFIX}
40
41 FW_JS = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}.js
42 FW_MIN = $(subst .js,.min.js,$(FW_JS))
43 FW_LIB_JS = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}-libs.js
44 FW_LIB_MIN = $(subst .js,.min.js,$(FW_LIB_JS))
45
46 FW_JS_THEME = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}-${THEME_NAME}-theme.js
47 FW_CSS = ${CSS_OUTPUT_ROOT}/${PROJECT_NAME}-theme.css
48 FW_LIBS_JS = ${JS_OUTPUT_ROOT}/${PROJECT_NAME}-libs.js
49 FW_THEME_CSS_FILE = ${PROJECT_NAME}-theme.css
50 FW_WIDGET_CSS_FILE = ${WIDGET_CSS_OUTPUT_ROOT}/${PROJECT_NAME}-widget.css
51
52 LIBS_JS_FILES = jquery.easing.1.3.js \
53                 jquery.tmpl.js \
54                 jquery.mobile.js \
55                 $(NULL)
56
57 JQUERY_MOBILE_CSS = submodules/jquery-mobile/compiled/jquery.mobile.structure.css \
58                     submodules/jquery-mobile/compiled/jquery.mobile.css \
59                     $(NULL)
60 JQUERY_MOBILE_IMAGES = submodules/jquery-mobile/css/themes/default/images
61
62 JQM_VERSION = jquery-mobile-1.2.0
63 JQM_LIB_PATH = $(CURDIR)/libs/js/${JQM_VERSION}
64
65 JQUERY = jquery-1.8.2.js
66 JQUERY_MIN = $(subst .js,.min.js,$(JQUERY))
67
68 all: libs_prepare third_party widgets libs_cleanup loader themes version version_compat compress
69
70 libs_prepare:
71         # Prepare libs/ build...
72         @@test -d ${LIBS_DIR}.bak && rm -rf ${LIBS_DIR} && mv ${LIBS_DIR}.bak ${LIBS_DIR}; \
73         cp -a ${LIBS_DIR} ${LIBS_DIR}.bak
74         for f in `ls ${LIBS_DIR}/patch/*.patch`; do \
75                 cd $(CURDIR); \
76                 echo "Apply patch: $$f";  \
77                 cat $$f | patch -p1 -N; \
78         done; \
79
80 libs_cleanup:
81         # Cleanup libs/ directory...
82         @@rm -rf ${LIBS_DIR} && mv ${LIBS_DIR}.bak ${LIBS_DIR}
83
84 jqm: init
85         # Building jQuery Mobile...
86         cd ${JQM_LIB_PATH} && make js NODE=/usr/bin/node || exit 1; \
87         cp -f ${JQM_LIB_PATH}/compiled/*.js ${JQM_LIB_PATH}/../; \
88
89 third_party: init jqm
90         # Building third party components...
91         @@cd ${LIBS_DIR}/js; \
92             for f in ${LIBS_JS_FILES}; do \
93                 cat $$f >> ${FW_LIB_JS}; \
94                 uglifyjs --ascii $$f >> ${FW_LIB_MIN}; \
95                 echo "" >> ${FW_LIB_MIN}; \
96             done; \
97             cp ${LIBS_DIR}/js/${JQUERY} ${JS_OUTPUT_ROOT}/jquery.js
98             cp ${LIBS_DIR}/js/${JQUERY_MIN} ${JS_OUTPUT_ROOT}/jquery.min.js
99
100 widgets: init third_party
101         # Building widgets...
102         @@ls -l ${WIDGETS_DIR} | grep '^d' | awk '{print $$NF;}' | \
103             while read REPLY; do \
104                 echo "  # Building widget $$REPLY"; \
105                         if test ${JSLINT_LEVEL} -ge 1; then \
106                                 if test $$REPLY != ${COMMON_WIDGET}; then \
107                                         for FNAME in ${WIDGETS_DIR}/$$REPLY/js/*.js; do \
108                                                 ${JSLINT} $$FNAME; \
109                                                 if test ${JSLINT_LEVEL} -ge 2 -a $$? -ne 0; then \
110                                                         exit 1; \
111                                                 fi; \
112                                         done; \
113                                 fi; \
114                         fi; \
115                         if test "x${INLINE_PROTO}x" = "x1x"; then \
116                                 ./tools/inline-protos.sh ${WIDGETS_DIR}/$$REPLY >> ${WIDGETS_DIR}/$$REPLY/js/$$REPLY.js.compiled; \
117                                 cat ${WIDGETS_DIR}/$$REPLY/js/$$REPLY.js.compiled >> ${FW_JS}; \
118                         else \
119                                 for f in `find ${WIDGETS_DIR}/$$REPLY -iname 'js/*.js' | sort`; do \
120                                         echo "          $$f"; \
121                                         cat $$f >> ${FW_JS}; \
122                                 done; \
123             fi; \
124                 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.js.theme' | sort`; do \
125                     echo "              $$f"; \
126                     cat $$f >> ${FW_JS_THEME}; \
127                 done; \
128                 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.less' | sort`; do \
129                     echo "              $$f"; \
130                     lessc $$f > $$f.css; \
131                 done; \
132                 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.css' | sort`; do \
133                     echo "              $$f"; \
134                     cat $$f >> ${FW_CSS}; \
135                 done; \
136                 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.gif' -or -iname '*.png' -or -iname '*.jpg' | sort`; do \
137                     echo "              $$f"; \
138                     cp $$f ${CSS_IMAGES_OUTPUT_DIR}; \
139                 done; \
140                 if test "x${INLINE_PROTO}x" != "x1x"; then \
141                   for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.prototype.html' | sort`; do \
142                       echo "            $$f"; \
143                       cp $$f ${PROTOTYPE_HTML_OUTPUT_DIR}; \
144                   done; \
145                 fi; \
146             done
147
148
149 loader: widgets globalize
150         cat 'src/loader/loader.js' >> ${FW_JS}
151
152
153 globalize: widgets
154         cat 'libs/js/globalize/lib/globalize.js' >> ${FW_JS}
155         # copy globalize libs...
156         cp -a libs/js/globalize/lib/cultures ${FRAMEWORK_ROOT}/js/
157
158
159 themes:
160         make -C src/themes || exit $?
161
162 version: loader themes
163         echo '(function($$){$$.tizen.frameworkData.pkgVersion="$(PKG_VERSION)";}(jQuery));' >> ${FW_JS}
164         echo "$(PKG_VERSION)" > ${FRAMEWORK_ROOT}/../VERSION
165
166 compress: widgets loader themes
167         # Javacript code compressing
168         @@echo "        # Compressing...."; \
169         echo '/*' > ${FW_MIN}; \
170         cat ${COPYING_FILE} >> ${FW_MIN}; \
171         echo '*/' >> ${FW_MIN}; \
172         uglifyjs --ascii -nc ${FW_JS} >> ${FW_MIN}; \
173         # CSS compressing
174         @@cd ${THEME_OUTPUT_ROOT}; \
175         for csspath in */*.css; do \
176                 echo "Compressing $$csspath"; \
177                 cleancss -o $${csspath/%.css/.min.css} $$csspath; \
178         done
179
180
181 docs: init
182         # Building documentation...
183         @@hash docco 2>&1 /dev/null || (echo "docco not found. Please see README."; exit 1); \
184         ls -l ${WIDGETS_DIR} | grep '^d' | awk '{print $$NF;}' | \
185         while read REPLY; do \
186                 echo "  # Building docs for widget $$REPLY"; \
187                 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.js' | sort`; do \
188                         docco $$f > /dev/null; \
189                 done; \
190         done; \
191         cp docs/docco.custom.css docs/docco.css; \
192         cat docs/index.header > docs/index.html; \
193         for f in `find docs -name '*.html' -not -name index.html | sort`; do \
194                 echo "<li><a href=\"$$(basename $$f)\">$$(basename $$f .html)</a></li>" >> docs/index.html; \
195         done; \
196         cat docs/index.footer >> docs/index.html
197
198
199 version_compat: third_party widgets
200         # Creating compatible version dirs...
201         for v_compat in ${VERSION_COMPAT}; do \
202                 ln -sf ${VERSION} ${FRAMEWORK_ROOT}/../$$v_compat; \
203         done;
204         ln -sf ${VERSION} ${FRAMEWORK_ROOT}/../latest
205
206 demo: widgets 
207         mkdir -p ${OUTPUT_ROOT}/demos
208         cp -av demos/* ${OUTPUT_ROOT}/demos/
209         cp -f src/template/bootstrap.js ${OUTPUT_ROOT}/demos/gallery/
210
211
212 install: all
213         mkdir -p ${INSTALL_DIR}/bin ${INSTALL_DIR}/share/tizen-web-ui-fw/demos/ ${INSTALL_DIR}/share/tizen-web-ui-fw/bin/
214         cp -av ${OUTPUT_ROOT}/tizen-web-ui-fw/* src/template ${INSTALL_DIR}/share/tizen-web-ui-fw/
215         cp -av tools/* ${INSTALL_DIR}/share/tizen-web-ui-fw/bin/
216         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
217
218
219 coverage: clean all
220         # Checking unit test coverage
221         $(CURDIR)/tests/coverage/instrument.sh
222
223
224 dist: clean all docs
225         # Creating tarball...
226         @@ \
227         TMPDIR=$$(mktemp -d tarball.XXXXXXXX); \
228         DESTDIR=$${TMPDIR}/${PROJECT_NAME}; \
229         MIN=''; \
230         if test "x${DEBUG}x" = "xnox"; then \
231                 MIN='.min'; \
232         fi; \
233         TARBALL=${PROJECT_NAME}-${VERSION}-`date +%Y%m%d`$${MIN}.tar.gz; \
234         mkdir -p $${DESTDIR}; \
235         cp -a ${FW_JS} \
236                 ${FW_LIBS_JS} \
237                 ${THEMES_OUTPUT_ROOT}/tizen/${FW_THEME_CSS_FILE} \
238                 ${FW_WIDGET_CSS_FILE} \
239                 ${THEMES_OUTPUT_ROOT}/tizen/images \
240                 docs \
241                 README.md \
242                 COPYING \
243                 $${DESTDIR}; \
244         hash git 2>&1 /dev/null && touch $${DESTDIR}/$$(git log | head -n 1 | awk '{print $$2;}'); \
245         tar cfzps \
246                 $${TARBALL} \
247                 --exclude='.git' \
248                 --exclude='*.less.css' \
249                 --exclude='*.js.compiled' \
250                 --exclude='submodules/jquery-mobile' \
251                 --exclude='${JQUERY}' \
252                 -C $${TMPDIR} ${PROJECT_NAME}; \
253         rm -rf $${TMPDIR}
254
255
256 clean:
257         # Removing destination directory...
258         @@rm -rf ${OUTPUT_ROOT}
259         # Remove generated files...
260         @@rm -f `find . -iname *.less.css`
261         @@rm -f `find . -iname *.js.compiled`
262
263
264 init: clean
265         # Check build environment...
266         @@hash lessc 2>/dev/null || (echo "lessc not found. Please see HACKING."; exit 1); \
267
268         # Initializing...
269         @@mkdir -p ${JS_OUTPUT_ROOT}
270         @@mkdir -p ${THEME_OUTPUT_ROOT}
271         @@mkdir -p ${CSS_OUTPUT_ROOT}
272         @@mkdir -p ${CSS_IMAGES_OUTPUT_DIR}
273         @@mkdir -p ${PROTOTYPE_HTML_OUTPUT_DIR}
274         @@rm -f docs/*.html