Build Fix -- compatibility issue with newer autoconf
[sxemacs] / m4 / sxe-libtool.m4
1 dnl sxe-libtool.m4 -- just a quick libtoolish macros
2 dnl
3 dnl Copyright (C) 2007, 2008 Sebastian Freundt.
4 dnl
5 dnl This file is part of SXEmacs
6
7 AC_DEFUN([SXE_CHECK_LIBTOOL], [dnl
8         AC_MSG_RESULT([starting libtool investigation...])
9         m4_ifdef([LT_INIT], [_SXE_CHECK_LT2], [_SXE_CHECK_LT1])
10
11         if test -n "$export_dynamic_flag_spec"; then
12                 sxe_cv_export_dynamic=$(\
13                         echo $(eval echo "$export_dynamic_flag_spec"))
14                 SXE_APPEND_UNDUP([$sxe_cv_export_dynamic], [LDFLAGS])
15         else
16                 AC_MSG_NOTICE([
17 Neither -export-dynamic nor equivalent flags are supported by your linker.
18 Emodules however will reference some symbols dynamically.
19 We assume that your linker will do what we need, but this assumption
20 might be wrong as well.
21 ])dnl AC_MSG_NOTICE
22         fi
23
24         ## cope with libtool's convenience lib/bin concept
25         if test -n "$lt_cv_objdir"; then
26                 ## this variable is a #define, too
27                 LT_OBJDIR="$lt_cv_objdir"
28         else
29                 ## hm, probably not the best idea but let's try
30                 LT_OBJDIR="."
31         fi
32         ## definitely subst that though
33         AC_SUBST([LT_OBJDIR])
34
35         ## currently there's no official variable for that, but `lt-'
36         ## seems to be a consistent choice throughout all libtools
37         LT_CONVENIENCE_PREFIX="lt-"
38         AC_SUBST([LT_CONVENIENCE_PREFIX])
39
40         ## prefix all the stuff in XCCLDFLAGS with XCCFLAG
41         ## assume XCCFLAG = -XCClinker for now
42         XCCFLAG="-XCClinker"
43         XCCLDFLAGS=$(echo "${XCCLDFLAGS}" | \
44                 sed -e 's/\B-/'${XCCFLAG}' -/g')
45 ])dnl SXE_CHECK_LIBTOOL
46
47 AC_DEFUN([_SXE_CHECK_LT2], [dnl
48         LT_CONFIG_LTDL_DIR([libltdl], [recursive])
49         LT_PREREQ([2.1])
50         AC_REQUIRE([_LT_SYS_DYNAMIC_LINKER])
51         AC_REQUIRE([_LT_COMPILER_PIC])
52         LT_INIT([dlopen])
53         LTDL_INSTALLABLE
54         LTDL_INIT
55
56         LT_LIB_DLLOAD
57         LT_LIB_M
58         LT_SYS_DLOPEN_DEPLIBS
59         LT_SYS_DLSEARCH_PATH
60         LT_SYS_MODULE_EXT
61         LT_SYS_MODULE_PATH
62         LT_SYS_SYMBOL_USCORE
63         LT_FUNC_DLSYM_USCORE
64
65         dnl Configure libltdl
66         dnl newer libtool2s will do this implicitly, we drop all support
67         dnl for the `old' libtool2 stuff as this is available through
68         dnl cvs only and we stick with the latest
69         dnl AC_CONFIG_SUBDIRS([libltdl])
70         AC_CONFIG_MACRO_DIR([libltdl/m4])
71 ])dnl _SXE_CHECK_LT2
72
73 m4_ifdef([LT_CONFIG_LTDL_DIR], [], [dnl else
74 AC_DEFUN([LT_CONFIG_LTDL_DIR], [dnl
75         AS_MESSAGE([trying to fake an initialisation of a libltdl subproject])
76 ])dnl LT_CONFIG_LTDL_DIR
77 ])
78
79 AC_DEFUN([_SXE_CHECK_LT1], [dnl
80         ## This overcomes a strange but existent scenario
81         ## (see ssh horstbox for one)
82         ## where autoconf is SO new that it can actually only work
83         ## with libtool2 but, sigh, of course, sigh, libtool-1.stone.age
84         ## is installed
85         LT_CONFIG_LTDL_DIR([libltdl], [recursive])
86
87         AC_LIBLTDL_INSTALLABLE
88         dnl AC_LTDL_ENABLE_INSTALL
89         dnl Check for dlopen support
90         AC_LIBTOOL_DLOPEN
91         AC_PROG_LIBTOOL([dlopen])
92         AC_LIB_LTDL
93         AC_LTDL_SYMBOL_USCORE
94
95         dnl Substitute LTDLINCL and LIBLTDL in the Makefiles
96         AC_SUBST(LTDLINCL)
97         AC_SUBST(LIBLTDL)
98         AC_SUBST([LIBTOOL_DEPS])
99
100         dnl Configure libltdl
101         AC_CONFIG_SUBDIRS([libltdl])
102 ])dnl _SXE_CHECK_LT1
103
104 AC_DEFUN([SXE_CHECK_LIBLTDL], [dnl
105         ## make sure the libtool stuff has been run before
106         AC_REQUIRE([SXE_CHECK_LIBTOOL])
107
108         AC_CACHE_CHECK([for dynamic loader provided by libltdl],
109                 [sxe_cv_feat_libltdl], [_SXE_CHECK_LIBLTDL])
110
111         ## if the user wants to use the included libltdl, descend
112         if test -z "$with_included_ltdl" -a \
113                 -d "${sxe_srcdir}/libltdl" -a \
114                 "$with_module_support" != "no" -a \
115                 "$sxe_cv_feat_libltdl" != "yes"; then
116                 with_included_ltdl="yes"
117                 ## assume we have a working ltdl lib afterwards
118                 sxe_cv_feat_libltdl="yes"
119                 ## also install that pig
120                 enable_ltdl_install="yes"
121                 ## add libltdl/ to the include path
122                 CPPFLAGS="$CPPFLAGS ${LTDLINCL}"
123                 ## and assume we've seen ltdl.h
124                 AC_DEFINE([HAVE_LTDL_H], [1], [Whether ltdl.h is somewhere])
125         elif test -d "${sxe_srcdir}/libltdl" -a \
126                 "$with_included_ltdl" = "yes"; then
127                 ## the user WANTS to use the included ltdl
128                 ## assume we have a working ltdl lib afterwards
129                 sxe_cv_feat_libltdl="yes"
130                 ## also install that pig
131                 enable_ltdl_install="yes"
132                 ## add libltdl/ to the include path
133                 CPPFLAGS="$CPPFLAGS -I${top_srcdir}/libltdl"
134                 ## and assume we've seen ltdl.h
135                 AC_DEFINE([HAVE_LTDL_H], [1], [Whether ltdl.h is somewhere])
136         else
137                 with_included_ltdl="no"
138         fi
139         AM_CONDITIONAL([DESCEND_LIBLTDL], [test "$with_included_ltdl" = "yes"])
140 ])dnl SXE_CHECK_LIBLTDL
141
142 AC_DEFUN([_SXE_CHECK_LIBLTDL], [dnl
143         AC_MSG_RESULT([])
144         SXE_CHECK_LTDL_HEADERS
145         SXE_CHECK_LTDL_FUNCS
146
147         if test "$ac_cv_header_ltdl_h" = "yes" -a \
148                 "$ac_cv_func_lt_dlopen" = "yes" -a \
149                 "$ac_cv_func_lt_dlclose" = "yes" -a \
150                 "$ac_cv_type_lt_dlhandle" = "yes" -a \
151                 "$ac_cv_type_lt_dlinfo" = "yes"; then
152                 sxe_cv_feat_libltdl="yes"
153         else
154                 sxe_cv_feat_libltdl="no"
155         fi
156 ])dnl _SXE_CHECK_LIBLTDL
157
158 AC_DEFUN([SXE_CHECK_LTDL_HEADERS], [dnl
159         AC_CHECK_HEADERS([ltdl.h])
160 ])dnl SXE_CHECK_LTDL_HEADERS
161
162 AC_DEFUN([SXE_CHECK_LTDL_FUNCS], [dnl
163         AC_REQUIRE([SXE_CHECK_LIBTOOL])
164
165         SXE_DUMP_LIBS
166         LIBS="$LIBS $LIBLTDL"
167         _SXE_CHECK_LTDL_FUNCS
168         SXE_RESTORE_LIBS
169
170         _SXE_CHECK_LTDL_TYPES
171 ])dnl _SXE_CHECK_LTDL_FUNCS
172
173 AC_DEFUN([_SXE_CHECK_LTDL_FUNCS], [dnl
174         AC_CHECK_FUNCS([dnl
175                 lt_dlopen lt_dlopenext dnl
176                 lt_dlclose lt_dlexit dnl
177                 lt_dlsym lt_dlgetinfo dnl
178                 lt_dlfree lt_dlforeach lt_dlhandle_next dnl
179                 lt_dlinterface_register lt_dlcaller_register lt_dlhandle_fetch dnl
180                 lt_dladdsearchdir dnl
181                 lt_dlcaller_set_data lt_dlcaller_get_data dnl
182                 lt_dlcaller_id dnl
183                 ])
184
185         AC_CHECK_DECLS([lt_dlopen, lt_dlopenext, lt_dlclose, lt_dlexit],
186                 [], [], [
187 #ifdef HAVE_LTDL_H
188 # include <ltdl.h>
189 #endif
190                 ])
191 ])dnl _SXE_CHECK_LTDL_FUNCS
192
193 AC_DEFUN([_SXE_CHECK_LTDL_TYPES], [dnl
194         AC_CHECK_TYPES([lt_dlinfo, lt_dlhandle], [], [], [
195 #ifdef HAVE_LTDL_H
196 # include <ltdl.h>
197 #endif
198                 ])
199 ])dnl _SXE_CHECK_LTDL_TYPES
200
201 dnl sxe-libtool.m4 ends here