From 494c9074b3dc32b7b3b7f84e6aca2781f9bdc096 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Thu, 17 Mar 2011 19:38:05 +0000 Subject: tools: do not link against unused libraries. A fair few things under tools link against libraries which they don't even use. Most of this appears to come from copy-and-pasting previous Makefile snippets and cargo-culting plus the tendency to define global $(LIBS) even for Makefiles which build multiple separate utilities or libraries. Identified by comparing a build with --as-needed to one without by looking at the NEEDED header of all ELF objects. Signed-off-by: Ian Campbell Acked-by: Ian Jackson Committed-by: Ian Jackson --- tools/xcutils/Makefile | 19 +++++++++++++++---- tools/xcutils/lsevtchn.c | 2 -- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'tools/xcutils') diff --git a/tools/xcutils/Makefile b/tools/xcutils/Makefile index 5872d57d8c..e16c6a334f 100644 --- a/tools/xcutils/Makefile +++ b/tools/xcutils/Makefile @@ -11,12 +11,20 @@ XEN_ROOT = $(CURDIR)/../.. include $(XEN_ROOT)/tools/Rules.mk -CFLAGS += -Werror -CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) PROGRAMS = xc_restore xc_save readnotes lsevtchn -LDLIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) +CFLAGS += -Werror + +CFLAGS_xc_restore := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) +CFLAGS_xc_save := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) +CFLAGS_readnotes := $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) +CFLAGS_lsevtchn := $(CFLAGS_libxenctrl) + +LDLIBS_xc_restore := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) +LDLIBS_xc_save := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) +LDLIBS_readnotes := $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) +LDLIBS_lsevtchn := $(LDLIBS_libxenctrl) .PHONY: all all: build @@ -24,8 +32,11 @@ all: build .PHONY: build build: $(PROGRAMS) +%.o: %.c + $(CC) $(CFLAGS) $(CFLAGS_$*) -c $^ -o $@ + $(PROGRAMS): %: %.o - $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) $(LDLIBS_$*) -o $@ .PHONY: install install: build diff --git a/tools/xcutils/lsevtchn.c b/tools/xcutils/lsevtchn.c index e79fe0990a..d1710613dd 100644 --- a/tools/xcutils/lsevtchn.c +++ b/tools/xcutils/lsevtchn.c @@ -4,9 +4,7 @@ #include #include -#include #include -#include int main(int argc, char **argv) { -- cgit v1.2.3