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