blob: e2c81fbc24e349f385a677dafa3d40b2c2148673 [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
31 # Prevent bootstrap script from verifying checksums
32 mkdir -p daemon/contrib/native
33 touch daemon/contrib/native/.sum-msgpack
34 touch daemon/contrib/native/.sum-opendht
35 touch daemon/contrib/native/.sum-pjproject
36
37 ###########################
38 ## Ring Daemon configure ##
39 ###########################
40 mkdir -p daemon/contrib/native
41 cd daemon/contrib/native && \
42 ../bootstrap \
43 --disable-ogg \
44 --disable-flac \
45 --disable-vorbis \
46 --disable-vorbisenc \
47 --disable-speex \
48 --disable-sndfile \
aviau9c5c4ad2016-07-20 14:07:34 -040049 --disable-gsm \
aviauf89d7062016-06-14 12:42:57 -040050 --disable-speexdsp && \
51 make list && \
aviau9c5c4ad2016-07-20 14:07:34 -040052 make -j1 V=1
aviauf89d7062016-06-14 12:42:57 -040053 cd daemon && \
54 ./autogen.sh && \
55 ./configure \
aviau9c5c4ad2016-07-20 14:07:34 -040056 --prefix=/usr
aviauf89d7062016-06-14 12:42:57 -040057
58 #############################
59 ## libringclient configure ##
60 #############################
61 cd lrc && \
62 mkdir build && \
63 cd build && \
64 cmake \
65 -DRING_BUILD_DIR=$(CURDIR)/daemon/src \
66 -DCMAKE_INSTALL_PREFIX=/usr \
aviau9c5c4ad2016-07-20 14:07:34 -040067 -DCMAKE_BUILD_TYPE=Debug \
aviauf89d7062016-06-14 12:42:57 -040068 ..
69
70 ############################
71 ## gnome client configure ##
72 ############################
73 cd client-gnome && \
74 mkdir build && \
75 cd build && \
76 cmake \
77 -DCMAKE_INSTALL_PREFIX=/usr \
78 -DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
79 ..
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 #######################
109 if [ -d daemon/contrib/native ]; then cd daemon/contrib/native && make distclean; fi
110 rm -rfv daemon/contrib/native
111 rm -rfv daemon/dring.1
112
113 #########################
114 ## libringclient clean ##
115 #########################
116 if [ -d lrc/build ]; then cd lrc/build && make distclean; fi
117 rm -rfv lrc/build
118
119 ########################
120 ## gnome client clean ##
121 ########################
122 if [ -d client-gnome/build ]; then cd client-gnome/build && make distclean; fi
123 rm -rfv client-gnome/build
124
125override_dh_auto_install:
126 #########################
127 ## Ring Daemon install ##
128 #########################
129 cd daemon && make DESTDIR=$(CURDIR)/debian/ring-daemon install
130 rm -rfv $(CURDIR)/debian/ring-daemon/usr/include
131 rm -rfv $(CURDIR)/debian/ring-daemon/usr/lib
132
133 ###########################
134 ## libringclient install ##
135 ###########################
136 cd lrc/build && make DESTDIR=$(CURDIR)/debian/ring install
137 rm -rfv $(CURDIR)/debian/ring/usr/include
138
139 # This is a symlink, should be in -dev package
140 rm -v $(CURDIR)/debian/ring/usr/lib/libringclient.so
141
142 # cmake files
143 rm -rfv $(CURDIR)/debian/ring/usr/lib/cmake
144
145 ##########################
146 ## gnome client install ##
147 ##########################
148 cd client-gnome/build && make DESTDIR=$(CURDIR)/debian/ring install
149
150 # Remove ring binary: it is not needed for now
151 rm $(CURDIR)/debian/ring/usr/bin/ring.cx
152
153tmpdir:= $(shell mktemp -d)
154workdir:= $(shell pwd)
155PKD := $(abspath $(dir $(MAKEFILE_LIST)))
156version_to_download := $(shell dpkg-parsechangelog -ldebian/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\~dfsg.+)(?:\-\d+.*)};')
157
158# Repacks the tarball with contrib tarballs unpacked.
159get-orig-source:
160 # Download ring tarball
161 if [ -n "$$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL" ]; then \
162 mv $$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL ${tmpdir}; \
163 else \
164 uscan --rename --destdir=${tmpdir} --download-version ${version_to_download} ;\
165 fi
166
167 # Unpack ring tarball
168 tar -C ${tmpdir} -xf ${tmpdir}/*.tar.gz
169
170 # Remove original tarball
171 rm ${tmpdir}/*.tar.gz
172
173 # Unpack all of the orig tarballs into tarballs-unpacked
174 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked
175 for i in `find ${tmpdir}/ring-project/daemon/contrib/tarballs/ -name "*.tar.*"`; do \
176 projectname=`basename $$i` && \
177 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname && \
178 tar -C ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname -xf $$i && \
179 echo "Unpacked $$projectname"; \
180 done
181
182 ###################
183 ## Exclude files ##
184 ###################
185 # This does not exclude everything that we need to exclude.
186 # debian/copyright's File-Excluded section also excludes files.
187
188 ## pjproject
189 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/g7221 # non-distributable (requires a license from Polycom)
190 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/ilbc # non distributable (the version included with pjproject)
191 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/milenage # non distributable
192 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/BaseClasses # non distributable (?)
193 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/portaudio # not needed
194 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/speex # not needed
195 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/mp3 # not needed
196 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/gsm # not needed
197 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/bdsound # not needed
198 #rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp # not needed
199 rm -f ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjmedia/src/pjmedia-audiodev/s60_g729_bitstream.h # non distributable
200 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/build/vs # not needed, VisualStudio files.
201
202 # Remove all contrib tarballs
203 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs
204
205 # Create the new tarball
206 cd ${tmpdir} && tar -czf ${workdir}/ring_${version_to_download}~dfsg1.orig.tar.gz ring-project
207
208 # Clear the temp dir
209 rm -rf ${tmpdir}