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: rm_try \
20 Getfile Myread test osname sed i_dld d_dlopen Findhdr Setvar src run \
21 cc ccflags ldflags optimize ls gccversion cat rsrc i_stdlib i_unistd
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|nonstopux) dflt='-KPIC' ;;
133 sunos) dflt='-pic' ;;
138 darwin) dflt='none' ;;
139 linux*|svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;;
144 *) dflt="$cccdlflags" ;;
146 rp="Any special flags to pass to $cc -c to compile shared library modules?"
149 ?X: Use ' ' so that a subsequent Configure run preserves the old state.
150 none) cccdlflags=' ' ;;
151 *) cccdlflags="$ans" ;;
156 Some systems use ld to create libraries that can be dynamically loaded,
157 while other systems (such as those using ELF) use $cc.
161 '') $cat >try.c <<EOM
162 /* Test for whether ELF binaries are produced */
174 int i = open("a.out",O_RDONLY);
177 if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
178 exit(0); /* succeed (yes, it's ELF) */
183 if $cc $ccflags $ldflags try.c >/dev/null 2>&1 && $run ./a.out; then
185 You appear to have ELF support. I'll use $cc to build dynamic libraries.
189 echo "I'll use ld to build dynamic libraries."
198 rp="What command should be used to create dynamic libraries?"
204 Some systems may require passing special flags to $ld to create a
205 library that can be dynamically loaded. If your ld flags include
206 -L/other/path options to locate libraries outside your loader's normal
207 search path, you may need to specify those -L options here as well. To
208 use no flags, say "none".
212 '') case "$osname" in
213 beos) dflt='-nostart' ;;
215 case "$gccversion" in
216 '') dflt="$dflt +vnocompatwarnings" ;;
219 linux|irix*|gnu*) dflt="-shared $optimize" ;;
221 solaris) dflt='-G' ;;
222 sunos) dflt='-assert nodefinitions' ;;
223 svr4*|esix*|nonstopux) dflt="-G $ldflags" ;;
227 *) dflt="$lddlflags" ;;
230 : Try to guess additional flags to pick up local libraries.
231 : Be careful not to append to a plain 'none'
235 for thisflag in $ldflags; do
240 *) dflt="$dflt $thisflag" ;;
247 ''|' ') dflt='none' ;;
250 rp="Any special flags to pass to $ld to create a dynamically loaded library?"
253 ?X: Use ' ' so that a subsequent Configure run preserves the old state.
254 none) lddlflags=' ' ;;
255 *) lddlflags="$ans" ;;
260 Some systems may require passing special flags to $cc to indicate that
261 the resulting executable will use dynamic linking. To use no flags,
266 '') case "$osname" in
267 linux|hpux|gnu*) dflt='-Wl,-E' ;;
268 next|sunos) dflt='none' ;;
272 *) dflt="$ccdlflags" ;;
274 rp="Any special flags to pass to $cc to use dynamic linking?"
277 ?X: Use ' ' so that a subsequent Configure run preserves the old state.
278 none) ccdlflags=' ' ;;
279 *) ccdlflags="$ans" ;;
282 ?X: End of usedl=y section