[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] Fixes for linking on Solaris



# HG changeset patch
# User john.levon@xxxxxxx
# Date 1161090130 25200
# Node ID afeef751f9dafa771726bcfb00b29a10b0baeabd
# Parent  7147e57f18552bbb8d25155cc1c635315283ee31
On Solaris, GCC is configured to use Sun's LD. Fix the build to use the correct
flags, and link against libsocket where necessary.

Signed-off-by: John Levon <john.levon@xxxxxxx>

diff --git a/config/Linux.mk b/config/Linux.mk
--- a/config/Linux.mk
+++ b/config/Linux.mk
@@ -20,6 +20,10 @@ INSTALL_PROG = $(INSTALL) -m0755
 
 LIB64DIR=lib64
 
+SOCKET_LIBS =
+SONAME_LDFLAG = -Wl,-soname
+SHLIB_FLAGS = -shared
+
 ifneq ($(debug),y)
 # Optimisation flags are overridable
 CFLAGS    ?= -O2 -fomit-frame-pointer
diff --git a/config/SunOS.mk b/config/SunOS.mk
--- a/config/SunOS.mk
+++ b/config/SunOS.mk
@@ -20,6 +20,10 @@ INSTALL_PROG = $(INSTALL) -m0755
 
 LIB64DIR=lib/amd64
 
+SOCKET_LIBS = -lsocket
+SONAME_LDFLAG = -Wl,-h
+SHLIB_FLAGS = -static-libgcc -shared
+
 ifneq ($(debug),y)
 # Optimisation flags are overridable
 CFLAGS    ?= -O2 -fno-omit-frame-pointer
diff --git a/tools/blktap/lib/Makefile b/tools/blktap/lib/Makefile
--- a/tools/blktap/lib/Makefile
+++ b/tools/blktap/lib/Makefile
@@ -52,7 +52,7 @@ clean:
        rm -rf *.a *.so* *.o *.rpm $(LIB) *~ $(DEPS) xen TAGS
 
 libblktap.a: $(OBJS) 
-       $(CC) $(CFLAGS) -Wl,-soname -Wl,$(SONAME) -shared         \
+       $(CC) $(CFLAGS) $(SONAME_LDFLAG) -Wl,$(SONAME) $(SHLIB_FLAGS) \
              -L$(XEN_XENSTORE) -l xenstore                       \
              -o libblktap.so.$(MAJOR).$(MINOR) $^ $(LIBS)
        ln -sf libblktap.so.$(MAJOR).$(MINOR) libblktap.so.$(MAJOR)
diff --git a/tools/console/Makefile b/tools/console/Makefile
--- a/tools/console/Makefile
+++ b/tools/console/Makefile
@@ -22,11 +22,11 @@ clean:
 
 xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c))
        $(CC) $(CFLAGS) $^ -o $@ -L$(XEN_LIBXC) -L$(XEN_XENSTORE) \
-              -lxenctrl -lxenstore
+              $(SOCKET_LIBS) -lxenctrl -lxenstore
 
 xenconsole: $(patsubst %.c,%.o,$(wildcard client/*.c))
        $(CC) $(CFLAGS) $^ -o $@ -L$(XEN_LIBXC) -L$(XEN_XENSTORE) \
-             -lxenctrl -lxenstore
+             $(SOCKET_LIBS) -lxenctrl -lxenstore
 
 .PHONY: install
 install: $(BIN)
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -117,7 +117,7 @@ libxenctrl.so.$(MAJOR): libxenctrl.so.$(
        ln -sf $< $@
 
 libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS)
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname -Wl,libxenctrl.so.$(MAJOR) 
-shared -o $@ $^
+       $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) 
$(SHLIB_FLAGS) -o $@ $^
 
 # libxenguest
 
@@ -130,7 +130,7 @@ libxenguest.so.$(MAJOR): libxenguest.so.
        ln -sf $< $@
 
 libxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS) libxenctrl.so
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname -Wl,libxenguest.so.$(MAJOR) 
-shared -o $@ $^ -lz -lxenctrl
+       $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) 
$(SHLIB_FLAGS) -o $@ $^ -lz -lxenctrl
 
 -include $(DEPS)
 
diff --git a/tools/vnet/libxutil/Makefile b/tools/vnet/libxutil/Makefile
--- a/tools/vnet/libxutil/Makefile
+++ b/tools/vnet/libxutil/Makefile
@@ -55,7 +55,7 @@ libxutil.so.$(MAJOR): libxutil.so.$(MAJO
        ln -sf $^ $@
 
 libxutil.so.$(MAJOR).$(MINOR): $(PIC_OBJS)
-       $(CC) $(CFLAGS) -Wl,-soname -Wl,libxutil.so.$(MAJOR) -shared -o $@ $^
+       $(CC) $(CFLAGS) $(SONAME_LDFLAG) -Wl,libxutil.so.$(MAJOR) 
$(SHLIB_FLAGS) -o $@ $^
 
 libxutil.a: $(LIB_OBJS)
        $(AR) rc $@ $^
diff --git a/tools/xenstat/libxenstat/Makefile 
b/tools/xenstat/libxenstat/Makefile
--- a/tools/xenstat/libxenstat/Makefile
+++ b/tools/xenstat/libxenstat/Makefile
@@ -30,7 +30,7 @@ SHLIB=src/libxenstat.so.$(MAJOR).$(MINOR
 SHLIB=src/libxenstat.so.$(MAJOR).$(MINOR)
 SHLIB_LINKS=src/libxenstat.so.$(MAJOR) src/libxenstat.so
 OBJECTS=src/xenstat.o
-SONAME_FLAGS=-Wl,-soname -Wl,libxenstat.so.$(MAJOR)
+SONAME_FLAGS=$(SONAME_LDFLAG) -Wl,libxenstat.so.$(MAJOR)
 
 WARN_FLAGS=-Wall -Werror
 
@@ -45,7 +45,7 @@ all: $(LIB)
        $(RANLIB) $@
 
 $(SHLIB): $(OBJECTS)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) -shared -o $@ $(OBJECTS) \
+       $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_FLAGS) $(SHLIB_FLAGS) -o $@ 
$(OBJECTS) \
                -lxenstore -lxenctrl
 
 src/xenstat.o: src/xenstat.c src/xenstat.h
@@ -97,7 +97,7 @@ PYTHON_FLAGS=-I/usr/include/python$(PYTH
        swig -python $(SWIG_FLAGS) -outdir $(@D) -o $(PYSRC) $<
 
 $(PYLIB): $(PYSRC)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(PYTHON_FLAGS) -shared -lxenstat -o $@ $<
+       $(CC) $(CFLAGS) $(LDFLAGS) $(PYTHON_FLAGS) $(SHLIB_FLAGS) -lxenstat -o 
$@ $<
 
 python-bindings: $(PYLIB) $(PYMOD)
 
@@ -118,7 +118,7 @@ PERL_FLAGS=`perl -MConfig -e 'print "$$C
        swig -perl $(SWIG_FLAGS) -outdir $(@D) -o $(PERLSRC) $<
 
 $(PERLLIB): $(PERLSRC)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) -shared -lxenstat -o $@ $<
+       $(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) $(SHLIB_FLAGS) -lxenstat -o $@ 
$<
 
 .PHONY: perl-bindings
 perl-bindings: $(PERLLIB) $(PERLMOD)
diff --git a/tools/xenstat/xentop/Makefile b/tools/xenstat/xentop/Makefile
--- a/tools/xenstat/xentop/Makefile
+++ b/tools/xenstat/xentop/Makefile
@@ -25,7 +25,7 @@ sbindir=$(prefix)/sbin
 
 CFLAGS += -DGCC_PRINTF -Wall -Werror -I$(XEN_LIBXENSTAT)
 LDFLAGS += -L$(XEN_LIBXENSTAT)
-LDLIBS += -lxenstat -lncurses
+LDLIBS += -lxenstat -lncurses $(SOCKET_LIBS)
 
 .PHONY: all
 all: xentop
diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -41,19 +41,19 @@ testcode: xs_test xenstored_test xs_rand
 testcode: xs_test xenstored_test xs_random
 
 xenstored: $(XENSTORED_OBJS)
-       $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxenctrl -o $@
+       $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxenctrl $(SOCKET_LIBS) -o $@
 
 $(CLIENTS): xenstore-%: xenstore_%.o libxenstore.so
-       $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@
+       $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@
 
 $(CLIENTS_OBJS): xenstore_%.o: xenstore_client.c
        $(COMPILE.c) -DCLIENT_$(*F) -o $@ $<
 
 xenstore-control: xenstore_control.o libxenstore.so
-       $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@
+       $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@
 
 xenstore-ls: xsls.o libxenstore.so
-       $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@
+       $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@
 
 xenstored_test: xenstored_core_test.o xenstored_watch_test.o 
xenstored_domain_test.o xenstored_transaction_test.o xs_lib.o talloc_test.o 
fake_libxc.o utils.o tdb.o
        $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
@@ -90,7 +90,7 @@ libxenstore.so.$(MAJOR): libxenstore.so.
        ln -sf $< $@
 
 libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
-       $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-soname -Wl,libxenstore.so.$(MAJOR) 
-shared -o $@ $^ -lpthread
+       $(CC) $(CFLAGS) $(LDFLAGS) $(SONAME_LDFLAG) -Wl,libxenstore.so.$(MAJOR) 
$(SHLIB_FLAGS) -o $@ $^ -lpthread
 
 libxenstore.a: xs.o xs_lib.o
        $(AR) rcs libxenstore.a $^

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.