diff -Naur rrdtool-1.3.0/configure.ac rrdtool-1.3.0.oden/configure.ac --- rrdtool-1.3.0/configure.ac 2008-06-10 12:38:10.000000000 -0400 +++ rrdtool-1.3.0.oden/configure.ac 2008-06-11 14:03:45.000000000 -0400 @@ -399,6 +399,34 @@ +dnl AC_LIBTOOL_NON_PIC ([ACTION-IF-WORKS], [ACTION-IF-FAILS]) +dnl check for nonbuggy libtool -prefer-non-pic +AC_DEFUN([AC_LIBTOOL_NON_PIC], + [AC_MSG_CHECKING([if libtool supports -prefer-non-pic flag]) + mkdir ac_test_libtool; cd ac_test_libtool; ac_cv_libtool_non_pic=no + echo "int x; int g (int i, int *p); int f (int i) {return g (i, &x);}" >f.c + echo "int x = 0; int (* hook) (int) = 0; int g (int i, int *p) {if (hook) i = hook (i); return i + 1;}" >g.c + ../libtool --mode=compile $CC $CFLAGS -prefer-non-pic \ + -c f.c >/dev/null 2>&1 && \ + ../libtool --mode=compile $CC $CFLAGS -prefer-non-pic \ + -c g.c >/dev/null 2>&1 && \ + ../libtool --mode=link $CC $CFLAGS -prefer-non-pic -o libfoo.la \ + -rpath / f.lo g.lo >/dev/null 2>&1 && + ac_cv_libtool_non_pic=yes + cd ..; rm -fr ac_test_libtool; AC_MSG_RESULT([$ac_cv_libtool_non_pic]) + if test x"$ac_cv_libtool_non_pic" = x"yes"; then + ifelse([$1],[],[:],[$1]) + else + ifelse([$2],[],[:],[$2]) + fi]) + +dnl Add -fPIC if the target OS does not support linking static library into DSO without PIC +AC_LIBTOOL_NON_PIC +if [[ x"$ac_cv_libtool_non_pic" = x"no" ]]; then + DSO_PIC_FLAGS="-fPIC -DPIC" +fi +AC_SUBST(DSO_PIC_FLAGS) + dnl add pic flag in any case this makes sure all our code is relocatable eval `./libtool --config | grep pic_flag` CFLAGS="$CFLAGS $pic_flag" diff -Naur rrdtool-1.3.0/src/Makefile.am rrdtool-1.3.0.oden/src/Makefile.am --- rrdtool-1.3.0/src/Makefile.am 2008-06-10 12:32:34.000000000 -0400 +++ rrdtool-1.3.0.oden/src/Makefile.am 2008-06-11 14:04:40.000000000 -0400 @@ -9,6 +9,10 @@ AM_LDFLAGS = -all-static endif +# We need -fPIC for the static library as it is to be linked into a DSO +DSO_PIC_FLAGS = @DSO_PIC_FLAGS@ +CFLAGS += $(DSO_PIC_FLAGS) + INCLUDES = -DLOCALEDIR="\"$(datadir)/locale\"" RRD_DEFAULT_FONT=@RRD_DEFAULT_FONT@ AM_CPPFLAGS = -DRRD_DEFAULT_FONT=\"$(RRD_DEFAULT_FONT)\" -DNUMVERS=@NUMVERS@