~motumedia/libav/packaging-trunk

1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
1
#!/usr/bin/make -f
2
44 by Rico Tzschichholz
Merge with debian/experimental
3
EPOCH=6:
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
4
DEB_SOURCE := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
5
DEB_VERSION := $(shell dpkg-parsechangelog | sed -n 's/^Version: //p')
6
UPSTREAM_VERSION := $(shell echo $(DEB_VERSION) | sed -r 's/[^:]+://; s/-[^-]+$$//')
64 by Reinhard Tartler
bump shlibs version
7
SHLIBS_VERSION := $(EPOCH)10~~
55 by Rico Tzschichholz
sync with debian/experimental
8
9
# In Debian, there is no need (anymore) for a separate libav-extra
10
# source package. Instead, the libavcodec-extra package is built
11
# directly from the 'main' source package.
12
#
13
# the libavcodec-extra package is necessary because it links against
14
# libraries that are GPLv3 licensed. Make sure that you do not link
15
# GPLv2 only applications against the libavcodec-extra flavor!
16
#
17
# Because of the lack of archive skew problems, only libavcodec produces
18
# an -extra variant.
19
20
VENDOR := Debian
45 by Rico Tzschichholz
Merge with debian/experimental
21
# these package do not build -extra variants
44 by Rico Tzschichholz
Merge with debian/experimental
22
LIB_PKGS := $(shell sed -nr 's/^Package:[[:space:]]*(lib(avutil|avdevice|avformat|avfilter|avresample|swscale)[0-9]+)[[:space:]]*$$/\1/p' debian/control)
45 by Rico Tzschichholz
Merge with debian/experimental
23
# these packages do build -extra variants
44 by Rico Tzschichholz
Merge with debian/experimental
24
LIB_PKGS2 := $(shell sed -nr 's/^Package:[[:space:]]*(libavcodec[0-9]+)[[:space:]]*$$/\1/p' debian/control)
45 by Rico Tzschichholz
Merge with debian/experimental
25
# these packages are the -extra- variants
44 by Rico Tzschichholz
Merge with debian/experimental
26
LIB_EXTRA_PKGS := $(shell sed -nr 's/^Package:[[:space:]]*(libavcodec-extra-[0-9]+)[[:space:]]*$$/\1/p' debian/control)
55 by Rico Tzschichholz
sync with debian/experimental
27
28
45 by Rico Tzschichholz
Merge with debian/experimental
29
# these are the -dev packages
44 by Rico Tzschichholz
Merge with debian/experimental
30
DEV_PKGS := $(shell echo $(LIB_PKGS) $(LIB_PKGS2) | sed 's/[0-9]\+\>/-dev/g')
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
31
32
# Support multiple makes at once
33
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
34
NUMJOBS = -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
35
else
36
# on i386 and amd64, we query the system unless overriden by DEB_BUILD_OPTIONS
37
ifeq      ($(DEB_HOST_ARCH),i386)
38
NUMJOBS := -j$(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
39
else ifeq ($(DEB_HOST_ARCH),amd64)
40
NUMJOBS := -j$(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
41
endif
42
endif
43
44
include debian/confflags
35 by Rico Tzschichholz
sync with ubuntu libav and add libav-extra features
45
OPT_FLAVORS := $(filter-out static shared, $(FLAVORS))
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
46
47
$(info FLAVORS = $(FLAVORS))
48
$(info DEB_BUILD_OPTIONS = $(DEB_BUILD_OPTIONS))
49
$(info CFLAGS = $(CFLAGS))
44 by Rico Tzschichholz
Merge with debian/experimental
50
$(info CPPFLAGS = $(CPPFLAGS))
14 by Reinhard Tartler
sanitize LDFLAGS variable
51
$(info LDFLAGS = $(LDFLAGS))
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
52
35 by Rico Tzschichholz
sync with ubuntu libav and add libav-extra features
53
define dh_install_file_opt_flavor
54
	  grep @DEB_HOST_MULTIARCH_OPT@ < $(1).in | \
55
	  sed 's:@DEB_HOST_MULTIARCH_OPT@:$(DEB_HOST_MULTIARCH)/$($(2)_shlibdir):g' >> $(1)
56
57
endef
58
44 by Rico Tzschichholz
Merge with debian/experimental
59
DH_INSTALL_FILES := $(foreach pkg, $(LIB_PKGS) $(LIB_PKGS2) $(LIB_EXTRA_PKGS) $(DEV_PKGS), debian/$(pkg).install)
35 by Rico Tzschichholz
sync with ubuntu libav and add libav-extra features
60
$(DH_INSTALL_FILES):
61
	sed 's/@DEB_HOST_MULTIARCH\(_OPT\)\?@/$(DEB_HOST_MULTIARCH)/g' $@.in > $@
62
	$(foreach opt_flavor,$(OPT_FLAVORS),$(call dh_install_file_opt_flavor,$@,$(opt_flavor)))
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
63
55 by Rico Tzschichholz
sync with debian/experimental
64
ifeq ($(DEB_SOURCE),libav-extra)
65
CONFIGURE := libav/configure
66
libav/configure:
67
	tar xvf /usr/src/libav-source.tar.gz
68
else
69
CONFIGURE := configure
70
endif
71
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
72
configure-%: configure-stamp-%
55 by Rico Tzschichholz
sync with debian/experimental
73
configure-stamp-%: $(CONFIGURE)
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
74
	dh_testdir
75
	mkdir -p debian-$*
55 by Rico Tzschichholz
sync with debian/experimental
76
	cd debian-$* && CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" $(CURDIR)/$(CONFIGURE) \
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
77
		$($*_build_confflags) $(extra_$*_build_confflags)
78
	touch $@
44 by Rico Tzschichholz
Merge with debian/experimental
79
configure-extra-stamp-%:
80
	dh_testdir
81
	mkdir -p debian-extra-$*
55 by Rico Tzschichholz
sync with debian/experimental
82
	cd debian-extra-$* && CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" $(CURDIR)/$(CONFIGURE) \
44 by Rico Tzschichholz
Merge with debian/experimental
83
		$($*_build_confflags) $(v3_confflags) $(extra_$*_build_confflags)
84
	touch $@
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
85
86
build-%: build-stamp-%
87
build-stamp-%: configure-stamp-%
88
	dh_testdir
18 by Reinhard Tartler
sync with debian libav package
89
	$(MAKE) -C debian-$* $(NUMJOBS) V=1
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
90
	touch $@
44 by Rico Tzschichholz
Merge with debian/experimental
91
build-extra-stamp-%: configure-extra-stamp-%
92
	dh_testdir
93
	$(MAKE) -C debian-extra-$* $(NUMJOBS) V=1
94
	touch $@
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
95
96
debian-shared/tools/qt-faststart: build-stamp-shared
18 by Reinhard Tartler
sync with debian libav package
97
	$(MAKE) -C debian-shared tools/qt-faststart V=1
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
98
99
build-doxy: build-doxy-stamp
35 by Rico Tzschichholz
sync with ubuntu libav and add libav-extra features
100
build-doxy-stamp:
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
101
	dh_testdir
55 by Rico Tzschichholz
sync with debian/experimental
102
	[ ! -x /usr/bin/doxygen ] || doxygen doc/Doxyfile
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
103
	touch $@
104
44 by Rico Tzschichholz
Merge with debian/experimental
105
build: build-stamp build-extra
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
106
build-stamp: $(addprefix build-stamp-, $(FLAVORS)) debian-shared/tools/qt-faststart
107
	touch $@
44 by Rico Tzschichholz
Merge with debian/experimental
108
build-extra: $(addprefix build-extra-stamp-, $(filter-out static,$(FLAVORS)))
109
	touch $@
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
110
58 by Rico Tzschichholz
sync with debian experimental
111
clean:
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
112
	dh_testdir
44 by Rico Tzschichholz
Merge with debian/experimental
113
	rm -f build-stamp build-extra $(addprefix build-stamp-, $(FLAVORS)) \
114
	    $(addprefix build-extra-stamp-, $(FLAVORS)) \
35 by Rico Tzschichholz
sync with ubuntu libav and add libav-extra features
115
	    $(addprefix configure-stamp-, $(FLAVORS)) \
44 by Rico Tzschichholz
Merge with debian/experimental
116
	    $(addprefix configure-extra-stamp-, $(FLAVORS)) \
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
117
	    build-doxy-stamp
55 by Rico Tzschichholz
sync with debian/experimental
118
	rm -rf libav/ # created by the libav-extra variant
44 by Rico Tzschichholz
Merge with debian/experimental
119
	rm -rf $(addprefix debian-, $(FLAVORS)) \
120
		$(addprefix debian-extra-, $(FLAVORS)) doxy
121
	dh_clean $(DH_INSTALL_FILES) $(wildcard formats*.txt) $(wildcard codecs*.txt)
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
122
123
# The trailing newline is important!
124
define install_flavor
125
	$(MAKE) -C debian-$(1) install DESTDIR=$(CURDIR)/debian/tmp \
126
	    mandir=$(CURDIR)/debian/tmp/usr/share/man
127
128
endef
129
44 by Rico Tzschichholz
Merge with debian/experimental
130
# The trailing newline is important!
131
define install_flavor_extra
132
	$(MAKE) -C debian-extra-$(1) install DESTDIR=$(CURDIR)/debian/tmp/extra \
133
	    mandir=$(CURDIR)/debian/tmp/usr/share/man
134
135
endef
136
137
install: install-common install-extra
138
install-common: build $(DH_INSTALL_FILES)
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
139
	dh_testdir
140
	dh_testroot
141
	dh_prep
55 by Rico Tzschichholz
sync with debian/experimental
142
ifeq ($(DEB_SOURCE), libav)
143
	# the libav-source package does exist in some derivatives such as ubuntu, etc.
144
	if grep -q 'Package: libav-source' debian/control; then \
145
	  dh_installdirs -ptmp usr/src;  \
146
	  tar czvf debian/tmp/usr/src/libav-source.tar.gz . \
147
	  	 --exclude 'debian*' --exclude .git  --exclude .pc --exclude '*-stamp' \
148
	  	 --transform 's,^./,libav/,' ; \
149
	fi
150
endif
17.1.2 by Reinhard Tartler
introduce new package lbav-source
151
	dh_installdirs -ptmp usr/src
35 by Rico Tzschichholz
sync with ubuntu libav and add libav-extra features
152
	dh_installdirs -ptmp usr/share/doc/libav/html etc
17.1.1 by Reinhard Tartler
Switch to libav packages
153
	dh_installdirs -ptmp usr/share/doc/libav-doc/html
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
154
	$(foreach flavor,$(FLAVORS),$(call install_flavor,$(flavor)))
18 by Reinhard Tartler
sync with debian libav package
155
	# don't fail on binary-indep only builds.
55 by Rico Tzschichholz
sync with debian/experimental
156
	-cp -avf doc/doxy/html debian/tmp/usr/share/doc/libav-doc
35 by Rico Tzschichholz
sync with ubuntu libav and add libav-extra features
157
	install -m 644 -D debian-shared/doc/*.html debian/tmp/usr/share/doc/libav/html/
28 by Rico Tzschichholz
follow ffserver->avserver rename
158
	install -m 644 -D doc/avserver.conf debian/tmp/etc/
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
159
	install -m 644 -D debian-shared/tools/qt-faststart debian/tmp/usr/bin/qt-faststart
44 by Rico Tzschichholz
Merge with debian/experimental
160
	dh_install $(addprefix -N,$(LIB_EXTRA_PKGS)) \
161
		-Xusr/share/doc/libav-doc \
162
		-Xusr/share/doc/libav --fail-missing --sourcedir=debian/tmp
163
	env LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)" \
164
	debian/tmp/usr/bin/avconv -formats | tee formats-$(DEB_HOST_ARCH).txt
165
	env LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)" \
166
	debian/tmp/usr/bin/avconv -codecs | tee codecs.txt
57 by Rico Tzschichholz
Follow soname bumps libavcodec/libavformat 54 > 55 and libavdevice 53 > 54, and merge with ubuntu
167
	dh_installdocs -plibavformat55 formats-$(DEB_HOST_ARCH).txt
168
	dh_installdocs -plibavcodec55 codecs.txt
44 by Rico Tzschichholz
Merge with debian/experimental
169
install-extra: build $(DH_INSTALL_FILES)
170
	dh_testdir
171
	dh_testroot
172
	$(foreach flavor,$(filter-out static,$(FLAVORS)),$(call install_flavor_extra,$(flavor)))
173
	dh_install $(addprefix -p,$(LIB_EXTRA_PKGS)) -Xusr/share/doc/libav-doc \
58 by Rico Tzschichholz
sync with debian experimental
174
		-Xusr/share/doc/libav --fail-missing \
44 by Rico Tzschichholz
Merge with debian/experimental
175
		--sourcedir=debian/tmp/extra
176
	env LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(CURDIR)/debian/tmp/extra/usr/lib/$(DEB_HOST_MULTIARCH)" \
177
	debian/tmp/usr/bin/avconv -codecs | tee codecs.txt
57 by Rico Tzschichholz
Follow soname bumps libavcodec/libavformat 54 > 55 and libavdevice 53 > 54, and merge with ubuntu
178
	dh_installdocs -plibavcodec-extra-55 codecs.txt
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
179
180
binary-indep: build-doxy install
181
44 by Rico Tzschichholz
Merge with debian/experimental
182
binary-arch: build install
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
183
	dh_testdir
184
	dh_testroot
44 by Rico Tzschichholz
Merge with debian/experimental
185
	dh_installman -plibav-tools debian/qt-faststart.1
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
186
	dh_installdocs -A debian/README.Debian
55 by Rico Tzschichholz
sync with debian/experimental
187
ifeq ($(DEB_SOURCE), libav)
35 by Rico Tzschichholz
sync with ubuntu libav and add libav-extra features
188
	dh_installdocs -p libavcodec-dev -plibavdevice-dev \
44 by Rico Tzschichholz
Merge with debian/experimental
189
		-plibavformat-dev -plibavfilter-dev -plibavresample-dev \
35 by Rico Tzschichholz
sync with ubuntu libav and add libav-extra features
190
		-plibswscale-dev -plibavutil-dev -plibav-doc \
191
		doc/APIchanges
192
	dh_installexamples -p libavcodec-dev libavcodec/api-example.c
55 by Rico Tzschichholz
sync with debian/experimental
193
	dh_strip --dbg-package=libav-dbg
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
194
	dh_installchangelogs Changelog
55 by Rico Tzschichholz
sync with debian/experimental
195
else
196
	dh_strip --dbg-package=libav-extra-dbg
197
	dh_installchangelogs libav/Changelog
198
endif
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
199
	dh_lintian
200
	dh_link
201
	dh_compress
202
	dh_fixperms
203
58 by Rico Tzschichholz
sync with debian experimental
204
	# operate on non -extra package producing packages
205
	for pkg in $(LIB_PKGS); do \
55 by Rico Tzschichholz
sync with debian/experimental
206
	    dh_makeshlibs -p"$$pkg" -V"$$pkg (>= $(SHLIBS_VERSION))"; \
45 by Rico Tzschichholz
Merge with debian/experimental
207
	done
58 by Rico Tzschichholz
sync with debian experimental
208
	# operate e.g. the -extra- packages, produce shlibs that have alternative dependencies
209
	for pkg in $(LIB_EXTRA_PKGS); do \
210
	    npkg=$$(echo "$$pkg" | sed -r 's/-extra-//'); \
211
	    dh_makeshlibs -p"$$pkg" -V"$$npkg (>= $(SHLIBS_VERSION)) | $$pkg (>= $(EPOCH)$(UPSTREAM_VERSION))"; \
212
	done
213
	# operate on packages with -extra- variants such as libavcodec54 - produce shlibs that have alternative dependencies
45 by Rico Tzschichholz
Merge with debian/experimental
214
	for pkg in $(LIB_PKGS2); do \
215
	    upkg=$$(echo "$$pkg" | sed -r 's/([0-9]+)$$/-extra-\1/'); \
55 by Rico Tzschichholz
sync with debian/experimental
216
	    dh_makeshlibs -p"$$pkg" -V"$$pkg (>= $(SHLIBS_VERSION)) | $$upkg (>= $(EPOCH)$(UPSTREAM_VERSION))"; \
45 by Rico Tzschichholz
Merge with debian/experimental
217
	done
218
	dh_shlibdeps
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
219
	dh_installdeb
55 by Rico Tzschichholz
sync with debian/experimental
220
	dh_gencontrol
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
221
	dh_md5sums
55 by Rico Tzschichholz
sync with debian/experimental
222
	dh_builddeb -- -Zxz
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
223
224
binary: binary-indep binary-arch
225
226
.PHONY: build $(addprefix build-, $(FLAVORS)) build-doxy \
35 by Rico Tzschichholz
sync with ubuntu libav and add libav-extra features
227
	clean \
1 by Reinhard Tartler
import packaging for 4:0.6.1-2ubuntu1
228
	configure $(addprefix configure-, $(FLAVORS)) \
229
	binary binary-indep binary-arch \
230
	install \
231
	get-orig-source