Set compiler flags according to dpkg-buildflags

...and in general, pass compiler flags down through all makefiles,
regardless of what creative names people found for the variables.
This commit is contained in:
Ben Hutchings 2015-09-25 20:18:12 +01:00
parent d13fc1ddbe
commit 5b5133ebf7
8 changed files with 61 additions and 9 deletions

View File

@ -6,10 +6,12 @@ SHELL = /bin/sh -e
CC = gcc
CXX = g++
CFLAGS ?= -O2 -Wall
CPPFLAGS = -I$(top_srcdir)/$(OUTDIR) -I$(top_srcdir)/debian/build/$(OUTDIR) \
CFLAGS := $(shell dpkg-buildflags --get CFLAGS) -Wall
CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS) \
-I$(top_srcdir)/$(OUTDIR) -I$(top_srcdir)/debian/build/$(OUTDIR) \
-isystem $(top_srcdir)/debian/build/include
CXXFLAGS = $(CFLAGS)
CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) -Wall
LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
all: all-local all-recursive
clean: clean-local clean-recursive

View File

@ -1,10 +1,13 @@
srcdir := $(top_srcdir)/tools/lib/lockdep
OUTDIR = tools/lib/lockdep
include ../../../Makefile.inc
DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
MAKE_LOCKDEP := $(MAKE) -C $(srcdir) O=$(CURDIR)/out V=1 \
MAKE_LOCKDEP := $(MAKE) -C $(top_srcdir)/$(OUTDIR) O=$(CURDIR)/out V=1 \
prefix=/usr libdir_relative=lib/$(DEB_HOST_MULTIARCH) \
LIBLOCKDEP_VERSION=$(VERSION)
LIBLOCKDEP_VERSION=$(VERSION) \
CONFIG_FLAGS='$(CFLAGS) $(filter -D%,$(CPPFLAGS))' LDFLAGS='$(LDFLAGS)'
unexport CFLAGS
@ -15,7 +18,7 @@ all:
install:
$(MAKE_LOCKDEP) install
mkdir -p $(DESTDIR)/usr/include
cp -R $(srcdir)/include/liblockdep $(DESTDIR)/usr/include/
cp -R $(top_srcdir)/$(OUTDIR)/include/liblockdep $(DESTDIR)/usr/include/
ln -s liblockdep.so.$(VERSION) \
$(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/liblockdep.so
# Upstream lockdep preload script is not suitable for installation

View File

@ -26,7 +26,7 @@ else ifneq ($(filter amd64 i386,$(DEB_HOST_ARCH_CPU)),)
KERNEL_ARCH_PERF = x86
endif
MAKE_PERF := $(MAKE) prefix=/usr V=1 ARCH=$(KERNEL_ARCH_PERF) EXTRA_WARNINGS=-Wno-error
MAKE_PERF := $(MAKE) prefix=/usr V=1 ARCH=$(KERNEL_ARCH_PERF) EXTRA_WARNINGS=-Wno-error EXTRA_CFLAGS='$(CFLAGS) $(CPPFLAGS)' LDFLAGS='$(LDFLAGS)'
# Disable Gtk UI until it's more usable
MAKE_PERF += NO_GTK2=1

View File

@ -8,7 +8,8 @@ unexport MAKEFLAGS
all:
cd $(srcdir) && ./autogen.sh
mkdir -p out
cd out && $(srcdir)/configure \
cd out && \
$(shell dpkg-buildflags --export=cmdline) $(srcdir)/configure \
--prefix=/usr \
--with-tcp-wrappers \
--with-usbids-dir=/usr/share/misc \

1
debian/changelog vendored
View File

@ -8,6 +8,7 @@ linux-tools (4.2-1) UNRELEASED; urgency=medium
* debian/bin/genorig.py: Make orig tarballs reproducible
* linux-perf: Fix installation directory for bash completions
* linux-perf: Remove shebang lines from perf scripts
* Set compiler flags according to dpkg-buildflags
-- Ben Hutchings <ben@decadent.org.uk> Fri, 25 Sep 2015 18:42:20 +0100

View File

@ -11,3 +11,5 @@ lockdep-fix-oot-build.patch
lockdep-fix-headers.patch
lockdep-fix-soname.patch
tools-perf-remove-shebangs.patch
tools-lib-traceevent-use-ldflags.patch
tools-lib-lockdep-use-ldflags.patch

View File

@ -0,0 +1,17 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Fri, 25 Sep 2015 21:36:29 +0100
Subject: tools/lib/lockdep: Use LDFLAGS
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
--- a/tools/lib/lockdep/Makefile
+++ b/tools/lib/lockdep/Makefile
@@ -98,7 +98,7 @@ build := -f $(srctree)/tools/build/Makef
do_compile_shared_library = \
($(print_shared_lib_compile) \
- $(CC) --shared $^ -o $@ -lpthread -ldl -Wl,-soname='$(@F)';$(shell ln -s $(@F) $(@D)/liblockdep.so))
+ $(CC) $(LDFLAGS) --shared $^ -o $@ -lpthread -ldl -Wl,-soname='$(@F)';$(shell ln -s $(@F) $(@D)/liblockdep.so))
do_build_static_lib = \
($(print_static_lib_build) \

View File

@ -0,0 +1,26 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Fri, 25 Sep 2015 21:26:48 +0100
Subject: tools/lib/traceevent: Use LDFLAGS
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -172,7 +172,7 @@ $(TE_IN): force
$(Q)$(MAKE) $(build)=libtraceevent
$(OUTPUT)libtraceevent.so: $(TE_IN)
- $(QUIET_LINK)$(CC) --shared $^ -o $@
+ $(QUIET_LINK)$(CC) $(LDFLAGS) --shared $^ -o $@
$(OUTPUT)libtraceevent.a: $(TE_IN)
$(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^
@@ -189,7 +189,7 @@ $(PLUGINS_IN): force
$(Q)$(MAKE) $(build)=$(plugin_obj)
$(OUTPUT)%.so: $(OUTPUT)%-in.o
- $(QUIET_LINK)$(CC) $(CFLAGS) -shared -nostartfiles -o $@ $^
+ $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -shared -nostartfiles -o $@ $^
define make_version.h
(echo '/* This file is automatically generated. Do not modify. */'; \