blob: 5a69c84857b09a5f9b716606dda1297d43784814 [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
15%:
16 dh $@
17
18override_dh_auto_configure:
19 ###############################################
20 ## Re-create tarballs from tarballs-unpacked ##
21 ###############################################
22 mkdir -p daemon/contrib/tarballs
23
24 # Create tarballs
25 for i in $(CURDIR)/daemon/contrib/tarballs-unpacked/*; do \
26 projectname=`basename $$i` && \
27 cd $$i && tar -caf ../../tarballs/$$projectname * && \
28 echo "Repacked $$projectname"; \
29 done
30
aviauf89d7062016-06-14 12:42:57 -040031 ###########################
32 ## Ring Daemon configure ##
33 ###########################
34 mkdir -p daemon/contrib/native
35 cd daemon/contrib/native && \
36 ../bootstrap \
aviaudc3c9de2016-10-05 11:13:23 -040037 --disable-downloads \
aviau2fd81442016-07-27 15:13:33 -040038 --no-checksums \
aviauf89d7062016-06-14 12:42:57 -040039 --disable-ogg \
40 --disable-flac \
41 --disable-vorbis \
42 --disable-vorbisenc \
43 --disable-speex \
44 --disable-sndfile \
aviau9c5c4ad2016-07-20 14:07:34 -040045 --disable-gsm \
Stepan Salenikovich19dd3342016-08-16 10:04:15 -040046 --disable-speexdsp \
Guillaume Roguez46bdda42017-04-17 13:38:18 -040047 --disable-natpmp \
48 --enable-gnutls && \
aviauf89d7062016-06-14 12:42:57 -040049 make list && \
aviau13264212016-11-04 17:12:45 -040050 make -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040051 cd daemon && \
52 ./autogen.sh && \
53 ./configure \
Stepan Salenikovicha61de1f2016-08-18 16:02:37 -040054 --prefix=/usr \
55 --disable-shared
aviauf89d7062016-06-14 12:42:57 -040056
57 #############################
58 ## libringclient configure ##
59 #############################
60 cd lrc && \
61 mkdir build && \
62 cd build && \
63 cmake \
64 -DRING_BUILD_DIR=$(CURDIR)/daemon/src \
65 -DCMAKE_INSTALL_PREFIX=/usr \
aviau9c5c4ad2016-07-20 14:07:34 -040066 -DCMAKE_BUILD_TYPE=Debug \
aviauf89d7062016-06-14 12:42:57 -040067 ..
68
69 ############################
70 ## gnome client configure ##
71 ############################
72 cd client-gnome && \
73 mkdir build && \
74 cd build && \
75 cmake \
76 -DCMAKE_INSTALL_PREFIX=/usr \
77 -DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
Stepan Salenikovichd6f588a2016-08-30 15:40:15 -040078 -DGSETTINGS_LOCALCOMPILE=OFF \
aviauf89d7062016-06-14 12:42:57 -040079 ..
80
81 dh_auto_configure
82
83override_dh_auto_build:
84 #######################
85 ## Ring Daemon build ##
86 #######################
aviau9c5c4ad2016-07-20 14:07:34 -040087 make -C daemon -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040088 pod2man daemon/man/dring.pod > daemon/dring.1
89
90 #########################
91 ## libringclient build ##
92 #########################
aviau9c5c4ad2016-07-20 14:07:34 -040093 make -C lrc/build -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040094
95 ########################
96 ## gnome client build ##
97 ########################
aviau9c5c4ad2016-07-20 14:07:34 -040098 make -C client-gnome/build LDFLAGS="-lpthread" -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040099
100override_dh_auto_clean:
101 ################################
102 ## Generated contrib tarballs ##
103 ################################
104 rm -rfv daemon/contrib/tarballs
105
106 #######################
107 ## Ring Daemon clean ##
108 #######################
aviau9ee77442016-09-06 14:31:00 -0400109 if [ -f daemon/contrib/native/Makefile ]; then make -C daemon/contrib/native distclean; fi
aviauf89d7062016-06-14 12:42:57 -0400110 rm -rfv daemon/contrib/native
111 rm -rfv daemon/dring.1
112
113 #########################
114 ## libringclient clean ##
115 #########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500116 # CMake build system has no distclean target, so use clean.
117 if [ -f lrc/build/Makefile ]; then make -C lrc/build clean; fi
aviauf89d7062016-06-14 12:42:57 -0400118 rm -rfv lrc/build
119
120 ########################
121 ## gnome client clean ##
122 ########################
Maxim Cournoyerdad4c3b2018-02-14 15:48:37 -0500123 # CMake build system has no distclean target, so use clean.
124 if [ -f client-gnome/build/Makefile ]; then make -C client-gnome/build clean; fi
aviauf89d7062016-06-14 12:42:57 -0400125 rm -rfv client-gnome/build
126
aviau5c3c1b32017-05-02 22:39:54 -0400127override_dh_clean:
128 # GNUTLS contains:
129 # ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/src/certtool-args.c.bak
130 # ring-project/daemon/contrib/tarballs-unpacked/gnutls-3.5.10.tar.xz/gnutls-3.5.10/doc/doxygen/Doxyfile.orig
131 dh_clean -X.bak -X.orig
132
aviauf89d7062016-06-14 12:42:57 -0400133override_dh_auto_install:
134 #########################
135 ## Ring Daemon install ##
136 #########################
137 cd daemon && make DESTDIR=$(CURDIR)/debian/ring-daemon install
138 rm -rfv $(CURDIR)/debian/ring-daemon/usr/include
aviauf6b38ee2016-07-28 17:10:03 -0400139 rm -rfv $(CURDIR)/debian/ring-daemon/usr/lib/*.a
140 rm -rfv $(CURDIR)/debian/ring-daemon/usr/lib/*.la
aviauf89d7062016-06-14 12:42:57 -0400141
142 ###########################
143 ## libringclient install ##
144 ###########################
145 cd lrc/build && make DESTDIR=$(CURDIR)/debian/ring install
146 rm -rfv $(CURDIR)/debian/ring/usr/include
147
148 # This is a symlink, should be in -dev package
149 rm -v $(CURDIR)/debian/ring/usr/lib/libringclient.so
150
151 # cmake files
152 rm -rfv $(CURDIR)/debian/ring/usr/lib/cmake
153
154 ##########################
155 ## gnome client install ##
156 ##########################
157 cd client-gnome/build && make DESTDIR=$(CURDIR)/debian/ring install
158
aviauf89d7062016-06-14 12:42:57 -0400159tmpdir:= $(shell mktemp -d)
160workdir:= $(shell pwd)
161PKD := $(abspath $(dir $(MAKEFILE_LIST)))
162version_to_download := $(shell dpkg-parsechangelog -ldebian/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\~dfsg.+)(?:\-\d+.*)};')
163
164# Repacks the tarball with contrib tarballs unpacked.
165get-orig-source:
166 # Download ring tarball
167 if [ -n "$$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL" ]; then \
168 mv $$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL ${tmpdir}; \
169 else \
170 uscan --rename --destdir=${tmpdir} --download-version ${version_to_download} ;\
171 fi
172
173 # Unpack ring tarball
174 tar -C ${tmpdir} -xf ${tmpdir}/*.tar.gz
175
176 # Remove original tarball
177 rm ${tmpdir}/*.tar.gz
178
179 # Unpack all of the orig tarballs into tarballs-unpacked
180 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked
181 for i in `find ${tmpdir}/ring-project/daemon/contrib/tarballs/ -name "*.tar.*"`; do \
182 projectname=`basename $$i` && \
183 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname && \
184 tar -C ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname -xf $$i && \
185 echo "Unpacked $$projectname"; \
186 done
187
188 ###################
189 ## Exclude files ##
190 ###################
191 # This does not exclude everything that we need to exclude.
192 # debian/copyright's File-Excluded section also excludes files.
193
194 ## pjproject
195 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/g7221 # non-distributable (requires a license from Polycom)
196 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/ilbc # non distributable (the version included with pjproject)
197 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/milenage # non distributable
198 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/BaseClasses # non distributable (?)
199 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/portaudio # not needed
200 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/speex # not needed
201 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/mp3 # not needed
202 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/gsm # not needed
203 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/bdsound # not needed
204 #rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp # not needed
205 rm -f ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjmedia/src/pjmedia-audiodev/s60_g729_bitstream.h # non distributable
206 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/build/vs # not needed, VisualStudio files.
207
208 # Remove all contrib tarballs
209 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs
210
211 # Create the new tarball
212 cd ${tmpdir} && tar -czf ${workdir}/ring_${version_to_download}~dfsg1.orig.tar.gz ring-project
213
214 # Clear the temp dir
215 rm -rf ${tmpdir}