1 dnl sxe-bldenv.m4 -- Things for/on the build environment
3 AC_DEFUN([SXE_LD_EXPORT_DYNAMIC], [dnl
4 AC_MSG_CHECKING([if linker understands -export-dynamic])
6 LDFLAGS="-export-dynamic $LDFLAGS"
7 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
11 ]])], [AC_MSG_RESULT([yes])
12 have_ld_export_dynamic="yes"], [
14 have_ld_export_dynamic="no"])
16 ])dnl SXE_LD_EXPORT_DYNAMIC
19 AC_DEFUN([SXE_LD_NO_PIE], [dnl
20 AC_MSG_CHECKING([if linker understands -no_pie])
22 LDFLAGS="-no_pie $LDFLAGS"
23 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
27 ]])], [AC_MSG_RESULT([yes])
28 have_ld_no_pie="yes"], [
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"`
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.
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"
52 echo "int main(int argc, char *argv[[]]) {return 0;}" \
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
58 for dir in `echo '' "$arg" | sed -e 's:^ ::' -e 's/^..//' -e 'y/:/ /'`; do
59 SXE_ADD_RUNPATH_DIR(["$dir"])
64 ld_switch_run="$ld_switch_run_save"
67 ## Add all directories with .so files to runpath
68 for arg in $ld_switch_site $ld_switch_x_site; do
71 SXE_ADD_RUNPATH_DIR(`echo '' "$arg" | sed -e 's:^ ::' -e 's/^-L//'`)
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";
81 fi dnl Compute $runpath
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"
91 ])dnl SXE_RILLY_COMPUTE_LD_RUN_PATH
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'`"
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])
105 ## -------------------------------------
106 ## Compute runtime library path
107 ## -------------------------------------
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.
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...
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)
125 ## add_runtime_path=no
128 if test -n "$add_runtime_path"; then
130 elif test "$with_dynamic" = "no"; then
132 elif test -n "$LD_RUN_PATH"; then
136 sol2 | irix* | *bsd* | decosf* )
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])
153 decosf* | linux* | irix*)
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"])
164 test -n "$dash_r" && break
168 if test -n "$dash_r"; then
169 AC_MSG_RESULT("${dash_r}")
171 AC_MSG_RESULT([NONE])
175 xe_add_unique_runpath_dir='
177 for xe_dir in $runpath_dirs; do dnl Uniquify
178 test "$xe_dir" = "$xe_runpath_dir" && xe_add_p=no
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"
186 ## t3h real computation
187 SXE_RILLY_COMPUTE_LD_RUN_PATH
188 ])dnl SXE_COMPUTE_LD_RUN_PATH
191 AC_DEFUN([SXE_COMPUTE_SITE_PREFIXES], [dnl
192 ## ---------------------------------------------------------------
193 ## Add site and system specific flags to compile and link commands
194 ## ---------------------------------------------------------------
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
205 SXE_DIE("Invalid site library \`$arg': no such directory")
209 SXE_APPEND_UNDUP($arg, ld_switch_site)
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
222 SXE_DIE("Invalid site include \`$arg': no such directory")
226 SXE_APPEND_UNDUP($arg, c_switch_site)
227 SXE_APPEND_UNDUP($arg, CPPFLAGS)
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
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'")
247 if test -d "$inc_dir"; then
248 SXE_APPEND_UNDUP(["-I$inc_dir"], [CPPFLAGS])
250 SXE_APPEND_UNDUP(["-L$lib_dir"], [LDFLAGS])
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])
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])
268 ])dnl SXE_COMPUTE_SITE_PREFIXES
271 AC_DEFUN([SXE_EXPLORE_BUILD_ENVIRONMENT], [dnl
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}'
282 AC_DEFINE([EXEC_PREFIX_USER_DEFINED], [1],
283 [exec-prefix has been specified on the configure line.])
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!])
293 ## datadir='${prefix}/share'
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!])
301 ##if test "x$mandir" = 'x${prefix}/man' || \
302 ## test "x$mandir" = 'x${datarootdir}/man'; then
303 ## mandir='${prefix}/man/man1'
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'
313 inststaticdir='${PROGNAME}'
314 instvardir='${PROGNAME}-${old_version}'
315 instvarsepdir='${PROGNAME}/${old_version}'
316 sitemoduledir='${libdir}/${inststaticdir}/${configuration}/site-modules'
318 dnl until someone explains what this is for!!!
319 dnl AC_SUBST([statedir], [$with_statedir])
321 ## Calculate canonical name for sxe_blddir (i.e. current directory)
323 ## ... and sxe_srcdir
325 ## general health checking
326 SXE_CHECK_SRCDIR_HEALTH
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
334 dnl sxe-bldenv.m4 ends here