aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2004-12-02 05:22:49 +0000
committerMike Frysinger <vapier@gentoo.org>2004-12-02 05:22:49 +0000
commitc519aea6404bd3dc7021fd7f994440e6744a2ee6 (patch)
tree1951ba9d78bcdd9b41d330d2e972c8f71b8abcde
parentneed to include config.h (diff)
downloadsandbox-c519aea6404bd3dc7021fd7f994440e6744a2ee6.tar.gz
sandbox-c519aea6404bd3dc7021fd7f994440e6744a2ee6.tar.bz2
sandbox-c519aea6404bd3dc7021fd7f994440e6744a2ee6.zip
turn create-localdecls into semi-autotooled
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--Makefile.am6
-rwxr-xr-xclean.sh2
-rw-r--r--configure.in23
-rwxr-xr-xcreate-localdecls115
-rw-r--r--libctest.c8
-rw-r--r--localdecls.h43
6 files changed, 69 insertions, 128 deletions
diff --git a/Makefile.am b/Makefile.am
index c06ddae..1b8776a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip
dist_pkgdata_DATA = sandbox.bashrc
EXTRA_DIST = sandbox.bashrc canonicalize.c create-localdecls libctest.c
-AM_CFLAGS = -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT
+AM_CFLAGS = -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT -DLIBC_VERSION=\"$(LIBC_VERSION)\"
lib_LTLIBRARIES = libsandbox.la
libsandbox_la_SOURCES = libsandbox.c sandbox_futils.c localdecls.h
@@ -13,7 +13,3 @@ libsandbox_la_CFLAGS = -Wc,-nostdlib -D_REENTRANT -D_GNU_SOURCE \
bin_PROGRAMS = sandbox
sandbox_SOURCES = sandbox.c sandbox.h sandbox_futils.c getcwd.c
sandbox_CFLAGS = -DSANDBOX_BASHRC_PATH=\"$(pkgdatadir)\" -DLIBSANDBOX_PATH=\"$(libdir)\"
-
-BUILT_SOURCES = localdecls.h
-localdecls.h: Makefile
- ./create-localdecls
diff --git a/clean.sh b/clean.sh
index 0d81b3a..01e136f 100755
--- a/clean.sh
+++ b/clean.sh
@@ -7,7 +7,7 @@ for f in \
aclocal.m4* autom4te.cache \
configure config.* \
depcomp install-sh ltmain.sh missing mkinstalldirs libtool \
- compile sandbox stamp-* localdecls.h ;
+ compile sandbox stamp-* ;
do
rm -rf $f
done
diff --git a/configure.in b/configure.in
index 9cef713..3d69967 100644
--- a/configure.in
+++ b/configure.in
@@ -45,4 +45,27 @@ rmdir setenv strcasecmp strchr strdup \
strerror strndup strrchr strspn strstr \
])
+dnl
+dnl FIXME: the following needs to be made portable
+dnl
+
+dnl when using libc5, (f)trucate's offset argument type is size_t with
+dnl libc5, but it's off_t with libc6 (glibc2).
+AC_MSG_CHECKING(truncate argument type)
+if grep -q 'truncate.*size_t' /usr/include/unistd.h ; then
+ AC_MSG_RESULT(size_t)
+ AC_DEFINE(TRUNCATE_T, size_t, [truncate arg type])
+else
+ AC_MSG_RESULT(off_t)
+ AC_DEFINE(TRUNCATE_T, off_t, [truncate arg type])
+fi
+
+AC_MSG_CHECKING(Checking libc version)
+echo "int main(void) { return 0; }" > libctest.c
+gcc -Wall -o libctest libctest.c
+LIBC_VERSION=`ldd libctest | grep libc\\.so | grep -v 'ld-uClibc' | awk '{print $1}'`
+rm -f libctest
+AC_SUBST(LIBC_VERSION)
+AC_MSG_RESULT(${LIBC_VERSION})
+
AC_OUTPUT([Makefile])
diff --git a/create-localdecls b/create-localdecls
deleted file mode 100755
index acc3f15..0000000
--- a/create-localdecls
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/bin/sh
-
-# This is a quick'n'dirty hack to make the program behave correctly
-# under different systems.
-# Example:
-# when using libc5, (f)trucate's offset argument type is size_t with
-# libc5, but it's off_t with libc6 (glibc2).
-#
-# Uhm... time to learn GNU autoconf :-)
-#
-# $Header$
-
-OUTFILE='localdecls.h'
-
-# if your arch needs to dlopen() glibc, add it here separated by space :]
-BROKEN_RTLD_ARCHLIST="mips"
-
-echo '/* This file is automatically generated *' > $OUTFILE
-echo ' * Modify create-localdecls instead of this */' >> $OUTFILE
-echo >> $OUTFILE
-echo '#ifndef __LOCALDECLS_H_' >> $OUTFILE
-echo '#define __LOCALDECLS_H_' >> $OUTFILE
-echo >> $OUTFILE
-
-###
-###
-###
-
-echo -n 'Checking truncate argument type... '
-if grep -q 'truncate.*size_t' /usr/include/unistd.h ; then
- echo 'size_t'
- echo '#define TRUNCATE_T size_t' >> $OUTFILE
-else
- echo 'off_t' # At least, I HOPE it's off_t :-)
- echo '#define TRUNCATE_T off_t' >> $OUTFILE
-fi
-
-###
-###
-###
-
-echo -n 'Checking libc version... '
-gcc -Wall -o libctest libctest.c
-VERSION=`ldd libctest | grep libc\\.so | grep -v 'ld-uClibc' | awk '{print $1}'`
-
-echo $VERSION
-echo "#define LIBC_VERSION \"$VERSION\"" >> $OUTFILE
-if test "$VERSION" = 'libc.so.5' ; then
- echo '#define BROKEN_RTLD_NEXT' >> $OUTFILE
- echo '#define LIBC 5' >> $OUTFILE
-else
- # for the arch's that need to dlopen() libc to fetch real funcs!
- # 16.12.02 -Torgeir Hansen <torgeir@trenger.ro>
- MYARCH=`/bin/uname -m`
- for x in $BROKEN_RTLD_ARCHLIST; do
- if [ $x = $MYARCH ]; then
- echo '#define BROKEN_RTLD_NEXT' >> $OUTFILE
- fi
- done
-
-fi
-
-if test "$VERSION" = 'libc.so.6' ; then
- echo -n 'Checking glibc subversion...'
- tmp="$(ldd libctest 2>/dev/null | grep libc.so 2>/dev/null | head -n 1)"
- LibcPath=`expr "$tmp" : '[^/]*\(/[^ ]*\)'`
- tmp="`strings $LibcPath | grep -i 'c library'`"
- OsLibcMajor=`expr "$tmp" : '.* \([0-9][0-9]*\)'`
- OsLibcMinor=`expr "$tmp" : '.* [0-9][0-9]*\.\([0-9][0-9]*\)'`
- echo " ${OsLibcMajor}.${OsLibcMinor}"
- case "$OsLibcMajor" in
- 2)
- # 2 is the glibc version
- case "$OsLibcMinor" in
- 0)
- echo '#define GLIBC_MINOR 0' >> $OUTFILE
- SUBVERSION='glibc-2.0' ;;
- 1)
- echo '#define GLIBC_MINOR 1' >> $OUTFILE
- SUBVERSION='glibc-2.1' ;;
- 2)
- echo '#define GLIBC_MINOR 2' >> $OUTFILE
- SUBVERSION='glibc-2.2' ;;
- 3)
- echo '#define GLIBC_MINOR 3' >> $OUTFILE
- SUBVERSION='glibc-2.3' ;;
- *)
- echo 'Treated as glibc >= 2.1 (finger crossed)'
- echo '#define GLIBC_MINOR 1' >> $OUTFILE
- SUBVERSION='glibc-2.1' ;;
- esac
- ;;
- esac
-fi
-
-rm libctest
-
-echo '
-#ifdef PATH_MAX
-# define SB_PATH_MAX PATH_MAX * 2
-# if (SB_PATH_MAX >= INT_MAX) || (SB_PATH_MAX < PATH_MAX)
-# undef SB_PATH_MAX
-# define SB_PATH_MAX PATH_MAX + 25
-# if (SB_PATH_MAX >= INT_MAX) || (SB_PATH_MAX < PATH_MAX)
-# error SB_PATH_MAX too big!
-# endif
-# endif
-#else
-# error PATH_MAX not defined!
-#endif' >> $OUTFILE
-
-echo >> $OUTFILE
-echo '#endif' >> $OUTFILE
-echo
-
diff --git a/libctest.c b/libctest.c
index 5365a20..78f2de1 100644
--- a/libctest.c
+++ b/libctest.c
@@ -1,7 +1 @@
-/* Dummy program to check your libc version */
-
-int
-main(void)
-{
- return 0;
-}
+int main(void) { return 0; }
diff --git a/localdecls.h b/localdecls.h
new file mode 100644
index 0000000..0a27b50
--- /dev/null
+++ b/localdecls.h
@@ -0,0 +1,43 @@
+/*
+ * File: localdecls.h
+ *
+ * Copyright 1999-2004 Gentoo Foundation
+ * Distributed under the terms of the GNU General Public License v2
+ * $Header$
+ */
+
+#ifndef __LOCALDECLS_H__
+#define __LOCALDECLS_H__
+
+/* take care of broken ld loading */
+#if defined(__GLIBC__)
+
+# if __GLIBC__ <= 2 && __GLIBC_MINOR__ <= 2
+# define BROKEN_RTLD_NEXT
+# define LIBC 5
+# endif
+
+# if !defined(BROKEN_RTLD_NEXT)
+# if defined(__mips__)
+# define BROKEN_RTLD_NEXT
+# endif
+# endif
+
+#endif
+
+#define GLIBC_MINOR __GLIBC_MINOR__
+
+#ifdef PATH_MAX
+# define SB_PATH_MAX PATH_MAX * 2
+# if (SB_PATH_MAX >= INT_MAX) || (SB_PATH_MAX < PATH_MAX)
+# undef SB_PATH_MAX
+# define SB_PATH_MAX PATH_MAX + 25
+# if (SB_PATH_MAX >= INT_MAX) || (SB_PATH_MAX < PATH_MAX)
+# error SB_PATH_MAX too big!
+# endif
+# endif
+#else
+# error PATH_MAX not defined!
+#endif
+
+#endif