3 ?RCS: Copyright (c) 1996-1998, Andy Dougherty
5 ?RCS: You may distribute under the terms of either the GNU General Public
6 ?RCS: License or the Artistic License, as specified in the README file.
8 ?RCS: $Log: dlsrc.U,v $
10 ?X: hpux support thanks to Jeff Okamoto <okamoto@hpcc101.corp.hp.com>
12 ?X: To create a shared library, you must compile ALL source files in the
13 ?X: library with +z (or possibly +Z if the library is whopping huge),
14 ?X: then link the library with -b. Example:
15 ?X: cc -c +z module_a.c
16 ?X: cc -c +z module_b.c
17 ?X: ld -b module_a.o module_b.o -o module.sl
19 ?MAKE:usedl ld dlsrc cccdlflags lddlflags ccdlflags: \
20 Getfile Myread test osname sed i_dld d_dlopen Findhdr Setvar \
21 cc ccflags ldflags ls gccversion cat rsrc src
22 ?MAKE: -pick add $@ %<
25 ?S: This variable indicates if the system supports dynamic
26 ?S: loading of some sort. See also dlsrc and dlobj.
29 ?S: This variable indicates the program to be used to link
30 ?S: libraries for dynamic loading. On some systems, it is 'ld'.
31 ?S: On ELF systems, it should be $cc. Mostly, we'll try to respect
32 ?S: the hint file setting.
35 ?S: This variable contains the name of the dynamic loading file that
36 ?S: will be used with the package.
39 ?S: This variable contains any special flags that might need to be
40 ?S: passed with 'cc -c' to compile modules to be used to create a shared
41 ?S: library that will be used for dynamic loading. For hpux, this
42 ?S: should be +z. It is up to the makefile to use it.
45 ?S: This variable contains any special flags that might need to be
46 ?S: passed to $ld to create a shared library suitable for dynamic
47 ?S: loading. It is up to the makefile to use it. For hpux, it
48 ?S: should be '-b'. For sunos 4.1, it is empty.
51 ?S: This variable contains any special flags that might need to be
52 ?S: passed to cc to link with a shared library for dynamic loading.
53 ?S: It is up to the makefile to use it. For sunos 4.1, it should
56 ?C:USE_DYNAMIC_LOADING ~ %<:
57 ?C: This symbol, if defined, indicates that dynamic loading of
58 ?C: some sort is available.
60 ?H:?%<:#$usedl USE_DYNAMIC_LOADING /**/
63 ?T:dldir thisflag tdir
64 : determine which dynamic loading, if any, to compile in
66 dldir="ext/DynaLoader"
84 : Does a dl_xxx.xs file exist for this operating system
85 $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
88 rp="Do you wish to use dynamic loading?"
95 if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
96 dflt="$dldir/dl_${osname}.xs"
97 elif $test "$d_dlopen" = "$define" ; then
98 dflt="$dldir/dl_dlopen.xs"
99 elif $test "$i_dld" = "$define" ; then
100 dflt="$dldir/dl_dld.xs"
105 *) dflt="$dldir/$dlsrc"
108 echo "The following dynamic loading files are available:"
109 : Can not go over to $dldir because getfile has path hard-coded in.
110 tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir
111 rp="Source file to use for dynamic loading"
117 dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
121 Some systems may require passing special flags to $cc -c to
122 compile modules that will be used to create a shared library.
123 To use no flags, say "none".
126 case "$cccdlflags" in
127 '') case "$gccversion" in
128 '') case "$osname" in
131 irix*) dflt='-KPIC' ;;
132 svr4*|esix*|solaris) dflt='-KPIC' ;;
133 sunos) dflt='-pic' ;;
138 svr4*|esix*|solaris) dflt='-fPIC' ;;
143 *) dflt="$cccdlflags" ;;
145 rp="Any special flags to pass to $cc -c to compile shared library modules?"
148 ?X: Use ' ' so that a subsequent Configure run preserves the old state.
149 none) cccdlflags=' ' ;;
150 *) cccdlflags="$ans" ;;
155 Some systems use ld to create libraries that can be dynamically loaded,
156 while other systems (such as those using ELF) use $cc.
160 '') $cat >try.c <<'EOM'
161 /* Test for whether ELF binaries are produced */
166 int i = open("a.out",O_RDONLY);
169 if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
170 exit(0); /* succeed (yes, it's ELF) */
175 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
177 You appear to have ELF support. I'll use $cc to build dynamic libraries.
181 echo "I'll use ld to build dynamic libraries."
190 rp="What command should be used to create dynamic libraries?"
196 Some systems may require passing special flags to $ld to create a
197 library that can be dynamically loaded. If your ld flags include
198 -L/other/path options to locate libraries outside your loader's normal
199 search path, you may need to specify those -L options here as well. To
200 use no flags, say "none".
204 '') case "$osname" in
205 beos) dflt='-nostart' ;;
206 hpux) dflt='-b +vnocompatwarnings' ;;
207 linux|irix*) dflt='-shared' ;;
209 solaris) dflt='-G' ;;
210 sunos) dflt='-assert nodefinitions' ;;
211 svr4*|esix*) dflt="-G $ldflags" ;;
215 *) dflt="$lddlflags" ;;
218 : Try to guess additional flags to pick up local libraries.
219 : Be careful not to append to a plain 'none'
223 for thisflag in $ldflags; do
228 *) dflt="$dflt $thisflag" ;;
235 ''|' ') dflt='none' ;;
238 rp="Any special flags to pass to $ld to create a dynamically loaded library?"
241 ?X: Use ' ' so that a subsequent Configure run preserves the old state.
242 none) lddlflags=' ' ;;
243 *) lddlflags="$ans" ;;
248 Some systems may require passing special flags to $cc to indicate that
249 the resulting executable will use dynamic linking. To use no flags,
254 '') case "$osname" in
255 hpux) dflt='-Wl,-E' ;;
256 linux) dflt='-rdynamic' ;;
258 sunos) dflt='none' ;;
262 *) dflt="$ccdlflags" ;;
264 rp="Any special flags to pass to $cc to use dynamic linking?"
267 ?X: Use ' ' so that a subsequent Configure run preserves the old state.
268 none) ccdlflags=' ' ;;
269 *) ccdlflags="$ans" ;;
272 ?X: End of usedl=y section