aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xcutils
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2011-03-17 19:38:05 +0000
committerIan Campbell <ian.campbell@citrix.com>2011-03-17 19:38:05 +0000
commit494c9074b3dc32b7b3b7f84e6aca2781f9bdc096 (patch)
tree8000a58e21976f02b503a137c09a299ad375bf58 /tools/xcutils
parent0394b57cda6f09f2d45feaf5a4f9dc62d6798c23 (diff)
downloadxen-494c9074b3dc32b7b3b7f84e6aca2781f9bdc096.tar.gz
xen-494c9074b3dc32b7b3b7f84e6aca2781f9bdc096.tar.bz2
xen-494c9074b3dc32b7b3b7f84e6aca2781f9bdc096.zip
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 <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/xcutils')
-rw-r--r--tools/xcutils/Makefile19
-rw-r--r--tools/xcutils/lsevtchn.c2
2 files changed, 15 insertions, 6 deletions
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 <string.h>
#include <stdio.h>
-#include <xs.h>
#include <xenctrl.h>
-#include <xenguest.h>
int main(int argc, char **argv)
{