Blame SOURCES/dlopen.sh

73cfcf
#!/bin/sh
73cfcf
73cfcf
tempdir=`mktemp -d /tmp/dlopenXXXXXX`
73cfcf
test -n "$tempdir" || exit 1
73cfcf
cat >> $tempdir/dlopen.c << _EOF
73cfcf
#include <dlfcn.h>
73cfcf
#include <stdio.h>
73cfcf
#include <limits.h>
73cfcf
#include <sys/stat.h>
73cfcf
/* Simple program to see if dlopen() would succeed. */
73cfcf
int main(int argc, char **argv)
73cfcf
{
73cfcf
	int i;
73cfcf
	struct stat st;
73cfcf
	char buf[PATH_MAX];
73cfcf
	for (i = 1; i < argc; i++) {
73cfcf
		if (dlopen(argv[i], RTLD_NOW)) {
73cfcf
			fprintf(stdout, "dlopen() of \"%s\" succeeded.\n",
73cfcf
				argv[i]);
73cfcf
		} else {
73cfcf
			snprintf(buf, sizeof(buf), "./%s", argv[i]);
73cfcf
			if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) {
73cfcf
				fprintf(stdout, "dlopen() of \"./%s\" "
73cfcf
					"succeeded.\n", argv[i]);
73cfcf
			} else {
73cfcf
				fprintf(stdout, "dlopen() of \"%s\" failed: "
73cfcf
					"%s\n", argv[i], dlerror());
73cfcf
				return 1;
73cfcf
			}
73cfcf
		}
73cfcf
	}
73cfcf
	return 0;
73cfcf
}
73cfcf
_EOF
73cfcf
73cfcf
for arg in $@ ; do
73cfcf
	case "$arg" in
73cfcf
	"")
73cfcf
		;;
73cfcf
	-I*|-D*|-f*|-m*|-g*|-O*|-W*)
73cfcf
		cflags="$cflags $arg"
73cfcf
		;;
73cfcf
	-l*|-L*)
73cfcf
		ldflags="$ldflags $arg"
73cfcf
		;;
73cfcf
	/*)
73cfcf
		modules="$modules $arg"
73cfcf
		;;
73cfcf
	*)
73cfcf
		modules="$modules $arg"
73cfcf
		;;
73cfcf
	esac
73cfcf
done
73cfcf
73cfcf
${CC:-gcc} $RPM_OPT_FLAGS $CFLAGS -o $tempdir/dlopen $cflags $tempdir/dlopen.c $ldflags -ldl
73cfcf
73cfcf
retval=0
73cfcf
for module in $modules ; do
73cfcf
	case "$module" in
73cfcf
	"")
73cfcf
		;;
73cfcf
	/*)
73cfcf
		$tempdir/dlopen "$module"
73cfcf
		retval=$?
73cfcf
		;;
73cfcf
	*)
73cfcf
		$tempdir/dlopen ./"$module"
73cfcf
		retval=$?
73cfcf
		;;
73cfcf
	esac
73cfcf
done
73cfcf
73cfcf
rm -f $tempdir/dlopen $tempdir/dlopen.c
73cfcf
rmdir $tempdir
73cfcf
exit $retval