@@ -105,12 +105,6 @@ define xenlibs-libs
$(XEN_ROOT)/tools/libs/$(lib)/lib$(FILENAME_$(lib))$(libextension))
endef
-# Flags for linking against all Xen libraries listed in $(1)
-define xenlibs-ldlibs
- $(call xenlibs-rpath,$(1)) $(call xenlibs-libs,$(1)) \
- $(foreach lib,$(1),$(xenlibs-ldlibs-$(lib)))
-endef
-
# Provide needed flags for linking an in-tree Xen library by an external
# project (or when it is necessary to link with "-lxen$(1)" instead of using
# the full path to the library).
@@ -119,12 +113,16 @@ define xenlibs-ldflags
$(foreach lib,$(1),-L$(XEN_ROOT)/tools/libs/$(lib))
endef
+# Flags for linking against all Xen libraries listed in $(1)
+define xenlibs-ldlibs
+ $(foreach lib,$(1),-l$(FILENAME_$(lib)) $(xenlibs-ldlibs-$(lib)))
+endef
+
# Flags for linking against all Xen libraries listed in $(1) but by making use
# of -L and -l instead of providing a path to the shared library.
define xenlibs-ldflags-ldlibs
$(call xenlibs-ldflags,$(1)) \
- $(foreach lib,$(1), -l$(FILENAME_$(lib))) \
- $(foreach lib,$(1),$(xenlibs-ldlibs-$(lib)))
+ $(call xenlibs-ldlibs,$(1))
endef
define LIB_defs
@@ -132,7 +130,7 @@ define LIB_defs
XEN_libxen$(1) = $$(XEN_ROOT)/tools/libs/$(1)
CFLAGS_libxen$(1) = $$(CFLAGS_xeninclude)
SHLIB_libxen$(1) = $$(call xenlibs-rpath,$(1)) -Wl,-rpath-link=$$(XEN_libxen$(1))
- LDLIBS_libxen$(1) = $$(call xenlibs-ldlibs,$(1))
+ LDLIBS_libxen$(1) = $$(call xenlibs-ldflags,$(1)) $$(call xenlibs-ldlibs,$(1))
endef
$(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_defs,$(lib))))
@@ -6,6 +6,7 @@ USELIBS := ctrl store
CFLAGS += $(call xenlibs-cflags,$(USELIBS))
CFLAGS += -include $(XEN_ROOT)/tools/config.h
+LDFLAGS += $(call xenlibs-ldflags,$(USELIBS))
LDLIBS += $(call xenlibs-ldlibs,$(USELIBS))
LDLIBS += $(SOCKET_LIBS)
@@ -7,6 +7,7 @@ CFLAGS += $(call xenlibs-cflags,$(USELIBS))
CFLAGS-$(CONFIG_ARM) += -DCONFIG_ARM
CFLAGS += -include $(XEN_ROOT)/tools/config.h
+LDFLAGS += $(call xenlibs-ldflags,$(USELIBS))
LDLIBS += $(call xenlibs-ldlibs,$(USELIBS))
LDLIBS += $(SOCKET_LIBS)
LDLIBS += $(UTIL_LIBS)
@@ -18,17 +18,20 @@ endif
XEN_INIT_DOM0_USELIBS := ctrl toollog store light
XEN_INIT_DOM0_OBJS = xen-init-dom0.o init-dom-json.o
$(XEN_INIT_DOM0_OBJS): CFLAGS += $(call xenlibs-cflags,$(XEN_INIT_DOM0_USELIBS))
+xen-init-dom0: LDFLAGS += $(call xenlibs-ldflags,$(XEN_INIT_DOM0_USELIBS))
xen-init-dom0: LDLIBS += $(call xenlibs-ldlibs,$(XEN_INIT_DOM0_USELIBS))
INIT_XENSTORE_DOMAIN_USELIBS := toollog store ctrl guest light
INIT_XENSTORE_DOMAIN_OBJS = init-xenstore-domain.o init-dom-json.o
$(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(call xenlibs-cflags,$(INIT_XENSTORE_DOMAIN_USELIBS))
$(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
+init-xenstore-domain: LDFLAGS += $(call xenlibs-ldflags,$(INIT_XENSTORE_DOMAIN_USELIBS))
init-xenstore-domain: LDLIBS += $(call xenlibs-ldlibs,$(INIT_XENSTORE_DOMAIN_USELIBS))
INIT_DOM0LESS_USELIBS := ctrl evtchn toollog store light guest foreignmemory
INIT_DOM0LESS_OBJS = init-dom0less.o init-dom-json.o
$(INIT_DOM0LESS_OBJS): CFLAGS += $(call xenlibs-cflags,$(INIT_DOM0LESS_USELIBS))
+init-dom0less: LDFLAGS += $(call xenlibs-ldflags,$(INIT_DOM0LESS_USELIBS))
init-dom0less: LDLIBS += $(call xenlibs-ldlibs,$(INIT_DOM0LESS_USELIBS))
.PHONY: all
@@ -17,6 +17,7 @@ CFLAGS += -Wmissing-prototypes
CFLAGS += $(CFLAGS_xeninclude)
CFLAGS += $(foreach lib, $(USELIBS_$(LIBNAME)), $(CFLAGS_libxen$(lib)))
+LDFLAGS += $(call xenlibs-ldflags,$(USELIBS_$(LIBNAME)))
LDLIBS += $(call xenlibs-ldlibs,$(USELIBS_$(LIBNAME)))
PIC_OBJS := $(OBJS-y:.o=.opic)
@@ -244,7 +244,7 @@ libxenlight_test.so: $(PIC_OBJS) $(LIBXL_TEST_OBJS)
$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS) $(APPEND_LDFLAGS)
test_%: test_%.o test_common.o libxenlight_test.so
- $(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) -lyajl $(APPEND_LDFLAGS)
+ $(CC) $(LDFLAGS) $(call xenlibs-ldflags,toollog toolcore light) -o $@ $^ $(call xenlibs-ldlibs,toollog toolcore) -lyajl $(APPEND_LDFLAGS)
libxl-save-helper: $(SAVE_HELPER_OBJS) libxenlight.so
$(CC) $(LDFLAGS) -o $@ $(SAVE_HELPER_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)