# HG changeset patch # User iap10@labyrinth.cl.cam.ac.uk # Date 1107594997 0 # Node ID f9b3b23cf5ffd11d989a1bf8782931f4af045e4b # Parent 70b22eeb86c1b60af030958245db085326cbc21e bitkeeper revision 1.1159.223.66 (42048ef5frMFQFFm-sKDC6PrU8yraQ) Name: pic-lib.patch Description: support PIC code generation Libraries have 2 methods of being compiled; a .so must contain non-pic objects, while the .a can contain standard objects. Signed-off-by: Adam Heath Signed-off-by: ian.pratt@cl.cam.ac.uk diff -r 70b22eeb86c1 -r f9b3b23cf5ff tools/libxc/Makefile --- a/tools/libxc/Makefile Sat Feb 05 09:11:51 2005 +0000 +++ b/tools/libxc/Makefile Sat Feb 05 09:16:37 2005 +0000 @@ -5,7 +5,8 @@ INSTALL_DIR = $(INSTALL) -d -m0755 MAJOR = 2.0 MINOR = 0 -SONAME = libxc.so.$(MAJOR) +LIB_NAME = libxc +SONAME = $(LIB_NAME).so.$(MAJOR) CC = gcc @@ -39,9 +40,10 @@ CFLAGS += $(INCLUDES) -I. CFLAGS += -Wp,-MD,.$(@F).d DEPS = .*.d -OBJS = $(patsubst %.c,%.o,$(SRCS)) +OBJS := $(patsubst %.c,%.o,$(SRCS)) +PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS)) -LIB = libxc.so libxc.so.$(MAJOR) libxc.so.$(MAJOR).$(MINOR) +LIB := $(LIB_NAME).a $(LIB_NAME).so $(LIB_NAME).so.$(MAJOR) $(LIB_NAME).so.$(MAJOR).$(MINOR) all: check-for-zlib mk-symlinks $(MAKE) $(LIB) @@ -68,13 +70,14 @@ mk-symlinks: install: all [ -d $(DESTDIR)/usr/lib ] || $(INSTALL_DIR) $(DESTDIR)/usr/lib [ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) $(DESTDIR)/usr/include - $(INSTALL_PROG) libxc.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib - ln -sf libxc.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib/libxc.so.$(MAJOR) - ln -sf libxc.so.$(MAJOR) $(DESTDIR)/usr/lib/libxc.so + $(INSTALL_PROG) $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib + $(INSTALL_DATA) $(LIB_NAME).a $(DESTDIR)/usr/lib + ln -sf $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so.$(MAJOR) + ln -sf $(LIB_NAME).so.$(MAJOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so $(INSTALL_DATA) xc.h $(DESTDIR)/usr/include clean: - rm -rf *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) xen + rm -rf *.a *.so *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen rpm: all rm -rf staging @@ -85,11 +88,17 @@ rpm: all mv staging/i386/*.rpm . rm -rf staging -libxc.so: - ln -sf libxc.so.$(MAJOR) $@ -libxc.so.$(MAJOR): - ln -sf libxc.so.$(MAJOR).$(MINOR) $@ -libxc.so.$(MAJOR).$(MINOR): $(OBJS) +$(PIC_OBJS): %.opic: %.c + $(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $< + +$(LIB_NAME).a: $(OBJS) + $(AR) rc $@ $^ + +$(LIB_NAME).so: $(LIB_NAME).so.$(MAJOR) + ln -sf $< $@ +$(LIB_NAME).so.$(MAJOR): $(LIB_NAME).so.$(MAJOR).$(MINOR) + ln -sf $< $@ +$(LIB_NAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS) $(CC) -Wl,-soname -Wl,$(SONAME) -shared -o $@ $^ -L../libxutil -lxutil -lz -include $(DEPS) diff -r 70b22eeb86c1 -r f9b3b23cf5ff tools/libxutil/Makefile --- a/tools/libxutil/Makefile Sat Feb 05 09:11:51 2005 +0000 +++ b/tools/libxutil/Makefile Sat Feb 05 09:16:37 2005 +0000 @@ -24,6 +24,7 @@ LIB_SRCS += sys_string.c LIB_SRCS += util.c LIB_OBJS := $(LIB_SRCS:.c=.o) +LIB_PIC_OBJS := $(LIB_SRCS:.c=.opic) CFLAGS += -Wall -Werror -O3 -fno-strict-aliasing @@ -34,6 +35,7 @@ DEPS = .*.d MAJOR := 2.0 MINOR := 0 LIB_NAME := libxutil +SO_NAME := $(LIB_NAME).so.$(MAJOR) LIB := $(LIB_NAME).so LIB += $(LIB_NAME).so.$(MAJOR) LIB += $(LIB_NAME).so.$(MAJOR).$(MINOR) @@ -42,14 +44,17 @@ LIB += $(LIB_NAME).a all: check-for-zlib $(MAKE) $(LIB) +$(LIB_PIC_OBJS): %.opic: %.c + $(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $< + $(LIB_NAME).so: $(LIB_NAME).so.$(MAJOR) ln -sf $^ $@ $(LIB_NAME).so.$(MAJOR): $(LIB_NAME).so.$(MAJOR).$(MINOR) ln -sf $^ $@ -$(LIB_NAME).so.$(MAJOR).$(MINOR): $(LIB_OBJS) - $(CC) -Wl,-soname -Wl,$(LIB_NAME).so.$(MAJOR) -shared -o $@ $^ +$(LIB_NAME).so.$(MAJOR).$(MINOR): $(LIB_PIC_OBJS) + $(CC) -Wl,-soname -Wl,$(SO_NAME) -shared -o $@ $^ $(LIB_NAME).a: $(LIB_OBJS) $(AR) rc $@ $^ @@ -65,11 +70,12 @@ check-for-zlib: install: all [ -d $(DESTDIR)/usr/lib ] || $(INSTALL_DIR) -p $(DESTDIR)/usr/lib $(INSTALL_PROG) $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib + $(INSTALL_DATA) $(LIB_NAME).a $(DESTDIR)/usr/lib ln -sf $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so.$(MAJOR) ln -sf $(LIB_NAME).so.$(MAJOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so clean: - $(RM) *.a *.so *.so.* *.o *.rpm + $(RM) *.a *.so *.so.* *.o *.opic *.rpm $(RM) *~ $(RM) $(DEPS)