?RCS: $Id: dlsrc.U,v$ ?RCS: ?RCS: Copyright (c) 1996-1998, Andy Dougherty ?RCS: ?RCS: You may distribute under the terms of either the GNU General Public ?RCS: License or the Artistic License, as specified in the README file. ?RCS: ?RCS: $Log: dlsrc.U,v $ ?RCS: ?X: hpux support thanks to Jeff Okamoto ?X: ?X: To create a shared library, you must compile ALL source files in the ?X: library with +z (or possibly +Z if the library is whopping huge), ?X: then link the library with -b. Example: ?X: cc -c +z module_a.c ?X: cc -c +z module_b.c ?X: ld -b module_a.o module_b.o -o module.sl ?X: ?MAKE:usedl ld dlsrc cccdlflags lddlflags ccdlflags: rm_try \ Getfile Myread test osname sed i_dld d_dlopen Findhdr Setvar src run \ cc ccflags ldflags optimize ls gccversion cat rsrc i_stdlib i_unistd ?MAKE: -pick add $@ %< ?Y:BOTTOM ?S:usedl: ?S: This variable indicates if the system supports dynamic ?S: loading of some sort. See also dlsrc and dlobj. ?S:. ?S:ld: ?S: This variable indicates the program to be used to link ?S: libraries for dynamic loading. On some systems, it is 'ld'. ?S: On ELF systems, it should be $cc. Mostly, we'll try to respect ?S: the hint file setting. ?S:. ?S:dlsrc: ?S: This variable contains the name of the dynamic loading file that ?S: will be used with the package. ?S:. ?S:cccdlflags: ?S: This variable contains any special flags that might need to be ?S: passed with 'cc -c' to compile modules to be used to create a shared ?S: library that will be used for dynamic loading. For hpux, this ?S: should be +z. It is up to the makefile to use it. ?S:. ?S:lddlflags: ?S: This variable contains any special flags that might need to be ?S: passed to $ld to create a shared library suitable for dynamic ?S: loading. It is up to the makefile to use it. For hpux, it ?S: should be '-b'. For sunos 4.1, it is empty. ?S:. ?S:ccdlflags: ?S: This variable contains any special flags that might need to be ?S: passed to cc to link with a shared library for dynamic loading. ?S: It is up to the makefile to use it. For sunos 4.1, it should ?S: be empty. ?S:. ?C:USE_DYNAMIC_LOADING ~ %<: ?C: This symbol, if defined, indicates that dynamic loading of ?C: some sort is available. ?C:. ?H:?%<:#$usedl USE_DYNAMIC_LOADING /**/ ?H:. ?W:%<:dlopen ?T:dldir thisflag tdir ?F:!a.out : determine which dynamic loading, if any, to compile in echo " " dldir="ext/DynaLoader" case "$usedl" in $define|y|true) dflt='y' usedl="$define" ;; $undef|n|false) dflt='n' usedl="$undef" ;; *) dflt='n' case "$d_dlopen" in $define) dflt='y' ;; esac case "$i_dld" in $define) dflt='y' ;; esac : Does a dl_xxx.xs file exist for this operating system $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y' ;; esac rp="Do you wish to use dynamic loading?" . ./myread usedl="$ans" case "$ans" in y*) usedl="$define" case "$dlsrc" in '') if $test -f $rsrc/$dldir/dl_${osname}.xs ; then dflt="$dldir/dl_${osname}.xs" elif $test "$d_dlopen" = "$define" ; then dflt="$dldir/dl_dlopen.xs" elif $test "$i_dld" = "$define" ; then dflt="$dldir/dl_dld.xs" else dflt='' fi ;; *) dflt="$dldir/$dlsrc" ;; esac echo "The following dynamic loading files are available:" : Can not go over to $dldir because getfile has path hard-coded in. tdir=`pwd`; cd "$rsrc"; $ls -C $dldir/dl*.xs; cd "$tdir" rp="Source file to use for dynamic loading" fn="fne" gfpth="$src" . ./getfile usedl="$define" : emulate basename dlsrc=`echo $ans | $sed -e 's%.*/\([^/]*\)$%\1%'` $cat << EOM Some systems may require passing special flags to $cc -c to compile modules that will be used to create a shared library. To use no flags, say "none". EOM case "$cccdlflags" in '') case "$gccversion" in '') case "$osname" in hpux) dflt='+z' ;; next) dflt='none' ;; irix*) dflt='-KPIC' ;; svr4*|esix*|solaris|nonstopux) dflt='-KPIC' ;; sunos) dflt='-pic' ;; *) dflt='none' ;; esac ;; *) case "$osname" in darwin) dflt='none' ;; linux*|svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;; *) dflt='-fpic' ;; esac ;; esac ;; ' ') dflt='none' ;; *) dflt="$cccdlflags" ;; esac rp="Any special flags to pass to $cc -c to compile shared library modules?" . ./myread case "$ans" in ?X: Use ' ' so that a subsequent Configure run preserves the old state. none) cccdlflags=' ' ;; *) cccdlflags="$ans" ;; esac cat << EOM Some systems use ld to create libraries that can be dynamically loaded, while other systems (such as those using ELF) use $cc. EOM case "$ld" in '') $cat >try.c < #$i_stdlib I_STDLIB #ifdef I_STDLIB #include #endif #$i_unistd I_UNISTD #ifdef I_UNISTD #include #endif int main() { char b[4]; int i = open("a.out",O_RDONLY); if(i == -1) exit(1); /* fail */ if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F') exit(0); /* succeed (yes, it's ELF) */ else exit(1); /* fail */ } EOM if $cc $ccflags $ldflags try.c >/dev/null 2>&1 && $run ./a.out; then cat <