3 # Copyright (C) Nalin Dahyabhai <nalin@redhat.com> 2003
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 tempdir=`mktemp -d /tmp/dlopenXXXXXX`
20 test -n "$tempdir" || exit 1
21 cat >> $tempdir/dlopen.c << _EOF
26 /* Simple program to see if dlopen() would succeed. */
27 int main(int argc, char **argv)
32 for (i = 1; i < argc; i++) {
33 if (dlopen(argv[i], RTLD_NOW)) {
34 fprintf(stdout, "dlopen() of \"%s\" succeeded.\n",
37 snprintf(buf, sizeof(buf), "./%s", argv[i]);
38 if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) {
39 fprintf(stdout, "dlopen() of \"./%s\" "
40 "succeeded.\n", argv[i]);
42 fprintf(stdout, "dlopen() of \"%s\" failed: "
43 "%s\n", argv[i], dlerror());
56 -I*|-D*|-f*|-m*|-g*|-O*|-W*)
60 ldflags="$ldflags $arg"
63 modules="$modules $arg"
66 modules="$modules $arg"
71 ${CC:-gcc} $RPM_OPT_FLAGS $CFLAGS -o $tempdir/dlopen $cflags $tempdir/dlopen.c $ldflags -ldl
74 for module in $modules ; do
79 $tempdir/dlopen "$module"
83 $tempdir/dlopen ./"$module"
89 rm -f $tempdir/dlopen $tempdir/dlopen.c