blob: 276f2f875260797c86d9245e408f91794c0a2ad5 [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
Maxim Cournoyercee40e12021-09-01 12:42:41 -04009# Ubuntu defaults to use -Bsymbolic-functions, which breaks linking
10# shared objects with static FFmpeg archives (see:
11# https://bugs.launchpad.net/ubuntu/+source/ffmpeg/+bug/1942352).
12ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes)
13ifneq (,$(LDFLAGS))
14 LDFLAGS := $(filter-out %-Bsymbolic-functions,$(LDFLAGS))
15endif
16endif
17
aviauf89d7062016-06-14 12:42:57 -040018# Number of CPUS
19NO_CPUS=$(shell nproc)
20ifeq ($(NO_CPUS),0)
21NO_CPUS=1
22endif
23
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -040024# Binary package names
Maxim Cournoyer0a269662021-02-05 16:02:43 -050025JAMI_ALL_IN_ONE_PKG_NAME="jami-all"
26JAMI_CLIENT_PKG_NAME="jami"
Amin Bandali6d0caec2021-03-17 10:40:22 -040027JAMI_CLIENT_GNOME_PKG_NAME="jami-gnome"
28JAMI_LIB_CLIENT_PKG_NAME="jami-libclient"
Maxim Cournoyer0a269662021-02-05 16:02:43 -050029JAMI_DAEMON_PKG_NAME="jami-daemon"
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -040030
Fredy Pb20faf62019-12-09 10:15:45 -050031# Bundled packages from contrib
Sébastien Blin14518942021-04-19 16:13:13 -040032BUNDLED_PKGS=""
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000033ifeq (raspbian_10_armhf,$(findstring raspbian_10_armhf, $(DISTRIBUTION)))
Fredy Pb20faf62019-12-09 10:15:45 -050034# Raspbian's yaml-cpp lib does not work properly
Sébastien Blin14518942021-04-19 16:13:13 -040035BUNDLED_PKGS="--enable-ffmpeg --enable-yaml-cpp"
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +000036# Add host environment variables
37CMAKE_OPTIONS=-DCHOST=${HOST_ARCH} \
Maxim Cournoyer7be07612021-06-11 11:34:19 -040038 -DCMAKE_C_COMPILER=${HOST_ARCH}-gcc \
39 -DCMAKE_CXX_COMPILER=${HOST_ARCH}-g++ \
40 -DCMAKE_FIND_ROOT_PATH=/usr/${HOST_ARCH} \
41 -DPKG_CONFIG_EXECUTABLE=/usr/bin/${HOST_ARCH}-pkg-config
Fredy Pb20faf62019-12-09 10:15:45 -050042endif
43
Amin Bandali6d0caec2021-03-17 10:40:22 -040044# Qt-related variables
45QT_JAMI_PREFIX := ${QT_JAMI_PREFIX}
46export PATH := $(QT_JAMI_PREFIX)/bin:${PATH}
47export LD_LIBRARY_PATH := $(QT_JAMI_PREFIX)/lib:${LD_LIBRARY_PATH}
48export PKG_CONFIG_PATH := $(QT_JAMI_PREFIX)/lib/pkgconfig:${PKG_CONFIG_PATH}
49export CMAKE_PREFIX_PATH := $(QT_JAMI_PREFIX)/lib/cmake:${CMAKE_PREFIX_PATH}
50
Maxim Cournoyer4e969702021-04-26 15:01:57 -040051# Installation directories.
52OCI_INSTALL_DIR = $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)
Amin Bandali6d0caec2021-03-17 10:40:22 -040053
aviauf89d7062016-06-14 12:42:57 -040054%:
55 dh $@
56
57override_dh_auto_configure:
aviauf89d7062016-06-14 12:42:57 -040058 ###########################
Sébastien Blin14518942021-04-19 16:13:13 -040059 ## Daemon configure ##
aviauf89d7062016-06-14 12:42:57 -040060 ###########################
61 mkdir -p daemon/contrib/native
62 cd daemon/contrib/native && \
63 ../bootstrap \
Maxim Cournoyer7be07612021-06-11 11:34:19 -040064 --host=${HOST_ARCH} \
65 --disable-downloads \
66 --no-checksums \
67 --disable-ogg \
68 --disable-flac \
69 --disable-vorbis \
70 --disable-vorbisenc \
71 --disable-speex \
72 --disable-sndfile \
73 --disable-gsm \
74 --disable-speexdsp \
75 --disable-natpmp \
76 --enable-gnutls $(BUNDLED_PKGS) && \
77 make list && \
78 make -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040079 cd daemon && \
Maxim Cournoyer7be07612021-06-11 11:34:19 -040080 ./autogen.sh && \
81 ./configure \
82 --disable-shared \
83 --prefix=/usr \
84 --host=${HOST_ARCH}
aviauf89d7062016-06-14 12:42:57 -040085
86 #############################
87 ## libringclient configure ##
88 #############################
89 cd lrc && \
Maxim Cournoyer7be07612021-06-11 11:34:19 -040090 mkdir build && \
91 cd build && \
92 cmake \
93 -DRING_BUILD_DIR=$(CURDIR)/daemon/src \
94 -DENABLE_LIBWRAP=false \
95 -DCMAKE_INSTALL_PREFIX=/usr \
96 -DCMAKE_INSTALL_LIBDIR=lib \
97 $(CMAKE_OPTIONS) ..
aviauf89d7062016-06-14 12:42:57 -040098
99 ############################
100 ## gnome client configure ##
101 ############################
102 cd client-gnome && \
103 mkdir build && \
104 cd build && \
105 cmake \
106 -DCMAKE_INSTALL_PREFIX=/usr \
Sébastien Blin47c61df2021-04-30 17:29:59 -0400107 -DCMAKE_INSTALL_LIBDIR=lib \
aviauf89d7062016-06-14 12:42:57 -0400108 -DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
Stepan Salenikovichd6f588a2016-08-30 15:40:15 -0400109 -DGSETTINGS_LOCALCOMPILE=OFF \
Sandra Tobajasd6dde7e2020-10-08 11:18:56 +0000110 $(CMAKE_OPTIONS) \
aviauf89d7062016-06-14 12:42:57 -0400111 ..
112
Amin Bandali6d0caec2021-03-17 10:40:22 -0400113 #########################
114 ## qt client configure ##
115 #########################
116 # needs to be done after lrc is built; see below
117
aviauf89d7062016-06-14 12:42:57 -0400118 dh_auto_configure
119
120override_dh_auto_build:
121 #######################
Sébastien Blin14518942021-04-19 16:13:13 -0400122 ## Daemon build ##
aviauf89d7062016-06-14 12:42:57 -0400123 #######################
aviau9c5c4ad2016-07-20 14:07:34 -0400124 make -C daemon -j$(NO_CPUS) V=1
Maxim Cournoyer2827b032021-06-09 14:21:36 -0400125 pod2man daemon/man/jamid.pod > daemon/jamid.1
aviauf89d7062016-06-14 12:42:57 -0400126
127 #########################
128 ## libringclient build ##
129 #########################
aviau9c5c4ad2016-07-20 14:07:34 -0400130 make -C lrc/build -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400131
132 ########################
133 ## gnome client build ##
134 ########################
aviau9c5c4ad2016-07-20 14:07:34 -0400135 make -C client-gnome/build LDFLAGS="-lpthread" -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400136
Amin Bandali6d0caec2021-03-17 10:40:22 -0400137 ###################################
138 ## qt client configure and build ##
139 ###################################
140 cd client-qt && \
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400141 mkdir build && \
142 cd build && \
143 cmake \
144 -DCMAKE_INSTALL_PREFIX=/usr \
145 -DLRC=$(CURDIR)/lrc \
146 $(CMAKE_OPTIONS) ..
Amin Bandali6d0caec2021-03-17 10:40:22 -0400147 make -C client-qt/build -j$(NO_CPUS) V=1
148
aviauf89d7062016-06-14 12:42:57 -0400149override_dh_auto_clean:
aviauf89d7062016-06-14 12:42:57 -0400150 #######################
Sébastien Blin14518942021-04-19 16:13:13 -0400151 ## Daemon clean ##
aviauf89d7062016-06-14 12:42:57 -0400152 #######################
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400153 [ -f daemon/contrib/native/Makefile ] && \
154 make -C daemon/contrib/native distclean || true
aviauf89d7062016-06-14 12:42:57 -0400155 rm -rfv daemon/contrib/native
Maxim Cournoyer2827b032021-06-09 14:21:36 -0400156 rm -rfv daemon/jamid.1
aviauf89d7062016-06-14 12:42:57 -0400157
158 #########################
159 ## libringclient clean ##
160 #########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500161 # CMake build system has no distclean target, so use clean.
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400162 [ -f lrc/build/Makefile ] && make -C lrc/build clean || true
aviauf89d7062016-06-14 12:42:57 -0400163 rm -rfv lrc/build
164
165 ########################
166 ## gnome client clean ##
167 ########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500168 # CMake build system has no distclean target, so use clean.
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400169 [ -f client-gnome/build/Makefile ] && \
170 make -C client-gnome/build clean || true
aviauf89d7062016-06-14 12:42:57 -0400171 rm -rfv client-gnome/build
172
Amin Bandali6d0caec2021-03-17 10:40:22 -0400173 #####################
174 ## qt client clean ##
175 #####################
176 # CMake build system has no distclean target, so use clean.
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400177 [ -f client-qt/build/Makefile ] && make -C client-qt/build clean || true
Amin Bandali6d0caec2021-03-17 10:40:22 -0400178 rm -rfv client-qt/build
179
aviauf89d7062016-06-14 12:42:57 -0400180override_dh_auto_install:
181 #########################
Sébastien Blin14518942021-04-19 16:13:13 -0400182 ## Daemon install ##
aviauf89d7062016-06-14 12:42:57 -0400183 #########################
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500184 cd daemon && make DESTDIR=$(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME) install
185 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/include
186 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/lib/*.a
187 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/lib/*.la
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400188
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400189 #########################
Fredy P553fef12019-10-10 15:05:06 -0400190 ## Jami client install ##
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400191 #########################
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400192 ## LibRingClient
Amin Bandali6d0caec2021-03-17 10:40:22 -0400193 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME) install
194 rm -rfv $(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME)/usr/include
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400195
196 # This is a symlink, should be in -dev package
Amin Bandali6d0caec2021-03-17 10:40:22 -0400197 rm -v $(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME)/usr/lib/libringclient.so
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400198
199 # cmake files
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500200 rm -rfv $(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME)/usr/lib/cmake
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400201
202 ## GNOME client
Amin Bandali6d0caec2021-03-17 10:40:22 -0400203 cd client-gnome/build && \
204 make DESTDIR=$(CURDIR)/debian/$(JAMI_CLIENT_GNOME_PKG_NAME) install
205 rm -rfv $(CURDIR)/debian/$(JAMI_CLIENT_GNOME_PKG_NAME)/usr/bin/jami
206
207 ## Qt client
208 cd client-qt/build && \
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400209 make DESTDIR=$(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME) install
Amin Bandali6d0caec2021-03-17 10:40:22 -0400210
Maxim Cournoyer4e969702021-04-26 15:01:57 -0400211 ## Custom Qt package for Jami (libqt-jami)
212 ## Copy our own Qt library package content into the OCI package.
213 for file_name in $$(dpkg-query -L libqt-jami); do \
214 mkdir -p "$(OCI_INSTALL_DIR)$$(dirname $$file_name)"; \
215 test -d "$$file_name" && continue; \
216 cp "$$file_name" "$(OCI_INSTALL_DIR)$$file_name"; \
217 done
218
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400219 ######################
Fredy P553fef12019-10-10 15:05:06 -0400220 ## Jami AiO install ##
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400221 ######################
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400222 ## daemon
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500223 cd daemon && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
224 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
225 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.a
226 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.la
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400227
228 ## LibRingClient
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500229 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
230 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
aviauf89d7062016-06-14 12:42:57 -0400231
232 # This is a symlink, should be in -dev package
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500233 rm -v $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/libringclient.so
aviauf89d7062016-06-14 12:42:57 -0400234
235 # cmake files
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500236 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/cmake
aviauf89d7062016-06-14 12:42:57 -0400237
Amin Bandali6d0caec2021-03-17 10:40:22 -0400238 ## Qt client
239 cd client-qt/build && \
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400240 make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
Amin Bandali6d0caec2021-03-17 10:40:22 -0400241
Amin Bandali6d0caec2021-03-17 10:40:22 -0400242override_dh_shlibdeps:
243 dh_shlibdeps -- -x$(JAMI_ALL_IN_ONE_PKG_NAME)
aviauf89d7062016-06-14 12:42:57 -0400244
aviauf89d7062016-06-14 12:42:57 -0400245tmpdir:= $(shell mktemp -d)
246workdir:= $(shell pwd)
247PKD := $(abspath $(dir $(MAKEFILE_LIST)))
248version_to_download := $(shell dpkg-parsechangelog -ldebian/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\~dfsg.+)(?:\-\d+.*)};')