summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--debian/changelog3
-rw-r--r--debian/dpkg-dev.install1
-rw-r--r--debian/dpkg.install2
-rw-r--r--scripts/Makefile.am2
-rw-r--r--scripts/mk/Makefile.am16
-rw-r--r--scripts/mk/architecture.mk25
-rw-r--r--scripts/mk/buildflags.mk25
-rw-r--r--scripts/mk/default.mk7
-rw-r--r--scripts/mk/vendor.mk18
10 files changed, 98 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 9b33080..8079f36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,6 +109,7 @@ AC_CONFIG_FILES([ Makefile
man/Makefile
po/Makefile.in
scripts/Makefile
+ scripts/mk/Makefile
scripts/po/Makefile.in
src/Makefile
utils/Makefile ])
diff --git a/debian/changelog b/debian/changelog
index 396fdc7..900a7d2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -79,6 +79,9 @@ dpkg (1.16.1) UNRELEASED; urgency=low
Closes: #633627
* Improve dpkg-source's error message complaining about the lack
of the upstream tarball. Closes: #634510
+ * Add some common makefile snippets for use in rules files in
+ /usr/share/dpkg/: default.mk, architecture.mk, buildflags.mk, vendor.mk
+ Closes: #606839
[ Guillem Jover ]
* Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520
diff --git a/debian/dpkg-dev.install b/debian/dpkg-dev.install
index 1a33079..f9fc84b 100644
--- a/debian/dpkg-dev.install
+++ b/debian/dpkg-dev.install
@@ -17,6 +17,7 @@ usr/bin/dpkg-scansources
usr/bin/dpkg-shlibdeps
usr/bin/dpkg-source
usr/bin/dpkg-vendor
+usr/share/dpkg/*.mk
usr/share/man/{*/*,*}/deb-control.5
usr/share/man/{*/*,*}/deb-src-control.5
usr/share/man/{*/*,*}/deb-version.5
diff --git a/debian/dpkg.install b/debian/dpkg.install
index 511effd..c95f6a3 100644
--- a/debian/dpkg.install
+++ b/debian/dpkg.install
@@ -13,7 +13,7 @@ usr/bin/dpkg-statoverride
usr/bin/dpkg-trigger
usr/bin/update-alternatives
usr/sbin
-usr/share/dpkg
+usr/share/dpkg/*table
usr/share/locale/*/LC_MESSAGES/dpkg.mo
usr/share/man/{*/*,*}/dpkg-deb.1
usr/share/man/{*/*,*}/dpkg-divert.8
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index be376c9..f70350a 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
-SUBDIRS = po
+SUBDIRS = mk po
bin_SCRIPTS = \
dpkg-architecture \
diff --git a/scripts/mk/Makefile.am b/scripts/mk/Makefile.am
new file mode 100644
index 0000000..710578d
--- /dev/null
+++ b/scripts/mk/Makefile.am
@@ -0,0 +1,16 @@
+## Process this file with automake to produce Makefile.in
+
+dist_pkgdata_DATA = \
+ architecture.mk \
+ buildflags.mk \
+ default.mk \
+ vendor.mk
+
+do_path_subst = $(AM_V_GEN) \
+ sed -e "s:dpkg_datadir[[:space:]]*=[[:space:]]*[^[:space:]]*:dpkg_datadir = $(pkgdatadir):"
+
+install-data-hook:
+ cp -p $(DESTDIR)$(pkgdatadir)/default.mk $(DESTDIR)$(pkgdatadir)/default.mk.tmp
+ $(do_path_subst) <$(DESTDIR)$(pkgdatadir)/default.mk.tmp \
+ >$(DESTDIR)$(pkgdatadir)/default.mk
+ rm $(DESTDIR)$(pkgdatadir)/default.mk.tmp
diff --git a/scripts/mk/architecture.mk b/scripts/mk/architecture.mk
new file mode 100644
index 0000000..4379e00
--- /dev/null
+++ b/scripts/mk/architecture.mk
@@ -0,0 +1,25 @@
+# This Makefile snippet defines all the DEB_HOST_* / DEB_BUILD_* variables
+# that dpkg-architecture can return. Existing values of those variables
+# are preserved as per policy.
+
+dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1)))
+
+DEB_HOST_ARCH ?= $(call dpkg_late_eval,DEB_HOST_ARCH,dpkg-architecture -qDEB_HOST_ARCH)
+DEB_HOST_ARCH_OS ?= $(call dpkg_late_eval,DEB_HOST_ARCH_OS,dpkg-architecture -qDEB_HOST_ARCH_OS)
+DEB_HOST_ARCH_CPU ?= $(call dpkg_late_eval,DEB_HOST_ARCH_CPU,dpkg-architecture -qDEB_HOST_ARCH_CPU)
+DEB_HOST_ARCH ?= $(call dpkg_late_eval,DEB_HOST_ARCH,dpkg-architecture -qDEB_HOST_ARCH_BITS)
+DEB_HOST_ARCH_ENDIAN ?= $(call dpkg_late_eval,DEB_HOST_ARCH_ENDIAN,dpkg-architecture -qDEB_HOST_ARCH_ENDIAN)
+DEB_HOST_GNU_CPU ?= $(call dpkg_late_eval,DEB_HOST_GNU_CPU,dpkg-architecture -qDEB_HOST_GNU_CPU)
+DEB_HOST_GNU_SYSTEM ?= $(call dpkg_late_eval,DEB_HOST_GNU_SYSTEM,dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
+DEB_HOST_GNU_TYPE ?= $(call dpkg_late_eval,DEB_HOST_GNU_TYPE,dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_HOST_MULTIARCH ?= $(call dpkg_late_eval,DEB_HOST_MULTIARCH,dpkg-architecture -qDEB_HOST_MULTIARCH)
+
+DEB_BUILD_ARCH ?= $(call dpkg_late_eval,DEB_BUILD_ARCH,dpkg-architecture -qDEB_BUILD_ARCH)
+DEB_BUILD_ARCH_OS ?= $(call dpkg_late_eval,DEB_BUILD_ARCH_OS,dpkg-architecture -qDEB_BUILD_ARCH_OS)
+DEB_BUILD_ARCH_CPU ?= $(call dpkg_late_eval,DEB_BUILD_ARCH_CPU,dpkg-architecture -qDEB_BUILD_ARCH_CPU)
+DEB_BUILD_ARCH ?= $(call dpkg_late_eval,DEB_BUILD_ARCH,dpkg-architecture -qDEB_BUILD_ARCH_BITS)
+DEB_BUILD_ARCH_ENDIAN ?= $(call dpkg_late_eval,DEB_BUILD_ARCH_ENDIAN,dpkg-architecture -qDEB_BUILD_ARCH_ENDIAN)
+DEB_BUILD_GNU_CPU ?= $(call dpkg_late_eval,DEB_BUILD_GNU_CPU,dpkg-architecture -qDEB_BUILD_GNU_CPU)
+DEB_BUILD_GNU_SYSTEM ?= $(call dpkg_late_eval,DEB_BUILD_GNU_SYSTEM,dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
+DEB_BUILD_GNU_TYPE ?= $(call dpkg_late_eval,DEB_BUILD_GNU_TYPE,dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+DEB_BUILD_MULTIARCH ?= $(call dpkg_late_eval,DEB_BUILD_MULTIARCH,dpkg-architecture -qDEB_BUILD_MULTIARCH)
diff --git a/scripts/mk/buildflags.mk b/scripts/mk/buildflags.mk
new file mode 100644
index 0000000..1b4a22c
--- /dev/null
+++ b/scripts/mk/buildflags.mk
@@ -0,0 +1,25 @@
+# This Makefile snippet defines the following variables:
+#
+# CFLAGS: flags for the C compiler
+# CPPFLAGS: flags for the C preprocessor
+# CXXFLAGS: flags for the C++ compiler
+# FFLAGS: flags for the Fortran compiler
+# LDFLAGS: flags for the linker
+#
+# You can also export them in the environment by setting
+# DPKG_EXPORT_BUILDFLAGS to a non-empty value.
+#
+# This list is kept in sync with the default set of flags returned
+# by dpkg-buildflags.
+
+dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1)))
+
+CFLAGS = $(call dpkg_late_eval,CFLAGS,dpkg-buildflags --get CFLAGS)
+CPPFLAGS = $(call dpkg_late_eval,CPPFLAGS,dpkg-buildflags --get CPPFLAGS)
+CXXFLAGS = $(call dpkg_late_eval,CXXFLAGS,dpkg-buildflags --get CXXFLAGS)
+FFLAGS = $(call dpkg_late_eval,FFLAGS,dpkg-buildflags --get FFLAGS)
+LDFLAGS = $(call dpkg_late_eval,LDFLAGS,dpkg-buildflags --get LDFLAGS)
+
+ifdef DPKG_EXPORT_BUILDFLAGS
+ export CFLAGS CPPFLAGS CXXFLAGS FFLAGS LDFLAGS
+endif
diff --git a/scripts/mk/default.mk b/scripts/mk/default.mk
new file mode 100644
index 0000000..9f9d61b
--- /dev/null
+++ b/scripts/mk/default.mk
@@ -0,0 +1,7 @@
+# Include all the Makefiles that define variables that can be useful
+# within debian/rules
+
+dpkg_datadir = .
+include $(dpkg_datadir)/architecture.mk
+include $(dpkg_datadir)/buildflags.mk
+include $(dpkg_datadir)/vendor.mk
diff --git a/scripts/mk/vendor.mk b/scripts/mk/vendor.mk
new file mode 100644
index 0000000..aa75cd6
--- /dev/null
+++ b/scripts/mk/vendor.mk
@@ -0,0 +1,18 @@
+# Makefile snippet defining the following vendor-related variables:
+#
+# DEB_VENDOR: output of dpkg-vendor --query Vendor
+# DEB_PARENT_VENDOR: output of dpkg-vendor --query Parent (can be empty)
+#
+# The snippet also defines a macro "dpkg_vendor_derives_from" that you can
+# use to verify if the current vendor derives from another vendor with a
+# simple test like this one:
+# ifeq ($(call dpkg_vendor_derives_from ubuntu),yes)
+# ...
+# endif
+
+dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1)))
+
+DEB_VENDOR = $(call dpkg_late_eval,DEB_VENDOR,dpkg-vendor --query Vendor)
+DEB_PARENT_VENDOR = $(call dpkg_late_eval,DEB_PARENT_VENDOR,dpkg-vendor --query Parent)
+
+dpkg_vendor_derives_from = dpkg-vendor --derives-from $(1) && echo yes || echo no