3 # shobj-conf -- output a series of variable assignments to be substituted
4 # into a Makefile by configure which specify system-dependent
5 # information for creating shared objects that may be loaded
6 # into bash with `enable -f'
8 # usage: shobj-conf [-C compiler] -c host_cpu -o host_os -v host_vendor
13 # Copyright (C) 1996-2009 Free Software Foundation, Inc.
15 # This file is part of GNU Bash, the Bourne Again SHell.
17 # This program is free software: you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation, either version 3 of the License, or
20 # (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program. If not, see <http://www.gnu.org/licenses/>.
34 SHOBJ_STATUS=supported
35 SHLIB_STATUS=supported
51 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF)'
52 SHLIB_DLLVERSION='$(SHLIB_MAJOR)'
54 PROGNAME=`basename $0`
55 USAGE="$PROGNAME [-C compiler] -c host_cpu -o host_os -v host_vendor"
57 while [ $# -gt 0 ]; do
59 -C) shift; SHOBJ_CC="$1"; shift ;;
60 -c) shift; host_cpu="$1"; shift ;;
61 -o) shift; host_os="$1"; shift ;;
62 -v) shift; host_vendor="$1"; shift ;;
63 *) echo "$USAGE" >&2 ; exit 2;;
67 case "${host_os}-${SHOBJ_CC}" in
71 SHOBJ_LDFLAGS='-assert pure-text'
73 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
79 SHOBJ_LDFLAGS='-assert pure-text'
81 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
84 sunos5*-*gcc*|solaris2*-*gcc*)
86 ld_used=`gcc -print-prog-name=ld`
87 if ${ld_used} -V 2>&1 | grep GNU >/dev/null 2>&1; then
88 # This line works for the GNU ld
89 SHOBJ_LDFLAGS='-shared -Wl,-h,$@'
90 # http://sourceware.org/ml/binutils/2001-08/msg00361.html
93 # This line works for the Solaris linker in /usr/ccs/bin/ld
94 SHOBJ_LDFLAGS='-shared -Wl,-i -Wl,-h,$@'
98 # SHLIB_XLDFLAGS='-R $(libdir)'
99 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
103 SHOBJ_CFLAGS='-K pic'
104 SHOBJ_LD=/usr/ccs/bin/ld
105 SHOBJ_LDFLAGS='-G -dy -z text -i -h $@'
107 # SHLIB_XLDFLAGS='-R $(libdir)'
108 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
111 # All versions of Linux or the semi-mythical GNU Hurd.
112 linux*-*|gnu*-*|k*bsd*-gnu-*)
115 SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
117 SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir) -Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
118 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
124 SHOBJ_LDFLAGS='-x -Bshareable'
126 SHLIB_XLDFLAGS='-R$(libdir)'
127 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
131 freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*|dragonfly*)
135 if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
136 SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
138 SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
139 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
141 SHOBJ_LDFLAGS='-shared'
143 SHLIB_XLDFLAGS='-R$(libdir)'
144 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
149 darwin[89]*|darwin10*)
150 SHOBJ_STATUS=supported
151 SHLIB_STATUS=supported
153 SHOBJ_CFLAGS='-fno-common'
155 SHOBJ_LD='MACOSX_DEPLOYMENT_TARGET=10.3 ${CC}'
157 SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)'
158 SHLIB_LIBSUFF='dylib'
160 SHOBJ_LDFLAGS='-dynamiclib -dynamic -undefined dynamic_lookup -arch_only `/usr/bin/arch`'
161 SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
163 SHLIB_LIBS='-lncurses' # see if -lcurses works on MacOS X 10.1
167 SHOBJ_STATUS=unsupported
168 SHLIB_STATUS=supported
170 SHOBJ_CFLAGS='-fno-common'
174 SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)'
175 SHLIB_LIBSUFF='dylib'
178 darwin[789]*|darwin10*) SHOBJ_LDFLAGS=''
179 SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
181 *) SHOBJ_LDFLAGS='-dynamic'
182 SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
186 SHLIB_LIBS='-lncurses' # see if -lcurses works on MacOS X 10.1
192 SHOBJ_LDFLAGS='-shared'
194 SHLIB_XLDFLAGS='-R$(libdir)'
195 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
203 SHOBJ_LIBS=-lc_s.2.1.0
205 # BSD/OS 2.x and 3.x `shared libraries' are too much of a pain in
206 # the ass -- they require changing {/usr/lib,etc}/shlib.map on
207 # each system, and the library creation process is byzantine
208 SHLIB_STATUS=unsupported
216 SHOBJ_LIBS=-lc_s.3.0.0
218 # BSD/OS 2.x and 3.x `shared libraries' are too much of a pain in
219 # the ass -- they require changing {/usr/lib,etc}/shlib.map on
220 # each system, and the library creation process is byzantine
221 SHLIB_STATUS=unsupported
225 # BSD/OS 4.x now supports ELF and SunOS-style dynamically-linked
226 # shared libraries. gcc 2.x is the standard compiler, and the
227 # `normal' gcc options should work as they do in Linux.
231 SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
233 SHLIB_XLDFLAGS='-Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
234 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
238 # Fix to use gcc linker driver from bfischer@TechFak.Uni-Bielefeld.DE
240 SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
242 SHLIB_XLDFLAGS='-rpath $(libdir)'
243 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
248 SHOBJ_LDFLAGS='-shared -soname $@ -expect_unresolved "*"'
250 SHLIB_XLDFLAGS='-rpath $(libdir)'
251 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
254 aix4.[2-9]*-*gcc*|aix[5-9].*-*gcc*) # lightly tested by jik@cisco.com
257 SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
260 SHLIB_XLDFLAGS='-bM:SRE'
261 SHLIB_LIBS='-lcurses -lc'
262 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
265 aix4.[2-9]*|aix[5-9].*)
268 SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
271 SHLIB_XLDFLAGS='-bM:SRE'
272 SHLIB_LIBS='-lcurses -lc'
273 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
277 # THE FOLLOWING ARE UNTESTED -- and some may not support the dlopen interface
282 SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
284 SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
285 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
289 SHOBJ_CFLAGS='-K PIC'
291 # SHOBJ_LDFLAGS='-call_shared -hidden_symbol -no_unresolved -soname $@'
292 # Change from David Kaelbling <drk@sgi.com>. If you have problems,
293 # remove the `-no_unresolved'
294 SHOBJ_LDFLAGS='-shared -no_unresolved -soname $@'
296 SHLIB_XLDFLAGS='-rpath $(libdir)'
297 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
301 # must use gcc; the bundled cc cannot compile PIC code
304 SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,+s'
306 SHLIB_XLDFLAGS='-Wl,+b,$(libdir)'
308 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
312 SHOBJ_STATUS=unsupported
313 SHLIB_STATUS=unsupported
315 # If you are using the HP ANSI C compiler, you can uncomment and use
316 # this code (I have not tested it)
317 # SHOBJ_STATUS=supported
318 # SHLIB_STATUS=supported
322 # SHOBJ_LDFLAGS='-b +s'
324 # SHLIB_XLDFLAGS='+b $(libdir)'
326 # SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
331 # must use gcc; the bundled cc cannot compile PIC code
334 # if you have problems linking here, moving the `-Wl,+h,$@' from
335 # SHLIB_XLDFLAGS to SHOBJ_LDFLAGS has been reported to work
336 SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s'
338 SHLIB_XLDFLAGS='-Wl,+h,$@ -Wl,+b,$(libdir)'
340 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
344 SHOBJ_STATUS=unsupported
345 SHLIB_STATUS=unsupported
347 # If you are using the HP ANSI C compiler, you can uncomment and use
348 # this code (I have not tested it)
349 # SHOBJ_STATUS=supported
350 # SHLIB_STATUS=supported
354 # SHOBJ_LDFLAGS='-b +s +h $@'
356 # SHLIB_XLDFLAGS='+b $(libdir)'
358 # SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
363 # must use gcc; the bundled cc cannot compile PIC code
366 # SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,-B,symbolic -Wl,+s -Wl,+std -Wl,+h,$@'
367 SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s -Wl,+h,$@'
369 SHLIB_XLDFLAGS='-Wl,+b,$(libdir)'
371 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
375 SHOBJ_STATUS=unsupported
376 SHLIB_STATUS=unsupported
378 # If you are using the HP ANSI C compiler, you can uncomment and use
379 # this code (I have not tested it)
380 # SHOBJ_STATUS=supported
381 # SHLIB_STATUS=supported
385 # SHOBJ_LDFLAGS='-b +s +h $@'
387 # SHLIB_XLDFLAGS='+b $(libdir)'
389 # SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
395 SHOBJ_LDFLAGS='-shared -h $@'
398 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
402 SHOBJ_CFLAGS='-K PIC'
404 SHOBJ_LDFLAGS='-dy -z text -G -h $@'
406 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
410 SHOBJ_CFLAGS='-fpic' # DEFAULTS TO ELF
412 SHOBJ_LDFLAGS='-shared'
414 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
418 SHOBJ_CFLAGS='-K pic -b elf'
420 SHOBJ_LDFLAGS='-G -b elf -dy -z text -h $@'
422 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
428 SHOBJ_LDFLAGS='-shared'
430 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
434 SHOBJ_CFLAGS='-K PIC'
436 SHOBJ_LDFLAGS='-G -dy -z text -h $@'
438 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
441 sysv5UnixWare*-*gcc*)
444 SHOBJ_LDFLAGS='-shared'
446 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
450 SHOBJ_CFLAGS='-K PIC'
452 SHOBJ_LDFLAGS='-G -dy -z text -h $@'
454 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
457 sysv5OpenUNIX*-*gcc*)
460 SHOBJ_LDFLAGS='-shared'
462 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
466 SHOBJ_CFLAGS='-K PIC'
468 SHOBJ_LDFLAGS='-G -dy -z text -h $@'
470 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
476 SHOBJ_LDFLAGS='-shared'
478 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
482 SHOBJ_CFLAGS='-K pic'
484 SHOBJ_LDFLAGS='-G -dy -h $@'
486 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
490 SHOBJ_STATUS=unsupported
491 SHLIB_STATUS=unsupported
496 SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
499 SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)'
500 SHLIB_LIBS='$(TERMCAP_LIB)'
503 # For official cygwin releases, DLLVERSION will be defined in the
504 # environment of configure, and will be incremented any time the API
505 # changes in a non-backwards compatible manner. Otherwise, it is just
507 if [ -n "$DLLVERSION" ] ; then
508 SHLIB_DLLVERSION="$DLLVERSION"
514 SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a'
516 SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)'
517 SHLIB_LIBS='$(TERMCAP_LIB)'
520 # For official cygwin releases, DLLVERSION will be defined in the
521 # environment of configure, and will be incremented any time the API
522 # changes in a non-backwards compatible manner. Otherwise, it is just
524 if [ -n "$DLLVERSION" ] ; then
525 SHLIB_DLLVERSION="$DLLVERSION"
530 # Rely on correct gcc configuration for everything else
535 SHOBJ_LDFLAGS='-shared'
537 SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
541 SHOBJ_STATUS=unsupported
542 SHLIB_STATUS=unsupported
547 echo SHOBJ_CC=\'"$SHOBJ_CC"\'
548 echo SHOBJ_CFLAGS=\'"$SHOBJ_CFLAGS"\'
549 echo SHOBJ_LD=\'"$SHOBJ_LD"\'
550 echo SHOBJ_LDFLAGS=\'"$SHOBJ_LDFLAGS"\'
551 echo SHOBJ_XLDFLAGS=\'"$SHOBJ_XLDFLAGS"\'
552 echo SHOBJ_LIBS=\'"$SHOBJ_LIBS"\'
554 echo SHLIB_XLDFLAGS=\'"$SHLIB_XLDFLAGS"\'
555 echo SHLIB_LIBS=\'"$SHLIB_LIBS"\'
557 echo SHLIB_DOT=\'"$SHLIB_DOT"\'
559 echo SHLIB_LIBPREF=\'"$SHLIB_LIBPREF"\'
560 echo SHLIB_LIBSUFF=\'"$SHLIB_LIBSUFF"\'
562 echo SHLIB_LIBVERSION=\'"$SHLIB_LIBVERSION"\'
563 echo SHLIB_DLLVERSION=\'"$SHLIB_DLLVERSION"\'
565 echo SHOBJ_STATUS=\'"$SHOBJ_STATUS"\'
566 echo SHLIB_STATUS=\'"$SHLIB_STATUS"\'