Tizen-winset : Footer changed from lower case to upper case. Change-Id: I80d5414d37bf...
[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 NODE = /usr/bin/node
13
14 JSLINT_LEVEL = 1
15 JSLINT = jslint --sloppy --eqeq --bitwise --forin --nomen --predef jQuery --color --plusplus --browser --jqmspace --regexp --continue
16 COMMON_WIDGET = common
17 INLINE_PROTO = 1
18 OUTPUT_ROOT = $(CURDIR)/build
19 FRAMEWORK_ROOT = ${OUTPUT_ROOT}/${PROJECT_NAME}/${VERSION}
20
21 LATEST_ROOT = ${OUTPUT_ROOT}/${PROJECT_NAME}/latest
22
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
30
31 JS_DIR = $(CURDIR)/src/js
32 WIDGETS_DIR = ${JS_DIR}/widgets
33 THEMES_DIR = $(CURDIR)/src/themes
34 LIBS_DIR = $(CURDIR)/libs
35
36 COPYING_FILE = $(CURDIR)/COPYING
37
38 DESTDIR ?=
39
40 PREFIX ?= /usr
41 INSTALL_DIR = ${DESTDIR}${PREFIX}
42
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))
47
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
53
54 LIBS_JS_FILES = jquery.easing.1.3.js \
55                 jquery.tmpl.js \
56                 jquery.mobile.js \
57                 globalize/lib/globalize.js \
58                 gl-matrix.js \
59                 $(NULL)
60
61 JQUERY_MOBILE_CSS = submodules/jquery-mobile/compiled/jquery.mobile.structure.css \
62                     submodules/jquery-mobile/compiled/jquery.mobile.css \
63                     $(NULL)
64 JQUERY_MOBILE_IMAGES = submodules/jquery-mobile/css/themes/default/images
65
66 JQM_VERSION = jquery-mobile-1.2.0
67 JQM_LIB_PATH = $(CURDIR)/libs/js/${JQM_VERSION}
68
69 JQUERY = jquery-1.8.2.js
70 JQUERY_MIN = $(subst .js,.min.js,$(JQUERY))
71
72 all: libs_prepare third_party js libs_cleanup themes version version_compat compress
73
74 libs_prepare:
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 \
79                 cd $(CURDIR); \
80                 echo "Apply patch: $$f";  \
81                 cat $$f | patch -p1 -N; \
82         done; \
83
84 libs_cleanup:
85         # Cleanup libs/ directory...
86         @@rm -rf ${LIBS_DIR} && mv ${LIBS_DIR}.bak ${LIBS_DIR}
87
88 jqm: init
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}/../; \
92
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}; \
100             done; \
101             cp ${LIBS_DIR}/js/${JQUERY} ${JS_OUTPUT_ROOT}/jquery.js
102             cp ${LIBS_DIR}/js/${JQUERY_MIN} ${JS_OUTPUT_ROOT}/jquery.min.js
103
104 js: init third_party
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 \
116                                 exit 1; \
117                         fi; \
118                 fi; \
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; \
122                         rm -f $$JSFILE; \
123                         mv $$JSFILE.compiled $$JSFILE; \
124                 else \
125                         echo "          $$f"; \
126                 fi; \
127         done; \
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';
132
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 \
141                                                 ${JSLINT} $$FNAME; \
142                                                 if test ${JSLINT_LEVEL} -ge 2 -a $$? -ne 0; then \
143                                                         exit 1; \
144                                                 fi; \
145                                         done; \
146                                 fi; \
147                         fi; \
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}; \
151                         else \
152                                 for f in `find ${WIDGETS_DIR}/$$REPLY -iname 'js/*.js' | sort`; do \
153                                         echo "          $$f"; \
154                                         cat $$f >> ${FW_JS}; \
155                                 done; \
156             fi; \
157                 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.js.theme' | sort`; do \
158                     echo "              $$f"; \
159                     cat $$f >> ${FW_JS_THEME}; \
160                 done; \
161                 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.less' | sort`; do \
162                     echo "              $$f"; \
163                     lessc $$f > $$f.css; \
164                 done; \
165                 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.css' | sort`; do \
166                     echo "              $$f"; \
167                     cat $$f >> ${FW_CSS}; \
168                 done; \
169                 for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.gif' -or -iname '*.png' -or -iname '*.jpg' | sort`; do \
170                     echo "              $$f"; \
171                     cp $$f ${CSS_IMAGES_OUTPUT_DIR}; \
172                 done; \
173                 if test "x${INLINE_PROTO}x" != "x1x"; then \
174                   for f in `find ${WIDGETS_DIR}/$$REPLY -iname '*.prototype.html' | sort`; do \
175                       echo "            $$f"; \
176                       cp $$f ${PROTOTYPE_HTML_OUTPUT_DIR}; \
177                   done; \
178                 fi; \
179             done
180
181 globalize:
182         # copy globalize libs...
183         cp -a libs/js/globalize/lib/cultures ${FRAMEWORK_ROOT}/js/
184
185 themes:
186         make -C src/themes || exit $?
187
188 version: js themes
189         echo '(function($$){$$.tizen.frameworkData.pkgVersion="$(PKG_VERSION)";}(jQuery));' >> ${FW_JS}
190         echo "$(PKG_VERSION)" > ${FRAMEWORK_ROOT}/../VERSION
191
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}; \
199         # CSS compressing
200         @@cd ${THEME_OUTPUT_ROOT}; \
201         for csspath in */*.css; do \
202                 echo "Compressing $$csspath"; \
203                 cleancss -o $${csspath/%.css/.min.css} $$csspath; \
204         done
205
206
207 docs: init
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; \
215                 done; \
216         done; \
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; \
221         done; \
222         cat docs/index.footer >> docs/index.html
223
224
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; \
229         done;
230         ln -sf ${VERSION} ${FRAMEWORK_ROOT}/../latest
231
232 demo: js
233         mkdir -p ${OUTPUT_ROOT}/demos
234         cp -av demos/* ${OUTPUT_ROOT}/demos/
235         cp -f src/template/bootstrap.js ${OUTPUT_ROOT}/demos/gallery/
236
237
238 install: all
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
243
244
245 coverage: clean all
246         # Checking unit test coverage
247         $(CURDIR)/tests/coverage/instrument.sh
248
249
250 dist: clean all docs
251         # Creating tarball...
252         @@ \
253         TMPDIR=$$(mktemp -d tarball.XXXXXXXX); \
254         DESTDIR=$${TMPDIR}/${PROJECT_NAME}; \
255         MIN=''; \
256         if test "x${DEBUG}x" = "xnox"; then \
257                 MIN='.min'; \
258         fi; \
259         TARBALL=${PROJECT_NAME}-${VERSION}-`date +%Y%m%d`$${MIN}.tar.gz; \
260         mkdir -p $${DESTDIR}; \
261         cp -a ${FW_JS} \
262                 ${FW_LIBS_JS} \
263                 ${THEMES_OUTPUT_ROOT}/tizen/${FW_THEME_CSS_FILE} \
264                 ${FW_WIDGET_CSS_FILE} \
265                 ${THEMES_OUTPUT_ROOT}/tizen/images \
266                 docs \
267                 README.md \
268                 COPYING \
269                 $${DESTDIR}; \
270         hash git 2>&1 /dev/null && touch $${DESTDIR}/$$(git log | head -n 1 | awk '{print $$2;}'); \
271         tar cfzps \
272                 $${TARBALL} \
273                 --exclude='.git' \
274                 --exclude='*.less.css' \
275                 --exclude='*.js.compiled' \
276                 --exclude='submodules/jquery-mobile' \
277                 --exclude='${JQUERY}' \
278                 -C $${TMPDIR} ${PROJECT_NAME}; \
279         rm -rf $${TMPDIR}
280
281
282 clean:
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`
288
289
290 init: clean
291         # Check build environment...
292         @@hash lessc 2>/dev/null || (echo "lessc not found. Please see HACKING."; exit 1); \
293
294         # Initializing...
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}
300         @@rm -f docs/*.html