1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_check_vscript.html
3 # ===========================================================================
11 # Check whether the linker supports version scripts. Version scripts are
12 # used when building shared libraries to bind symbols to version nodes
13 # (helping to detect incompatibilities) or to limit the visibility of
18 # If version scripts are supported, VSCRIPT_LDFLAGS will contain the
19 # appropriate flag to pass to the linker. On GNU systems this would
20 # typically be "-Wl,--version-script", and on Solaris it would typically
23 # Two Automake conditionals are also set:
25 # HAVE_VSCRIPT is true if the linker supports version scripts with
26 # entries that use simple wildcards, like "local: *".
28 # HAVE_VSCRIPT_COMPLEX is true if the linker supports version scripts with
29 # pattern matching wildcards, like "global: Java_*".
31 # On systems that do not support symbol versioning, such as Mac OS X, both
32 # conditionals will be false. They will also be false if the user passes
33 # "--disable-symvers" on the configure command line.
44 # libfoo_la_LDFLAGS += $(VSCRIPT_LDFLAGS),@srcdir@/libfoo.map
47 # if HAVE_VSCRIPT_COMPLEX
48 # libbar_la_LDFLAGS += $(VSCRIPT_LDFLAGS),@srcdir@/libbar.map
53 # Copyright (c) 2014 Kevin Cernekee <cernekee@gmail.com>
55 # Copying and distribution of this file, with or without modification, are
56 # permitted in any medium without royalty provided the copyright notice
57 # and this notice are preserved. This file is offered as-is, without any
62 # _AX_CHECK_VSCRIPT(flag, global-sym, action-if-link-succeeds, [junk-file=no])
63 AC_DEFUN([_AX_CHECK_VSCRIPT], [
65 ax_check_vscript_save_flags="$LDFLAGS"
66 echo "V1 { global: $2; local: *; };" > conftest.map
67 AS_IF([test x$4 = xyes], [
68 echo "{" >> conftest.map
70 LDFLAGS="$LDFLAGS -Wl,$1,conftest.map"
71 AC_LINK_IFELSE([AC_LANG_PROGRAM([[int show, hide;]], [])], [$3])
72 LDFLAGS="$ax_check_vscript_save_flags"
75 ]) dnl _AX_CHECK_VSCRIPT
77 AC_DEFUN([AX_CHECK_VSCRIPT], [
79 AC_ARG_ENABLE([symvers],
80 AS_HELP_STRING([--disable-symvers],
81 [disable library symbol versioning [default=auto]]),
82 [want_symvers=$enableval],
86 AS_IF([test x$want_symvers = xyes], [
88 dnl First test --version-script and -M with a simple wildcard.
90 AC_CACHE_CHECK([linker version script flag], ax_cv_check_vscript_flag, [
91 ax_cv_check_vscript_flag=unsupported
92 _AX_CHECK_VSCRIPT([--version-script], [show], [
93 ax_cv_check_vscript_flag=--version-script
95 AS_IF([test x$ax_cv_check_vscript_flag = xunsupported], [
96 _AX_CHECK_VSCRIPT([-M], [show], [ax_cv_check_vscript_flag=-M])
99 dnl The linker may interpret -M (no argument) as "produce a load map."
100 dnl If "-M conftest.map" doesn't fail when conftest.map contains
101 dnl obvious syntax errors, assume this is the case.
103 AS_IF([test x$ax_cv_check_vscript_flag != xunsupported], [
104 _AX_CHECK_VSCRIPT([$ax_cv_check_vscript_flag], [show],
105 [ax_cv_check_vscript_flag=unsupported], [yes])
109 dnl If the simple wildcard worked, retest with a complex wildcard.
111 AS_IF([test x$ax_cv_check_vscript_flag != xunsupported], [
112 ax_check_vscript_flag=$ax_cv_check_vscript_flag
113 AC_CACHE_CHECK([if version scripts can use complex wildcards],
114 ax_cv_check_vscript_complex_wildcards, [
115 ax_cv_check_vscript_complex_wildcards=no
116 _AX_CHECK_VSCRIPT([$ax_cv_check_vscript_flag], [sh*], [
117 ax_cv_check_vscript_complex_wildcards=yes])
119 ax_check_vscript_complex_wildcards="$ax_cv_check_vscript_complex_wildcards"
121 ax_check_vscript_flag=
122 ax_check_vscript_complex_wildcards=no
125 AC_MSG_CHECKING([linker version script flag])
126 AC_MSG_RESULT([disabled])
128 ax_check_vscript_flag=
129 ax_check_vscript_complex_wildcards=no
132 AS_IF([test x$ax_check_vscript_flag != x], [
133 VSCRIPT_LDFLAGS="-Wl,$ax_check_vscript_flag"
134 AC_SUBST([VSCRIPT_LDFLAGS])
137 AM_CONDITIONAL([HAVE_VSCRIPT],
138 [test x$ax_check_vscript_flag != x])
139 AM_CONDITIONAL([HAVE_VSCRIPT_COMPLEX],
140 [test x$ax_check_vscript_complex_wildcards = xyes])
142 ]) dnl AX_CHECK_VSCRIPT