blob: 2d2e7c9fc4bedba0215d4ddb08246fcfefeb7996 [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:
Maxim Cournoyer6096e312021-06-02 09:52:47 -040058
59override_dh_auto_build:
60 # Daemon contribs build + configure
aviauf89d7062016-06-14 12:42:57 -040061 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 && \
Maxim Cournoyer0bd14252021-09-16 14:05:20 -040078 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 \
Maxim Cournoyer7be07612021-06-11 11:34:19 -040082 --prefix=/usr \
Sébastien Blinfc62f4a2021-11-09 11:27:49 -050083 --without-dbus \
Maxim Cournoyer7be07612021-06-11 11:34:19 -040084 --host=${HOST_ARCH}
aviauf89d7062016-06-14 12:42:57 -040085
Maxim Cournoyer6096e312021-06-02 09:52:47 -040086 # Daemon build
87 make -C daemon -j$(NO_CPUS) V=1
88 pod2man daemon/man/jamid.pod > daemon/jamid.1
89
90 # Libringclient configure
aviauf89d7062016-06-14 12:42:57 -040091 cd lrc && \
Maxim Cournoyer7be07612021-06-11 11:34:19 -040092 mkdir build && \
93 cd build && \
94 cmake \
95 -DRING_BUILD_DIR=$(CURDIR)/daemon/src \
Maxim Cournoyer6096e312021-06-02 09:52:47 -040096 -DENABLE_LIBWRAP=true \
Maxim Cournoyer7be07612021-06-11 11:34:19 -040097 -DCMAKE_INSTALL_PREFIX=/usr \
98 -DCMAKE_INSTALL_LIBDIR=lib \
99 $(CMAKE_OPTIONS) ..
aviauf89d7062016-06-14 12:42:57 -0400100
Maxim Cournoyer6096e312021-06-02 09:52:47 -0400101 # libringclient build
aviau9c5c4ad2016-07-20 14:07:34 -0400102 make -C lrc/build -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400103
Maxim Cournoyer6096e312021-06-02 09:52:47 -0400104 # GNOME client configure
105 cd client-gnome && \
106 mkdir build && \
107 cd build && \
108 cmake -DCMAKE_INSTALL_PREFIX=/usr \
109 -DCMAKE_INSTALL_LIBDIR=lib \
110 -DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
111 -DGSETTINGS_LOCALCOMPILE=OFF \
112 $(CMAKE_OPTIONS) ..
113
114 # GNOME client build
aviau9c5c4ad2016-07-20 14:07:34 -0400115 make -C client-gnome/build LDFLAGS="-lpthread" -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400116
Maxim Cournoyer6096e312021-06-02 09:52:47 -0400117 # Qt client configure and build
Amin Bandali6d0caec2021-03-17 10:40:22 -0400118 cd client-qt && \
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400119 mkdir build && \
120 cd build && \
121 cmake \
122 -DCMAKE_INSTALL_PREFIX=/usr \
123 -DLRC=$(CURDIR)/lrc \
124 $(CMAKE_OPTIONS) ..
Amin Bandali6d0caec2021-03-17 10:40:22 -0400125 make -C client-qt/build -j$(NO_CPUS) V=1
126
aviauf89d7062016-06-14 12:42:57 -0400127override_dh_auto_clean:
aviauf89d7062016-06-14 12:42:57 -0400128 #######################
Sébastien Blin14518942021-04-19 16:13:13 -0400129 ## Daemon clean ##
aviauf89d7062016-06-14 12:42:57 -0400130 #######################
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400131 [ -f daemon/contrib/native/Makefile ] && \
132 make -C daemon/contrib/native distclean || true
aviauf89d7062016-06-14 12:42:57 -0400133 rm -rfv daemon/contrib/native
Maxim Cournoyer2827b032021-06-09 14:21:36 -0400134 rm -rfv daemon/jamid.1
aviauf89d7062016-06-14 12:42:57 -0400135
136 #########################
137 ## libringclient clean ##
138 #########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500139 # CMake build system has no distclean target, so use clean.
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400140 [ -f lrc/build/Makefile ] && make -C lrc/build clean || true
aviauf89d7062016-06-14 12:42:57 -0400141 rm -rfv lrc/build
142
143 ########################
144 ## gnome client clean ##
145 ########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500146 # CMake build system has no distclean target, so use clean.
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400147 [ -f client-gnome/build/Makefile ] && \
148 make -C client-gnome/build clean || true
aviauf89d7062016-06-14 12:42:57 -0400149 rm -rfv client-gnome/build
150
Amin Bandali6d0caec2021-03-17 10:40:22 -0400151 #####################
152 ## qt client clean ##
153 #####################
154 # CMake build system has no distclean target, so use clean.
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400155 [ -f client-qt/build/Makefile ] && make -C client-qt/build clean || true
Amin Bandali6d0caec2021-03-17 10:40:22 -0400156 rm -rfv client-qt/build
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 #########################
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500162 cd daemon && make DESTDIR=$(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME) install
163 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/include
164 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/lib/*.a
165 rm -rfv $(CURDIR)/debian/$(JAMI_DAEMON_PKG_NAME)/usr/lib/*.la
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400166
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400167 #########################
Fredy P553fef12019-10-10 15:05:06 -0400168 ## Jami client install ##
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400169 #########################
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400170 ## LibRingClient
Amin Bandali6d0caec2021-03-17 10:40:22 -0400171 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME) install
172 rm -rfv $(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME)/usr/include
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400173
174 # This is a symlink, should be in -dev package
Amin Bandali6d0caec2021-03-17 10:40:22 -0400175 rm -v $(CURDIR)/debian/$(JAMI_LIB_CLIENT_PKG_NAME)/usr/lib/libringclient.so
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400176
177 # cmake files
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500178 rm -rfv $(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME)/usr/lib/cmake
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400179
180 ## GNOME client
Amin Bandali6d0caec2021-03-17 10:40:22 -0400181 cd client-gnome/build && \
182 make DESTDIR=$(CURDIR)/debian/$(JAMI_CLIENT_GNOME_PKG_NAME) install
183 rm -rfv $(CURDIR)/debian/$(JAMI_CLIENT_GNOME_PKG_NAME)/usr/bin/jami
184
185 ## Qt client
186 cd client-qt/build && \
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400187 make DESTDIR=$(CURDIR)/debian/$(JAMI_CLIENT_PKG_NAME) install
Amin Bandali6d0caec2021-03-17 10:40:22 -0400188
Maxim Cournoyer4e969702021-04-26 15:01:57 -0400189 ## Custom Qt package for Jami (libqt-jami)
190 ## Copy our own Qt library package content into the OCI package.
191 for file_name in $$(dpkg-query -L libqt-jami); do \
192 mkdir -p "$(OCI_INSTALL_DIR)$$(dirname $$file_name)"; \
193 test -d "$$file_name" && continue; \
194 cp "$$file_name" "$(OCI_INSTALL_DIR)$$file_name"; \
195 done
196
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400197 ######################
Fredy P553fef12019-10-10 15:05:06 -0400198 ## Jami AiO install ##
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400199 ######################
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400200 ## daemon
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500201 cd daemon && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
202 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
203 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.a
204 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.la
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400205
206 ## LibRingClient
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500207 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
208 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
aviauf89d7062016-06-14 12:42:57 -0400209
210 # This is a symlink, should be in -dev package
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500211 rm -v $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/libringclient.so
aviauf89d7062016-06-14 12:42:57 -0400212
213 # cmake files
Maxim Cournoyer0a269662021-02-05 16:02:43 -0500214 rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/cmake
aviauf89d7062016-06-14 12:42:57 -0400215
Amin Bandali6d0caec2021-03-17 10:40:22 -0400216 ## Qt client
217 cd client-qt/build && \
Maxim Cournoyer7be07612021-06-11 11:34:19 -0400218 make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
Amin Bandali6d0caec2021-03-17 10:40:22 -0400219
Amin Bandali6d0caec2021-03-17 10:40:22 -0400220override_dh_shlibdeps:
221 dh_shlibdeps -- -x$(JAMI_ALL_IN_ONE_PKG_NAME)
aviauf89d7062016-06-14 12:42:57 -0400222
aviauf89d7062016-06-14 12:42:57 -0400223tmpdir:= $(shell mktemp -d)
224workdir:= $(shell pwd)
225PKD := $(abspath $(dir $(MAKEFILE_LIST)))
226version_to_download := $(shell dpkg-parsechangelog -ldebian/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\~dfsg.+)(?:\-\d+.*)};')