blob: a2b8b315e3fc14ad6d93d525bf414f314d41fe3e [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 \
aviau2fd81442016-07-27 15:13:33 -040037 --no-checksums \
aviauf89d7062016-06-14 12:42:57 -040038 --disable-ogg \
39 --disable-flac \
40 --disable-vorbis \
41 --disable-vorbisenc \
42 --disable-speex \
43 --disable-sndfile \
aviau9c5c4ad2016-07-20 14:07:34 -040044 --disable-gsm \
aviauf89d7062016-06-14 12:42:57 -040045 --disable-speexdsp && \
46 make list && \
aviau9c5c4ad2016-07-20 14:07:34 -040047 make -j1 V=1
aviauf89d7062016-06-14 12:42:57 -040048 cd daemon && \
49 ./autogen.sh && \
50 ./configure \
aviau9c5c4ad2016-07-20 14:07:34 -040051 --prefix=/usr
aviauf89d7062016-06-14 12:42:57 -040052
53 #############################
54 ## libringclient configure ##
55 #############################
56 cd lrc && \
57 mkdir build && \
58 cd build && \
59 cmake \
60 -DRING_BUILD_DIR=$(CURDIR)/daemon/src \
61 -DCMAKE_INSTALL_PREFIX=/usr \
aviau9c5c4ad2016-07-20 14:07:34 -040062 -DCMAKE_BUILD_TYPE=Debug \
aviauf89d7062016-06-14 12:42:57 -040063 ..
64
65 ############################
66 ## gnome client configure ##
67 ############################
68 cd client-gnome && \
69 mkdir build && \
70 cd build && \
71 cmake \
72 -DCMAKE_INSTALL_PREFIX=/usr \
73 -DLibRingClient_PROJECT_DIR=/$(CURDIR)/lrc \
74 ..
75
76 dh_auto_configure
77
78override_dh_auto_build:
79 #######################
80 ## Ring Daemon build ##
81 #######################
aviau9c5c4ad2016-07-20 14:07:34 -040082 make -C daemon -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040083 pod2man daemon/man/dring.pod > daemon/dring.1
84
85 #########################
86 ## libringclient build ##
87 #########################
aviau9c5c4ad2016-07-20 14:07:34 -040088 make -C lrc/build -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040089
90 ########################
91 ## gnome client build ##
92 ########################
aviau9c5c4ad2016-07-20 14:07:34 -040093 make -C client-gnome/build LDFLAGS="-lpthread" -j$(NO_CPUS) V=1
aviauf89d7062016-06-14 12:42:57 -040094
95override_dh_auto_clean:
96 ################################
97 ## Generated contrib tarballs ##
98 ################################
99 rm -rfv daemon/contrib/tarballs
100
101 #######################
102 ## Ring Daemon clean ##
103 #######################
104 if [ -d daemon/contrib/native ]; then cd daemon/contrib/native && make distclean; fi
105 rm -rfv daemon/contrib/native
106 rm -rfv daemon/dring.1
107
108 #########################
109 ## libringclient clean ##
110 #########################
111 if [ -d lrc/build ]; then cd lrc/build && make distclean; fi
112 rm -rfv lrc/build
113
114 ########################
115 ## gnome client clean ##
116 ########################
117 if [ -d client-gnome/build ]; then cd client-gnome/build && make distclean; fi
118 rm -rfv client-gnome/build
119
120override_dh_auto_install:
121 #########################
122 ## Ring Daemon install ##
123 #########################
124 cd daemon && make DESTDIR=$(CURDIR)/debian/ring-daemon install
125 rm -rfv $(CURDIR)/debian/ring-daemon/usr/include
126 rm -rfv $(CURDIR)/debian/ring-daemon/usr/lib
127
128 ###########################
129 ## libringclient install ##
130 ###########################
131 cd lrc/build && make DESTDIR=$(CURDIR)/debian/ring install
132 rm -rfv $(CURDIR)/debian/ring/usr/include
133
134 # This is a symlink, should be in -dev package
135 rm -v $(CURDIR)/debian/ring/usr/lib/libringclient.so
136
137 # cmake files
138 rm -rfv $(CURDIR)/debian/ring/usr/lib/cmake
139
140 ##########################
141 ## gnome client install ##
142 ##########################
143 cd client-gnome/build && make DESTDIR=$(CURDIR)/debian/ring install
144
145 # Remove ring binary: it is not needed for now
146 rm $(CURDIR)/debian/ring/usr/bin/ring.cx
147
148tmpdir:= $(shell mktemp -d)
149workdir:= $(shell pwd)
150PKD := $(abspath $(dir $(MAKEFILE_LIST)))
151version_to_download := $(shell dpkg-parsechangelog -ldebian/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\~dfsg.+)(?:\-\d+.*)};')
152
153# Repacks the tarball with contrib tarballs unpacked.
154get-orig-source:
155 # Download ring tarball
156 if [ -n "$$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL" ]; then \
157 mv $$GET_ORIG_SOURCE_OVERRIDE_USCAN_TARBALL ${tmpdir}; \
158 else \
159 uscan --rename --destdir=${tmpdir} --download-version ${version_to_download} ;\
160 fi
161
162 # Unpack ring tarball
163 tar -C ${tmpdir} -xf ${tmpdir}/*.tar.gz
164
165 # Remove original tarball
166 rm ${tmpdir}/*.tar.gz
167
168 # Unpack all of the orig tarballs into tarballs-unpacked
169 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked
170 for i in `find ${tmpdir}/ring-project/daemon/contrib/tarballs/ -name "*.tar.*"`; do \
171 projectname=`basename $$i` && \
172 mkdir ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname && \
173 tar -C ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/$$projectname -xf $$i && \
174 echo "Unpacked $$projectname"; \
175 done
176
177 ###################
178 ## Exclude files ##
179 ###################
180 # This does not exclude everything that we need to exclude.
181 # debian/copyright's File-Excluded section also excludes files.
182
183 ## pjproject
184 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/g7221 # non-distributable (requires a license from Polycom)
185 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/ilbc # non distributable (the version included with pjproject)
186 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/milenage # non distributable
187 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/BaseClasses # non distributable (?)
188 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/portaudio # not needed
189 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/speex # not needed
190 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/mp3 # not needed
191 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/gsm # not needed
192 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/bdsound # not needed
193 #rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/third_party/srtp # not needed
194 rm -f ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/pjmedia/src/pjmedia-audiodev/s60_g729_bitstream.h # non distributable
195 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs-unpacked/pjproject-*/pjproject-*/build/vs # not needed, VisualStudio files.
196
197 # Remove all contrib tarballs
198 rm -rf ${tmpdir}/ring-project/daemon/contrib/tarballs
199
200 # Create the new tarball
201 cd ${tmpdir} && tar -czf ${workdir}/ring_${version_to_download}~dfsg1.orig.tar.gz ring-project
202
203 # Clear the temp dir
204 rm -rf ${tmpdir}