1
# -*- mode: makefile; coding: utf-8 -*-
2
# Copyright © 2003 Jeff Bailey <jbailey@debian.org>
3
# Description: A class for Tarball-based packages
5
# This program is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU General Public License as
7
# published by the Free Software Foundation; either version 2, or (at
8
# your option) any later version.
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
# General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21
# facilitates unpacking into a directory and setting DEB_SRCDIR and
22
# DEB_BUILDDIR appropriately. Note that tarball.mk MUST come
23
# *FIRST* in the list of included rules.
26
_cdbs_scripts_path ?= /usr/lib/cdbs
27
_cdbs_rules_path ?= /usr/share/cdbs/1/rules
28
_cdbs_class_path ?= /usr/share/cdbs/1/class
30
ifndef _cdbs_rules_tarball
31
_cdbs_rules_tarball = 1
33
-include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
35
# The user developper may override this variable to choose which tarballs
38
ifeq ($(DEB_TAR_SRCDIR),)
39
$(error DEB_TAR_SRCDIR must be specified)
42
_cdbs_tarball_dir = build-tree
44
DEB_SRCDIR = $(_cdbs_tarball_dir)/$(DEB_TAR_SRCDIR)
45
DEB_BUILDDIR ?= $(DEB_SRCDIR)
47
# This is not my finest piece of work.
48
# Essentially, it's never right to unpack a tarball more than once
49
# so we have to emit stamps. The stamps then have to be the rule
50
# we use. Then we have to figure out what file we're working on
51
# based on the stamp name. Also, tar-gzip archives can be either
52
# .tar.gz or .tgz. tar-bzip archives can be either tar.bz or tar.bz2
53
# tar-lzma archives can be either tar.7z or tar.lzma
55
_cdbs_tarball_stamps = $(addprefix debian/stamp-,$(notdir $(DEB_TARBALL)))
56
_cdbs_tarball_stamp_base = $(basename $(_cdbs_tarball_stamps))
58
ifeq ($(DEB_VERBOSE_ALL),yes)
59
_cdbs_tar_verbose = -v
62
pre-build:: $(_cdbs_tarball_stamps)
63
ifneq (, $(config_guess_tar))
64
if test -e /usr/share/misc/config.guess ; then \
65
for i in $(config_guess_tar) ; do \
66
cp --remove-destination /usr/share/misc/config.guess \
67
$(_cdbs_tarball_dir)/$$i ; \
71
ifneq (, $(config_sub_tar))
72
if test -e /usr/share/misc/config.sub ; then \
73
for i in $(config_sub_tar) ; do \
74
cp --remove-destination /usr/share/misc/config.sub \
75
$(_cdbs_tarball_dir)/$$i ; \
79
ifneq (, $(config_rpath_tar))
80
if test -e /usr/share/gnulib/config/config.rpath ; then \
81
for i in $(config_rpath_tar) ; do \
82
cp --remove-destination /usr/share/gnulib/config/config.rpath \
83
$(_cdbs_tarball_dir)/$$i ; \
88
_cdbs_stampname_to_tarname = $(filter $(patsubst stamp-%,%,$(notdir $(1))) %/$(patsubst stamp-%,%,$(notdir $(1))),$(DEB_TARBALL))
90
$(addsuffix .tar,$(_cdbs_tarball_stamp_base)):
91
tar -C $(_cdbs_tarball_dir) $(_cdbs_tar_verbose) -x -f $(call _cdbs_stampname_to_tarname,$@)
94
$(addsuffix .gz,$(_cdbs_tarball_stamp_base)) $(addsuffix .tgz,$(_cdbs_tarball_stamp_base)):
95
tar -C $(_cdbs_tarball_dir) $(_cdbs_tar_verbose) -x -z -f $(call _cdbs_stampname_to_tarname,$@)
98
$(addsuffix .bz,$(_cdbs_tarball_stamp_base)) $(addsuffix .bz2,$(_cdbs_tarball_stamp_base)):
99
tar -C $(_cdbs_tarball_dir) $(_cdbs_tar_verbose) -x -j -f $(call _cdbs_stampname_to_tarname,$@)
102
$(addsuffix .7z,$(_cdbs_tarball_stamp_base)) $(addsuffix .lzma,$(_cdbs_tarball_stamp_base)):
103
# Hardy's tar doesn't support lzma
104
# tar -C $(_cdbs_tarball_dir) $(_cdbs_tar_verbose) -x --lzma -f $(call _cdbs_stampname_to_tarname,$@)
105
lzma -dkc $(call _cdbs_stampname_to_tarname,$@) | ( cd $(_cdbs_tarball_dir) ; tar xf - )
108
$(addsuffix .zip,$(_cdbs_tarball_stamp_base)):
109
unzip $(call _cdbs_stampname_to_tarname,$@) -d $(_cdbs_tarball_dir)
113
rm -rf $(_cdbs_tarball_dir)
114
rm -f $(_cdbs_tarball_stamps)
115
rm -f debian/stamp-patch-*
116
rm -rf debian/patched