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, see <http://www.gnu.org/licenses/>.
18 tempdir
=`mktemp -d /tmp/dlopenXXXXXX`
19 test -n "$tempdir" ||
exit 1
20 cat >> $tempdir/dlopen.c
<< _EOF
25 /* Simple program to see if dlopen() would succeed. */
26 int main(int argc, char **argv)
31 for (i = 1; i < argc; i++) {
32 if (dlopen(argv[i], RTLD_NOW)) {
33 fprintf(stdout, "dlopen() of \"%s\" succeeded.\n",
36 snprintf(buf, sizeof(buf), "./%s", argv[i]);
37 if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) {
38 fprintf(stdout, "dlopen() of \"./%s\" "
39 "succeeded.\n", argv[i]);
41 fprintf(stdout, "dlopen() of \"%s\" failed: "
42 "%s\n", argv[i], dlerror());
55 -I*|
-D*|
-f*|
-m*|
-g*|
-O*|
-W*)
59 ldflags
="$ldflags $arg"
62 modules
="$modules $arg"
65 modules
="$modules $arg"
70 ${CC:-gcc} $RPM_OPT_FLAGS $CFLAGS -o $tempdir/dlopen
$cflags $tempdir/dlopen.c
$ldflags
73 for module
in $modules ; do
78 $tempdir/dlopen
"$module"
82 $tempdir/dlopen .
/"$module"
88 rm -f $tempdir/dlopen
$tempdir/dlopen.c