Backslash ${prefix} for kde3 too...
[gnash.git] / packaging / deb.am
blob6ad3928eb1b85522a9a536de2f72bc4c6ebffb88
1
2 #   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16
18 # Build a Debian/Ubuntu .deb GNU/Linux package
20 deb: revno.h snapshot-src setup-deb snapshot-deb
22 # Build a .deb snapshot, which means we have to munge the release data
23 # into the proper files to build a package with the version in
24 # all the right places. This involves editing the debian/changelog
25 # file. Configure.ac is edited by the snapshot target.
26 # We also edit the gtk-plugin-gnash paths, as these differ between
27 # python versions and GNU/Linux distributions. Also if configured
28 # with the plugin not going into the standard directory of
29 # /usr/lib/mozilla/plugins or $HOME/.mozilla/plugins, we also
30 # have to change the path to the NPAPI plugin so it gets installed
31 # for the correct browser.
33 # DEB_BUILD_OPTIONS is used to change the configuration of the
34 # packages that get built. This is used for both the debian/rules
35 # file and here. By default, this looks for the value in the users
36 # environment, which is what dpkg-buildpackage does as well. If
37 # DEB_BUILD_OPTIONS is defined on the command line to make, then
38 # that value takes precedence. Once we have the value of the
39 # build options, we can then see what is enabled or not. The
40 # default produces a package with normal defaults.
41 DEB_BUILD_OPTIONS ?= $(shell echo $DEB_BUILD_OPTIONS)
42 FFMPEG := $(shell echo $(DEB_BUILD_OPTIONS) | grep -c "ffmpeg")
43 OGL := $(shell echo $(DEB_BUILD_OPTIONS) | grep -c "ogl")
44 VAAPI := $(shell echo $(DEB_BUILD_OPTIONS) | grep -c "vaapi")
46 # Look at the build options to calculate the new build name. This is
47 # used for the the snapshot source directory name.
48 BUILD_DIR := $(shell \
49         snapshot_dir=$(SNAPSHOT_DIR); \
50         if test $(OGL) -eq 1 -o $(FFMPEG) -eq 1 -o $(VAAPI) -eq 1; then \
51           if test $(OGL) -eq 1 -a $(FFMPEG) -eq 1; then \
52             snapshot_dir=$(subst git,git.ogl.ffmpeg,$(SNAPSHOT_DIR)); \
53           fi; \
54           if test $(OGL) -eq 1 -a $(FFMPEG) -eq 0; then \
55             snapshot_dir=$(subst git,git.ogl,$(SNAPSHOT_DIR)); \
56           fi; \
57           if test $(OGL) -eq 0 -a $(FFMPEG) -eq 1; then \
58             snapshot_dir=$(subst git,git.ffmpeg,$(SNAPSHOT_DIR)); \
59           fi; \
60           if test $(VAAPI) -eq 1; then \
61             snapshot_dir=$(subst git,git.vaapi,$(SNAPSHOT_DIR)); \
62           fi; \
63         fi; \
64         echo "$${snapshot_dir}")
66 # Look at the build options to calculate the new build name. This is
67 # used for the the snapshot version.
68 BUILD_VERSION := $(shell \
69         snapshot_version=$(SNAPSHOT_VERSION); \
70         if test $(OGL) -eq 1 -o $(FFMPEG) -eq 1 -o $(VAAPI) -eq 1; then \
71           if test $(OGL) -eq 1 -a $(FFMPEG) -eq 1; then \
72             snapshot_version=$(subst git,git.ogl.ffmpeg,$(SNAPSHOT_VERSION)); \
73           fi; \
74           if test $(OGL) -eq 1 -a $(FFMPEG) -eq 0; then \
75             snapshot_version=$(subst git,git.ogl,$(SNAPSHOT_VERSION)); \
76           fi; \
77           if test $(OGL) -eq 0 -a $(FFMPEG) -eq 1; then \
78             snapshot_version=$(subst git,git.ffmpeg,$(SNAPSHOT_VERSION)); \
79           fi; \
80           if test $(VAAPI) -eq 1; then \
81             snapshot_version=$(subst git,git.vaapi,$(SNAPSHOT_VERSION)); \
82           fi; \
83         fi; \
84         echo "$${snapshot_version}")
86 # This is a list of all the packages in the control file.
87 PACKAGES := \
88         if test -f $(srcdir)/packaging/debian/control; then \
89           grep Package $(srcdir)/packaging/debian/control | sed -e 's/Package\://'; \
90         else \
91           echo "gnash"; \
92         fi
94 # SNAPSHOT_VERSION is the name that gets used for the packages. By default
95 # it is "$(NEXT_RELEASE)~git.$(BRANCH_NICK)$(BRANCH_REVNO)", but when
96 # building alternate packages, we want to rename them so there isn't a
97 # name collision.
99 # This gets more fun, as if we configure with ffmpeg, the two utilities that
100 # deal with Gstreamer based input devices, findwebcam and findmicrophone,
101 # don't get built. So we strip them out of the packages.
102 setup-deb: deb-copy-files deb-edit-changelog deb-edit-configure deb-edit-control deb-edit-utilities deb-edit-python deb-edit-browser
104 # Rename the directory created by distdir to the snapshot. This is
105 # usually something like "gnash-master" to "0.8.8~git.ogl.ffmpeg.master11977".
106 # This requires distdir to be run first, but it's not a dependency as we
107 # don't want to always rebuild the source tree, just the dependencies.
108 deb-rename-build:
109         @echo "Building package in: $(BUILD_DIR)..."
110         @if test -d gnash-$(PACKAGE_VERSION); then \
111           if test ! -d $(BUILD_DIR); then \
112             mv -f gnash-$(PACKAGE_VERSION) $(BUILD_DIR); \
113           fi; \
114         fi
116 # Once the directory has been renamed, we copy over the Debian packaging
117 # files. Then we have to edit a few of them to match this snapshot
118 deb-copy-files: deb-copy-stamp
119 deb-copy-stamp: deb-rename-build
120         @echo "Copying debian packaging files..."
121         @if test ! -d $(BUILD_DIR)/debian; then \
122           mkdir -p $(BUILD_DIR)/debian; \
123         fi
124         @cp -rfp $(srcdir)/packaging/debian/* $(BUILD_DIR)/debian/
125         @touch $@
127 # The findwebcam and findmicrophone utilities are only support for Gstreamer
128 # builds, so we have to remove them from packaging when configuring with ffmpeg.
129 deb-edit-utilities:
130         @if test $(FFMPEG) -eq 1; then \
131            echo "Removing findwebcam and findmicrophone files from package as they aren't supported with ffmpeg..."; \
132            if test -e $(BUILD_DIR)/debian/gnash-tools.install; then \
133              mv -f $(BUILD_DIR)/debian/gnash-tools.install $(BUILD_DIR)/debian/gnash-tools.install.orig; \
134            fi; \
135            sed -e '/webcam/d' -e '/microphone/d' $(BUILD_DIR)/debian/gnash-tools.install.orig > $(BUILD_DIR)/debian/gnash-tools.install; \
136            if test -e $(BUILD_DIR)/debian/gnash-tools.manpages; then \
137              mv -f $(BUILD_DIR)/debian/gnash-tools.manpages $(BUILD_DIR)/debian/gnash-tools.manpages.orig; \
138            fi; \
139            sed -e '/webcam/d' -e '/microphone/d' $(BUILD_DIR)/debian/gnash-tools.manpages.orig > $(BUILD_DIR)/debian/gnash-tools.manpages; \
140         fi;
142 # Python is at different revisions and paths depending on the Distribution
143 # and release. Debian uses site-packages, while Ubuntu uses dist-packages.
144 deb-edit-python:
145         @release=`lsb_release -i | sed -e 's/.*:[ \t]//'`; \
146         version=`python --version  2>&1 | tr -d '.' | cut -d ' ' -f 2 | sed -e 's:rc[0-9]*::'`; \
147         if test $${version} -gt 260; then \
148           echo "Editing $(BUILD_DIR)/debian/gtk-plugin-gnash.install for Python 2.6"; \
149           pdir=2.6; \
150           packages="dist-packages"; \
151         else \
152           echo "Editing $(BUILD_DIR)/debian/gtk-plugin-gnash.install for Python 2.5"; \
153           pdir=2.5; \
154           packages="site-packages"; \
155         fi; \
156         if test -e $(BUILD_DIR)/debian/python-gtk-gnash.install; then \
157           mv -f $(BUILD_DIR)/debian/python-gtk-gnash.install $(BUILD_DIR)/debian/python-gtk-gnash.install.orig; \
158         fi; \
159         sed -e "s:python2.X/site-packages:python$${pdir}/$${packages}:" $(BUILD_DIR)/debian/python-gtk-gnash.install.orig > $(BUILD_DIR)/debian/python-gtk-gnash.install; \
160         if test -e $(BUILD_DIR)/debian/python-gtk-gnash.dirs; then \
161           mv -f $(BUILD_DIR)/debian/python-gtk-gnash.dirs $(BUILD_DIR)/debian/python-gtk-gnash.dirs.orig; \
162         fi; \
163         sed -e "s:python2.X/site-packages:python$${pdir}/$${packages}:" $(BUILD_DIR)/debian/python-gtk-gnash.dirs.orig > $(BUILD_DIR)/debian/python-gtk-gnash.dirs;
165 deb-edit-browser:
166         @if test `echo $(FIREFOX_PLUGINS) | grep -c mozilla` -eq 0; then \
167            echo "Adjusting plugin path for a NPAPI compliant browser"; \
168            if test -e $(BUILD_DIR)/debian/browser-plugin-gnash.dirs; then \
169              mv -f $(BUILD_DIR)/debian/browser-plugin-gnash.dirs $(BUILD_DIR)/debian/browser-plugin-gnash.orig; \
170            fi; \
171            echo $(FIREFOX_PLUGINS) | sed -e 's:/::' > $(BUILD_DIR)/debian/browser-plugin-gnash.dirs; \
172         fi;
174 # Edit the debian/changelog file. This is because the version in the top level
175 # entry becomes the name of the source directory, the build directory, and
176 # the packages. We do it this way so the snapshot matches the branch nickname
177 # with the revision.
178 # DIST is set in the environment when using pbuilder, so we use that so
179 # our distribution matches the repoository. DIST is usually one of lenny,
180 # squeeze, lucid, karmic, metad.
181 deb-edit-changelog:
182         @echo "Editing debian/changelog for snapshot: $(BUILD_VERSION)"
183         if test x"$${DIST}" = x; then \
184           if test -e /etc/lsb-release; then \
185             . /etc/lsb-release; \
186             dist=$${DISTRIB_CODENAME}; \
187           fi; \
188           if test x"$${dist}" = x; then \
189             if test -x /usr/bin/lsb_release; then \
190               dist="`lsb_release -cs`"; \
191             else \
192               dist="lenny"; \
193             fi; \
194           fi; \
195         else \
196           dist=$(DIST); \
197         fi; \
198         if test -z "$$dist" ; then \
199           echo "Missing distribution name"; exit 1; \
200         else \
201           echo "Building for distribution '$$dist''"; \
202         fi; \
203         if test -e $(BUILD_DIR)/debian/changelog; then \
204           mv -f $(BUILD_DIR)/debian/changelog $(BUILD_DIR)/debian/changelog.orig; \
205           sed -e "s:master:$(BUILD_VERSION):" -e "s/distro/$${dist}/" $(srcdir)/packaging/debian/changelog > $(BUILD_DIR)/debian/changelog; \
206         else \
207           sed -e "s:master:$(BUILD_VERSION):"  -e "s/distro/$${dist}/" $(srcdir)/packaging/debian/changelog > $(BUILD_DIR)/debian/changelog; \
208         fi
210 # Edit the configure scripts, so if somebody reconfigures from this tarball,
211 # they'll get the exact same name for all the packages.
212 deb-edit-configure: 
213         @echo "Editing configure.ac in $(BUILD_VERSION)..."
214         @if test ! -f $(BUILD_DIR)/configure.ac.orig; then \
215           mv -f $(BUILD_DIR)/configure.ac $(BUILD_DIR)/configure.ac.orig; \
216           sed -e "s/AC_INIT(gnash, [^)]*)/AC_INIT(gnash, $(BUILD_VERSION))/" \
217             $(BUILD_DIR)/configure.ac.orig > $(BUILD_DIR)/configure.ac; \
218         fi
219         @echo "Editing configure in $(BUILD_VERSION)..."
220         @if test ! -f $(BUILD_DIR)/configure.orig; then \
221           mv -f $(BUILD_DIR)/configure $(BUILD_DIR)/configure.orig; \
222           sed -e "s/ VERSION='[^']*'/ VERSION='$(BUILD_VERSION)'/" \
223             $(BUILD_DIR)/configure.orig > $(BUILD_DIR)/configure; \
224            chmod u+x $(BUILD_DIR)/configure; \
225         fi
227 # Edit the debian/control file. This is because we want to produce packages with
228 # unique names, so differently configured packages of the same branch and revision
229 # can all live in the same deb repository.
230 deb-edit-control: deb-copy-files
231         @if test $(OGL) -eq 1 -o $(FFMPEG) -eq 1 -o $(VAAPI) -eq 1; then \
232           echo -n "Editing debian/control for alternate configuration..."; \
233           if test -e $(BUILD_DIR)/debian/control; then \
234             mv -f $(BUILD_DIR)/debian/control $(BUILD_DIR)/debian/control.orig; \
235           fi; \
236           if test $(OGL) -eq 1 -a $(FFMPEG) -eq 1; then \
237             pkg_version="opengl-ffmpeg"; \
238           fi; \
239           if test $(OGL) -eq 1 -a $(FFMPEG) -eq 0; then \
240             pkg_version="opengl"; \
241           fi; \
242           if test $(OGL) -eq 0 -a $(FFMPEG) -eq 1; then \
243             pkg_version="ffmpeg"; \
244           fi; \
245           if test $(VAAPI) -eq 1; then \
246             pkg_version="vaapi"; \
247           fi; \
248           echo "$${pkg_version}"; \
249           sed -e "/^Conflicts:/d" \
250               -e "s/^Package: .*$$/&-$${pkg_version}/" \
251               -e "s/^Depends: gnash-common/Depends: gnash-common-$${pkg_version}/" \
252               -e "s/^Depends: gnash /Depends: gnash-$${pkg_version} /" \
253               -e "s/^Depends: klash /Depends: klash-$${pkg_version} /" \
254           $(top_srcdir)/packaging/debian/control > $(BUILD_DIR)/debian/control; \
255         fi
257 # Build the package. debuild would also work. This requires all
258 # the file editing to be done
259 snapshot-deb:
260         (cd $(BUILD_DIR); dpkg-buildpackage -rfakeroot -j4)
262 deb-build-clean:
263         @for i in $(PACKAGES); do \
264           rm -fr $(BUILD_DIR)/debian/$$i; \
265         done
267 # these files are created when building packages
268 CLEANFILES += *master*.deb *.dsc *.gz *.bz2 *trunk*.changes deb-copy-stamp
270 .PHONY : deb debian snapshot-deb setup-deb deb-edit-control deb-edit-changelog deb-copy-files deb-rename-build deb-edit-configure deb-edit-install deb-edit-utilities deb-edit-python deb-edit-browser deb-build-clean