summaryrefslogtreecommitdiff
path: root/U/dlsrc.U
blob: 616818d346bdb8b7d4f7ea38431c34fd3a3b65fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
?RCS: $Id: dlsrc.U,v$
?RCS:
?RCS: You may redistribute only under the terms of the Artistic Licence,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic Licence; a copy of which may be found at the root
?RCS: of the source tree for dist 3.0.
?RCS:
?RCS: $Log: dlsrc.U,v $
?RCS:
?X:  hpux support thanks to Jeff Okamoto <okamoto@hpcc101.corp.hp.com>
?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 dlsrc dlobj dldir cccdlflags lddlflags ccdlflags \
	shlibsuffix: Getfile Myread test osname sed i_dlfcn Findhdr cc
?MAKE:	-pick add $@ %<
?S:usedl:
?S:	This variable contains indicates if the the system supports dynamic
?S:	loading of some sort.  See also dlsrc and dlobj.
?S:.
?S:dlsrc:
?S:	This variable contains the name of the dynamic loading file that
?S:	will be used with the package.
?S:.
?S:dlobj:
?S:	This variable contains the name of the dynamic loading object
?S:	file that will be used with the package.  This is used in Makefile.
?S:.
?S:dldir:
?S:	This variable contains the directory from which to fetch dlsrc.
?S:	It is up to the makefile to use it.
?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:.
?S:shlibsuffix:
?S:	Shared libraries are built by Makefile in the form
?S:	lib/auto/xxx/xxx${shsuffix}, where xxx is
?S:	the name of the library, e.g. /lib/auto/POSIX/POSIX.so 
?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
?INIT:: File to use for dynamic loading
?INIT:usedl=''
?T:xxx
?X:
?X:  We select a default of 'define' for usedl if either dl_$osname.c
?X:  exists or if i_dlfcn is defined (which probably means dl_sunos.c
?X:  will work.)
?X:
: determine which dynamic loading, if any, to compile in
echo " "
case "$usedl" in
'') case "$i_dlfcn" in
    define) dflt='y' ;;
    *)      dflt='n' ;;
    esac
    : Does a dl.c file exist for this operating system
    $test -f ../ext/dl/dl_${osname}.c && dflt='y'
    ;;
define|y|true) dflt='y'
    usedl="$define"
    ;;
*)  dflt='n'
    ;;
esac
rp="Do you wish to attempt to use dynamic loading?"
. ./myread
usedl="$ans"
case "$ans" in
y*) usedl="$define"
    if $test -f ../ext/dl/dl_${osname}.c ; then
	dflt="ext/dl/dl_${osname}.c"
    else
	dflt='ext/dl/dl.c'
    fi
    echo "The following dynamic loading files are available:"
    cd ..; ls -C ext/dl/dl*.c; cd UU
    rp="Source file to use for dynamic loading"
    fn="fne~"
    . ./getfile
    : emulate  basename and dirname
    xxx=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@' -e 's@\.c$@@'`
    dlobj=$xxx.o
    dlsrc=$xxx.c
    dldir=`echo $ans | $sed 's@\(.*\)/[^/]*$@\1@'`
    case "$dldir" in
    '') dldir="." ;;
    *) ;;
    esac
    if $test -f ../$dldir/$dlsrc; then
        usedl="$define"
    else
	echo "File $dlsrc does not exist -- ignored"
	usedl="$undef"
    fi

    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 "$osname" in
			hpux)  dflt='+z' ;;
			next)  dflt='none' ;;
			sunos) dflt='none' ;;
	        *)     dflt='none' ;;
			esac
			;;
    *) dflt="$cccdlflags" ;;
    esac
    rp="Any special flags to pass to $cc -c to compile shared library modules?"
    . ./myread
    case "$ans" in
    none) cccdlflags='' ;;
    *) cccdlflags="$ans" ;;
    esac

    cat << 'EOM'

Some systems may require passing special flags to ld to
create a shared library.  To use no flags, say "none".
EOM
?X: I have received one report that NeXT requires -r here.
?X: On SunOS 4.1.3, that makes the library no longer shared.
    case "$lddlflags" in
    ''|' ') case "$osname" in
			hpux)  dflt='-b' ;;
			next)  dflt='none' ;;
			sunos) dflt='none' ;;
	        *)     dflt='none' ;;
			esac
			;;
    *) dflt="$lddlflags" ;;
    esac
    rp="Any special flags to pass to ld to create a shared library?"
    . ./myread
    case "$ans" in
    none) lddlflags='' ;;
    *) lddlflags="$ans" ;;
    esac

	cat <<EOM

Some systems may require passing special flags to $cc to indicate that
dynamic linking will be used.  To use no flags, say "none".
EOM
    case "$ccdlflags" in
    ''|' ')
		case "$osname" in
		hpux)  dflt='none' ;;
		next)  dflt='none' ;;
		sunos) dflt='none' ;;
	    *)     dflt='none' ;;
		esac
		;;
    *)  dflt="$ccdlflags"
	    ;;
    esac
    rp="Any special flags to pass to $cc to use dynamic loading?"
    . ./myread
    case "$ans" in
    none) ccdlflags='' ;;
    *) ccdlflags="$ans" ;;
    esac
	cat <<EOM

Some systems may require using a special suffix for shared libraries.
To create the shared library for POSIX, for example, you may need to
actually build the file POSIX.so.

EOM
    case "$shlibsuffix" in
	'')
		case "$osname" in
		hpux)  dflt='.sl' ;;
		next)  dflt='.so' ;;
		sunos) dflt='.so' ;;
		*)     dflt='.so' ;;
		esac
		;;
    *)  dflt="$shlibsuffix"
	;;
    esac
    rp="What is the suffix used for shared libraries?"
    . ./myread
    case "$ans" in
    none) shlibsuffix='' ;;
    *) shlibsuffix="$ans" ;;
    esac
    ;;
?X: End of usedl=y section
*)  usedl="$undef"
    : These are currently not used.
    dlsrc=''
    dlobj=''
    dldir=''
    lddlflags=''
    ccdlflags=''
    shlibsuffix='.o'
    ;;
esac