rules 8.27 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/make -f
# -*- makefile -*-

# Hardening
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

# Number of CPUS
NO_CPUS=$(shell nproc)
ifeq ($(NO_CPUS),0)
NO_CPUS=1
endif

# Binary package names
16
JAMI_ALL_IN_ONE_PKG_NAME="jami-all"
17

18
# Bundled packages from contrib
Sébastien Blin's avatar
Sébastien Blin committed
19
BUNDLED_PKGS=""
20
ifeq (raspbian_10_armhf,$(findstring raspbian_10_armhf, $(DISTRIBUTION)))
21
# Raspbian's yaml-cpp lib does not work properly
Sébastien Blin's avatar
Sébastien Blin committed
22
BUNDLED_PKGS="--enable-ffmpeg --enable-yaml-cpp"
23
24
25
26
27
28
# Add host environment variables
CMAKE_OPTIONS=-DCHOST=${HOST_ARCH} \
		-DCMAKE_C_COMPILER=${HOST_ARCH}-gcc \
		-DCMAKE_CXX_COMPILER=${HOST_ARCH}-g++ \
		-DCMAKE_FIND_ROOT_PATH=/usr/${HOST_ARCH} \
		-DPKG_CONFIG_EXECUTABLE=/usr/bin/${HOST_ARCH}-pkg-config
Sébastien Blin's avatar
Sébastien Blin committed
29
30
31
32
else
ifneq (ubuntu_21.04,$(findstring ubuntu_21.04, $(DISTRIBUTION)))
BUNDLED_PKGS="--enable-ffmpeg" # For ubuntu 21.04 it seems there is massive issues with linking for swscale
endif
33
34
endif

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
%:
	dh $@

override_dh_auto_configure:
	###############################################
	## Re-create tarballs from tarballs-unpacked ##
	###############################################
	mkdir -p daemon/contrib/tarballs

	# Create tarballs
	for i in $(CURDIR)/daemon/contrib/tarballs-unpacked/*; do \
		projectname=`basename $$i` && \
		cd $$i && tar -caf ../../tarballs/$$projectname * && \
		echo "Repacked $$projectname"; \
	done

	###########################
Sébastien Blin's avatar
Sébastien Blin committed
52
	## Daemon configure      ##
53
54
55
56
	###########################
	mkdir -p daemon/contrib/native
	cd daemon/contrib/native && \
        ../bootstrap \
57
				--host=${HOST_ARCH} \
58
59
60
61
62
63
64
65
66
67
				--disable-downloads \
				--no-checksums \
				--disable-ogg \
				--disable-flac \
				--disable-vorbis \
				--disable-vorbisenc \
				--disable-speex \
				--disable-sndfile \
				--disable-gsm \
				--disable-speexdsp \
Sébastien Blin's avatar
Sébastien Blin committed
68
69
				--disable-natpmp  \
				--enable-gnutls $(BUNDLED_PKGS) && \
70
		make list && \
Sébastien Blin's avatar
Sébastien Blin committed
71
		make -j$(NO_CPUS) V=1
72
73
74
75
	cd daemon && \
		./autogen.sh && \
		./configure \
				--prefix=/usr \
76
77
				--disable-shared \
				--host=${HOST_ARCH}
78
79
80
81
82
83
84
85
86
87

	#############################
	## libringclient configure ##
	#############################
	cd lrc && \
		mkdir build && \
		cd build && \
		cmake  \
			-DRING_BUILD_DIR=$(CURDIR)/daemon/src \
			-DCMAKE_INSTALL_PREFIX=/usr \
88
			$(CMAKE_OPTIONS) \
89
90
91
92
93
94
95
96
97
98
99
100
			..

	############################
	## gnome client configure ##
	############################
	cd client-gnome && \
		mkdir build && \
		cd build && \
		cmake \
			-DCMAKE_INSTALL_PREFIX=/usr \
			-DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
			-DGSETTINGS_LOCALCOMPILE=OFF \
101
			$(CMAKE_OPTIONS) \
102
103
104
105
106
107
			..

	dh_auto_configure

override_dh_auto_build:
	#######################
Sébastien Blin's avatar
Sébastien Blin committed
108
	## Daemon build      ##
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
	#######################
	make -C daemon -j$(NO_CPUS) V=1
	pod2man daemon/man/dring.pod > daemon/dring.1

	#########################
	## libringclient build ##
	#########################
	make -C lrc/build -j$(NO_CPUS) V=1

	########################
	## gnome client build ##
	########################
	make -C client-gnome/build LDFLAGS="-lpthread" -j$(NO_CPUS) V=1

override_dh_auto_clean:
	################################
	## Generated contrib tarballs ##
	################################
	rm -rfv daemon/contrib/tarballs

	#######################
Sébastien Blin's avatar
Sébastien Blin committed
130
	## Daemon clean      ##
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
	#######################
	if [ -f daemon/contrib/native/Makefile ]; then make -C daemon/contrib/native distclean; fi
	rm -rfv daemon/contrib/native
	rm -rfv daemon/dring.1

	#########################
	## libringclient clean ##
	#########################
	# CMake build system has no distclean target, so use clean.
	if [ -f lrc/build/Makefile ]; then make -C lrc/build clean; fi
	rm -rfv lrc/build

	########################
	## gnome client clean ##
	########################
	# CMake build system has no distclean target, so use clean.
	if [ -f client-gnome/build/Makefile ]; then make -C client-gnome/build clean; fi
	rm -rfv client-gnome/build

override_dh_clean:
	# GNUTLS contains:
	# ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/src/certtool-args.c.bak
	# ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/doc/doxygen/Doxyfile.orig
	dh_clean -X.bak -X.orig

override_dh_auto_install:
	######################
158
	## Jami AiO install ##
159
160
161
	######################

        ## daemon
162
163
164
165
	cd daemon && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
	rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
	rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.a
	rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/*.la
166
167

        ## LibRingClient
168
169
	cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
	rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/include
170
171

	# This is a symlink, should be in -dev package
172
	rm -v $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/libringclient.so
173
174

	# cmake files
175
	rm -rfv $(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME)/usr/lib/cmake
176
177

        ## GNOME client
178
	cd client-gnome/build && make DESTDIR=$(CURDIR)/debian/$(JAMI_ALL_IN_ONE_PKG_NAME) install
179
	ln -sf /usr/bin/jami $(CURDIR)/debian/jami-all/usr/bin/ring.cx
180
181
182
183
184
185
186
187

tmpdir:= $(shell mktemp -d)
workdir:= $(shell pwd)
PKD := $(abspath $(dir $(MAKEFILE_LIST)))
version_to_download := $(shell dpkg-parsechangelog -ldebian/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\~dfsg.+)(?:\-\d+.*)};')

# Repacks the tarball with contrib tarballs unpacked.
get-orig-source:
188
	# Download jami tarball
189
190
191
192
193
194
	if [ -n "$$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL" ]; then \
	    mv $$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL ${tmpdir}; \
	else \
	    uscan --rename --destdir=${tmpdir} --download-version ${version_to_download} ;\
	fi

195
	# Unpack jami tarball
196
197
198
199
200
201
	tar -C ${tmpdir} -xf ${tmpdir}/*.tar.gz

	# Remove original tarball
	rm ${tmpdir}/*.tar.gz

	# Unpack all of the orig tarballs into tarballs-unpacked
202
203
	if [ -d "${tmpdir}/jami/" ]; then \
		mv ${tmpdir}/jami/ ${tmpdir}/ring-project/; \
204
	fi
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
	mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked
	for i in `find ${tmpdir}/ring-project/daemon/contrib/tarballs/ -name "*.tar.*"`; do \
		projectname=`basename $$i` && \
		mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname && \
		tar -C ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname -xf $$i && \
		echo "Unpacked $$projectname"; \
    done

	###################
	## Exclude files ##
	###################
	# This does not exclude everything that we need to exclude.
	# debian/copyright's File-Excluded section also excludes files.

    ## pjproject
	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/g7221 # non-distributable (requires a license from Polycom)
	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/ilbc # non distributable (the version included with pjproject)
	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/milenage # non distributable
	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/BaseClasses # non distributable (?)
	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/portaudio # not needed
	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/speex # not needed
	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/mp3 # not needed
	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/gsm # not needed
	rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/bdsound # not needed
	#rm -rf  ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp # not needed
	rm -f ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjmedia/src/pjmedia-audiodev/s60_g729_bitstream.h # non distributable
	rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/build/vs # not needed, VisualStudio files.

	# Remove all contrib tarballs
	rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs

	# Create the new tarball
237
	cd ${tmpdir} && tar -czf ${workdir}/jami_${version_to_download}~dfsg1.orig.tar.gz ring-project
238
239
240

	# Clear the temp dir
	rm -rf ${tmpdir}