blob: 7128192dfb4cb37c5d6b17bfb8116888d4eb3fb3 [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
16RING_ALL_IN_ONE_PKG_NAME="ring-all"
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -040017RING_CLIENT_PKG_NAME="ring"
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -040018RING_DAEMON_PKG_NAME="ring-daemon"
19
aviauf89d7062016-06-14 12:42:57 -040020%:
21 dh $@
22
23override_dh_auto_configure:
24 ###############################################
25 ## Re-create tarballs from tarballs-unpacked ##
26 ###############################################
27 mkdir -p daemon/contrib/tarballs
28
29 # Create tarballs
30 for i in $(CURDIR)/daemon/contrib/tarballs-unpacked/*; do \
31 projectname=`basename $$i` && \
32 cd $$i && tar -caf ../../tarballs/$$projectname * && \
33 echo "Repacked $$projectname"; \
34 done
35
aviauf89d7062016-06-14 12:42:57 -040036 ###########################
37 ## Ring Daemon configure ##
38 ###########################
39 mkdir -p daemon/contrib/native
40 cd daemon/contrib/native && \
41 ../bootstrap \
aviaudc3c9de2016-10-05 11:13:23 -040042 --disable-downloads \
aviau2fd81442016-07-27 15:13:33 -040043 --no-checksums \
aviauf89d7062016-06-14 12:42:57 -040044 --disable-ogg \
45 --disable-flac \
46 --disable-vorbis \
47 --disable-vorbisenc \
48 --disable-speex \
49 --disable-sndfile \
aviau9c5c4ad2016-07-20 14:07:34 -040050 --disable-gsm \
Stepan Salenikovich19dd3342016-08-16 10:04:15 -040051 --disable-speexdsp \
Guillaume Roguez46bdda42017-04-17 13:38:18 -040052 --disable-natpmp \
53 --enable-gnutls && \
aviauf89d7062016-06-14 12:42:57 -040054 make list && \
aviau13264212016-11-04 17:12:45 -040055 make -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040056 cd daemon && \
57 ./autogen.sh && \
58 ./configure \
Stepan Salenikovicha61de1f2016-08-18 16:02:37 -040059 --prefix=/usr \
60 --disable-shared
aviauf89d7062016-06-14 12:42:57 -040061
62 #############################
63 ## libringclient configure ##
64 #############################
65 cd lrc && \
66 mkdir build && \
67 cd build && \
68 cmake \
69 -DRING_BUILD_DIR=$(CURDIR)/daemon/src \
70 -DCMAKE_INSTALL_PREFIX=/usr \
aviau9c5c4ad2016-07-20 14:07:34 -040071 -DCMAKE_BUILD_TYPE=Debug \
aviauf89d7062016-06-14 12:42:57 -040072 ..
73
74 ############################
75 ## gnome client configure ##
76 ############################
77 cd client-gnome && \
78 mkdir build && \
79 cd build && \
80 cmake \
81 -DCMAKE_INSTALL_PREFIX=/usr \
82 -DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
Stepan Salenikovichd6f588a2016-08-30 15:40:15 -040083 -DGSETTINGS_LOCALCOMPILE=OFF \
aviauf89d7062016-06-14 12:42:57 -040084 ..
85
86 dh_auto_configure
87
88override_dh_auto_build:
89 #######################
90 ## Ring Daemon build ##
91 #######################
aviau9c5c4ad2016-07-20 14:07:34 -040092 make -C daemon -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040093 pod2man daemon/man/dring.pod > daemon/dring.1
94
95 #########################
96 ## libringclient build ##
97 #########################
aviau9c5c4ad2016-07-20 14:07:34 -040098 make -C lrc/build -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040099
100 ########################
101 ## gnome client build ##
102 ########################
aviau9c5c4ad2016-07-20 14:07:34 -0400103 make -C client-gnome/build LDFLAGS="-lpthread" -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -0400104
105override_dh_auto_clean:
106 ################################
107 ## Generated contrib tarballs ##
108 ################################
109 rm -rfv daemon/contrib/tarballs
110
111 #######################
112 ## Ring Daemon clean ##
113 #######################
aviau9ee77442016-09-06 14:31:00 -0400114 if [ -f daemon/contrib/native/Makefile ]; then make -C daemon/contrib/native distclean; fi
aviauf89d7062016-06-14 12:42:57 -0400115 rm -rfv daemon/contrib/native
116 rm -rfv daemon/dring.1
117
118 #########################
119 ## libringclient clean ##
120 #########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500121 # CMake build system has no distclean target, so use clean.
122 if [ -f lrc/build/Makefile ]; then make -C lrc/build clean; fi
aviauf89d7062016-06-14 12:42:57 -0400123 rm -rfv lrc/build
124
125 ########################
126 ## gnome client clean ##
127 ########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500128 # CMake build system has no distclean target, so use clean.
129 if [ -f client-gnome/build/Makefile ]; then make -C client-gnome/build clean; fi
aviauf89d7062016-06-14 12:42:57 -0400130 rm -rfv client-gnome/build
131
aviau5c3c1b32017-05-02 22:39:54 -0400132override_dh_clean:
133 # GNUTLS contains:
134 # ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/src/certtool-args.c.bak
135 # ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/doc/doxygen/Doxyfile.orig
136 dh_clean -X.bak -X.orig
137
aviauf89d7062016-06-14 12:42:57 -0400138override_dh_auto_install:
139 #########################
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400140 ## Ring daemon install ##
aviauf89d7062016-06-14 12:42:57 -0400141 #########################
aviauf89d7062016-06-14 12:42:57 -0400142
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400143 cd daemon && make DESTDIR=$(CURDIR)/debian/$(RING_DAEMON_PKG_NAME) install
144 rm -rfv $(CURDIR)/debian/$(RING_DAEMON_PKG_NAME)/usr/include
145 rm -rfv $(CURDIR)/debian/$(RING_DAEMON_PKG_NAME)/usr/lib/*.a
146 rm -rfv $(CURDIR)/debian/$(RING_DAEMON_PKG_NAME)/usr/lib/*.la
147
Hugo Lefeuvrec79ae4d2018-08-07 14:48:28 -0400148 #########################
149 ## Ring client install ##
150 #########################
151
152 ## LibRingClient
153 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(RING_CLIENT_PKG_NAME) install
154 rm -rfv $(CURDIR)/debian/$(RING_CLIENT_PKG_NAME)/usr/include
155
156 # This is a symlink, should be in -dev package
157 rm -v $(CURDIR)/debian/$(RING_CLIENT_PKG_NAME)/usr/lib/libringclient.so
158
159 # cmake files
160 rm -rfv $(CURDIR)/debian/$(RING_CLIENT_PKG_NAME)/usr/lib/cmake
161
162 ## GNOME client
163 cd client-gnome/build && make DESTDIR=$(CURDIR)/debian/$(RING_CLIENT_PKG_NAME) install
164
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400165 ######################
166 ## Ring AiO install ##
167 ######################
168
169 ## daemon
170 cd daemon && make DESTDIR=$(CURDIR)/debian/$(RING_ALL_IN_ONE_PKG_NAME) install
171 rm -rfv $(CURDIR)/debian/$(RING_ALL_IN_ONE_PKG_NAME)/usr/include
172 rm -rfv $(CURDIR)/debian/$(RING_ALL_IN_ONE_PKG_NAME)/usr/lib/*.a
173 rm -rfv $(CURDIR)/debian/$(RING_ALL_IN_ONE_PKG_NAME)/usr/lib/*.la
174
175 ## LibRingClient
176 cd lrc/build && make DESTDIR=$(CURDIR)/debian/$(RING_ALL_IN_ONE_PKG_NAME) install
177 rm -rfv $(CURDIR)/debian/$(RING_ALL_IN_ONE_PKG_NAME)/usr/include
aviauf89d7062016-06-14 12:42:57 -0400178
179 # This is a symlink, should be in -dev package
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400180 rm -v $(CURDIR)/debian/$(RING_ALL_IN_ONE_PKG_NAME)/usr/lib/libringclient.so
aviauf89d7062016-06-14 12:42:57 -0400181
182 # cmake files
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400183 rm -rfv $(CURDIR)/debian/$(RING_ALL_IN_ONE_PKG_NAME)/usr/lib/cmake
aviauf89d7062016-06-14 12:42:57 -0400184
Hugo Lefeuvrec902ea12018-07-19 14:23:32 -0400185 ## GNOME client
186 cd client-gnome/build && make DESTDIR=$(CURDIR)/debian/$(RING_ALL_IN_ONE_PKG_NAME) install
aviauf89d7062016-06-14 12:42:57 -0400187
aviauf89d7062016-06-14 12:42:57 -0400188tmpdir:= $(shell mktemp -d)
189workdir:= $(shell pwd)
190PKD := $(abspath $(dir $(MAKEFILE_LIST)))
191version_to_download := $(shell dpkg-parsechangelog -ldebian/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\~dfsg.+)(?:\-\d+.*)};')
192
193# Repacks the tarball with contrib tarballs unpacked.
194get-orig-source:
195 # Download ring tarball
196 if [ -n "$$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL" ]; then \
197 mv $$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL ${tmpdir}; \
198 else \
199 uscan --rename --destdir=${tmpdir} --download-version ${version_to_download} ;\
200 fi
201
202 # Unpack ring tarball
203 tar -C ${tmpdir} -xf ${tmpdir}/*.tar.gz
204
205 # Remove original tarball
206 rm ${tmpdir}/*.tar.gz
207
208 # Unpack all of the orig tarballs into tarballs-unpacked
209 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked
210 for i in `find ${tmpdir}/ring-project/daemon/contrib/tarballs/ -name "*.tar.*"`; do \
211 projectname=`basename $$i` && \
212 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname && \
213 tar -C ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname -xf $$i && \
214 echo "Unpacked $$projectname"; \
215 done
216
217 ###################
218 ## Exclude files ##
219 ###################
220 # This does not exclude everything that we need to exclude.
221 # debian/copyright's File-Excluded section also excludes files.
222
223 ## pjproject
224 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/g7221 # non-distributable (requires a license from Polycom)
225 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/ilbc # non distributable (the version included with pjproject)
226 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/milenage # non distributable
227 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/BaseClasses # non distributable (?)
228 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/portaudio # not needed
229 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/speex # not needed
230 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/mp3 # not needed
231 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/gsm # not needed
232 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/bdsound # not needed
233 #rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp # not needed
234 rm -f ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjmedia/src/pjmedia-audiodev/s60_g729_bitstream.h # non distributable
235 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/build/vs # not needed, VisualStudio files.
236
237 # Remove all contrib tarballs
238 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs
239
240 # Create the new tarball
Hugo Lefeuvre2ae32532018-07-24 15:58:03 -0400241 cd ${tmpdir} && tar -czf ${workdir}/ring_${version_to_download}~dfsg1.orig.tar.gz ring-project
aviauf89d7062016-06-14 12:42:57 -0400242
243 # Clear the temp dir
244 rm -rf ${tmpdir}