blob: 27a990d4bdc021b9813685f3a793d6378918fa55 [file] [log] [blame]
aviauf89d7062016-06-14 12:42:57 -04001#!/usr/bin/make -f
2# -*- makefile -*-
3
4# Hardening
5export DEB_BUILD_MAINT_OPTIONS = hardening=+all
6DPKG_EXPORT_BUILDFLAGS = 1
7include /usr/share/dpkg/buildflags.mk
8
9# Number of CPUS
10NO_CPUS=$(shell nproc)
11ifeq ($(NO_CPUS),0)
12NO_CPUS=1
13endif
14
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -040015# Binary package names
Maxim Cournoyer0a269662021-02-05 16:02:43 -050016JAMI_ALL_IN_ONE_PKG_NAME="jami-all"
17JAMI_CLIENT_PKG_NAME="jami"
Amin Bandali6d0caec2021-03-17 10:40:22 -040018JAMI_CLIENT_GNOME_PKG_NAME="jami-gnome"
19JAMI_LIB_CLIENT_PKG_NAME="jami-libclient"
Maxim Cournoyer0a269662021-02-05 16:02:43 -050020JAMI_DAEMON_PKG_NAME="jami-daemon"
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -040021
Fredy Pb20faf62019-12-09 10:15:45 -050022# Bundled packages from contrib
Sébastien Blin14518942021-04-19 16:13:13 -040023BUNDLED_PKGS=""
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000024ifeq (raspbian_10_armhf,$(findstring raspbian_10_armhf, $(DISTRIBUTION)))
Fredy Pb20faf62019-12-09 10:15:45 -050025# Raspbian's yaml-cpp lib does not work properly
Sébastien Blin14518942021-04-19 16:13:13 -040026BUNDLED_PKGS="--enable-ffmpeg --enable-yaml-cpp"
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000027# Add host environment variables
28CMAKE_OPTIONS=-DCHOST=${HOST_ARCH} \
29 -DCMAKE_C_COMPILER=${HOST_ARCH}-gcc \
30 -DCMAKE_CXX_COMPILER=${HOST_ARCH}-g++ \
31 -DCMAKE_FIND_ROOT_PATH=/usr/${HOST_ARCH} \
32 -DPKG_CONFIG_EXECUTABLE=/usr/bin/${HOST_ARCH}-pkg-config
Sébastien Blin14518942021-04-19 16:13:13 -040033else
34ifneq (ubuntu_21.04,$(findstring ubuntu_21.04, $(DISTRIBUTION)))
35BUNDLED_PKGS="--enable-ffmpeg" # For ubuntu 21.04 it seems there is massive issues with linking for swscale
36endif
Fredy Pb20faf62019-12-09 10:15:45 -050037endif
38
Amin Bandali6d0caec2021-03-17 10:40:22 -040039# Qt-related variables
40QT_JAMI_PREFIX := ${QT_JAMI_PREFIX}
41export PATH := $(QT_JAMI_PREFIX)/bin:${PATH}
42export LD_LIBRARY_PATH := $(QT_JAMI_PREFIX)/lib:${LD_LIBRARY_PATH}
43export PKG_CONFIG_PATH := $(QT_JAMI_PREFIX)/lib/pkgconfig:${PKG_CONFIG_PATH}
44export CMAKE_PREFIX_PATH := $(QT_JAMI_PREFIX)/lib/cmake:${CMAKE_PREFIX_PATH}
45
46
aviauf89d7062016-06-14 12:42:57 -040047%:
48 dh $@
49
50override_dh_auto_configure:
51 ###############################################
52 ## Re-create tarballs from tarballs-unpacked ##
53 ###############################################
54 mkdir -p daemon/contrib/tarballs
55
56 # Create tarballs
57 for i in $(CURDIR)/daemon/contrib/tarballs-unpacked/*; do \
58 projectname=`basename $$i` && \
59 cd $$i && tar -caf ../../tarballs/$$projectname * && \
60 echo "Repacked $$projectname"; \
61 done
62
aviauf89d7062016-06-14 12:42:57 -040063 ###########################
Sébastien Blin14518942021-04-19 16:13:13 -040064 ## Daemon configure ##
aviauf89d7062016-06-14 12:42:57 -040065 ###########################
66 mkdir -p daemon/contrib/native
67 cd daemon/contrib/native && \
68 ../bootstrap \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000069 --host=${HOST_ARCH} \
aviaudc3c9de2016-10-05 11:13:23 -040070 --disable-downloads \
aviau2fd81442016-07-27 15:13:33 -040071 --no-checksums \
aviauf89d7062016-06-14 12:42:57 -040072 --disable-ogg \
73 --disable-flac \
74 --disable-vorbis \
75 --disable-vorbisenc \
76 --disable-speex \
77 --disable-sndfile \
aviau9c5c4ad2016-07-20 14:07:34 -040078 --disable-gsm \
Stepan Salenikovich19dd3342016-08-16 10:04:15 -040079 --disable-speexdsp \
Sébastien Blin14518942021-04-19 16:13:13 -040080 --disable-natpmp \
81 --enable-gnutls $(BUNDLED_PKGS) && \
aviauf89d7062016-06-14 12:42:57 -040082 make list && \
Sébastien Blin14518942021-04-19 16:13:13 -040083 make -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040084 cd daemon && \
85 ./autogen.sh && \
86 ./configure \
Stepan Salenikovicha61de1f2016-08-18 16:02:37 -040087 --prefix=/usr \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000088 --disable-shared \
89 --host=${HOST_ARCH}
aviauf89d7062016-06-14 12:42:57 -040090
91 #############################
92 ## libringclient configure ##
93 #############################
94 cd lrc && \
95 mkdir build && \
96 cd build && \
97 cmake \
98 -DRING_BUILD_DIR=$(CURDIR)/daemon/src \
99 -DCMAKE_INSTALL_PREFIX=/usr \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +0000100 $(CMAKE_OPTIONS) \
aviauf89d7062016-06-14 12:42:57 -0400101 ..
102
103 ############################
104 ## gnome client configure ##
105 ############################
106 cd client-gnome && \
107 mkdir build && \
108 cd build && \
109 cmake \
110 -DCMAKE_INSTALL_PREFIX=/usr \
111 -DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
Stepan Salenikovichd6f588a2016-08-30 15:40:15 -0400112 -DGSETTINGS_LOCALCOMPILE=OFF \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +0000113 $(CMAKE_OPTIONS) \
aviauf89d7062016-06-14 12:42:57 -0400114 ..
115
Amin Bandali6d0caec2021-03-17 10:40:22 -0400116 #########################
117 ## qt client configure ##
118 #########################
119 # needs to be done after lrc is built; see below
120
aviauf89d7062016-06-14 12:42:57 -0400121 dh_auto_configure
122
123override_dh_auto_build:
124 #######################
Sébastien Blin14518942021-04-19 16:13:13 -0400125 ## Daemon build ##
aviauf89d7062016-06-14 12:42:57 -0400126 #######################
aviau9c5c4ad2016-07-20 14:07:34 -0400127 make -C daemon -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400128 pod2man daemon/man/dring.pod > daemon/dring.1
129
130 #########################
131 ## libringclient build ##
132 #########################
aviau9c5c4ad2016-07-20 14:07:34 -0400133 make -C lrc/build -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400134
135 ########################
136 ## gnome client build ##
137 ########################
aviau9c5c4ad2016-07-20 14:07:34 -0400138 make -C client-gnome/build LDFLAGS="-lpthread" -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400139
Amin Bandali6d0caec2021-03-17 10:40:22 -0400140 ###################################
141 ## qt client configure and build ##
142 ###################################
143 cd client-qt && \
144 mkdir build && \
145 cd build && \
146 cmake \
147 -DCMAKE_INSTALL_PREFIX=/usr \
148 -DLRC=$(CURDIR)/lrc \
149 $(CMAKE_OPTIONS) \
150 ..
151 make -C client-qt/build -j$(NO_CPUS) V=1
152
aviauf89d7062016-06-14 12:42:57 -0400153override_dh_auto_clean:
154 ################################
155 ## Generated contrib tarballs ##
156 ################################
157 rm -rfv daemon/contrib/tarballs
158
159 #######################
Sébastien Blin14518942021-04-19 16:13:13 -0400160 ## Daemon clean ##
aviauf89d7062016-06-14 12:42:57 -0400161 #######################
aviau9ee77442016-09-06 14:31:00 -0400162 if [ -f daemon/contrib/native/Makefile ]; then make -C daemon/contrib/native distclean; fi
aviauf89d7062016-06-14 12:42:57 -0400163 rm -rfv daemon/contrib/native
164 rm -rfv daemon/dring.1
165
166 #########################
167 ## libringclient clean ##
168 #########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500169 # CMake build system has no distclean target, so use clean.
170 if [ -f lrc/build/Makefile ]; then make -C lrc/build clean; fi
aviauf89d7062016-06-14 12:42:57 -0400171 rm -rfv lrc/build
172
173 ########################
174 ## gnome client clean ##
175 ########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500176 # CMake build system has no distclean target, so use clean.
177 if [ -f client-gnome/build/Makefile ]; then make -C client-gnome/build clean; fi
aviauf89d7062016-06-14 12:42:57 -0400178 rm -rfv client-gnome/build
179
Amin Bandali6d0caec2021-03-17 10:40:22 -0400180 #####################
181 ## qt client clean ##
182 #####################
183 # CMake build system has no distclean target, so use clean.
184 if [ -f client-qt/build/Makefile ]; then make -C client-qt/build clean; fi
185 rm -rfv client-qt/build
186
aviau5c3c1b32017-05-02 22:39:54 -0400187override_dh_clean:
188 # GNUTLS contains:
189 # ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/src/certtool-args.c.bak
190 # ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/doc/doxygen/Doxyfile.orig
191 dh_clean -X.bak -X.orig
192
aviauf89d7062016-06-14 12:42:57 -0400193override_dh_auto_install:
194 #########################
Sébastien Blin14518942021-04-19 16:13:13 -0400195 ## Daemon install ##
aviauf89d7062016-06-14 12:42:57 -0400196 #########################
aviauf89d7062016-06-14 12:42:57 -0400197
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500198 cd daemon && make DESTDIR=$(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME) install
199 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/include
200 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/lib/*.a
201 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/lib/*.la
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400202
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400203 #########################
Fredy P553fef12019-10-10 15:05:06 -0400204 ## Jami client install ##
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400205 #########################
206
207 ## LibRingClient
Amin Bandali6d0caec2021-03-17 10:40:22 -0400208 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME) install
209 rm -rfv $(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME)/usr/include
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400210
211 # This is a symlink, should be in -dev package
Amin Bandali6d0caec2021-03-17 10:40:22 -0400212 rm -v $(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME)/usr/lib/libringclient.so
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400213
214 # cmake files
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500215 rm -rfv $(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME)/usr/lib/cmake
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400216
217 ## GNOME client
Amin Bandali6d0caec2021-03-17 10:40:22 -0400218 cd client-gnome/build && \
219 make DESTDIR=$(CURDIR)/debian/$(JAMI_CLIENT_GNOME_PKG_NAME) install
220 rm -rfv $(CURDIR)/debian/$(JAMI_CLIENT_GNOME_PKG_NAME)/usr/bin/jami
221
222 ## Qt client
223 cd client-qt/build && \
224 make DESTDIR=$(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME) install
225
Fredy P553fef12019-10-10 15:05:06 -0400226 ln -sf /usr/bin/jami $(CURDIR)/debian/jami/usr/bin/ring.cx
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400227
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400228 ######################
Fredy P553fef12019-10-10 15:05:06 -0400229 ## Jami AiO install ##
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400230 ######################
231
232 ## daemon
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500233 cd daemon && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
234 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
235 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.a
236 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.la
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400237
238 ## LibRingClient
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500239 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
240 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
aviauf89d7062016-06-14 12:42:57 -0400241
242 # This is a symlink, should be in -dev package
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500243 rm -v $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/libringclient.so
aviauf89d7062016-06-14 12:42:57 -0400244
245 # cmake files
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500246 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/cmake
aviauf89d7062016-06-14 12:42:57 -0400247
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400248 ## GNOME client
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500249 cd client-gnome/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
Amin Bandali6d0caec2021-03-17 10:40:22 -0400250 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/bin/jami
251
252 ## Qt client
253 cd client-qt/build && \
254 make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
255
256 ln -sf /usr/bin/jami $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/bin/ring.cx
257
258override_dh_shlibdeps:
259 dh_shlibdeps -- -x$(JAMI_ALL_IN_ONE_PKG_NAME)
aviauf89d7062016-06-14 12:42:57 -0400260
aviauf89d7062016-06-14 12:42:57 -0400261tmpdir:= $(shell mktemp -d)
262workdir:= $(shell pwd)
263PKD := $(abspath $(dir $(MAKEFILE_LIST)))
264version_to_download := $(shell dpkg-parsechangelog -ldebian/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\~dfsg.+)(?:\-\d+.*)};')
265
266# Repacks the tarball with contrib tarballs unpacked.
267get-orig-source:
Fredy P553fef12019-10-10 15:05:06 -0400268 # Download jami tarball
aviauf89d7062016-06-14 12:42:57 -0400269 if [ -n "$$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL" ]; then \
270 mv $$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL ${tmpdir}; \
271 else \
272 uscan --rename --destdir=${tmpdir} --download-version ${version_to_download} ;\
273 fi
274
Fredy P553fef12019-10-10 15:05:06 -0400275 # Unpack jami tarball
aviauf89d7062016-06-14 12:42:57 -0400276 tar -C ${tmpdir} -xf ${tmpdir}/*.tar.gz
277
278 # Remove original tarball
279 rm ${tmpdir}/*.tar.gz
280
281 # Unpack all of the orig tarballs into tarballs-unpacked
Fredy P553fef12019-10-10 15:05:06 -0400282 if [ -d "${tmpdir}/jami/" ]; then \
283 mv ${tmpdir}/jami/ ${tmpdir}/ring-project/; \
Sébastien Blin94aaa832019-04-19 14:04:38 -0400284 fi
aviauf89d7062016-06-14 12:42:57 -0400285 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked
286 for i in `find ${tmpdir}/ring-project/daemon/contrib/tarballs/ -name "*.tar.*"`; do \
287 projectname=`basename $$i` && \
288 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname && \
289 tar -C ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname -xf $$i && \
290 echo "Unpacked $$projectname"; \
291 done
292
293 ###################
294 ## Exclude files ##
295 ###################
296 # This does not exclude everything that we need to exclude.
297 # debian/copyright's File-Excluded section also excludes files.
298
299 ## pjproject
300 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/g7221 # non-distributable (requires a license from Polycom)
301 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/ilbc # non distributable (the version included with pjproject)
302 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/milenage # non distributable
303 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/BaseClasses # non distributable (?)
304 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/portaudio # not needed
305 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/speex # not needed
306 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/mp3 # not needed
307 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/gsm # not needed
308 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/bdsound # not needed
309 #rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp # not needed
310 rm -f ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjmedia/src/pjmedia-audiodev/s60_g729_bitstream.h # non distributable
311 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/build/vs # not needed, VisualStudio files.
312
313 # Remove all contrib tarballs
314 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs
315
316 # Create the new tarball
Fredy P553fef12019-10-10 15:05:06 -0400317 cd ${tmpdir} && tar -czf ${workdir}/jami_${version_to_download}~dfsg1.orig.tar.gz ring-project
aviauf89d7062016-06-14 12:42:57 -0400318
319 # Clear the temp dir
320 rm -rf ${tmpdir}