Tiny whitespace cleanup
[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         LT_INIT([dlopen])
51         LTDL_INSTALLABLE
52         LTDL_INIT
53
54         LT_LIB_DLLOAD
55         LT_LIB_M
56         LT_SYS_DLOPEN_DEPLIBS
57         LT_SYS_DLSEARCH_PATH
58         LT_SYS_MODULE_EXT
59         LT_SYS_MODULE_PATH
60         LT_SYS_SYMBOL_USCORE
61         LT_FUNC_DLSYM_USCORE
62
63         dnl Configure libltdl
64         dnl newer libtool2s will do this implicitly, we drop all support
65         dnl for the `old' libtool2 stuff as this is available through
66         dnl cvs only and we stick with the latest
67         dnl AC_CONFIG_SUBDIRS([libltdl])
68         AC_CONFIG_MACRO_DIR([libltdl/m4])
69 ])dnl _SXE_CHECK_LT2
70
71 m4_ifdef([LT_CONFIG_LTDL_DIR], [], [dnl else
72 AC_DEFUN([LT_CONFIG_LTDL_DIR], [dnl
73         AS_MESSAGE([trying to fake an initialisation of a libltdl subproject])
74 ])dnl LT_CONFIG_LTDL_DIR
75 ])
76
77 AC_DEFUN([_SXE_CHECK_LT1], [dnl
78         ## This overcomes a strange but existent scenario
79         ## (see ssh horstbox for one)
80         ## where autoconf is SO new that it can actually only work
81         ## with libtool2 but, sigh, of course, sigh, libtool-1.stone.age
82         ## is installed
83         LT_CONFIG_LTDL_DIR([libltdl], [recursive])
84
85         AC_LIBLTDL_INSTALLABLE
86         dnl AC_LTDL_ENABLE_INSTALL
87         dnl Check for dlopen support
88         AC_LIBTOOL_DLOPEN
89         AC_PROG_LIBTOOL([dlopen])
90         AC_LIB_LTDL
91         AC_LTDL_SYMBOL_USCORE
92
93         dnl Substitute LTDLINCL and LIBLTDL in the Makefiles
94         AC_SUBST(LTDLINCL)
95         AC_SUBST(LIBLTDL)
96         AC_SUBST([LIBTOOL_DEPS])
97
98         dnl Configure libltdl
99         AC_CONFIG_SUBDIRS([libltdl])
100 ])dnl _SXE_CHECK_LT1
101
102 AC_DEFUN([SXE_CHECK_LIBLTDL], [dnl
103         ## make sure the libtool stuff has been run before
104         AC_REQUIRE([SXE_CHECK_LIBTOOL])
105
106         AC_CACHE_CHECK([for dynamic loader provided by libltdl],
107                 [sxe_cv_feat_libltdl], [_SXE_CHECK_LIBLTDL])
108
109         ## if the user wants to use the included libltdl, descend
110         if test -z "$with_included_ltdl" -a \
111                 -d "${sxe_srcdir}/libltdl" -a \
112                 "$with_module_support" != "no" -a \
113                 "$sxe_cv_feat_libltdl" != "yes"; then
114                 with_included_ltdl="yes"
115                 ## assume we have a working ltdl lib afterwards
116                 sxe_cv_feat_libltdl="yes"
117                 ## also install that pig
118                 enable_ltdl_install="yes"
119                 ## add libltdl/ to the include path
120                 CPPFLAGS="$CPPFLAGS ${LTDLINCL}"
121                 ## and assume we've seen ltdl.h
122                 AC_DEFINE([HAVE_LTDL_H], [1], [Whether ltdl.h is somewhere])
123         elif test -d "${sxe_srcdir}/libltdl" -a \
124                 "$with_included_ltdl" = "yes"; then
125                 ## the user WANTS to use the included ltdl
126                 ## assume we have a working ltdl lib afterwards
127                 sxe_cv_feat_libltdl="yes"
128                 ## also install that pig
129                 enable_ltdl_install="yes"
130                 ## add libltdl/ to the include path
131                 CPPFLAGS="$CPPFLAGS -I${top_srcdir}/libltdl"
132                 ## and assume we've seen ltdl.h
133                 AC_DEFINE([HAVE_LTDL_H], [1], [Whether ltdl.h is somewhere])
134         else
135                 with_included_ltdl="no"
136         fi
137         AM_CONDITIONAL([DESCEND_LIBLTDL], [test "$with_included_ltdl" = "yes"])
138 ])dnl SXE_CHECK_LIBLTDL
139
140 AC_DEFUN([_SXE_CHECK_LIBLTDL], [dnl
141         AC_MSG_RESULT([])
142         SXE_CHECK_LTDL_HEADERS
143         SXE_CHECK_LTDL_FUNCS
144
145         if test "$ac_cv_header_ltdl_h" = "yes" -a \
146                 "$ac_cv_func_lt_dlopen" = "yes" -a \
147                 "$ac_cv_func_lt_dlclose" = "yes" -a \
148                 "$ac_cv_type_lt_dlhandle" = "yes" -a \
149                 "$ac_cv_type_lt_dlinfo" = "yes"; then
150                 sxe_cv_feat_libltdl="yes"
151         else
152                 sxe_cv_feat_libltdl="no"
153         fi
154 ])dnl _SXE_CHECK_LIBLTDL
155
156 AC_DEFUN([SXE_CHECK_LTDL_HEADERS], [dnl
157         AC_CHECK_HEADERS([ltdl.h])
158 ])dnl SXE_CHECK_LTDL_HEADERS
159
160 AC_DEFUN([SXE_CHECK_LTDL_FUNCS], [dnl
161         AC_REQUIRE([SXE_CHECK_LIBTOOL])
162
163         SXE_DUMP_LIBS
164         LIBS="$LIBS $LIBLTDL"
165         _SXE_CHECK_LTDL_FUNCS
166         SXE_RESTORE_LIBS
167
168         _SXE_CHECK_LTDL_TYPES
169 ])dnl _SXE_CHECK_LTDL_FUNCS
170
171 AC_DEFUN([_SXE_CHECK_LTDL_FUNCS], [dnl
172         AC_CHECK_FUNCS([dnl
173                 lt_dlopen lt_dlopenext dnl
174                 lt_dlclose lt_dlexit dnl
175                 lt_dlsym lt_dlgetinfo dnl
176                 lt_dlfree lt_dlforeach lt_dlhandle_next dnl
177                 lt_dlinterface_register lt_dlcaller_register lt_dlhandle_fetch dnl
178                 lt_dladdsearchdir dnl
179                 lt_dlcaller_set_data lt_dlcaller_get_data dnl
180                 lt_dlcaller_id dnl
181                 ])
182
183         AC_CHECK_DECLS([lt_dlopen, lt_dlopenext, lt_dlclose, lt_dlexit],
184                 [], [], [
185 #ifdef HAVE_LTDL_H
186 # include <ltdl.h>
187 #endif
188                 ])
189 ])dnl _SXE_CHECK_LTDL_FUNCS
190
191 AC_DEFUN([_SXE_CHECK_LTDL_TYPES], [dnl
192         AC_CHECK_TYPES([lt_dlinfo, lt_dlhandle], [], [], [
193 #ifdef HAVE_LTDL_H
194 # include <ltdl.h>
195 #endif
196                 ])
197 ])dnl _SXE_CHECK_LTDL_TYPES
198
199 dnl sxe-libtool.m4 ends here