s3: Lift the server_messaging_context from notify_job_status
[Samba/gbeck.git] / source3 / script / tests / dlopen.sh
blob6412bc5fcd42968e7509d8938ce2be0470a74654
1 #!/bin/sh
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
21 #include <dlfcn.h>
22 #include <stdio.h>
23 #include <limits.h>
24 #include <sys/stat.h>
25 /* Simple program to see if dlopen() would succeed. */
26 int main(int argc, char **argv)
28 int i;
29 struct stat st;
30 char buf[PATH_MAX];
31 for (i = 1; i < argc; i++) {
32 if (dlopen(argv[i], RTLD_NOW)) {
33 fprintf(stdout, "dlopen() of \"%s\" succeeded.\n",
34 argv[i]);
35 } else {
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]);
40 } else {
41 fprintf(stdout, "dlopen() of \"%s\" failed: "
42 "%s\n", argv[i], dlerror());
43 return 1;
47 return 0;
49 _EOF
51 for arg in $@ ; do
52 case "$arg" in
53 "")
55 -I*|-D*|-f*|-m*|-g*|-O*|-W*)
56 cflags="$cflags $arg"
58 -l*|-L*)
59 ldflags="$ldflags $arg"
61 /*)
62 modules="$modules $arg"
65 modules="$modules $arg"
67 esac
68 done
70 ${CC:-gcc} $RPM_OPT_FLAGS $CFLAGS -o $tempdir/dlopen $cflags $tempdir/dlopen.c $ldflags
72 retval=0
73 for module in $modules ; do
74 case "$module" in
75 "")
77 /*)
78 $tempdir/dlopen "$module"
79 retval=$?
82 $tempdir/dlopen ./"$module"
83 retval=$?
85 esac
86 done
88 rm -f $tempdir/dlopen $tempdir/dlopen.c
89 rmdir $tempdir
90 exit $retval