+
+ifndef BUILD_PIC_LIBS
+ifeq ($(wildcard /etc/debian_version),)
+BUILD_PIC_LIBS=n
+else
+BUILD_PIC_LIBS=y
+endif
+endif
+
INSTALL = install
INSTALL_PROG = $(INSTALL) -m0755
INSTALL_DATA = $(INSTALL) -m0644
MAJOR = 2.0
MINOR = 0
-LIB_NAME = libxc
-SONAME = $(LIB_NAME).so.$(MAJOR)
CC = gcc
CFLAGS += -Wp,-MD,.$(@F).d
DEPS = .*.d
-OBJS := $(patsubst %.c,%.o,$(SRCS))
+LIB_OBJS := $(patsubst %.c,%.o,$(SRCS))
PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS))
-LIB := $(LIB_NAME).a $(LIB_NAME).so $(LIB_NAME).so.$(MAJOR) $(LIB_NAME).so.$(MAJOR).$(MINOR)
+LIB := libxc.a libxc.so libxc.so.$(MAJOR) libxc.so.$(MAJOR).$(MINOR)
all: check-for-zlib mk-symlinks
$(MAKE) $(LIB)
install: all
[ -d $(DESTDIR)/usr/lib ] || $(INSTALL_DIR) $(DESTDIR)/usr/lib
[ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) $(DESTDIR)/usr/include
- $(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_PROG) libxc.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib
+ $(INSTALL_DATA) libxc.a $(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_DATA) xc.h $(DESTDIR)/usr/include
clean:
- rm -rf *.a *.so *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen
+ rm -rf *.a *.so* *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen
rpm: all
rm -rf staging
$(PIC_OBJS): %.opic: %.c
$(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $<
-
-$(LIB_NAME).a: $(OBJS)
+
+libxc.a: $(OBJS)
$(AR) rc $@ $^
-$(LIB_NAME).so: $(LIB_NAME).so.$(MAJOR)
+libxc.so: libxc.so.$(MAJOR)
ln -sf $< $@
-$(LIB_NAME).so.$(MAJOR): $(LIB_NAME).so.$(MAJOR).$(MINOR)
+libxc.so.$(MAJOR): libxc.so.$(MAJOR).$(MINOR)
ln -sf $< $@
-$(LIB_NAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS)
- $(CC) -Wl,-soname -Wl,$(SONAME) -shared -o $@ $^ -L../libxutil -lxutil -lz
+
+ifeq ($(BUILD_PIC_LIBS),y)
+libxc.so.$(MAJOR).$(MINOR): $(PIC_OBJS)
+ $(CC) -Wl,-soname -Wl,libxc.so.$(MAJOR) -shared -o $@ $^ -L../libxutil -lxutil -lz
+else
+libxc.so.$(MAJOR).$(MINOR): $(LIB_OBJS)
+ $(CC) -Wl,-soname -Wl,libxc.so.$(MAJOR) -shared -o $@ $^ -L../libxutil -lxutil -lz
+endif
-include $(DEPS)
+
+ifndef BUILD_PIC_LIBS
+ifeq ($(wildcard /etc/debian_version),)
+BUILD_PIC_LIBS=n
+else
+BUILD_PIC_LIBS=y
+endif
+endif
+
XEN_ROOT = ../..
INSTALL = install
INSTALL_DATA = $(INSTALL) -m0644
LIB_SRCS += util.c
LIB_OBJS := $(LIB_SRCS:.c=.o)
-LIB_PIC_OBJS := $(LIB_SRCS:.c=.opic)
+PIC_OBJS := $(LIB_SRCS:.c=.opic)
CFLAGS += -Wall -Werror -O3 -fno-strict-aliasing
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)
-LIB += $(LIB_NAME).a
+LIB := libxutil.so
+LIB += libxutil.so.$(MAJOR)
+LIB += libxutil.so.$(MAJOR).$(MINOR)
+LIB += libxutil.a
all: check-for-zlib
$(MAKE) $(LIB)
-$(LIB_PIC_OBJS): %.opic: %.c
+$(PIC_OBJS): %.opic: %.c
$(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $<
-$(LIB_NAME).so: $(LIB_NAME).so.$(MAJOR)
+libxutil.so: libxutil.so.$(MAJOR)
ln -sf $^ $@
-$(LIB_NAME).so.$(MAJOR): $(LIB_NAME).so.$(MAJOR).$(MINOR)
+libxutil.so.$(MAJOR): libxutil.so.$(MAJOR).$(MINOR)
ln -sf $^ $@
-$(LIB_NAME).so.$(MAJOR).$(MINOR): $(LIB_PIC_OBJS)
- $(CC) -Wl,-soname -Wl,$(SO_NAME) -shared -o $@ $^
+ifeq ($(BUILD_PIC_LIBS),y)
+libxutil.so.$(MAJOR).$(MINOR): $(PIC_OBJS)
+ $(CC) -Wl,-soname -Wl,libxutil.so.$(MAJOR) -shared -o $@ $^
+else
+libxutil.so.$(MAJOR).$(MINOR): $(LIB_OBJS)
+ $(CC) -Wl,-soname -Wl,libxutil.so.$(MAJOR) -shared -o $@ $^
+endif
-$(LIB_NAME).a: $(LIB_OBJS)
+libxutil.a: $(LIB_OBJS)
$(AR) rc $@ $^
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
+ $(INSTALL_PROG) libxutil.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib
+ $(INSTALL_DATA) libxutil.a $(DESTDIR)/usr/lib
+ ln -sf libxutil.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib/libxutil.so.$(MAJOR)
+ ln -sf libxutil.so.$(MAJOR) $(DESTDIR)/usr/lib/libxutil.so
clean:
- $(RM) *.a *.so *.so.* *.o *.opic *.rpm
+ $(RM) *.a *.so* *.o *.opic *.rpm
$(RM) *~
$(RM) $(DEPS)