summaryrefslogtreecommitdiff
path: root/scripts/mk
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2015-03-02 23:56:08 +0100
committerGuillem Jover <guillem@debian.org>2017-10-16 11:03:38 +0200
commit4618ae2495a843b40ea5223fa7a4910543194297 (patch)
tree6ce3370f9b12112a986f5596f1cb8e8d681739f7 /scripts/mk
parentd917dd74cfb8c78f7a99a7e02d4098866f3f763d (diff)
downloaddpkg-4618ae2495a843b40ea5223fa7a4910543194297.tar.gz
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
Diffstat (limited to 'scripts/mk')
-rw-r--r--scripts/mk/Makefile.am7
-rw-r--r--scripts/mk/buildtools.mk56
-rw-r--r--scripts/mk/default.mk2
3 files changed, 64 insertions, 1 deletions
diff --git a/scripts/mk/Makefile.am b/scripts/mk/Makefile.am
index 4b92b7847..54a41e712 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 000000000..d5638f50e
--- /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 b4b123c35..c17235401 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