add --with(out)?-pic configure options

This makes configure smell more like standard configure scripts and
easier for larger build systems to control the nature of the build.

When building non-pic, don't build the shared object, as a non-pic
shared object doesn't make a huge amount of sense.
ck_pring
Wez Furlong 11 years ago
parent 26e4c27578
commit 9c6b95c4dc

@ -46,20 +46,26 @@ install-headers:
chmod 755 $(DESTDIR)/$(HEADERS)/spinlock
chmod 644 $(DESTDIR)/$(HEADERS)/spinlock/*.h || exit
install: all install-headers
$(MAKE) -C doc install
mkdir -p $(DESTDIR)/$(LIBRARY) || exit
cp src/libck.so $(DESTDIR)/$(LIBRARY)/$(LDNAME_VERSION) || exit
ln -s $(LDNAME_VERSION) $(DESTDIR)/$(LIBRARY)/$(LDNAME)
ln -s $(LDNAME_VERSION) $(DESTDIR)/$(LIBRARY)/$(LDNAME_MAJOR)
install-so:
mkdir -p $(DESTDIR)/$(LIBRARY)
cp src/libck.so $(DESTDIR)/$(LIBRARY)/$(LDNAME_VERSION)
ln -sf $(LDNAME_VERSION) $(DESTDIR)/$(LIBRARY)/$(LDNAME)
ln -sf $(LDNAME_VERSION) $(DESTDIR)/$(LIBRARY)/$(LDNAME_MAJOR)
chmod 744 $(DESTDIR)/$(LIBRARY)/$(LDNAME_VERSION) \
$(DESTDIR)/$(LIBRARY)/$(LDNAME) \
$(DESTDIR)/$(LIBRARY)/$(LDNAME_MAJOR)
install-lib:
mkdir -p $(DESTDIR)/$(LIBRARY)
cp src/libck.a $(DESTDIR)/$(LIBRARY)/libck.a
chmod 644 $(DESTDIR)/$(LIBRARY)/libck.a
install: all install-headers @INSTALL_LIBS@
$(MAKE) -C doc install
mkdir -p $(DESTDIR)/$(LIBRARY) || exit
mkdir -p $(DESTDIR)/$(PKGCONFIG_DATA) || exit
chmod 755 $(DESTDIR)/$(PKGCONFIG_DATA)
cp build/ck.pc $(DESTDIR)/$(PKGCONFIG_DATA)/ck.pc || exit
cp src/libck.a $(DESTDIR)/$(LIBRARY)/libck.a || exit
chmod 644 $(DESTDIR)/$(LIBRARY)/libck.a || exit
@echo
@echo
@echo ---[ Concurrency Kit has installed successfully.

@ -4,6 +4,7 @@ SRC_DIR=@SRC_DIR@
BUILD_DIR=@BUILD_DIR@
CFLAGS=@CFLAGS@ -I$(SRC_DIR)/include -I$(BUILD_DIR)/include
LDFLAGS=@LDFLAGS@
ALL_LIBS=@ALL_LIBS@
LD=@LD@
include $(BUILD_DIR)/build/ck.build.@PROFILE@

36
configure vendored

@ -30,6 +30,7 @@ REQUIRE_HEADER="stdbool.h stddef.h stdint.h string.h"
EXIT_SUCCESS=0
EXIT_FAILURE=1
WANT_PIC=yes
P_PWD=`pwd`
MAINTAINER='sbahra@repnop.org'
@ -90,6 +91,8 @@ generate()
-e "s#@LIBRARY@#$LIBRARY#g" \
-e "s#@PREFIX@#$PREFIX#g" \
-e "s#@CORES@#$CORES#g" \
-e "s#@ALL_LIBS@#$ALL_LIBS#g" \
-e "s#@INSTALL_LIBS@#$INSTALL_LIBS#g" \
-e "s#@LD@#$LD#g" \
-e "s#@LDFLAGS@#$LDFLAGS#g" \
-e "s#@PTHREAD_CFLAGS@#$PTHREAD_CFLAGS#g" \
@ -215,6 +218,23 @@ for option in $*; do
--mandir=*)
MANDIR=$value
;;
--with-pic)
WANT_PIC=yes
;;
--without-pic)
WANT_PIC=no
;;
--build=*|--host=*|--target=*|--exec-prefix=*|--bindir=*|--sbindir=*|\
--sysconfdir=*|--datadir=*|--libexecdir=*|--localstatedir=*|\
--enable-static|\
--sharedstatedir=*|--infodir=*|--enable-shared|--disable-shared)
# ignore for compat with regular configure
;;
--*)
echo "$0 [--help]"
echo "Unknown option $option"
exit $EXIT_FAILURE
;;
*=*)
NAME=`expr "$option" : '\([^=]*\)='`
VALUE=`echo "$value" | sed "s/'/'\\\\\\\\''/g"`
@ -223,6 +243,7 @@ for option in $*; do
;;
*)
echo "$0 [--help]"
echo "Unknown option $option"
exit $EXIT_FAILURE
;;
esac
@ -541,7 +562,20 @@ elif test "$COMPILER" = "gcc" || test "$COMPILER" = "clang" || test "$COMPILER"
else
CC_WL_OPT="-soname"
fi
LDFLAGS="-shared -fPIC -Wl,$CC_WL_OPT,$SONAME $LDFLAGS"
LDFLAGS="-Wl,$CC_WL_OPT,$SONAME $LDFLAGS"
if test "$WANT_PIC" = "yes"; then
LDFLAGS="$LDFLAGS -shared -fPIC"
CFLAGS="$CFLAGS -fPIC"
ALL_LIBS="libck.so libck.a"
INSTALL_LIBS="install-so install-lib"
else
LDFLAGS="$LDFLAGS -fno-PIC"
CFLAGS="$CFLAGS -fno-PIC"
ALL_LIBS="libck.a"
INSTALL_LIBS="install-lib"
fi
CFLAGS="-D_XOPEN_SOURCE=600 -D_BSD_SOURCE -std=gnu99 -pedantic -Wall -W -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wdisabled-optimization -fstrict-aliasing -O2 -pipe -Wno-parentheses $CFLAGS"
PTHREAD_CFLAGS="-pthread"
if test "$COMPILER" = "mingw64"; then

@ -1,7 +1,6 @@
.PHONY: clean distribution
include @BUILD_DIR@/build/ck.build
CFLAGS+=-fPIC
TARGET_DIR=$(BUILD_DIR)/src
SDIR=$(SRC_DIR)/src
@ -19,7 +18,7 @@ OBJECTS=ck_barrier_centralized.o \
ck_rhs.o \
ck_array.o
all: libck.so libck.a
all: $(ALL_LIBS)
libck.so: $(OBJECTS)
$(LD) $(LDFLAGS) -o $(TARGET_DIR)/libck.so $(OBJECTS)

Loading…
Cancel
Save