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