Переглянути джерело

dpkg-dev: add some common makefile snippets for use in rules files

data/architecture.mk: variables related to dpkg-architecture
data/buildflags.mk: variables related to dpkg-builflags
data/vendor.mk: variables related to dpkg-vendor
data/default.mk: all of the above
Raphaël Hertzog 15 роки тому
батько
коміт
b858e07bdd

+ 1 - 0
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 ])

+ 3 - 0
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

+ 1 - 0
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

+ 1 - 1
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

+ 1 - 1
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 \

+ 16 - 0
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

+ 25 - 0
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)

+ 25 - 0
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

+ 7 - 0
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

+ 18 - 0
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