blob: 847c39cd6fc5d2cb2486e394ca6e791c7746291a [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"
18JAMI_DAEMON_PKG_NAME="jami-daemon"
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -040019
Fredy Pb20faf62019-12-09 10:15:45 -050020# Bundled packages from contrib
Sébastien Blin14518942021-04-19 16:13:13 -040021BUNDLED_PKGS=""
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000022ifeq (raspbian_10_armhf,$(findstring raspbian_10_armhf, $(DISTRIBUTION)))
Fredy Pb20faf62019-12-09 10:15:45 -050023# Raspbian's yaml-cpp lib does not work properly
Sébastien Blin14518942021-04-19 16:13:13 -040024BUNDLED_PKGS="--enable-ffmpeg --enable-yaml-cpp"
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000025# Add host environment variables
26CMAKE_OPTIONS=-DCHOST=${HOST_ARCH} \
27 -DCMAKE_C_COMPILER=${HOST_ARCH}-gcc \
28 -DCMAKE_CXX_COMPILER=${HOST_ARCH}-g++ \
29 -DCMAKE_FIND_ROOT_PATH=/usr/${HOST_ARCH} \
30 -DPKG_CONFIG_EXECUTABLE=/usr/bin/${HOST_ARCH}-pkg-config
Sébastien Blin14518942021-04-19 16:13:13 -040031else
32ifneq (ubuntu_21.04,$(findstring ubuntu_21.04, $(DISTRIBUTION)))
33BUNDLED_PKGS="--enable-ffmpeg" # For ubuntu 21.04 it seems there is massive issues with linking for swscale
34endif
Fredy Pb20faf62019-12-09 10:15:45 -050035endif
36
aviauf89d7062016-06-14 12:42:57 -040037%:
38 dh $@
39
40override_dh_auto_configure:
41 ###############################################
42 ## Re-create tarballs from tarballs-unpacked ##
43 ###############################################
44 mkdir -p daemon/contrib/tarballs
45
46 # Create tarballs
47 for i in $(CURDIR)/daemon/contrib/tarballs-unpacked/*; do \
48 projectname=`basename $$i` && \
49 cd $$i && tar -caf ../../tarballs/$$projectname * && \
50 echo "Repacked $$projectname"; \
51 done
52
aviauf89d7062016-06-14 12:42:57 -040053 ###########################
Sébastien Blin14518942021-04-19 16:13:13 -040054 ## Daemon configure ##
aviauf89d7062016-06-14 12:42:57 -040055 ###########################
56 mkdir -p daemon/contrib/native
57 cd daemon/contrib/native && \
58 ../bootstrap \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000059 --host=${HOST_ARCH} \
aviaudc3c9de2016-10-05 11:13:23 -040060 --disable-downloads \
aviau2fd81442016-07-27 15:13:33 -040061 --no-checksums \
aviauf89d7062016-06-14 12:42:57 -040062 --disable-ogg \
63 --disable-flac \
64 --disable-vorbis \
65 --disable-vorbisenc \
66 --disable-speex \
67 --disable-sndfile \
aviau9c5c4ad2016-07-20 14:07:34 -040068 --disable-gsm \
Stepan Salenikovich19dd3342016-08-16 10:04:15 -040069 --disable-speexdsp \
Sébastien Blin14518942021-04-19 16:13:13 -040070 --disable-natpmp \
71 --enable-gnutls $(BUNDLED_PKGS) && \
aviauf89d7062016-06-14 12:42:57 -040072 make list && \
Sébastien Blin14518942021-04-19 16:13:13 -040073 make -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040074 cd daemon && \
75 ./autogen.sh && \
76 ./configure \
Stepan Salenikovicha61de1f2016-08-18 16:02:37 -040077 --prefix=/usr \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000078 --disable-shared \
79 --host=${HOST_ARCH}
aviauf89d7062016-06-14 12:42:57 -040080
81 #############################
82 ## libringclient configure ##
83 #############################
84 cd lrc && \
85 mkdir build && \
86 cd build && \
87 cmake \
88 -DRING_BUILD_DIR=$(CURDIR)/daemon/src \
89 -DCMAKE_INSTALL_PREFIX=/usr \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000090 $(CMAKE_OPTIONS) \
aviauf89d7062016-06-14 12:42:57 -040091 ..
92
93 ############################
94 ## gnome client configure ##
95 ############################
96 cd client-gnome && \
97 mkdir build && \
98 cd build && \
99 cmake \
100 -DCMAKE_INSTALL_PREFIX=/usr \
101 -DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
Stepan Salenikovichd6f588a2016-08-30 15:40:15 -0400102 -DGSETTINGS_LOCALCOMPILE=OFF \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +0000103 $(CMAKE_OPTIONS) \
aviauf89d7062016-06-14 12:42:57 -0400104 ..
105
106 dh_auto_configure
107
108override_dh_auto_build:
109 #######################
Sébastien Blin14518942021-04-19 16:13:13 -0400110 ## Daemon build ##
aviauf89d7062016-06-14 12:42:57 -0400111 #######################
aviau9c5c4ad2016-07-20 14:07:34 -0400112 make -C daemon -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400113 pod2man daemon/man/dring.pod > daemon/dring.1
114
115 #########################
116 ## libringclient build ##
117 #########################
aviau9c5c4ad2016-07-20 14:07:34 -0400118 make -C lrc/build -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400119
120 ########################
121 ## gnome client build ##
122 ########################
aviau9c5c4ad2016-07-20 14:07:34 -0400123 make -C client-gnome/build LDFLAGS="-lpthread" -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400124
125override_dh_auto_clean:
126 ################################
127 ## Generated contrib tarballs ##
128 ################################
129 rm -rfv daemon/contrib/tarballs
130
131 #######################
Sébastien Blin14518942021-04-19 16:13:13 -0400132 ## Daemon clean ##
aviauf89d7062016-06-14 12:42:57 -0400133 #######################
aviau9ee77442016-09-06 14:31:00 -0400134 if [ -f daemon/contrib/native/Makefile ]; then make -C daemon/contrib/native distclean; fi
aviauf89d7062016-06-14 12:42:57 -0400135 rm -rfv daemon/contrib/native
136 rm -rfv daemon/dring.1
137
138 #########################
139 ## libringclient clean ##
140 #########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500141 # CMake build system has no distclean target, so use clean.
142 if [ -f lrc/build/Makefile ]; then make -C lrc/build clean; fi
aviauf89d7062016-06-14 12:42:57 -0400143 rm -rfv lrc/build
144
145 ########################
146 ## gnome client clean ##
147 ########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500148 # CMake build system has no distclean target, so use clean.
149 if [ -f client-gnome/build/Makefile ]; then make -C client-gnome/build clean; fi
aviauf89d7062016-06-14 12:42:57 -0400150 rm -rfv client-gnome/build
151
aviau5c3c1b32017-05-02 22:39:54 -0400152override_dh_clean:
153 # GNUTLS contains:
154 # ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/src/certtool-args.c.bak
155 # ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/doc/doxygen/Doxyfile.orig
156 dh_clean -X.bak -X.orig
157
aviauf89d7062016-06-14 12:42:57 -0400158override_dh_auto_install:
159 #########################
Sébastien Blin14518942021-04-19 16:13:13 -0400160 ## Daemon install ##
aviauf89d7062016-06-14 12:42:57 -0400161 #########################
aviauf89d7062016-06-14 12:42:57 -0400162
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500163 cd daemon && make DESTDIR=$(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME) install
164 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/include
165 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/lib/*.a
166 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/lib/*.la
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400167
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400168 #########################
Fredy P553fef12019-10-10 15:05:06 -0400169 ## Jami client install ##
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400170 #########################
171
172 ## LibRingClient
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500173 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME) install
174 rm -rfv $(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME)/usr/include
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400175
176 # This is a symlink, should be in -dev package
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500177 rm -v $(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME)/usr/lib/libringclient.so
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400178
179 # cmake files
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500180 rm -rfv $(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME)/usr/lib/cmake
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400181
182 ## GNOME client
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500183 cd client-gnome/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME) install
Fredy P553fef12019-10-10 15:05:06 -0400184 ln -sf /usr/bin/jami $(CURDIR)/debian/jami/usr/bin/ring.cx
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400185
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400186 ######################
Fredy P553fef12019-10-10 15:05:06 -0400187 ## Jami AiO install ##
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400188 ######################
189
190 ## daemon
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500191 cd daemon && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
192 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
193 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.a
194 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.la
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400195
196 ## LibRingClient
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500197 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
198 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
aviauf89d7062016-06-14 12:42:57 -0400199
200 # This is a symlink, should be in -dev package
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500201 rm -v $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/libringclient.so
aviauf89d7062016-06-14 12:42:57 -0400202
203 # cmake files
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500204 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/cmake
aviauf89d7062016-06-14 12:42:57 -0400205
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400206 ## GNOME client
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500207 cd client-gnome/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
Fredy P553fef12019-10-10 15:05:06 -0400208 ln -sf /usr/bin/jami $(CURDIR)/debian/jami-all/usr/bin/ring.cx
aviauf89d7062016-06-14 12:42:57 -0400209
aviauf89d7062016-06-14 12:42:57 -0400210tmpdir:= $(shell mktemp -d)
211workdir:= $(shell pwd)
212PKD := $(abspath $(dir $(MAKEFILE_LIST)))
213version_to_download := $(shell dpkg-parsechangelog -ldebian/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\~dfsg.+)(?:\-\d+.*)};')
214
215# Repacks the tarball with contrib tarballs unpacked.
216get-orig-source:
Fredy P553fef12019-10-10 15:05:06 -0400217 # Download jami tarball
aviauf89d7062016-06-14 12:42:57 -0400218 if [ -n "$$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL" ]; then \
219 mv $$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL ${tmpdir}; \
220 else \
221 uscan --rename --destdir=${tmpdir} --download-version ${version_to_download} ;\
222 fi
223
Fredy P553fef12019-10-10 15:05:06 -0400224 # Unpack jami tarball
aviauf89d7062016-06-14 12:42:57 -0400225 tar -C ${tmpdir} -xf ${tmpdir}/*.tar.gz
226
227 # Remove original tarball
228 rm ${tmpdir}/*.tar.gz
229
230 # Unpack all of the orig tarballs into tarballs-unpacked
Fredy P553fef12019-10-10 15:05:06 -0400231 if [ -d "${tmpdir}/jami/" ]; then \
232 mv ${tmpdir}/jami/ ${tmpdir}/ring-project/; \
Sébastien Blin94aaa832019-04-19 14:04:38 -0400233 fi
aviauf89d7062016-06-14 12:42:57 -0400234 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked
235 for i in `find ${tmpdir}/ring-project/daemon/contrib/tarballs/ -name "*.tar.*"`; do \
236 projectname=`basename $$i` && \
237 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname && \
238 tar -C ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname -xf $$i && \
239 echo "Unpacked $$projectname"; \
240 done
241
242 ###################
243 ## Exclude files ##
244 ###################
245 # This does not exclude everything that we need to exclude.
246 # debian/copyright's File-Excluded section also excludes files.
247
248 ## pjproject
249 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/g7221 # non-distributable (requires a license from Polycom)
250 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/ilbc # non distributable (the version included with pjproject)
251 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/milenage # non distributable
252 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/BaseClasses # non distributable (?)
253 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/portaudio # not needed
254 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/speex # not needed
255 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/mp3 # not needed
256 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/gsm # not needed
257 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/bdsound # not needed
258 #rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp # not needed
259 rm -f ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjmedia/src/pjmedia-audiodev/s60_g729_bitstream.h # non distributable
260 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/build/vs # not needed, VisualStudio files.
261
262 # Remove all contrib tarballs
263 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs
264
265 # Create the new tarball
Fredy P553fef12019-10-10 15:05:06 -0400266 cd ${tmpdir} && tar -czf ${workdir}/jami_${version_to_download}~dfsg1.orig.tar.gz ring-project
aviauf89d7062016-06-14 12:42:57 -0400267
268 # Clear the temp dir
269 rm -rf ${tmpdir}