ia64/xen-unstable

changeset 3489:78a95a35e3f1

bitkeeper revision 1.1159.223.16 (41f2c5dbDRm_plztIOBiTaL3Nj5qAQ)

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.

From: Adam Heath <doogie@brainfood.com>
Signed-off-by: ian.pratt@cl.cam.ac.uk
author iap10@labyrinth.cl.cam.ac.uk
date Sat Jan 22 21:30:03 2005 +0000 (2005-01-22)
parents 4c5d9524b934
children 519af10797e4
files tools/libxc/Makefile tools/libxutil/Makefile
line diff
     1.1 --- a/tools/libxc/Makefile	Sat Jan 22 21:23:10 2005 +0000
     1.2 +++ b/tools/libxc/Makefile	Sat Jan 22 21:30:03 2005 +0000
     1.3 @@ -1,7 +1,8 @@
     1.4  
     1.5 -MAJOR    = 2.0
     1.6 -MINOR    = 0
     1.7 -SONAME   = libxc.so.$(MAJOR)
     1.8 +MAJOR		:= 2.0
     1.9 +MINOR		:= 0
    1.10 +LIB_NAME	:= libxc
    1.11 +SONAME		:= $(LIB_NAME).so.$(MAJOR)
    1.12  
    1.13  CC       = gcc
    1.14  
    1.15 @@ -35,9 +36,10 @@ CFLAGS   += $(INCLUDES) -I.
    1.16  CFLAGS   += -Wp,-MD,.$(@F).d
    1.17  DEPS     = .*.d
    1.18  
    1.19 -OBJS     = $(patsubst %.c,%.o,$(SRCS))
    1.20 +OBJS     := $(patsubst %.c,%.o,$(SRCS))
    1.21 +PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS))
    1.22  
    1.23 -LIB      = libxc.so libxc.so.$(MAJOR) libxc.so.$(MAJOR).$(MINOR)
    1.24 +LIB		:= $(LIB_NAME).a $(LIB_NAME).so $(LIB_NAME).so.$(MAJOR) $(LIB_NAME).so.$(MAJOR).$(MINOR)
    1.25  
    1.26  all: check-for-zlib mk-symlinks
    1.27  	$(MAKE) $(LIB)
    1.28 @@ -65,12 +67,12 @@ install: all
    1.29  	mkdir -p $(prefix)/usr/lib
    1.30  	mkdir -p $(prefix)/usr/include
    1.31  	install -m0755 $(LIB) $(prefix)/usr/lib
    1.32 -	ln -sf libxc.so.$(MAJOR).$(MINOR) $(prefix)/usr/lib/libxc.so.$(MAJOR)
    1.33 -	ln -sf libxc.so.$(MAJOR) $(prefix)/usr/lib/libxc.so
    1.34 +	ln -sf $(LIB_NAME).so.$(MAJOR).$(MINOR) $(prefix)/usr/lib/$(LIB_NAME).so.$(MAJOR)
    1.35 +	ln -sf $(LIB_NAME).so.$(MAJOR) $(prefix)/usr/lib/$(LIB_NAME).so
    1.36  	install -m0644 xc.h $(prefix)/usr/include
    1.37  
    1.38  clean:
    1.39 -	rm -rf *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) xen
    1.40 +	rm -rf *.a *.so *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen
    1.41  
    1.42  rpm: all
    1.43  	rm -rf staging
    1.44 @@ -81,11 +83,17 @@ rpm: all
    1.45  	mv staging/i386/*.rpm .
    1.46  	rm -rf staging
    1.47  
    1.48 -libxc.so:
    1.49 -	ln -sf libxc.so.$(MAJOR) $@
    1.50 -libxc.so.$(MAJOR):
    1.51 -	ln -sf libxc.so.$(MAJOR).$(MINOR) $@
    1.52 -libxc.so.$(MAJOR).$(MINOR): $(OBJS)
    1.53 +$(PIC_OBJS): %.opic: %.c
    1.54 +	$(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $<
    1.55 +
    1.56 +$(LIB_NAME).a: $(OBJS)
    1.57 +	$(AR) rc $@ $^
    1.58 +
    1.59 +$(LIB_NAME).so: $(LIB_NAME).so.$(MAJOR)
    1.60 +	ln -sf $< $@
    1.61 +$(LIB_NAME).so.$(MAJOR): $(LIB_NAME).so.$(MAJOR).$(MINOR)
    1.62 +	ln -sf $< $@
    1.63 +$(LIB_NAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS)
    1.64  	$(CC) -Wl,-soname -Wl,$(SONAME) -shared -o $@ $^ -L../libxutil -lxutil -lz
    1.65  
    1.66  -include $(DEPS)
     2.1 --- a/tools/libxutil/Makefile	Sat Jan 22 21:23:10 2005 +0000
     2.2 +++ b/tools/libxutil/Makefile	Sat Jan 22 21:30:03 2005 +0000
     2.3 @@ -19,6 +19,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
    2.10  CFLAGS   += -Werror
    2.11 @@ -33,6 +34,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 @@ -41,14 +43,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 @@ -68,7 +73,7 @@ install: all
    2.40  	ln -sf $(LIB_NAME).so.$(MAJOR) $(prefix)/usr/lib/$(LIB_NAME).so
    2.41  
    2.42  clean:
    2.43 -	$(RM) *.a *.so *.so.* *.o *.rpm 
    2.44 +	$(RM) *.a *.so *.so.* *.o *.opic *.rpm 
    2.45  	$(RM) *~
    2.46  	$(RM) $(DEPS)
    2.47