Update PUI to use ffi-curl
[sxemacs] / m4 / sxe-bldenv.m4
1 dnl sxe-bldenv.m4 -- Things for/on the build environment
2
3 AC_DEFUN([SXE_LD_EXPORT_DYNAMIC], [dnl
4         AC_MSG_CHECKING([if linker understands -export-dynamic])
5         SXE_DUMP_LIBS
6         LDFLAGS="-export-dynamic $LDFLAGS"
7         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
8 #include <stdlib.h>
9 ]],[[
10 return 0;
11 ]])],  [AC_MSG_RESULT([yes])
12         have_ld_export_dynamic="yes"], [
13         AC_MSG_RESULT([no])
14         have_ld_export_dynamic="no"])
15         SXE_RESTORE_LIBS
16 ])dnl SXE_LD_EXPORT_DYNAMIC
17
18
19 AC_DEFUN([SXE_LD_NO_PIE], [dnl
20         AC_MSG_CHECKING([if linker understands -no_pie])
21         SXE_DUMP_LIBS
22         LDFLAGS="-no_pie $LDFLAGS"
23         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
24 #include <stdlib.h>
25 ]],[[
26 return 0;
27 ]])],  [AC_MSG_RESULT([yes])
28         have_ld_no_pie="yes"], [
29         AC_MSG_RESULT([no])
30         have_ld_no_pie="no"])
31         SXE_RESTORE_LIBS
32 ])dnl SXE_LD_NO_PIE
33
34 dnl SXE_RILLY_COMPUTE_LD_RUN_PATH()
35 AC_DEFUN([SXE_RILLY_COMPUTE_LD_RUN_PATH], [dnl
36         if test "$add_runtime_path" = "yes" -a -n "$dash_r"; then
37                 ## Remove runtime paths from current ld switches
38                 ld_switch_site=`echo   '' $ld_switch_site   | sed -e 's:^ ::' -e "s/$dash_r[[^ ]]*//g"`
39                 ld_switch_x_site=`echo '' $ld_switch_x_site | sed -e 's:^ ::' -e "s/$dash_r[[^ ]]*//g"`
40
41                 ## Fix up Runtime path
42                 ## If LD_RUN_PATH is set in environment, use that.
43                 ## In this case, assume user has set the right value.
44                 runpath=""
45                 runpath_dirs=""
46                 if test -n "$LD_RUN_PATH"; then
47                         runpath="$LD_RUN_PATH"
48                 elif test "$GCC" = "yes"; then
49                         ## Compute runpath from gcc's -v output
50                         ld_switch_run_save="$ld_switch_run"
51                         ld_switch_run=""
52                         echo "int main(int argc, char *argv[[]]) {return 0;}" \
53                                 > conftest.c
54                         xe_runpath_link='${CC-cc} -o conftest -v $CFLAGS '"$xe_ldflags"' conftest.$ac_ext 2>&1 1>/dev/null'
55                         for arg in `eval "$xe_runpath_link" | grep ' -L'`; do
56                                 case "$arg" in
57                                 P,* | -L* | -R* )
58                                         for dir in `echo '' "$arg" | sed -e 's:^ ::' -e 's/^..//' -e 'y/:/ /'`; do
59                                                 SXE_ADD_RUNPATH_DIR(["$dir"])
60                                         done
61                                         ;;
62                                 esac
63                         done
64                         ld_switch_run="$ld_switch_run_save"
65                         rm -f conftest*
66                 else
67                         ## Add all directories with .so files to runpath
68                         for arg in $ld_switch_site $ld_switch_x_site; do
69                                 case "$arg" in
70                                 -L*)
71                                         SXE_ADD_RUNPATH_DIR(`echo '' "$arg" | sed -e 's:^ ::' -e 's/^-L//'`)
72                                         ;;
73                                 esac
74                         done
75                         ## Sometimes /opt/SUNWdt/lib is the only
76                         ## installed Motif available
77                         if test "$opsys $need_motif" = "sol2 yes"; then
78                                 xe_runpath_dir="/opt/SUNWdt/lib";
79                                 eval "$xe_add_unique_runpath_dir";
80                         fi
81                 fi dnl Compute $runpath
82
83                 if test -n "$runpath"; then
84                         ld_switch_run="${dash_r}${runpath}"
85                         SXE_PROTECT_LINKER_FLAGS(ld_switch_run)
86                         if test "$extra_verbose" = "yes"; then
87                                 echo "Setting runpath to $runpath"
88                         fi
89                 fi
90         fi
91 ])dnl SXE_RILLY_COMPUTE_LD_RUN_PATH
92
93 AC_DEFUN([SXE_COMPUTE_LD_RUN_PATH], [dnl
94         ## --with-site-runtime-libraries (multiple dirs)
95         SXE_COLON_TO_SPACE(with_site_runtime_libraries)
96         if test -n "$with_site_runtime_libraries"; then
97                 LD_RUN_PATH="`echo $with_site_runtime_libraries | sed -e 's/  */:/g'`"
98                 export LD_RUN_PATH
99                 for path in $with_site_runtime_libraries; do
100                         dnl SXE_APPEND_UNDUP("-R$path ", $ld_switch_run)
101                         SXE_APPEND_UNDUP(["-R${path} "], [LDFLAGS])
102                 done
103         fi
104
105         ## -------------------------------------
106         ## Compute runtime library path
107         ## -------------------------------------
108
109         ## Linux systems have dynamic runtime library directories listed in
110         ## /etc/ld.so.conf.  Since those are used at run time, it seems pretty
111         ## safe to use them at link time, and less controversial than forcing
112         ## the run-time to use the link-time libraries.  This also helps avoid
113         ## mismatches between the link-time and run-time libraries.
114
115         ## #### Unfortunately, there are horrible libc4 and libc5 libraries
116         ## listed in /etc/ld.so.conf on some systems, and including them on
117         ## the link path leads to linking in utterly broken libc's.
118         ## There are many clever ways of approaching this problem,
119         ## but finding one that actually works...
120
121         ## if test -z "$LD_RUN_PATH" -a -r "/etc/ld.so.conf"; then
122         ##   for dir in `cat /etc/ld.so.conf`; do
123         ##     test -d "$dir" && SXE_APPEND_UNDUP(-L${dir}, ld_switch_system)
124         ##   done
125         ##   add_runtime_path=no
126         ## fi
127
128         if test -n "$add_runtime_path"; then
129                 :
130         elif test "$with_dynamic" = "no"; then
131                 add_runtime_path=no
132         elif test -n "$LD_RUN_PATH"; then
133                 add_runtime_path=yes
134         else
135                 case "$opsys" in
136                 sol2 | irix* | *bsd* | decosf* )
137                         add_runtime_path=yes
138                         ;;
139                 * )
140                         add_runtime_path=no
141                         ;;
142                 esac
143         fi
144
145         if test "$add_runtime_path" = "yes"; then
146                 ## Try to autodetect runtime library flag (usually -R),
147                 ## and whether it works (or at least does no harm)
148                 AC_MSG_CHECKING([for runtime libraries flag])
149                 case "$opsys" in
150                 sol2 )
151                         dash_r="-R"
152                         ;;
153                 decosf* | linux* | irix*)
154                         dash_r="-rpath "
155                         ;;
156                 *)
157                         dash_r=""
158                         for try_dash_r in "-R" "-R " "-rpath "; do
159                                 xe_check_libs="${try_dash_r}/no/such/file-or-directory"
160                                 SXE_PROTECT_LINKER_FLAGS(xe_check_libs)
161                                 AC_LINK_IFELSE([AC_LANG_SOURCE([[]])],
162                                         [dash_r="$try_dash_r"])
163                                 xe_check_libs=""
164                                 test -n "$dash_r" && break
165                         done
166                         ;;
167                 esac
168                 if test -n "$dash_r"; then
169                         AC_MSG_RESULT("${dash_r}")
170                 else
171                         AC_MSG_RESULT([NONE])
172                 fi
173         fi
174
175         xe_add_unique_runpath_dir='
176         xe_add_p=yes
177         for xe_dir in $runpath_dirs; do   dnl Uniquify
178                 test "$xe_dir" = "$xe_runpath_dir" && xe_add_p=no
179         done
180         if test "$xe_add_p" = "yes"; then
181                 test -n "$runpath" && runpath="${runpath}:"
182                 runpath="${runpath}${xe_runpath_dir}"
183                 runpath_dirs="$runpath_dirs $xe_runpath_dir"
184         fi'
185
186         ## t3h real computation
187         SXE_RILLY_COMPUTE_LD_RUN_PATH
188 ])dnl SXE_COMPUTE_LD_RUN_PATH
189
190
191 AC_DEFUN([SXE_COMPUTE_SITE_PREFIXES], [dnl
192         ## ---------------------------------------------------------------
193         ## Add site and system specific flags to compile and link commands
194         ## ---------------------------------------------------------------
195
196         dnl --with-site-libraries (multiple dirs)
197         SXE_COLON_TO_SPACE(with_site_libraries)
198         if test -n "$with_site_libraries"; then
199                 for arg in $with_site_libraries; do
200                         case "$arg" in
201                         -* )
202                                 ;;
203                         * )
204                                 test -d "$arg" || \
205                                 SXE_DIE("Invalid site library \`$arg': no such directory")
206                                 arg="-L${arg}"
207                                 ;;
208                         esac
209                         SXE_APPEND_UNDUP($arg, ld_switch_site)
210                 done
211         fi
212
213         dnl --with-site-includes (multiple dirs)
214         SXE_COLON_TO_SPACE(with_site_includes)
215         if test -n "$with_site_includes"; then
216                 for arg in $with_site_includes; do
217                         case "$arg" in
218                         -* )
219                                 ;;
220                         * )
221                                 test -d "$arg" || \
222                                 SXE_DIE("Invalid site include \`$arg': no such directory")
223                                 arg="-I${arg}"
224                                 ;;
225                         esac
226                         SXE_APPEND_UNDUP($arg, c_switch_site)
227                         SXE_APPEND_UNDUP($arg, CPPFLAGS)
228                 done
229         fi
230
231         dnl --with-site-prefixes (multiple dirs)
232         dnl --with-site-prefixes=dir1:dir2 is a convenient shorthand for
233         dnl --with-site-libraries=dir1/lib:dir2/lib
234         dnl --with-site-includes=dir1/include:dir2/include
235         ## Site prefixes take precedence over the standard places, but not over
236         ## with-site-includes and with-site-libraries.
237         SXE_COLON_TO_SPACE(with_site_prefixes)
238         if test -n "$with_site_prefixes"; then
239                 for dir in $with_site_prefixes; do
240                         lib_dir="${dir}/lib"
241                         inc_dir="${dir}/include"
242                         if test ! -d "$dir"; then
243                                 SXE_DIE("Invalid site prefix \`$dir': no such directory")
244                         elif test ! -d "$lib_dir"; then
245                                 SXE_DIE("Invalid site prefix \`$dir': no such directory \`$lib_dir'")
246                         else
247                                 if test -d "$inc_dir"; then
248                                         SXE_APPEND_UNDUP(["-I$inc_dir"], [CPPFLAGS])
249                                 fi
250                                 SXE_APPEND_UNDUP(["-L$lib_dir"], [LDFLAGS])
251                         fi
252                 done
253         fi
254
255         dnl GNU software installs by default into /usr/local/{include,lib}
256         if test -d "/usr/local/include" -a -d "/usr/local/lib"; then
257                 SXE_APPEND_UNDUP(["-L/usr/local/lib"], [LDFLAGS])
258                 SXE_APPEND_UNDUP(["-I/usr/local/include"], [CPPFLAGS])
259         fi
260
261         dnl Extra system-specific library directories - please add to list
262         for dir in "/usr/ccs/lib"; do
263                 dnl test -d "$dir" && SXE_APPEND_UNDUP(-L${dir}, ld_switch_system)
264                 if test -d "$dir"; then
265                         SXE_APPEND_UNDUP([-L${dir}], [LDFLAGS])
266                 fi
267         done
268 ])dnl SXE_COMPUTE_SITE_PREFIXES
269
270
271 AC_DEFUN([SXE_EXPLORE_BUILD_ENVIRONMENT], [dnl
272 dnl AC_ARG_PROGRAM
273         AC_CANONICAL_BUILD
274         AC_CANONICAL_HOST
275
276         dnl Local paths
277         test "x$prefix" = xNONE && prefix=$ac_default_prefix
278         # Let make expand exec_prefix.
279         if test "x$exec_prefix" = xNONE; then
280                 exec_prefix='${prefix}'
281         else
282                 AC_DEFINE([EXEC_PREFIX_USER_DEFINED], [1],
283                         [exec-prefix has been specified on the configure line.])
284         fi
285         ##datarootdir='${prefix}/share'
286         if test "x$datadir" != 'x${prefix}/share' && \
287            test "x$datadir" != 'x${datarootdir}'; then
288                 AC_DEFINE([INFODIR_USER_DEFINED], [1], [Description here!])
289                 AC_DEFINE([LISPDIR_USER_DEFINED], [1], [Description here!])
290                 AC_DEFINE([ETCDIR_USER_DEFINED], [1], [Description here!])
291                 AC_DEFINE([DOCDIR_USER_DEFINED], [1], [Description here!])
292         ##else
293         ##      datadir='${prefix}/share'
294         fi
295
296         if test "x$libdir" != 'x${exec_prefix}/lib'; then
297                 AC_DEFINE([ARCHLIBDIR_USER_DEFINED], [1], [Description here!])
298                 AC_DEFINE([MODULEDIR_USER_DEFINED], [1], [Description here!])
299                 AC_DEFINE([SITEMODULEDIR_USER_DEFINED], [1], [Description here!])
300         fi
301         ##if test "x$mandir" = 'x${prefix}/man' || \
302         ##   test "x$mandir" = 'x${datarootdir}/man'; then
303         ##      mandir='${prefix}/man/man1'
304         ##fi
305         if test "x$infodir" != 'x${prefix}/info' -a \
306                 "x$infodir" != 'x${datarootdir}/info'; then
307                 AC_DEFINE([INFODIR_USER_DEFINED], [1], [Description here!])
308         elif test "x$infodir" = 'x${prefix}/info'; then
309                 ## use new convention
310                 infodir='${prefix}/share/info'
311         fi
312
313         inststaticdir='${PROGNAME}'
314         instvardir='${PROGNAME}-${old_version}'
315         instvarsepdir='${PROGNAME}/${old_version}'
316         sitemoduledir='${libdir}/${inststaticdir}/${configuration}/site-modules'
317
318         dnl until someone explains what this is for!!!
319         dnl AC_SUBST([statedir], [$with_statedir])
320
321         ## Calculate canonical name for sxe_blddir (i.e. current directory)
322         SXE_COMPUTE_BLDDIR
323         ## ... and sxe_srcdir
324         SXE_COMPUTE_SRCDIR
325         ## general health checking
326         SXE_CHECK_SRCDIR_HEALTH
327
328         ## derive emodblddir from this
329         emodblddir=$sxe_blddir/modules
330         ## derivate emodsrcdir from srcdir
331         emodsrcdir=$sxe_srcdir/modules
332 ])dnl SXE_EXPLORE_BUILD_ENVIRONMENT
333
334 dnl sxe-bldenv.m4 ends here