[dpkg] 161/192: scripts/mk: Add new buildtools.mk support
Ximin Luo
infinity0 at debian.org
Tue Oct 17 11:04:13 UTC 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch pu/reproducible_builds
in repository dpkg.
commit 4618ae2495a843b40ea5223fa7a4910543194297
Author: Guillem Jover <guillem at debian.org>
Date: Mon Mar 2 23:56:08 2015 +0100
scripts/mk: Add new buildtools.mk support
This make fragment contains setup for build tool variables for both TOOL
and TOOL_FOR_BUILD. It does not get included by default from default.mk
---
debian/changelog | 3 +++
scripts/Makefile.am | 1 +
scripts/mk/Makefile.am | 7 ++++++
scripts/mk/buildtools.mk | 56 ++++++++++++++++++++++++++++++++++++++++++++++
scripts/mk/default.mk | 2 +-
scripts/t/mk.t | 28 ++++++++++++++++++++++-
scripts/t/mk/buildtools.mk | 21 +++++++++++++++++
7 files changed, 116 insertions(+), 2 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 79657a1..125610c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -40,6 +40,9 @@ dpkg (1.19.0) UNRELEASED; urgency=medium
* Add new “future” feature area in dpkg-buildflags:
- Add new «lfs» feature, to be used instead of the getconf(1) interface
which cannot support cross-building.
+ * Add new buildtools.mk make fragment to support build tools variable
+ setup, for both TOOL and TOOL_FOR_BUILD variables. Not included by
+ default from default.mk.
* Perl modules:
- Switch from Dpkg::Util to List::Util, now that the module in the
new required Perl contains the needed functions.
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index bc9351b..3dac552 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -346,6 +346,7 @@ test_data = \
t/mk/debian/changelog \
t/mk/architecture.mk \
t/mk/buildflags.mk \
+ t/mk/buildtools.mk \
t/mk/pkg-info.mk \
t/mk/vendor.mk \
t/origins/debian \
diff --git a/scripts/mk/Makefile.am b/scripts/mk/Makefile.am
index 4b92b78..54a41e7 100644
--- a/scripts/mk/Makefile.am
+++ b/scripts/mk/Makefile.am
@@ -3,6 +3,7 @@
dist_pkgdata_DATA = \
architecture.mk \
buildflags.mk \
+ buildtools.mk \
default.mk \
pkg-info.mk \
vendor.mk
@@ -16,3 +17,9 @@ install-data-hook:
$(do_path_subst) <$(DESTDIR)$(pkgdatadir)/default.mk.tmp \
>$(DESTDIR)$(pkgdatadir)/default.mk
rm -f $(DESTDIR)$(pkgdatadir)/default.mk.tmp
+
+ mv $(DESTDIR)$(pkgdatadir)/buildtools.mk \
+ $(DESTDIR)$(pkgdatadir)/buildtools.mk.tmp
+ $(do_path_subst) <$(DESTDIR)$(pkgdatadir)/buildtools.mk.tmp \
+ >$(DESTDIR)$(pkgdatadir)/buildtools.mk
+ rm -f $(DESTDIR)$(pkgdatadir)/buildtools.mk.tmp
diff --git a/scripts/mk/buildtools.mk b/scripts/mk/buildtools.mk
new file mode 100644
index 0000000..d5638f5
--- /dev/null
+++ b/scripts/mk/buildtools.mk
@@ -0,0 +1,56 @@
+# This Makefile snippet defines the following variables for host tools:
+#
+# CPP: C preprocessor
+# CC: C compiler
+# CXX: C++ compiler
+# OBJC: Objective C compiler
+# OBJCXX: Objective C++ compiler
+# GCJ: GNU Java compiler
+# F77: Fortran 77 compiler
+# FC: Fortran 9x compiler
+# LD: linker
+# PKG_CONFIG: pkg-config tool
+#
+# All the above variables have a counterpart variable for the build tool,
+# as in CC → CC_FOR_BUILD.
+#
+# The variables are not exported by default. This can be changed by
+# defining DPKG_EXPORT_BUILDTOOLS.
+
+dpkg_datadir = $(srcdir)/mk
+include $(dpkg_datadir)/architecture.mk
+
+# We set the TOOL_FOR_BUILD variables to the specified value, and the TOOL
+# variables (for the host) to the their triplet-prefixed form iff they are
+# not defined or contain the make built-in defaults. On native builds if
+# TOOL is defined and TOOL_FOR_BUILD is not, we fallback to use TOOL.
+define dpkg_buildtool_setvar
+ifeq ($(origin $(1)),default)
+$(1) = $(DEB_HOST_GNU_TYPE)-$(2)
+endif
+$(1) ?= $(DEB_HOST_GNU_TYPE)-$(2)
+
+# On native build fallback to use TOOL if that's defined.
+ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+ifdef $(1)
+$(1)_FOR_BUILD ?= $$($(1))
+endif
+endif
+$(1)_FOR_BUILD ?= $(DEB_BUILD_GNU_TYPE)-$(2)
+
+ifdef DPKG_EXPORT_BUILDTOOLS
+export $(1)
+export $(1)_FOR_BUILD
+endif
+endef
+
+$(eval $(call dpkg_buildtool_setvar,CPP,gcc -E))
+$(eval $(call dpkg_buildtool_setvar,CC,gcc))
+$(eval $(call dpkg_buildtool_setvar,CXX,g++))
+$(eval $(call dpkg_buildtool_setvar,OBJC,gcc))
+$(eval $(call dpkg_buildtool_setvar,OBJCXX,g++))
+$(eval $(call dpkg_buildtool_setvar,GCJ,gcj))
+$(eval $(call dpkg_buildtool_setvar,F77,f77))
+$(eval $(call dpkg_buildtool_setvar,FC,f77))
+$(eval $(call dpkg_buildtool_setvar,LD,ld))
+$(eval $(call dpkg_buildtool_setvar,PKG_CONFIG,pkg-config))
diff --git a/scripts/mk/default.mk b/scripts/mk/default.mk
index b4b123c..c172354 100644
--- a/scripts/mk/default.mk
+++ b/scripts/mk/default.mk
@@ -1,7 +1,7 @@
# Include all the Makefiles that define variables that can be useful
# within debian/rules
-dpkg_datadir = .
+dpkg_datadir = $(srcdir)/mk
include $(dpkg_datadir)/architecture.mk
include $(dpkg_datadir)/buildflags.mk
include $(dpkg_datadir)/pkg-info.mk
diff --git a/scripts/t/mk.t b/scripts/t/mk.t
index 95ccedf..e711270 100644
--- a/scripts/t/mk.t
+++ b/scripts/t/mk.t
@@ -16,7 +16,7 @@
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More tests => 6;
use File::Spec::Functions qw(rel2abs);
use Dpkg ();
@@ -79,6 +79,32 @@ delete $ENV{$_} foreach keys %buildflag;
$ENV{"TEST_$_"} = $buildflag{$_} foreach keys %buildflag;
test_makefile('buildflags.mk');
+my %buildtools = (
+ CPP => 'gcc -E',
+ CC => 'gcc',
+ CXX => 'g++',
+ OBJC => 'gcc',
+ OBJCXX => 'g++',
+ GCJ => 'gcj',
+ F77 => 'f77',
+ FC => 'f77',
+ LD => 'ld',
+ PKG_CONFIG => 'pkg-config',
+);
+
+foreach my $tool (keys %buildtools) {
+ delete $ENV{$tool};
+ $ENV{"TEST_$tool"} = "$ENV{DEB_HOST_GNU_TYPE}-$buildtools{$tool}";
+ delete $ENV{"${tool}_FOR_BUILD"};
+ $ENV{"TEST_${tool}_FOR_BUILD"} = "$ENV{DEB_BUILD_GNU_TYPE}-$buildtools{$tool}";
+}
+test_makefile('buildtools.mk');
+
+foreach my $tool (keys %buildtools) {
+ delete $ENV{${tool}};
+ delete $ENV{"${tool}_FOR_BUILD"};
+}
+
test_makefile('pkg-info.mk');
test_makefile('vendor.mk');
diff --git a/scripts/t/mk/buildtools.mk b/scripts/t/mk/buildtools.mk
new file mode 100644
index 0000000..8bba964
--- /dev/null
+++ b/scripts/t/mk/buildtools.mk
@@ -0,0 +1,21 @@
+include $(srcdir)/mk/buildtools.mk
+
+test:
+ test "$(CC)" = "$(TEST_CC)"
+ test "$(CC_FOR_BUILD)" = "$(TEST_CC_FOR_BUILD)"
+ test "$(CXX)" = "$(TEST_CXX)"
+ test "$(CXX_FOR_BUILD)" = "$(TEST_CXX_FOR_BUILD)"
+ test "$(OBJC)" = "$(TEST_OBJC)"
+ test "$(OBJC_FOR_BUILD)" = "$(TEST_OBJC_FOR_BUILD)"
+ test "$(OBJCXX)" = "$(TEST_OBJCXX)"
+ test "$(OBJCXX_FOR_BUILD)" = "$(TEST_OBJCXX_FOR_BUILD)"
+ test "$(GCJ)" = "$(TEST_GCJ)"
+ test "$(GCJ_FOR_BUILD)" = "$(TEST_GCJ_FOR_BUILD)"
+ test "$(F77)" = "$(TEST_F77)"
+ test "$(F77_FOR_BUILD)" = "$(TEST_F77_FOR_BUILD)"
+ test "$(FC)" = "$(TEST_FC)"
+ test "$(FC_FOR_BUILD)" = "$(TEST_FC_FOR_BUILD)"
+ test "$(LD)" = "$(TEST_LD)"
+ test "$(LD_FOR_BUILD)" = "$(TEST_LD_FOR_BUILD)"
+ test "$(PKG_CONFIG)" = "$(TEST_PKG_CONFIG)"
+ test "$(PKG_CONFIG_FOR_BUILD)" = "$(TEST_PKG_CONFIG_FOR_BUILD)"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git
More information about the Reproducible-commits
mailing list