summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-10-30 11:09:26 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-10-30 11:09:26 +0000
commite9ab29c6ad9976fcf45ec09c5b647d667201d841 (patch)
treecaafdfb1d72b356dad3df2b0ca0d118ad899c082
parent8330521d9b370bad4b804d7fb6dfeb9ed8aafc2c (diff)
downloads6-networking-e9ab29c6ad9976fcf45ec09c5b647d667201d841.tar.xz
Make all-pic a user option
-rw-r--r--Makefile4
-rwxr-xr-xconfigure30
-rw-r--r--package/deps.mak12
-rwxr-xr-xtools/gen-deps.sh2
4 files changed, 36 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 259d624..610dbb6 100644
--- a/Makefile
+++ b/Makefile
@@ -42,7 +42,11 @@ version_M := $(basename $(version_m))
version_l := $(basename $(version_M))
CPPFLAGS_ALL := $(CPPFLAGS_AUTO) $(CPPFLAGS)
CFLAGS_ALL := $(CFLAGS_AUTO) $(CFLAGS)
+ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)
CFLAGS_SHARED := -fPIC
+else
+CFLAGS_SHARED :=
+endif
LDFLAGS_ALL := $(LDFLAGS_AUTO) $(LDFLAGS)
REALCC = $(CROSS_COMPILE)$(CC)
AR := $(CROSS_COMPILE)ar
diff --git a/configure b/configure
index d4f484b..3bebe3b 100755
--- a/configure
+++ b/configure
@@ -40,6 +40,7 @@ Optional features:
--disable-static do not build static libraries [enabled]
--disable-allstatic do not prefer linking against static libraries [enabled]
--enable-static-libc make entirely static binaries [disabled]
+ --enable-all-pic build everything as PIC [enabled iff toolchain builds PIE]
--enable-slashpackage[=ROOT] assume /package installation at ROOT [disabled]
--enable-absolute-paths do not rely on PATH to access this package's binaries,
hardcode absolute BINDIR/foobar paths instead [disabled]
@@ -146,6 +147,7 @@ sysdeps='$prefix/lib/skalibs/sysdeps'
manualsysdeps=false
shared=false
static=true
+allpic=detect
slashpackage=false
abspath=false
sproot=
@@ -183,6 +185,8 @@ for arg ; do
--disable-allstatic|--enable-allstatic=no) allstatic=false ; evenmorestatic=false ;;
--enable-static-libc|--enable-static-libc=yes) allstatic=true ; evenmorestatic=true ;;
--disable-static-libc|--enable-static-libc=no) evenmorestatic=false ;;
+ --enable-all-pic|--enable-all-pic=yes) allpic=true ;;
+ --disable-all-pic|--enable-all-pic=no) allpic=false ;;
--enable-slashpackage=*) sproot=${arg#*=} ; slashpackage=true ; ;;
--enable-slashpackage) sproot= ; slashpackage=true ;;
--disable-slashpackage) sproot= ; slashpackage=false ;;
@@ -301,14 +305,18 @@ if [ "x$target" != "x$(cat $sysdeps/target)" ] ; then
exit 1
fi
-defaultpie=false
-echo "Checking whether we're building PIE..."
-if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -dM -E - < /dev/null | grep -qF __PIE__ ; then
- defaultpie=true
- CFLAGS_AUTO="$CFLAGS_AUTO -fPIC"
- echo " ... yes"
-else
- echo " ... no"
+if test $allpic = detect ; then
+ echo "Checking whether we need to build everything as PIC..."
+ if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -dM -E - < /dev/null | grep -qF __PIE__ ; then
+ allpic=true
+ echo " ... yes"
+ else
+ allpic=false
+ echo " ... no"
+ fi
+fi
+if $allpic ; then
+ tryflag CFLAGS_AUTO -fPIC
fi
spawn_lib=$(cat $sysdeps/spawn.lib)
@@ -424,10 +432,10 @@ if $shared ; then
else
echo "DO_SHARED :="
fi
-if $defaultpie ; then
- echo "DEFAULT_PIE := 1"
+if $ allpic ; then
+ echo "STATIC_LIBS_ARE_PIC := 1"
else
- echo "DEFAULT_PIE :="
+ echo "STATIC_LIBS_ARE_PIC :="
fi
if test -n $ssl ; then
echo "SSL_IMPL := $ssl"
diff --git a/package/deps.mak b/package/deps.mak
index 840e716..fb26f3c 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -113,14 +113,26 @@ s6-tlsd: EXTRA_LIBS := ${CRYPTO_LIB} ${SOCKET_LIB} ${SPAWN_LIB} ${TAINNOW_LIB}
s6-tlsd: src/conn-tools/s6-tlsd.o ${LIBCRYPTOSUPPORT} -lskarnet
s6-tlsserver: EXTRA_LIBS :=
s6-tlsserver: src/conn-tools/s6-tlsserver.o -lskarnet
+ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)
libs6net.a.xyzzy: src/libs6net/s6net_ident_client.o src/libs6net/s6net_ident_reply_get.o src/libs6net/s6net_ident_reply_parse.o src/libs6net/s6net_ident_error.o
+else
+libs6net.a.xyzzy: src/libs6net/s6net_ident_client.lo src/libs6net/s6net_ident_reply_get.lo src/libs6net/s6net_ident_reply_parse.lo src/libs6net/s6net_ident_error.lo
+endif
libs6net.so.xyzzy: EXTRA_LIBS := -lskarnet
libs6net.so.xyzzy: src/libs6net/s6net_ident_client.lo src/libs6net/s6net_ident_reply_get.lo src/libs6net/s6net_ident_reply_parse.lo src/libs6net/s6net_ident_error.lo
minidentd: EXTRA_LIBS := ${SOCKET_LIB} ${TAINNOW_LIB}
minidentd: src/minidentd/minidentd.o src/minidentd/mgetuid.o -lskarnet
+ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)
libsbearssl.a.xyzzy: src/sbearssl/sbearssl_append.o src/sbearssl/sbearssl_prep_spawn_drop.o src/sbearssl/sbearssl_cert_from.o src/sbearssl/sbearssl_cert_readbigpem.o src/sbearssl/sbearssl_cert_readfile.o src/sbearssl/sbearssl_cert_to.o src/sbearssl/sbearssl_ec_issuer_keytype.o src/sbearssl/sbearssl_ec_pkey_from.o src/sbearssl/sbearssl_ec_pkey_to.o src/sbearssl/sbearssl_ec_skey_from.o src/sbearssl/sbearssl_ec_skey_to.o src/sbearssl/sbearssl_error_str.o src/sbearssl/sbearssl_isder.o src/sbearssl/sbearssl_pem_decode_from_buffer.o src/sbearssl/sbearssl_pem_decode_from_string.o src/sbearssl/sbearssl_pem_push.o src/sbearssl/sbearssl_pkey_from.o src/sbearssl/sbearssl_pkey_to.o src/sbearssl/sbearssl_rsa_pkey_from.o src/sbearssl/sbearssl_rsa_pkey_to.o src/sbearssl/sbearssl_rsa_skey_from.o src/sbearssl/sbearssl_rsa_skey_to.o src/sbearssl/sbearssl_run.o src/sbearssl/sbearssl_skey_from.o src/sbearssl/sbearssl_skey_readfile.o src/sbearssl/sbearssl_skey_to.o src/sbearssl/sbearssl_ta_cert.o src/sbearssl/sbearssl_ta_certs.o src/sbearssl/sbearssl_ta_from.o src/sbearssl/sbearssl_ta_readdir.o src/sbearssl/sbearssl_ta_readfile.o src/sbearssl/sbearssl_ta_to.o src/sbearssl/sbearssl_x500_name_len.o src/sbearssl/sbearssl_x500_from_ta.o src/sbearssl/sbearssl_x509_minimal_set_tai.o src/sbearssl/sbearssl_s6tlsc.o src/sbearssl/sbearssl_s6tlsd.o
+else
+libsbearssl.a.xyzzy: src/sbearssl/sbearssl_append.lo src/sbearssl/sbearssl_prep_spawn_drop.lo src/sbearssl/sbearssl_cert_from.lo src/sbearssl/sbearssl_cert_readbigpem.lo src/sbearssl/sbearssl_cert_readfile.lo src/sbearssl/sbearssl_cert_to.lo src/sbearssl/sbearssl_ec_issuer_keytype.lo src/sbearssl/sbearssl_ec_pkey_from.lo src/sbearssl/sbearssl_ec_pkey_to.lo src/sbearssl/sbearssl_ec_skey_from.lo src/sbearssl/sbearssl_ec_skey_to.lo src/sbearssl/sbearssl_error_str.lo src/sbearssl/sbearssl_isder.lo src/sbearssl/sbearssl_pem_decode_from_buffer.lo src/sbearssl/sbearssl_pem_decode_from_string.lo src/sbearssl/sbearssl_pem_push.lo src/sbearssl/sbearssl_pkey_from.lo src/sbearssl/sbearssl_pkey_to.lo src/sbearssl/sbearssl_rsa_pkey_from.lo src/sbearssl/sbearssl_rsa_pkey_to.lo src/sbearssl/sbearssl_rsa_skey_from.lo src/sbearssl/sbearssl_rsa_skey_to.lo src/sbearssl/sbearssl_run.lo src/sbearssl/sbearssl_skey_from.lo src/sbearssl/sbearssl_skey_readfile.lo src/sbearssl/sbearssl_skey_to.lo src/sbearssl/sbearssl_ta_cert.lo src/sbearssl/sbearssl_ta_certs.lo src/sbearssl/sbearssl_ta_from.lo src/sbearssl/sbearssl_ta_readdir.lo src/sbearssl/sbearssl_ta_readfile.lo src/sbearssl/sbearssl_ta_to.lo src/sbearssl/sbearssl_x500_name_len.lo src/sbearssl/sbearssl_x500_from_ta.lo src/sbearssl/sbearssl_x509_minimal_set_tai.lo src/sbearssl/sbearssl_s6tlsc.lo src/sbearssl/sbearssl_s6tlsd.lo
+endif
libsbearssl.so.xyzzy: EXTRA_LIBS := -lbearssl -lskarnet
libsbearssl.so.xyzzy: src/sbearssl/sbearssl_append.lo src/sbearssl/sbearssl_prep_spawn_drop.lo src/sbearssl/sbearssl_cert_from.lo src/sbearssl/sbearssl_cert_readbigpem.lo src/sbearssl/sbearssl_cert_readfile.lo src/sbearssl/sbearssl_cert_to.lo src/sbearssl/sbearssl_ec_issuer_keytype.lo src/sbearssl/sbearssl_ec_pkey_from.lo src/sbearssl/sbearssl_ec_pkey_to.lo src/sbearssl/sbearssl_ec_skey_from.lo src/sbearssl/sbearssl_ec_skey_to.lo src/sbearssl/sbearssl_error_str.lo src/sbearssl/sbearssl_isder.lo src/sbearssl/sbearssl_pem_decode_from_buffer.lo src/sbearssl/sbearssl_pem_decode_from_string.lo src/sbearssl/sbearssl_pem_push.lo src/sbearssl/sbearssl_pkey_from.lo src/sbearssl/sbearssl_pkey_to.lo src/sbearssl/sbearssl_rsa_pkey_from.lo src/sbearssl/sbearssl_rsa_pkey_to.lo src/sbearssl/sbearssl_rsa_skey_from.lo src/sbearssl/sbearssl_rsa_skey_to.lo src/sbearssl/sbearssl_run.lo src/sbearssl/sbearssl_skey_from.lo src/sbearssl/sbearssl_skey_readfile.lo src/sbearssl/sbearssl_skey_to.lo src/sbearssl/sbearssl_ta_cert.lo src/sbearssl/sbearssl_ta_certs.lo src/sbearssl/sbearssl_ta_from.lo src/sbearssl/sbearssl_ta_readdir.lo src/sbearssl/sbearssl_ta_readfile.lo src/sbearssl/sbearssl_ta_to.lo src/sbearssl/sbearssl_x500_name_len.lo src/sbearssl/sbearssl_x500_from_ta.lo src/sbearssl/sbearssl_x509_minimal_set_tai.lo src/sbearssl/sbearssl_s6tlsc.lo src/sbearssl/sbearssl_s6tlsd.lo
+ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)
libstls.a.xyzzy: src/stls/stls_prep_spawn_drop.o src/stls/stls_run.o src/stls/stls_s6tlsc.o src/stls/stls_s6tlsd.o
+else
+libstls.a.xyzzy: src/stls/stls_prep_spawn_drop.lo src/stls/stls_run.lo src/stls/stls_s6tlsc.lo src/stls/stls_s6tlsd.lo
+endif
libstls.so.xyzzy: EXTRA_LIBS := -ltls -lskarnet
libstls.so.xyzzy: src/stls/stls_prep_spawn_drop.lo src/stls/stls_run.lo src/stls/stls_s6tlsc.lo src/stls/stls_s6tlsd.lo
diff --git a/tools/gen-deps.sh b/tools/gen-deps.sh
index 67ec2d4..6383ac2 100755
--- a/tools/gen-deps.sh
+++ b/tools/gen-deps.sh
@@ -65,7 +65,7 @@ for dir in $(ls -1 src | grep -v ^include) ; do
deps="$deps src/$dir/$dep"
fi
done < src/$dir/deps-lib/$file
- echo 'ifeq ($(strip $(DEFAULT_PIE)),)'
+ echo 'ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)'
echo "lib${file}.a.xyzzy:$deps"
echo else
echo "lib${file}.a.xyzzy:$(echo "$deps" | sed 's/\.o/.lo/g')"