summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-10-30 11:09:34 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-10-30 11:09:34 +0000
commit511f24c5b7ebfbf7549b54455948298c47c7e6c2 (patch)
treedc17bfa70edc7991ff837cad09b5c3c24e532730
parentb98b560ad3092f32e8a1e76090799ad843ff38f0 (diff)
downloads6-rc-511f24c5b7ebfbf7549b54455948298c47c7e6c2.tar.xz
Make all-pic a user option
-rw-r--r--Makefile4
-rwxr-xr-xconfigure30
-rw-r--r--package/deps.mak4
-rwxr-xr-xtools/gen-deps.sh2
4 files changed, 28 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 65166e1..63f5d9c 100755
--- a/configure
+++ b/configure
@@ -41,6 +41,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]
@@ -144,6 +145,7 @@ sysdeps='$prefix/lib/skalibs/sysdeps'
manualsysdeps=false
shared=false
static=true
+allpic=detect
slashpackage=false
abspath=false
sproot=
@@ -181,6 +183,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 ;;
@@ -295,14 +299,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)
@@ -417,10 +425,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
exec 1>&3 3>&-
diff --git a/package/deps.mak b/package/deps.mak
index 738d6b8..0cece4a 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -33,7 +33,11 @@ src/s6-rc/s6-rc-oneshot-run.o src/s6-rc/s6-rc-oneshot-run.lo: src/s6-rc/s6-rc-on
src/s6-rc/s6-rc-update.o src/s6-rc/s6-rc-update.lo: src/s6-rc/s6-rc-update.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h
src/s6-rc/s6-rc.o src/s6-rc/s6-rc.lo: src/s6-rc/s6-rc.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h
+ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)
libs6rc.a.xyzzy: src/libs6rc/s6rc_db_check_depcycles.o src/libs6rc/s6rc_db_check_pipelines.o src/libs6rc/s6rc_db_check_revdeps.o src/libs6rc/s6rc_db_read.o src/libs6rc/s6rc_db_read_sizes.o src/libs6rc/s6rc_db_read_uint32.o src/libs6rc/s6rc_graph_closure.o src/libs6rc/s6rc_livedir_prefix.o src/libs6rc/s6rc_livedir_prefixsize.o src/libs6rc/s6rc_lock.o src/libs6rc/s6rc_read_uint.o src/libs6rc/s6rc_sanitize_dir.o src/libs6rc/s6rc_servicedir_internal.o src/libs6rc/s6rc_servicedir_block.o src/libs6rc/s6rc_servicedir_unblock.o src/libs6rc/s6rc_servicedir_copy_offline.o src/libs6rc/s6rc_servicedir_copy_online.o src/libs6rc/s6rc_servicedir_manage.o src/libs6rc/s6rc_servicedir_unsupervise.o
+else
+libs6rc.a.xyzzy: src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_livedir_prefix.lo src/libs6rc/s6rc_livedir_prefixsize.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo src/libs6rc/s6rc_servicedir_manage.lo src/libs6rc/s6rc_servicedir_unsupervise.lo
+endif
libs6rc.so.xyzzy: EXTRA_LIBS := -ls6 -lskarnet
libs6rc.so.xyzzy: src/libs6rc/s6rc_db_check_depcycles.lo src/libs6rc/s6rc_db_check_pipelines.lo src/libs6rc/s6rc_db_check_revdeps.lo src/libs6rc/s6rc_db_read.lo src/libs6rc/s6rc_db_read_sizes.lo src/libs6rc/s6rc_db_read_uint32.lo src/libs6rc/s6rc_graph_closure.lo src/libs6rc/s6rc_livedir_prefix.lo src/libs6rc/s6rc_livedir_prefixsize.lo src/libs6rc/s6rc_lock.lo src/libs6rc/s6rc_read_uint.lo src/libs6rc/s6rc_sanitize_dir.lo src/libs6rc/s6rc_servicedir_internal.lo src/libs6rc/s6rc_servicedir_block.lo src/libs6rc/s6rc_servicedir_unblock.lo src/libs6rc/s6rc_servicedir_copy_offline.lo src/libs6rc/s6rc_servicedir_copy_online.lo src/libs6rc/s6rc_servicedir_manage.lo src/libs6rc/s6rc_servicedir_unsupervise.lo
s6-rc: EXTRA_LIBS := ${TAINNOW_LIB} ${SPAWN_LIB}
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')"