ia64/xen-unstable

changeset 3660:f9b3b23cf5ff

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 <doogie@brainfood.com>
Signed-off-by: ian.pratt@cl.cam.ac.uk
author iap10@labyrinth.cl.cam.ac.uk
date Sat Feb 05 09:16:37 2005 +0000 (2005-02-05)
parents 70b22eeb86c1
children 09723a1de726 e264eb30eba0
files tools/libxc/Makefile tools/libxutil/Makefile
line diff
     1.1 --- a/tools/libxc/Makefile	Sat Feb 05 09:11:51 2005 +0000
     1.2 +++ b/tools/libxc/Makefile	Sat Feb 05 09:16:37 2005 +0000
     1.3 @@ -5,7 +5,8 @@ INSTALL_DIR	= $(INSTALL) -d -m0755
     1.4  
     1.5  MAJOR    = 2.0
     1.6  MINOR    = 0
     1.7 -SONAME   = libxc.so.$(MAJOR)
     1.8 +LIB_NAME = libxc
     1.9 +SONAME   = $(LIB_NAME).so.$(MAJOR)
    1.10  
    1.11  CC       = gcc
    1.12  
    1.13 @@ -39,9 +40,10 @@ CFLAGS   += $(INCLUDES) -I.
    1.14  CFLAGS   += -Wp,-MD,.$(@F).d
    1.15  DEPS     = .*.d
    1.16  
    1.17 -OBJS     = $(patsubst %.c,%.o,$(SRCS))
    1.18 +OBJS     := $(patsubst %.c,%.o,$(SRCS))
    1.19 +PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS))
    1.20  
    1.21 -LIB      = libxc.so libxc.so.$(MAJOR) libxc.so.$(MAJOR).$(MINOR)
    1.22 +LIB		:= $(LIB_NAME).a $(LIB_NAME).so $(LIB_NAME).so.$(MAJOR) $(LIB_NAME).so.$(MAJOR).$(MINOR)
    1.23  
    1.24  all: check-for-zlib mk-symlinks
    1.25  	$(MAKE) $(LIB)
    1.26 @@ -68,13 +70,14 @@ mk-symlinks:
    1.27  install: all
    1.28  	[ -d $(DESTDIR)/usr/lib ] || $(INSTALL_DIR) $(DESTDIR)/usr/lib
    1.29  	[ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) $(DESTDIR)/usr/include
    1.30 -	$(INSTALL_PROG) libxc.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib
    1.31 -	ln -sf libxc.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib/libxc.so.$(MAJOR)
    1.32 -	ln -sf libxc.so.$(MAJOR) $(DESTDIR)/usr/lib/libxc.so
    1.33 +	$(INSTALL_PROG) $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib
    1.34 +	$(INSTALL_DATA) $(LIB_NAME).a $(DESTDIR)/usr/lib
    1.35 +	ln -sf $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so.$(MAJOR)
    1.36 +	ln -sf $(LIB_NAME).so.$(MAJOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so
    1.37  	$(INSTALL_DATA) xc.h $(DESTDIR)/usr/include
    1.38  
    1.39  clean:
    1.40 -	rm -rf *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) xen
    1.41 +	rm -rf *.a *.so *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen
    1.42  
    1.43  rpm: all
    1.44  	rm -rf staging
    1.45 @@ -85,11 +88,17 @@ rpm: all
    1.46  	mv staging/i386/*.rpm .
    1.47  	rm -rf staging
    1.48  
    1.49 -libxc.so:
    1.50 -	ln -sf libxc.so.$(MAJOR) $@
    1.51 -libxc.so.$(MAJOR):
    1.52 -	ln -sf libxc.so.$(MAJOR).$(MINOR) $@
    1.53 -libxc.so.$(MAJOR).$(MINOR): $(OBJS)
    1.54 +$(PIC_OBJS): %.opic: %.c
    1.55 +	$(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $<
    1.56 +	
    1.57 +$(LIB_NAME).a: $(OBJS)
    1.58 +	$(AR) rc $@ $^
    1.59 +
    1.60 +$(LIB_NAME).so: $(LIB_NAME).so.$(MAJOR)
    1.61 +	ln -sf $< $@
    1.62 +$(LIB_NAME).so.$(MAJOR): $(LIB_NAME).so.$(MAJOR).$(MINOR)
    1.63 +	ln -sf $< $@
    1.64 +$(LIB_NAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS)
    1.65  	$(CC) -Wl,-soname -Wl,$(SONAME) -shared -o $@ $^ -L../libxutil -lxutil -lz
    1.66  
    1.67  -include $(DEPS)
     2.1 --- a/tools/libxutil/Makefile	Sat Feb 05 09:11:51 2005 +0000
     2.2 +++ b/tools/libxutil/Makefile	Sat Feb 05 09:16:37 2005 +0000
     2.3 @@ -24,6 +24,7 @@ LIB_SRCS += sys_string.c
     2.4  LIB_SRCS += util.c
     2.5  
     2.6  LIB_OBJS := $(LIB_SRCS:.c=.o)
     2.7 +LIB_PIC_OBJS := $(LIB_SRCS:.c=.opic)
     2.8  
     2.9  CFLAGS   += -Wall -Werror -O3 -fno-strict-aliasing
    2.10  
    2.11 @@ -34,6 +35,7 @@ DEPS     = .*.d
    2.12  MAJOR    := 2.0
    2.13  MINOR    := 0
    2.14  LIB_NAME := libxutil
    2.15 +SO_NAME  := $(LIB_NAME).so.$(MAJOR)
    2.16  LIB      := $(LIB_NAME).so 
    2.17  LIB      += $(LIB_NAME).so.$(MAJOR)
    2.18  LIB      += $(LIB_NAME).so.$(MAJOR).$(MINOR)
    2.19 @@ -42,14 +44,17 @@ LIB      += $(LIB_NAME).a
    2.20  all: check-for-zlib
    2.21  	$(MAKE) $(LIB)
    2.22  
    2.23 +$(LIB_PIC_OBJS): %.opic: %.c
    2.24 +	$(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $<
    2.25 +
    2.26  $(LIB_NAME).so: $(LIB_NAME).so.$(MAJOR)
    2.27  	ln -sf $^ $@
    2.28  
    2.29  $(LIB_NAME).so.$(MAJOR): $(LIB_NAME).so.$(MAJOR).$(MINOR)
    2.30  	ln -sf $^ $@
    2.31  
    2.32 -$(LIB_NAME).so.$(MAJOR).$(MINOR): $(LIB_OBJS)
    2.33 -	$(CC) -Wl,-soname -Wl,$(LIB_NAME).so.$(MAJOR) -shared -o $@ $^
    2.34 +$(LIB_NAME).so.$(MAJOR).$(MINOR): $(LIB_PIC_OBJS)
    2.35 +	$(CC) -Wl,-soname -Wl,$(SO_NAME) -shared -o $@ $^
    2.36  
    2.37  $(LIB_NAME).a: $(LIB_OBJS)
    2.38  	$(AR) rc $@ $^
    2.39 @@ -65,11 +70,12 @@ check-for-zlib:
    2.40  install: all
    2.41  	[ -d $(DESTDIR)/usr/lib ] || $(INSTALL_DIR) -p $(DESTDIR)/usr/lib
    2.42  	$(INSTALL_PROG) $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib
    2.43 +	$(INSTALL_DATA) $(LIB_NAME).a $(DESTDIR)/usr/lib
    2.44  	ln -sf $(LIB_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so.$(MAJOR)
    2.45  	ln -sf $(LIB_NAME).so.$(MAJOR) $(DESTDIR)/usr/lib/$(LIB_NAME).so
    2.46  
    2.47  clean:
    2.48 -	$(RM) *.a *.so *.so.* *.o *.rpm 
    2.49 +	$(RM) *.a *.so *.so.* *.o *.opic *.rpm 
    2.50  	$(RM) *~
    2.51  	$(RM) $(DEPS)
    2.52