depend libgcrypt
[pkg-chromium/pkg-chromium.git] / debian / rules
1 #!/usr/bin/make -f
2 export DH_VERBOSE = 1
3
4 DEBIAN_NAME             := chromium
5 SOURCE_NAME             := chromium-browser
6 DEBIAN_VERSION          := $(shell dpkg-parsechangelog | sed -n 's/^Version: *\(.*\)$$/\1/ p')
7 DEBIAN_UPSTREAM_VERSION := $(shell echo $(DEBIAN_VERSION) | sed 's/^\(.*\)-[^-]*$$/\1/')
8 DEBIAN_REVISION         := $(shell echo $(DEBIAN_VERSION) | sed 's/^.*r\([^-]*\)-.*/\1/')
9 DEBIAN_DIST             := $(shell lsb_release -ds | tr -d '()')
10 DEBIAN_DIST_NAME        := $(shell lsb_release -si)
11 DEBIAN_DIST_VERSION     := $(shell cat /etc/debian_version)
12 MULTIARCH               := $(shell dpkg-architecture -qDEB_BUILD_MULTIARCH)
13 USE_SYSTEM_FFMPEG       := 0
14 ifeq (1,$(USE_SYSTEM_FFMPEG))
15 LIBAVCODEC_BASENAME     := $(shell basename $$(ls -x /usr/lib/$(MULTIARCH)/libavcodec.so.* | cut -d ' ' -f 1))
16 LIBAVFORMAT_BASENAME    := $(shell basename $$(ls -x /usr/lib/$(MULTIARCH)/libavformat.so.* | cut -d ' ' -f 1))
17 LIBAVUTIL_BASENAME      := $(shell basename $$(ls -x /usr/lib/$(MULTIARCH)/libavutil.so.* | cut -d ' ' -f 1))
18 endif
19
20 # DEB_TAR_SRCDIR has to be 'src' as this is what gyp expects :(
21 DEB_TAR_SRCDIR := src
22 SRC_DIR        := $(CURDIR)/$(DEB_TAR_SRCDIR)
23 LIB_DIR        := usr/lib/$(DEBIAN_NAME)
24 DEB_BUILDDIR   := $(SRC_DIR)
25 #BUILD_ARGS     := --keep-going
26
27 WANT_XZ_SRC      ?= 1
28 WANT_DEBUG       := 0
29 WANT_SYSTEM_LIBS ?= 1
30 WANT_SHARED_LIBS ?= 0
31 WANT_TESTS       ?= 0
32 WANT_SANDBOXING  ?= 1
33 USE_SYSTEM_V8    ?= 0
34
35 # enable build hardening options (pie disabled due to ffmpeg linking issue)
36 export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
37 DPKG_EXPORT_BUILDFLAGS = 1
38 include /usr/share/dpkg/buildflags.mk
39
40 #use DEB_BUILD_OPTIONS's parallel=n option (see Policy 4.9.1)
41 ifneq (,$(findstring parallel,$(DEB_BUILD_OPTIONS)))
42 PARALLEL_JOBS := $(shell echo $(DEB_BUILD_OPTIONS) | \
43         sed -e 's/.*parallel=\([0-9]\+\).*/\1/')
44 ifeq ($(DEB_BUILD_OPTIONS),$(PARALLEL_JOBS))
45 PARALLEL_JOBS := $(shell if [ -f /proc/cpuinfo ]; \
46         then echo `cat /proc/cpuinfo | grep 'processor' | wc -l`; \
47         else echo 1; fi)
48 endif
49 NJOBS := -j$(PARALLEL_JOBS)
50 DEB_MAKE_ENVVARS := MAKEFLAGS=$(NJOBS)
51 endif
52
53 ifneq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
54 WANT_TESTS := 0
55 endif
56
57 # Disable SSE2
58 GYP_DEFINES = disable_sse2=1
59
60 #Debian Chromium Api Key
61 GYP_DEFINES += google_api_key='AIzaSyCkfPOPZXDKNn8hhgu3JrA62wIgC93d44k'
62 GYP_DEFINES += google_default_client_id='811574891467.apps.googleusercontent.com'
63 GYP_DEFINES += google_default_client_secret='kdloedMFGdGla2P1zacGjAQh'
64
65 # Enable all codecs for HTML5 in chromium, depending on which ffmpeg sumo lib
66 # is installed, the set of usable codecs (at runtime) will still vary
67 GYP_DEFINES += proprietary_codecs=1
68
69 # enable compile-time dependency on gnome-keyring
70 GYP_DEFINES += use_gnome_keyring=1 linux_link_gnome_keyring=1
71
72 # controlling the use of GConf (the classic GNOME configuration
73 # and GIO, which contains GSettings (the new GNOME config system)
74 GYP_DEFINES += use_gconf=1 use_gio=1
75
76 #Disable nacl
77 GYP_DEFINES += disable_nacl=1
78
79 # do not use third_party/gold as the linker.
80 GYP_DEFINES += linux_use_gold_binary=0 linux_use_gold_flags=0
81
82 #disable tcmalloc
83 GYP_DEFINES += linux_use_tcmalloc=0
84
85 # Use explicit library dependencies instead of dlopen.
86 # This makes breakages easier to detect by revdep-rebuild.
87 GYP_DEFINES += linux_link_gsettings=1
88
89 # Disable breakpad crash reporting
90 GYP_DEFINES += linux_breakpad=0
91
92 DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
93 DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
94
95 ifeq (arm,$(DEB_HOST_ARCH_CPU))
96 GYP_DEFINES += \
97         target_arch=arm \
98         disable_nacl=1 \
99         linux_use_tcmalloc=0 \
100         enable_webrtc=0 \
101         use_cups=1 \
102         $(NULL)
103 ifeq (armel,$(DEB_HOST_ARCH))
104 GYP_DEFINES += \
105         v8_use_arm_eabi_hardfloat=false \
106         arm_float_abi=soft \
107         arm_thumb=0 \
108         armv7=0 \
109         arm_neon=0 \
110         $(NULL)
111 endif
112 ifeq (armhf,$(DEB_HOST_ARCH))
113 GYP_DEFINES += -DUSE_EABI_HARDFLOAT 
114 GYP_DEFINES += \
115         v8_use_arm_eabi_hardfloat=true \
116         arm_fpu=vfpv3 \
117         arm_float_abi=hard \
118         arm_thumb=1 \
119         armv7=1 \
120         arm_neon=0 \
121         $(NULL)
122 endif
123
124 WANT_TESTS     := 0
125 else
126 ifeq (amd64,$(DEB_HOST_ARCH_CPU))
127 GYP_DEFINES += target_arch=x64
128 else
129 ifeq (i386,$(DEB_HOST_ARCH_CPU))
130 GYP_DEFINES += target_arch=ia32
131 else
132 $(warning unsupported target arch $(DEB_HOST_ARCH_CPU) - continuing anyway)
133 endif
134 endif
135 endif
136
137 # Don't let dh_installinit install *.default in /etc/default
138 DEB_DH_INSTALLINIT_ARGS += --noscripts --onlyscripts
139
140 # don't miss installing newly added files in new upstream releases
141 DEB_DH_INSTALL_ARGS += --list-missing
142
143 ifeq (1,$(WANT_DEBUG))
144 BUILD_TYPE := Debug
145 else
146 BUILD_TYPE := Release
147 # Add symbols
148 BUILD_ARGS += SYMBOLS=1
149 endif
150 BUILD_ARGS += BUILDTYPE=$(BUILD_TYPE)
151
152 # Verbose?
153 ifeq (1,$(DH_VERBOSE))
154 BUILD_ARGS += V=1
155 endif
156
157 # Shared libraries
158 ifeq (1,$(WANT_SHARED_LIBS))
159 GYP_DEFINES += library=shared_library
160 endif
161
162 # Always ignore compiler warnings
163 GYP_DEFINES += werror=$(NULL)
164
165 ifeq (1,$(WANT_XZ_SRC))
166 TAR_EXT   := xz
167 TAR_FLAGS := --xz
168 DEB_TARBALL = $(wildcard *.tar.bz2 *.tar.$(TAR_EXT))
169 else
170 TAR_EXT   := bz2
171 TAR_FLAGS := -j
172 endif
173
174 include /usr/share/cdbs/1/rules/debhelper.mk
175 include /usr/share/cdbs/1/class/makefile.mk
176
177 INSTALL_EXCLUDE_DIRS = \
178         lib \
179         lib.target \
180         obj \
181         obj.target \
182         obj.host \
183         opt \
184         dbg \
185         plugins \
186         '*.d' \
187         .deps \
188         calendar_app \
189         docs_app \
190         gmail_app \
191         pyproto \
192         DumpRenderTree_resources \
193         $(NULL)
194
195 INSTALL_EXCLUDE_FILES = \
196         .sconsign.dblite \
197         linker.lock \
198         convert_dict \
199         chrome-wrapper \
200         product_logo_48.png \
201         libnpapi_layout_test_plugin.so \
202         libnpapi_test_plugin.so \
203         mksnapshot \
204         ncdecode_table \
205         ncdecode_tablegen \
206         springboard_gen \
207         timestats \
208         tramp_gen \
209         protoc \
210         libppapi_tests.so \
211         *.d \
212         genmacro \
213         genmodule \
214         genperf \
215         genstring \
216         genversion \
217         re2c \
218         yasm \
219         $(NULL)
220
221 # List of tests
222 # - prefix the name with a "-" to disable the test suite completely and
223 #   append a reason after a ":"
224 # - prefix the name with a "@" to run the test suite in xvfb-run (fake
225 #   X server for machines with no display hardware and no physical input
226 #   devices).
227 # - to disable one or more tests within a given testsuite,
228 #   append the names of the tests (using the Google Test filter syntax)
229 #   or call the gtfilter macro
230 ifeq (1,$(WANT_TESTS))
231 gtfilter = -$(shell echo $(SKIP_$(1)) | tr ' ' :)
232
233 # tests we can't pass because we don't have enough permissions
234 SKIP_base_unittests := \
235         StatsTableTest.* \
236         SysInfoTest.GetPrimaryDisplayDimensions \
237         $(NULL)
238
239 SKIP_page_cycler_tests := \
240         PageCyclerTest.* \
241         PageCyclerReferenceTest.* \
242         $(NULL)
243
244 SKIP_ui_tests := \
245         WorkerTest.MultipleWorkers \
246         WorkerTest.IncognitoSharedWorkers \
247         $(NULL)
248
249 # tests we can't pass because we need to access internet (~61 out of 987 tests)
250 SKIP_net_unittests := \
251         HttpNetworkLayerTest.GoogleGET \
252         TelnetServerTest.* \
253         PageCyclerTest.* \
254         URLRequestTestHTTP.* \
255         URLRequestTest.QuitTest \
256         URLRequestTest.DoNotSendCookies \
257         URLRequestTest.DoNotSaveCookies \
258         HTTPSRequestTest.* \
259         URLRequestTestFTP.* \
260         SSLClientSocketTest.* \
261         ProxyScriptFetcherTest.* \
262         ListenSocketTest.* \
263         $(NULL)
264
265 TESTS ?= \
266         @app_unittests:-FontTest.LoadArial \
267         base_unittests:$(call gtfilter,base_unittests) \
268         googleurl_unittests \
269         ipc_tests \
270         media_unittests \
271         net_perftests \
272         net_unittests:$(call gtfilter,net_unittests) \
273         @page_cycler_tests:$(call gtfilter,page_cycler_tests) \
274         perf_tests \
275         printing_unittests \
276         @startup_tests \
277         @test_shell_tests \
278         @ui_tests:$(call gtfilter,ui_tests) \
279         unit_tests \
280         $(NULL)
281 endif
282
283 # FFmpeg-mt
284 ifeq (1,$(USE_SYSTEM_FFMPEG))
285 GYP_DEFINES += build_ffmpegsumo=0
286 else
287 GYP_DEFINES += ffmpeg_branding=Chrome
288 endif
289
290 USE_SYSTEM_SQLITE := $(shell pkg-config 'sqlite3 >= 3.6.1' && echo 1 || echo 0)
291 USE_SYSTEM_SQLITE := 0
292
293 USE_SYSTEM_LIBWEBP := $(shell pkg-config 'libwebp >= 0.3.0' && echo 1 || echo 0)
294 USE_SYSTEM_LIBWEBP := 0
295
296 ifneq (,$(filter 8.10 9.04,$(DEBIAN_DIST)))
297 # Don't build with system zlib on Intrepid/Jaunty. See http://crbug.com/38073
298 GYP_DEFINES += use_system_zlib=0
299 endif
300
301 # System libs
302 ifeq (1,$(WANT_SYSTEM_LIBS))
303 GYP_DEFINES += \
304         use_system_bzip2=1 \
305         use_system_libjpeg=1 \
306         use_system_libpng=1 \
307         use_system_sqlite=$(USE_SYSTEM_SQLITE) \
308         use_system_libxml=1 \
309         use_system_libxslt=1 \
310         use_system_zlib=0 \
311         use_system_libevent=1 \
312         use_system_icu=0 \
313         use_system_yasm=1 \
314         use_system_ffmpeg=$(USE_SYSTEM_FFMPEG) \
315         use_system_libvpx=1 \
316         use_system_xdg_utils=1 \
317         use_system_flac=1 \
318         use_system_libwebp=$(USE_SYSTEM_LIBWEBP) \
319         use_system_speex=1 \
320         linux_link_libspeechd=1 \
321         $(NULL)
322 endif
323
324 # Use pulseaudio
325 GYP_DEFINES += use_pulseaudio=1
326
327 # Build everything (like All), including test programs but minus things we don't
328 # want (breakpad, courgette, ..) or don't need (the other small tools)
329 BUILD_TARGETS := \
330         chrome \
331         chrome_sandbox \
332         $(NULL)
333
334 TESTS_TARGETS := \
335         app_unittests \
336         base_unittests \
337         browser_tests \
338         googleurl_unittests \
339         ipc_tests \
340         media_unittests \
341         memory_test \
342         net_perftests \
343         net_unittests \
344         page_cycler_tests \
345         perf_tests \
346         printing_unittests \
347         startup_tests \
348         tab_switching_test \
349         test_shell_tests \
350         ui_tests \
351         unit_tests \
352         url_fetch_test \
353         wav_ola_test \
354         $(NULL)
355
356 ifeq (1,$(WANT_TESTS))
357 INSTALL_EXCLUDE_FILES += \
358         $(TESTS_TARGETS) \
359         test_shell.pak \
360         xdisplaycheck \
361         $(NULL)
362
363 INSTALL_EXCLUDE_DIRS += \
364         app_unittests_strings \
365         $(NULL)
366 endif
367
368 ifeq (1,$(WANT_SANDBOXING))
369 GYP_DEFINES += \
370         linux_sandbox_path=/$(LIB_DIR)/$(DEBIAN_NAME)-sandbox \
371         linux_sandbox_chrome_path=/$(LIB_DIR)/$(DEBIAN_NAME) \
372         $(NULL)
373
374 # needed to preserve the suid and make the sandbox happy
375 DEB_FIXPERMS_EXCLUDE := $(DEBIAN_NAME)-sandbox
376 endif
377
378 # use system v8
379 ifeq (1,$(USE_SYSTEM_V8))
380 GYP_DEFINES += \
381         javascript_engine=v8 \
382         $(NULL)
383 endif
384
385 ######
386 DO = (touch r1; echo '$(1)'; $(1); touch r2 ; T1=`date -r r1 +%s` ; T2=`date -r r2 +%s`; echo "PERF: '$(2)' built in "`expr $$T2 - $$T1`" sec"; rm -f r1 r2;)
387
388 subst_files = \
389         debian/$(DEBIAN_NAME).sh \
390         $(NULL)
391
392 %:: %.in
393         sed -e 's|@BUILD_DIST@|$(DEBIAN_DIST_NAME) $(DEBIAN_DIST_VERSION)|g' \
394             -e 's|@BUILD_DIST_NAME@|$(DEBIAN_DIST_NAME)|g' \
395             -e 's|@BUILD_DIST_VERSION)@|$(DEBIAN_DIST_VERSION)|g' \
396             < $< > $@
397
398 pre-build:: $(subst_files)
399 ifneq (,$(findstring Ubuntu,$(DEBIAN_DIST)))
400         sed -ri '/const PrepopulatedEngine google = \{/,/\}\;/ { s/sourceid=chrome\&/&client=ubuntu\&channel=cs\&/g; }' \
401                 src/chrome/browser/search_engines/template_url_prepopulate_data.cc
402 endif
403
404 DEB_MAKE_BUILD_TARGET := $(BUILD_ARGS) $(BUILD_TARGETS)
405
406 configure/$(DEBIAN_NAME):: debian/configure-stamp
407
408 debian/configure-stamp: GYP_ENV = GYP_GENERATORS=make
409 ifneq (,$(GYP_DEFINES))
410 debian/configure-stamp: GYP_ENV += GYP_DEFINES="$(GYP_DEFINES)"
411 endif
412 debian/configure-stamp:
413         cd $(SRC_DIR) && $(GYP_ENV) python build/gyp_chromium --no-circular-check build/all.gyp
414         touch $@
415         # Populate the LASTCHANGE file template as we no longer have the VCS
416         # files at this point
417         echo "$(DEBIAN_REVISION)" > $(SRC_DIR)/build/LASTCHANGE.in
418         # BUILD_ARGS=$(BUILD_ARGS)
419         cp -p /usr/share/misc/config.guess src/third_party/yasm/source/patched-yasm/config
420         cp -p /usr/share/misc/config.sub src/third_party/yasm/source/patched-yasm/config
421
422 common-build-arch common-build-indep:: debian/stamp-makefile-build-perf
423 debian/stamp-makefile-build-perf: debian/stamp-makefile-build
424         @T2=`date +%s`; T1=`date -r debian/configure-stamp +%s`; echo "PERF: '$(BUILD_TARGETS)' built in "`expr $$T2 - $$T1`" sec"
425         touch $@
426
427 # we don't want all the test binaries linked at the same time when using -jX (X > 2)
428 # Each ld takes ~1.5GB of memory. So run make for each target separatly to workaround that
429 ifeq (1,$(WANT_TESTS))
430 common-build-arch common-build-indep:: debian/stamp-makefile-build-tests
431 debian/stamp-makefile-build-tests: debian/stamp-makefile-build
432         @$(foreach target,$(TESTS_TARGETS),$(call DO,$(DEB_MAKE_INVOKE) $(BUILD_ARGS) $(target),$(target));)
433         touch $@
434 endif
435
436 clean::
437         rm -f debian/configure-stamp debian/stamp-makefile-build-*
438         rm -f *.cdbs-config_list $(subst_files)
439         rm -fr src/out src/Makefile
440         find src -name *.tmp -execdir rm -f {} \;
441         find src -name *.pyc -execdir rm -f {} \;
442         find src -name *.mk -execdir rm -f {} \;
443         find src -name *.Makefile -execdir rm -f {} \;
444         rm -f src/build/LASTCHANGE.in
445         rm -f src/third_party/WebKit/Source/WebCore/WebCore.gyp/idls_list_temp_file.tmp
446         rm -f src/v8/tools/gyp/v8.log
447         rm -f src/third_party/yasm/source/patched-yasm/config/config.guess
448         rm -f src/third_party/yasm/source/patched-yasm/config/config.sub
449
450 # Install: there's no install rules in scons yet, do it manually
451 common-install-prehook-impl::
452         mkdir -p debian/tmp/$(LIB_DIR)
453         ( cd $(SRC_DIR)/out/$(BUILD_TYPE) && tar $(foreach excl,$(INSTALL_EXCLUDE_DIRS),--exclude=$(excl)) -cf - . ) | \
454         ( cd debian/tmp/$(LIB_DIR) && tar xvf - )
455         cd debian/tmp/$(LIB_DIR) && rm -f $(INSTALL_EXCLUDE_FILES)
456         # Launcher script
457         mkdir -p debian/tmp/usr/bin
458 ifneq (,$(findstring Debian,$(DEBIAN_DIST)))
459         sed -ri 's:'CHROME_VERSION_EXTRA=Ubuntu':'CHROME_VERSION_EXTRA=Debian':' debian/$(DEBIAN_NAME).sh
460 endif
461         cp -a debian/$(DEBIAN_NAME).sh debian/tmp/usr/bin/$(DEBIAN_NAME)
462         chmod 755 debian/tmp/usr/bin/$(DEBIAN_NAME)
463         # Preferences
464         mkdir -p debian/tmp/etc/$(DEBIAN_NAME)
465         cp -a debian/$(DEBIAN_NAME).default debian/tmp/etc/$(DEBIAN_NAME)/default
466         # Rename the binary from chrome to $(DEBIAN_NAME), this is required
467         # as chromium dereferences all symlinks before starting its children
468         # making the Gnome System Monitor confused with icons
469         mv debian/tmp/$(LIB_DIR)/chrome debian/tmp/$(LIB_DIR)/$(DEBIAN_NAME)
470         mv debian/tmp/$(LIB_DIR)/chrome_sandbox debian/tmp/$(LIB_DIR)/$(DEBIAN_NAME)-sandbox
471         # Manpage
472         mv debian/tmp/$(LIB_DIR)/chrome.1 debian/tmp/$(LIB_DIR)/chromium.1
473         dh_installman -pchromium debian/tmp/$(LIB_DIR)/chromium.1
474         rm -f debian/tmp/$(LIB_DIR)/chromium.1
475         strip debian/tmp/usr/lib/chromium/nacl_irt_x86_32.nexe || true
476         strip debian/tmp/usr/lib/chromium/nacl_irt_x86_64.nexe || true
477
478 binary-install/$(DEBIAN_NAME)::
479         mkdir -p $(CURDIR)/debian/$(DEBIAN_NAME)/usr/share/pixmaps
480         cp -a src/chrome/app/theme/chromium/product_logo_48.png $(CURDIR)/debian/$(DEBIAN_NAME)/usr/share/pixmaps/$(DEBIAN_NAME).png
481         for size in 16 22 24 32 48 64 128 256 ; do \
482           mkdir -p $(CURDIR)/debian/$(DEBIAN_NAME)/usr/share/icons/hicolor/$${size}x$${size}/apps ; \
483           cp -a src/chrome/app/theme/chromium/product_logo_$$size.png  \
484             $(CURDIR)/debian/$(DEBIAN_NAME)/usr/share/icons/hicolor/$${size}x$${size}/apps/$(DEBIAN_NAME).png ; \
485         done
486         mkdir -p $(CURDIR)/debian/$(DEBIAN_NAME)/usr/share/icons/hicolor/scalable/apps
487         cp -a $(CURDIR)/debian/$(DEBIAN_NAME).svg $(CURDIR)/debian/$(DEBIAN_NAME)/usr/share/icons/hicolor/scalable/apps
488 ifeq (1,$(WANT_SANDBOXING))
489         chmod 4755 $(CURDIR)/debian/$(DEBIAN_NAME)/$(LIB_DIR)/$(DEBIAN_NAME)-sandbox
490 else
491         rm -vf $(CURDIR)/debian/$(DEBIAN_NAME)/$(LIB_DIR)/$(DEBIAN_NAME)-sandbox
492 endif
493         # Locales: only keep en-US in the main deb
494         cd $(CURDIR)/debian/$(DEBIAN_NAME)/$(LIB_DIR)/locales && \
495           rm -f $(filter-out en-US.pak,$(notdir $(wildcard $(CURDIR)/debian/$(DEBIAN_NAME)/$(LIB_DIR)/locales/*)))
496         # DEB_ARCH_PACKAGES=$(DEB_ARCH_PACKAGES)
497         # DEB_INDEP_PACKAGES=$(DEB_INDEP_PACKAGES)
498 ifneq (i386,$(DEB_HOST_ARCH_CPU))
499         # DEB_HOST_ARCH_CPU=$(DEB_HOST_ARCH_CPU)
500         # We assume we're *not* doing the "Architecture: all" packages so we need
501         # to drop the -l10n files from debian/tmp to make 'compare' happy
502         cd $(CURDIR)/debian/tmp/$(LIB_DIR)/locales && \
503           rm $(filter-out en-US.pak,$(notdir $(wildcard $(CURDIR)/debian/tmp/$(LIB_DIR)/locales/*)))
504         # same for inspector
505         rm -rf $(CURDIR)/debian/tmp/$(LIB_DIR)/resources/inspector/*
506 endif
507 ifeq (1,$(USE_SYSTEM_FFMPEG))
508         # Install symlinks to system ffmpeg libs
509         ln -sf "../$(MULTIARCH)/$(LIBAVCODEC_BASENAME)" \
510                 "$(CURDIR)/debian/$(DEBIAN_NAME)/$(LIB_DIR)/$(LIBAVCODEC_BASENAME)"
511         ln -sf "../$(MULTIARCH)/$(LIBAVFORMAT_BASENAME)" \
512                 "$(CURDIR)/debian/$(DEBIAN_NAME)/$(LIB_DIR)/$(LIBAVFORMAT_BASENAME)"
513         ln -sf "../$(MULTIARCH)/$(LIBAVUTIL_BASENAME)" \
514                 "$(CURDIR)/debian/$(DEBIAN_NAME)/$(LIB_DIR)/$(LIBAVUTIL_BASENAME)"
515 endif
516
517 binary-install/$(DEBIAN_NAME)-l10n::
518         rm $(CURDIR)/debian/$(DEBIAN_NAME)-l10n/$(LIB_DIR)/locales/en-US.pak
519
520 # Tests
521 ifeq (1,$(WANT_TESTS))
522 binary-post-install/$(DEBIAN_NAME)::
523         ######################### TESTS ######################################
524         # Run all possible tests from the chromium testsuite
525         # Buildd doesn't allow network accesses so the corresponding
526         # tests have to be skipped
527         @chmod u+x $(CURDIR)/debian/run-test.sh
528         @mkdir -p debian/test-results
529         @T1=`date +%s`; cd $(SRC_DIR)/out/$(BUILD_TYPE) && \
530         for test in $(TESTS) ; do \
531                 tname=`echo "$$test" | sed -e 's/^[-@]\?\([^:]*\).*/\1/'` ; \
532                 filter=`echo "$$test" | sed -e 's/^[^-][^:]*://' | grep -v -- "$$test"` ; \
533                 echo "==========================================================================" ; \
534                 if [ Z"`echo $$test | sed -e 's/^-.*//'`" = Z ] ; then \
535                         echo "Skipped '$$tname', reason: "`echo $$test | sed -e 's/^[^:]*://'` ; \
536                         continue ; \
537                 fi ; \
538                 OPT="" ; \
539                 if [ Z"`echo $$test | sed -e 's/^@.*//'`" = Z ] ; then \
540                         OPT=-x ; \
541                 fi ; \
542                 $(CURDIR)/debian/run-test.sh $$OPT ./$$tname $(CURDIR)/debian/test-results/ $$filter || true ; \
543                 echo "==========================================================================" ; \
544                 echo ; \
545         done; \
546         T2=`date +%s`; echo "PERF: all tests run in "`expr $$T2 - $$T1`" sec"
547 endif
548
549 # Compare
550 PKG_DIRS = $(addprefix debian/,$(shell grep ^Package debian/control | cut -d' ' -f2))
551
552 binary-predeb/$(DEBIAN_NAME):: compare
553
554 compare:
555         # Look for duplicates, fail if we find any
556         @DUPES=`find $(PKG_DIRS) -type f -print | grep -v /DEBIAN/ | cut -d/ -f3- | sort | uniq -c | grep -vE '^  *1 '` ; \
557         if [ "Z$$DUPES" != Z ] ; then \
558           echo " => Found duplicates:\n $$DUPES" ; \
559           exit 1 ; \
560         else \
561           echo " => No duplicate found" ; \
562         fi
563         # Find missing
564         @find $(PKG_DIRS) -type f -print | grep -v /DEBIAN/ | grep -vE '(/usr/lib/debug|/test-results/|/locales/|/inspector/)' | \
565           grep $(LIB_DIR) | cut -d/ -f5- | sort > /tmp/pkg-$$$$.indebs ; \
566         find debian/tmp/$(LIB_DIR) -type f -print | cut -d/ -f5- | grep -vE '(\.log$$|/locales/|/inspector/|\.stamp$$)' | sort > /tmp/pkg-$$$$.inhammer ; \
567         diff -u /tmp/pkg-$$$$.inhammer /tmp/pkg-$$$$.indebs ; \
568         if [ $$? -eq 0 ] ; then \
569           echo " => All fine" ; \
570         else \
571           echo " => Found differences, please investigate" ; \
572           exit 1 ; \
573         fi ; \
574         rm -f /tmp/pkg-$$$$.inhammer /tmp/pkg-$$$$.indebs
575
576 binary-makedeb-IMPL/$(DEBIAN_NAME)::
577         dh_gencontrol -p$(DEBIAN_NAME)
578 ifeq (1,$(USE_SYSTEM_FFMPEG))
579         # Manually insert ffmpeg libs shlib deps for chromium since the
580         # libs are dlopened.
581         sed "s/^Depends:.*$$/&, $$(sh debian/var_info LIBAVCODEC_DEPENDS)/" \
582                 -i "debian/$(DEBIAN_NAME)/DEBIAN/control"
583         sed "s/^Depends:.*$$/&, $$(sh debian/var_info LIBAVFORMAT_DEPENDS)/" \
584                 -i "debian/$(DEBIAN_NAME)/DEBIAN/control"
585         sed "s/^Depends:.*$$/&, $$(sh debian/var_info LIBAVUTIL_DEPENDS)/" \
586                 -i "debian/$(DEBIAN_NAME)/DEBIAN/control"
587 endif
588         dh_md5sums -p$(DEBIAN_NAME)
589         dh_builddeb -p$(DEBIAN_NAME)
590
591
592 ###############################################################################################
593
594 # Tarball (get-orig-source & get-current-source)
595 GCLIENT_URL  := http://src.chromium.org/svn/trunk/tools/depot_tools
596 CHROMIUM_URL := http://src.chromium.org/svn/trunk/src
597 CHROMIUM_RLZ := http://src.chromium.org/svn/releases
598 DEPS_URL     := http://src.chromium.org/svn/trunk/deps/third_party
599 GREEN_REV_URL := http://chromium-status.appspot.com/lkgr
600 CHANNELS_URL  := http://omahaproxy.appspot.com/all
601
602 # See Staying Green More Of The Time at http://dev.chromium.org/developers/how-tos/get-the-code
603 USE_GREEN_REV ?= 0
604
605 STRIP_TARBALL ?= 1
606
607 STRIPPED_DIRS_FROM_CO := \
608         src/breakpad/src \
609         src/tools/gyp \
610         src/chrome/tools/test/reference_build \
611         src/chrome/tools/test/reference_build/chrome_linux \
612         src/webkit/data/layout_tests/LayoutTests \
613         src/third_party/WebKit/LayoutTests \
614         src/third_party/ffmpeg/binaries/chromium/linux/ia32 \
615         src/third_party/ffmpeg/binaries/chromium/linux/ia32_dbg \
616         src/third_party/ffmpeg/binaries/chromium/linux/x64 \
617         src/third_party/ffmpeg/binaries/chromium/linux/x64_dbg \
618         $(NULL)
619
620 # stuff we don't have access to and shouldn't be in DEPS
621 STRIPPED_DIRS_FROM_CO += \
622         src/chrome/app/theme/google_chrome \
623         src/chrome/installer/linux \
624         $(NULL)
625
626 # prefix with _ those that we can't remove (just yet) because of the gclient
627 # hooks (see build/all.gyp) or of some unneeded deps/includes
628 STRIPPED_DIRS := \
629         chrome/test/data/safe_browsing/old \
630         chrome/test/data/firefox2_nss_mac \
631         chrome/third_party/wtl/ \
632         gears \
633         google_update \
634         o3d \
635         third_party/boost \
636         third_party/bsdiff \
637         third_party/bspatch \
638         third_party/ffmpeg/binaries \
639         third_party/fuzzymatch \
640         third_party/gles_book_examples \
641         third_party/gold \
642         third_party/hunspell/dictionaries \
643         third_party/icu/mac \
644         third_party/lcov \
645         third_party/lighttpd \
646         third_party/nspr \
647         third_party/nss \
648         third_party/ocmock \
649         third_party/pthread \
650         third_party/pyftpdlib \
651         third_party/simplejson \
652         third_party/scons \
653         _third_party/tcmalloc \
654         tools/symsrc \
655         tools/site_compare \
656         tools/stats_viewer \
657         tools/valgrind \
658         tools/wine_valgrind \
659         v8/test/cctest \
660         webkit/data/layout_tests \
661         native_client/toolchain/linux_x86/info \
662         native_client/toolchain/linux_x86/man \
663         native_client/toolchain/linux_x86/share/info \
664         native_client/toolchain/linux_x86/x86_64-nacl/share/info \
665         native_client/toolchain/linux_x86_newlib/info \
666         native_client/toolchain/linux_x86_newlib/man \
667         native_client/toolchain/linux_x86_newlib/share/info \
668         $(NULL)
669
670 # There are directories we want to strip, but that are unnecessarily required by the build-system
671 # So we drop everything but the gyp/gypi files and README.chromium (to see what that dir contained)
672 ALMOST_STRIPPED_DIRS := \
673         courgette \
674         third_party/gles2_book \
675         $(NULL)
676
677 ifeq (1,$(WANT_SYSTEM_LIBS))
678 # Directories that will be dropped if the corresponding system lib are enabled in GYP_DEFINES
679 # We need to keep some files (like *.gyp) so we can't use STRIPPED_DIRS
680 # We can't drop third_party/zlib because we don't have contrib/minizip/*zip.h, and
681 # third_party/sqlite because it's a conditional build (see USE_SYSTEM_SQLITE)
682 STRIPPED_SYSTEM_LIB_DIRS += \
683         third_party/bzip2 \
684         third_party/libjpeg \
685         third_party/libpng \
686         third_party/libxslt \
687         $(NULL)
688 endif
689
690 STRIP_SYSTEM_DIRS = \
691         ($(foreach DIR,$(1),$(if $(findstring use_system_$(notdir $(DIR))=1,$(GYP_DEFINES)),\
692           (cd $(2)/$(dir $(DIR)) && \
693           find $(notdir $(DIR)) -depth -mindepth 1 \! \( -name \*.gyp -o -name \*.gypi -o -name README.chromium -o -name \*.patch \) -print -delete );)))
694
695 ALMOST_STRIP_DIRS = \
696         ($(foreach DIR,$(1),(cd $(2)/$(dir $(DIR)) && \
697           find $(notdir $(DIR)) -depth -mindepth 1 \! \( -name \*.gyp -o -name \*.gypi -o -name README.chromium \) -print -delete );))
698
699 TMP_DDIR     := $(DEBIAN_NAME)-$(shell echo $$$$)
700 ifeq (,$(LOCAL_BRANCH))
701 TMP_DIR      := $(TMP_DDIR)
702 else
703 TMP_DIR      := $(LOCAL_BRANCH)
704 endif
705
706 get-orig-source: REVISION = $(NULL)
707 get-orig-source: TAG      = $(NULL)
708 ifneq (,$(DEBIAN_TAG))
709 get-orig-source: TAG      = $(DEBIAN_TAG)
710 else
711 ifneq (,$(DEBIAN_REV))
712 get-orig-source: REVISION = --revision src@$(DEBIAN_REV)
713 else
714 # Doing either the dev or beta or stable channel
715 ifneq (,$(CHANNEL))
716 ifneq (,$(filter-out stable beta dev Stable Beta Dev,$(CHANNEL)))
717 # Assume it's a version
718 get-orig-source: VERS          = $(CHANNEL)
719 else
720 get-orig-source: VERS          = $(shell wget -qO - $(CHANNELS_URL) | grep -i '^linux,$(CHANNEL)' | cut -d, -f3)
721 endif
722 get-orig-source: CHROMIUM_URL  = $(CHROMIUM_RLZ)/$(VERS)
723 get-orig-source: USE_GREEN_REV = 0
724 endif
725 endif
726 endif
727 get-orig-source: gos-all
728
729 get-current-source: TAG      = $(NULL)
730 get-current-source: REVISION = --revision src@$(DEBIAN_REVISION)
731 ifneq (,$(DEBIAN_REV))
732 get-current-source: REVISION = --revision src@$(DEBIAN_REV)
733 endif
734 get-current-source: gos-all
735
736 gos-all: gos-co gos-pack
737 gos-co:
738 ifneq (,$(CHANNEL))
739         @if [ Z$(VERS) = Z ] ; then \
740           echo "Error: Cannot parse $(CHANNELS_URL) to get the release version for channel $(CHANNEL)" ; \
741           exit 1 ; \
742         fi
743 endif
744 ifneq (,$(TAG))
745         $(error gclient doesn\'t support tags. We need to tweak CHROMIUM_URL. Abort)
746 endif
747 ifeq (,$(LOCAL_BRANCH))
748         rm -rf $(TMP_DIR)
749 endif
750         @if [ ! -d $(TMP_DIR) ] ; then echo mkdir $(TMP_DIR); mkdir $(TMP_DIR) ; fi
751         @if [ ! -d $(TMP_DIR)/tools/depot_tools ] ; then \
752           echo svn co $(GCLIENT_URL) $(TMP_DIR)/tools/depot_tools ; \
753           svn co $(GCLIENT_URL) $(TMP_DIR)/tools/depot_tools ; \
754         else \
755           echo svn update $(TMP_DIR)/tools/depot_tools ; \
756           svn update $(TMP_DIR)/tools/depot_tools ; \
757         fi
758         rm -f $(TMP_DIR)/.gclient
759 ifeq (1,$(USE_GREEN_REV)$(REVISION))
760         cd $(TMP_DIR) && ./tools/depot_tools/gclient config $(CHROMIUM_URL) $(GREEN_REV_URL)
761 else
762         cd $(TMP_DIR) && ./tools/depot_tools/gclient config $(CHROMIUM_URL)
763 endif
764 ifeq (1,$(STRIP_TARBALL))
765 ifneq (,$(STRIPPED_DIRS_FROM_CO))
766         # Add exclusions in .gclient for $(STRIPPED_DIRS_FROM_CO)
767         @for excl in $(STRIPPED_DIRS_FROM_CO) ; do \
768           perl -i -pe 's,("custom_deps"\s*:\s*{),$$1\n      "'$$excl'": None\,,' $(TMP_DIR)/.gclient ; \
769         done
770         grep -Ev '^($$|[[:blank:]]*#)' $(TMP_DIR)/.gclient
771 endif
772 endif
773         # Checkout (drop the previous content and retry if gclient failed, see http://crbug.com/39954)
774         cd $(TMP_DIR) && ./tools/depot_tools/gclient update --nohooks $(REVISION) || \
775           ( rm -rf $(foreach dir,src [0-9]*,$(wildcard $(TMP_DIR)/$(dir))) ; ./tools/depot_tools/gclient update --nohooks $(REVISION) )
776         # For NaCL, run the hooks, but not the gyp ones
777         ( cd $(TMP_DIR) ; \
778                 SDIR=`grep '"name"' .gclient | cut -d\" -f4` ; \
779                 perl -i~ -pe 's%(.python., .src/build/gyp_chromium.)%"echo", "#disabled#", $$1%' $$SDIR/DEPS; \
780                 ./tools/depot_tools/gclient runhooks ; \
781                 mv $$SDIR/DEPS~ $$SDIR/DEPS ; )
782
783 ifneq (,$(LOCAL_BRANCH))
784         rm -rf $(TMP_DDIR)
785         cp -la $(TMP_DIR) $(TMP_DDIR)
786 endif
787 ifeq (1,$(STRIP_TARBALL))
788         # Strip tarball from some big directories not needed on the linux platform
789         cd $(TMP_DDIR)/src && rm -rfv $(STRIPPED_DIRS) | grep -vE '/\.svn(/|.$$)' > REMOVED-stripped.txt
790 ifneq (,$(ALMOST_STRIPPED_DIRS))
791         # Strip listed dirs almost completely (keep *.gyp and README.chromium)
792         $(call ALMOST_STRIP_DIRS,$(ALMOST_STRIPPED_DIRS),$(TMP_DDIR)/src) | grep -vE '/\.svn(/|.$$)' >> $(TMP_DDIR)/src/REMOVED-stripped.txt
793 endif
794 ifneq (,$(STRIPPED_SYSTEM_LIB_DIRS))
795         $(call STRIP_SYSTEM_DIRS,$(STRIPPED_SYSTEM_LIB_DIRS),$(TMP_DDIR)/src) | grep -vE '/\.svn(/|.$$)' >> $(TMP_DDIR)/src/REMOVED-stripped.txt
796 endif
797 endif
798         # Remove binaries
799         cd $(TMP_DDIR)/src && find . -type f \( -iname \*.exe -o -iname \*.dll -o -iname \*.pdb -o -name \*.o -o -name \*.a -o -name \*.dylib -o -name \*.so -o -name \*.so.\* \) -ls -delete > REMOVED-bin_only.txt
800         wc -l $(TMP_DDIR)/src/REMOVED-*.txt
801
802         # Remove cache files and backups
803         cd $(TMP_DDIR)/src && find . -type f \( -iname \*.bak -o -iname \*.orig -o -iname \*.cache \) -ls -delete > REMOVED-ephemera.txt
804         wc -l $(TMP_DDIR)/src/REMOVED-*.txt
805
806         # Remove known files that have non-free licenses
807         cd $(TMP_DDIR)/src && find . -name bfd.info -ls -delete > REMOVED-nonfree.txt
808         wc -l $(TMP_DDIR)/src/REMOVED-*.txt
809
810         # Remove unused webkit layout tests
811         rm -rf $(TMP_DDIR)/src/third_party/WebKit/LayoutTests
812
813         # Remove unsafe symlink
814         rm -rf src/native_client/toolchain/pnacl_linux_x86/newlib/sysroot/sys-include
815         
816 gos-pack: TMP_DIR  = $(TMP_DDIR)
817 ifneq (,$(DEBIAN_TAG))
818 gos-pack: VERSION  = $(shell echo $(DEBIAN_TAG) | cut -d= -f2)
819 else
820 ifeq (,$(CHANNEL))
821 gos-pack: REVISION = $(shell cd $(TMP_DIR)/src && svn log --xml --limit 1 | grep -E '^( *revision=|<date>)' | tr -d '\n' | \
822                      sed -e 's/.*"\([0-9]*\)".*>\(....\)-\(..\)-\(..\)T.*/\2\3\4r\1/')
823 gos-pack: VERSION  = $(shell cut -d= -f2 $(TMP_DIR)/src/chrome/VERSION | sed -e 's,$$,.,' | tr -d '\n' | sed -e 's/.$$//')~svn$(REVISION)
824 else
825 gos-pack: REVISION = $(shell cd $(TMP_DIR)/src && svn log --xml --limit 1 | grep '^ *revision=' | cut -d'"' -f2)
826 gos-pack: VERSION  = $(shell cut -d= -f2 $(TMP_DIR)/src/chrome/VERSION | sed -e 's,$$,.,' | tr -d '\n' | sed -e 's/.$$//')
827 endif
828 endif
829 gos-pack:
830         # Pack
831         if [ src != $(DEB_TAR_SRCDIR) ] ; then mv $(TMP_DIR)/src $(TMP_DIR)/$(DEB_TAR_SRCDIR) ; fi
832         mv $(TMP_DIR)/tools/depot_tools $(TMP_DIR)/$(DEB_TAR_SRCDIR)/depot_tools
833         mkdir $(TMP_DIR)/$(SOURCE_NAME)-$(VERSION)
834         mv $(TMP_DIR)/$(DEB_TAR_SRCDIR) $(TMP_DIR)/$(SOURCE_NAME)-$(VERSION)/
835         cd $(TMP_DIR) && tar -c $(TAR_FLAGS) -f ../$(SOURCE_NAME)_$(VERSION).orig.tar.$(TAR_EXT) --exclude=.svn --exclude=.git $(SOURCE_NAME)-$(VERSION)
836         rm -rf $(TMP_DIR)
837         @echo "# Done (created $(SOURCE_NAME)_$(VERSION).orig.tar.$(TAR_EXT))"
838         @ls -l $(SOURCE_NAME)_$(VERSION).orig.tar.$(TAR_EXT)