blob: c806cd61773f061d04d305f4ee593905bf03326b [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
Maxim Cournoyer4e969702021-04-26 15:01:57 -040046# Installation directories.
47OCI_INSTALL_DIR = $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)
Amin Bandali6d0caec2021-03-17 10:40:22 -040048
aviauf89d7062016-06-14 12:42:57 -040049%:
50 dh $@
51
52override_dh_auto_configure:
53 ###############################################
54 ## Re-create tarballs from tarballs-unpacked ##
55 ###############################################
56 mkdir -p daemon/contrib/tarballs
57
58 # Create tarballs
59 for i in $(CURDIR)/daemon/contrib/tarballs-unpacked/*; do \
60 projectname=`basename $$i` && \
61 cd $$i && tar -caf ../../tarballs/$$projectname * && \
62 echo "Repacked $$projectname"; \
63 done
64
aviauf89d7062016-06-14 12:42:57 -040065 ###########################
Sébastien Blin14518942021-04-19 16:13:13 -040066 ## Daemon configure ##
aviauf89d7062016-06-14 12:42:57 -040067 ###########################
68 mkdir -p daemon/contrib/native
69 cd daemon/contrib/native && \
70 ../bootstrap \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000071 --host=${HOST_ARCH} \
aviaudc3c9de2016-10-05 11:13:23 -040072 --disable-downloads \
aviau2fd81442016-07-27 15:13:33 -040073 --no-checksums \
aviauf89d7062016-06-14 12:42:57 -040074 --disable-ogg \
75 --disable-flac \
76 --disable-vorbis \
77 --disable-vorbisenc \
78 --disable-speex \
79 --disable-sndfile \
aviau9c5c4ad2016-07-20 14:07:34 -040080 --disable-gsm \
Stepan Salenikovich19dd3342016-08-16 10:04:15 -040081 --disable-speexdsp \
Sébastien Blin14518942021-04-19 16:13:13 -040082 --disable-natpmp \
83 --enable-gnutls $(BUNDLED_PKGS) && \
aviauf89d7062016-06-14 12:42:57 -040084 make list && \
Sébastien Blin14518942021-04-19 16:13:13 -040085 make -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040086 cd daemon && \
87 ./autogen.sh && \
88 ./configure \
Stepan Salenikovicha61de1f2016-08-18 16:02:37 -040089 --prefix=/usr \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000090 --disable-shared \
91 --host=${HOST_ARCH}
aviauf89d7062016-06-14 12:42:57 -040092
93 #############################
94 ## libringclient configure ##
95 #############################
96 cd lrc && \
97 mkdir build && \
98 cd build && \
99 cmake \
100 -DRING_BUILD_DIR=$(CURDIR)/daemon/src \
101 -DCMAKE_INSTALL_PREFIX=/usr \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +0000102 $(CMAKE_OPTIONS) \
aviauf89d7062016-06-14 12:42:57 -0400103 ..
104
105 ############################
106 ## gnome client configure ##
107 ############################
108 cd client-gnome && \
109 mkdir build && \
110 cd build && \
111 cmake \
112 -DCMAKE_INSTALL_PREFIX=/usr \
113 -DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
Stepan Salenikovichd6f588a2016-08-30 15:40:15 -0400114 -DGSETTINGS_LOCALCOMPILE=OFF \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +0000115 $(CMAKE_OPTIONS) \
aviauf89d7062016-06-14 12:42:57 -0400116 ..
117
Amin Bandali6d0caec2021-03-17 10:40:22 -0400118 #########################
119 ## qt client configure ##
120 #########################
121 # needs to be done after lrc is built; see below
122
aviauf89d7062016-06-14 12:42:57 -0400123 dh_auto_configure
124
125override_dh_auto_build:
126 #######################
Sébastien Blin14518942021-04-19 16:13:13 -0400127 ## Daemon build ##
aviauf89d7062016-06-14 12:42:57 -0400128 #######################
aviau9c5c4ad2016-07-20 14:07:34 -0400129 make -C daemon -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400130 pod2man daemon/man/dring.pod > daemon/dring.1
131
132 #########################
133 ## libringclient build ##
134 #########################
aviau9c5c4ad2016-07-20 14:07:34 -0400135 make -C lrc/build -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400136
137 ########################
138 ## gnome client build ##
139 ########################
aviau9c5c4ad2016-07-20 14:07:34 -0400140 make -C client-gnome/build LDFLAGS="-lpthread" -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400141
Amin Bandali6d0caec2021-03-17 10:40:22 -0400142 ###################################
143 ## qt client configure and build ##
144 ###################################
145 cd client-qt && \
146 mkdir build && \
147 cd build && \
148 cmake \
149 -DCMAKE_INSTALL_PREFIX=/usr \
150 -DLRC=$(CURDIR)/lrc \
151 $(CMAKE_OPTIONS) \
152 ..
153 make -C client-qt/build -j$(NO_CPUS) V=1
154
aviauf89d7062016-06-14 12:42:57 -0400155override_dh_auto_clean:
156 ################################
157 ## Generated contrib tarballs ##
158 ################################
159 rm -rfv daemon/contrib/tarballs
160
161 #######################
Sébastien Blin14518942021-04-19 16:13:13 -0400162 ## Daemon clean ##
aviauf89d7062016-06-14 12:42:57 -0400163 #######################
aviau9ee77442016-09-06 14:31:00 -0400164 if [ -f daemon/contrib/native/Makefile ]; then make -C daemon/contrib/native distclean; fi
aviauf89d7062016-06-14 12:42:57 -0400165 rm -rfv daemon/contrib/native
166 rm -rfv daemon/dring.1
167
168 #########################
169 ## libringclient clean ##
170 #########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500171 # CMake build system has no distclean target, so use clean.
172 if [ -f lrc/build/Makefile ]; then make -C lrc/build clean; fi
aviauf89d7062016-06-14 12:42:57 -0400173 rm -rfv lrc/build
174
175 ########################
176 ## gnome client clean ##
177 ########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500178 # CMake build system has no distclean target, so use clean.
179 if [ -f client-gnome/build/Makefile ]; then make -C client-gnome/build clean; fi
aviauf89d7062016-06-14 12:42:57 -0400180 rm -rfv client-gnome/build
181
Amin Bandali6d0caec2021-03-17 10:40:22 -0400182 #####################
183 ## qt client clean ##
184 #####################
185 # CMake build system has no distclean target, so use clean.
186 if [ -f client-qt/build/Makefile ]; then make -C client-qt/build clean; fi
187 rm -rfv client-qt/build
188
aviau5c3c1b32017-05-02 22:39:54 -0400189override_dh_clean:
190 # GNUTLS contains:
191 # ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/src/certtool-args.c.bak
192 # ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/doc/doxygen/Doxyfile.orig
193 dh_clean -X.bak -X.orig
194
aviauf89d7062016-06-14 12:42:57 -0400195override_dh_auto_install:
196 #########################
Sébastien Blin14518942021-04-19 16:13:13 -0400197 ## Daemon install ##
aviauf89d7062016-06-14 12:42:57 -0400198 #########################
aviauf89d7062016-06-14 12:42:57 -0400199
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500200 cd daemon && make DESTDIR=$(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME) install
201 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/include
202 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/lib/*.a
203 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/lib/*.la
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400204
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400205 #########################
Fredy P553fef12019-10-10 15:05:06 -0400206 ## Jami client install ##
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400207 #########################
208
209 ## LibRingClient
Amin Bandali6d0caec2021-03-17 10:40:22 -0400210 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME) install
211 rm -rfv $(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME)/usr/include
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400212
213 # This is a symlink, should be in -dev package
Amin Bandali6d0caec2021-03-17 10:40:22 -0400214 rm -v $(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME)/usr/lib/libringclient.so
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400215
216 # cmake files
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500217 rm -rfv $(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME)/usr/lib/cmake
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400218
219 ## GNOME client
Amin Bandali6d0caec2021-03-17 10:40:22 -0400220 cd client-gnome/build && \
221 make DESTDIR=$(CURDIR)/debian/$(JAMI_CLIENT_GNOME_PKG_NAME) install
222 rm -rfv $(CURDIR)/debian/$(JAMI_CLIENT_GNOME_PKG_NAME)/usr/bin/jami
223
224 ## Qt client
225 cd client-qt/build && \
226 make DESTDIR=$(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME) install
227
Fredy P553fef12019-10-10 15:05:06 -0400228 ln -sf /usr/bin/jami $(CURDIR)/debian/jami/usr/bin/ring.cx
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400229
Maxim Cournoyer4e969702021-04-26 15:01:57 -0400230 ## Custom Qt package for Jami (libqt-jami)
231 ## Copy our own Qt library package content into the OCI package.
232 for file_name in $$(dpkg-query -L libqt-jami); do \
233 mkdir -p "$(OCI_INSTALL_DIR)$$(dirname $$file_name)"; \
234 test -d "$$file_name" && continue; \
235 cp "$$file_name" "$(OCI_INSTALL_DIR)$$file_name"; \
236 done
237
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400238 ######################
Fredy P553fef12019-10-10 15:05:06 -0400239 ## Jami AiO install ##
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400240 ######################
241
242 ## daemon
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500243 cd daemon && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
244 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
245 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.a
246 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.la
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400247
248 ## LibRingClient
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500249 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
250 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
aviauf89d7062016-06-14 12:42:57 -0400251
252 # This is a symlink, should be in -dev package
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500253 rm -v $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/libringclient.so
aviauf89d7062016-06-14 12:42:57 -0400254
255 # cmake files
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500256 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/cmake
aviauf89d7062016-06-14 12:42:57 -0400257
Amin Bandali6d0caec2021-03-17 10:40:22 -0400258 ## Qt client
259 cd client-qt/build && \
260 make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
261
262 ln -sf /usr/bin/jami $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/bin/ring.cx
263
264override_dh_shlibdeps:
265 dh_shlibdeps -- -x$(JAMI_ALL_IN_ONE_PKG_NAME)
aviauf89d7062016-06-14 12:42:57 -0400266
aviauf89d7062016-06-14 12:42:57 -0400267tmpdir:= $(shell mktemp -d)
268workdir:= $(shell pwd)
269PKD := $(abspath $(dir $(MAKEFILE_LIST)))
270version_to_download := $(shell dpkg-parsechangelog -ldebian/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\~dfsg.+)(?:\-\d+.*)};')
271
272# Repacks the tarball with contrib tarballs unpacked.
273get-orig-source:
Fredy P553fef12019-10-10 15:05:06 -0400274 # Download jami tarball
aviauf89d7062016-06-14 12:42:57 -0400275 if [ -n "$$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL" ]; then \
276 mv $$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL ${tmpdir}; \
277 else \
278 uscan --rename --destdir=${tmpdir} --download-version ${version_to_download} ;\
279 fi
280
Fredy P553fef12019-10-10 15:05:06 -0400281 # Unpack jami tarball
aviauf89d7062016-06-14 12:42:57 -0400282 tar -C ${tmpdir} -xf ${tmpdir}/*.tar.gz
283
284 # Remove original tarball
285 rm ${tmpdir}/*.tar.gz
286
287 # Unpack all of the orig tarballs into tarballs-unpacked
Fredy P553fef12019-10-10 15:05:06 -0400288 if [ -d "${tmpdir}/jami/" ]; then \
289 mv ${tmpdir}/jami/ ${tmpdir}/ring-project/; \
Sébastien Blin94aaa832019-04-19 14:04:38 -0400290 fi
aviauf89d7062016-06-14 12:42:57 -0400291 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked
292 for i in `find ${tmpdir}/ring-project/daemon/contrib/tarballs/ -name "*.tar.*"`; do \
293 projectname=`basename $$i` && \
294 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname && \
295 tar -C ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname -xf $$i && \
296 echo "Unpacked $$projectname"; \
297 done
298
299 ###################
300 ## Exclude files ##
301 ###################
302 # This does not exclude everything that we need to exclude.
303 # debian/copyright's File-Excluded section also excludes files.
304
305 ## pjproject
306 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/g7221 # non-distributable (requires a license from Polycom)
307 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/ilbc # non distributable (the version included with pjproject)
308 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/milenage # non distributable
309 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/BaseClasses # non distributable (?)
310 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/portaudio # not needed
311 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/speex # not needed
312 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/mp3 # not needed
313 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/gsm # not needed
314 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/bdsound # not needed
315 #rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp # not needed
316 rm -f ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjmedia/src/pjmedia-audiodev/s60_g729_bitstream.h # non distributable
317 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/build/vs # not needed, VisualStudio files.
318
319 # Remove all contrib tarballs
320 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs
321
322 # Create the new tarball
Fredy P553fef12019-10-10 15:05:06 -0400323 cd ${tmpdir} && tar -czf ${workdir}/jami_${version_to_download}~dfsg1.orig.tar.gz ring-project
aviauf89d7062016-06-14 12:42:57 -0400324
325 # Clear the temp dir
326 rm -rf ${tmpdir}