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
18 dnl SXE_RILLY_COMPUTE_LD_RUN_PATH()
19 AC_DEFUN([SXE_RILLY_COMPUTE_LD_RUN_PATH], [dnl
20 if test "$add_runtime_path" = "yes" -a -n "$dash_r"; then
21 ## Remove runtime paths from current ld switches
22 ld_switch_site=`echo '' $ld_switch_site | sed -e 's:^ ::' -e "s/$dash_r[[^ ]]*//g"`
23 ld_switch_x_site=`echo '' $ld_switch_x_site | sed -e 's:^ ::' -e "s/$dash_r[[^ ]]*//g"`
25 ## Fix up Runtime path
26 ## If LD_RUN_PATH is set in environment, use that.
27 ## In this case, assume user has set the right value.
30 if test -n "$LD_RUN_PATH"; then
31 runpath="$LD_RUN_PATH"
32 elif test "$GCC" = "yes"; then
33 ## Compute runpath from gcc's -v output
34 ld_switch_run_save="$ld_switch_run"
36 echo "int main(int argc, char *argv[[]]) {return 0;}" \
38 xe_runpath_link='${CC-cc} -o conftest -v $CFLAGS '"$xe_ldflags"' conftest.$ac_ext 2>&1 1>/dev/null'
39 for arg in `eval "$xe_runpath_link" | grep ' -L'`; do
42 for dir in `echo '' "$arg" | sed -e 's:^ ::' -e 's/^..//' -e 'y/:/ /'`; do
43 SXE_ADD_RUNPATH_DIR(["$dir"])
48 ld_switch_run="$ld_switch_run_save"
51 ## Add all directories with .so files to runpath
52 for arg in $ld_switch_site $ld_switch_x_site; do
55 SXE_ADD_RUNPATH_DIR(`echo '' "$arg" | sed -e 's:^ ::' -e 's/^-L//'`)
59 ## Sometimes /opt/SUNWdt/lib is the only
60 ## installed Motif available
61 if test "$opsys $need_motif" = "sol2 yes"; then
62 xe_runpath_dir="/opt/SUNWdt/lib";
63 eval "$xe_add_unique_runpath_dir";
65 fi dnl Compute $runpath
67 if test -n "$runpath"; then
68 ld_switch_run="${dash_r}${runpath}"
69 SXE_PROTECT_LINKER_FLAGS(ld_switch_run)
70 if test "$extra_verbose" = "yes"; then
71 echo "Setting runpath to $runpath"
75 ])dnl SXE_RILLY_COMPUTE_LD_RUN_PATH
77 AC_DEFUN([SXE_COMPUTE_LD_RUN_PATH], [dnl
78 ## --with-site-runtime-libraries (multiple dirs)
79 SXE_COLON_TO_SPACE(with_site_runtime_libraries)
80 if test -n "$with_site_runtime_libraries"; then
81 LD_RUN_PATH="`echo $with_site_runtime_libraries | sed -e 's/ */:/g'`"
83 for path in $with_site_runtime_libraries; do
84 dnl SXE_APPEND("-R$path ", $ld_switch_run)
85 SXE_APPEND(["-R${path} "], [LDFLAGS])
89 ## -------------------------------------
90 ## Compute runtime library path
91 ## -------------------------------------
93 ## Linux systems have dynamic runtime library directories listed in
94 ## /etc/ld.so.conf. Since those are used at run time, it seems pretty
95 ## safe to use them at link time, and less controversial than forcing
96 ## the run-time to use the link-time libraries. This also helps avoid
97 ## mismatches between the link-time and run-time libraries.
99 ## #### Unfortunately, there are horrible libc4 and libc5 libraries
100 ## listed in /etc/ld.so.conf on some systems, and including them on
101 ## the link path leads to linking in utterly broken libc's.
102 ## There are many clever ways of approaching this problem,
103 ## but finding one that actually works...
105 ## if test -z "$LD_RUN_PATH" -a -r "/etc/ld.so.conf"; then
106 ## for dir in `cat /etc/ld.so.conf`; do
107 ## test -d "$dir" && SXE_APPEND(-L${dir}, ld_switch_system)
109 ## add_runtime_path=no
112 if test -n "$add_runtime_path"; then
114 elif test "$with_dynamic" = "no"; then
116 elif test -n "$LD_RUN_PATH"; then
120 sol2 | irix* | *bsd* | decosf* )
129 if test "$add_runtime_path" = "yes"; then
130 ## Try to autodetect runtime library flag (usually -R),
131 ## and whether it works (or at least does no harm)
132 AC_MSG_CHECKING([for runtime libraries flag])
137 decosf* | linux* | irix*)
142 for try_dash_r in "-R" "-R " "-rpath "; do
143 xe_check_libs="${try_dash_r}/no/such/file-or-directory"
144 SXE_PROTECT_LINKER_FLAGS(xe_check_libs)
145 AC_LINK_IFELSE([AC_LANG_SOURCE([[]])],
146 [dash_r="$try_dash_r"])
148 test -n "$dash_r" && break
152 if test -n "$dash_r"; then
153 AC_MSG_RESULT("${dash_r}")
155 AC_MSG_RESULT([NONE])
159 xe_add_unique_runpath_dir='
161 for xe_dir in $runpath_dirs; do dnl Uniquify
162 test "$xe_dir" = "$xe_runpath_dir" && xe_add_p=no
164 if test "$xe_add_p" = "yes"; then
165 test -n "$runpath" && runpath="${runpath}:"
166 runpath="${runpath}${xe_runpath_dir}"
167 runpath_dirs="$runpath_dirs $xe_runpath_dir"
170 ## t3h real computation
171 SXE_RILLY_COMPUTE_LD_RUN_PATH
172 ])dnl SXE_COMPUTE_LD_RUN_PATH
175 AC_DEFUN([SXE_COMPUTE_SITE_PREFIXES], [dnl
176 ## ---------------------------------------------------------------
177 ## Add site and system specific flags to compile and link commands
178 ## ---------------------------------------------------------------
180 dnl --with-site-libraries (multiple dirs)
181 SXE_COLON_TO_SPACE(with_site_libraries)
182 if test -n "$with_site_libraries"; then
183 for arg in $with_site_libraries; do
189 SXE_DIE("Invalid site library \`$arg': no such directory")
193 SXE_APPEND($arg, ld_switch_site)
197 dnl --with-site-includes (multiple dirs)
198 SXE_COLON_TO_SPACE(with_site_includes)
199 if test -n "$with_site_includes"; then
200 for arg in $with_site_includes; do
206 SXE_DIE("Invalid site include \`$arg': no such directory")
210 SXE_APPEND($arg, c_switch_site)
211 SXE_APPEND($arg, CPPFLAGS)
215 dnl --with-site-prefixes (multiple dirs)
216 dnl --with-site-prefixes=dir1:dir2 is a convenient shorthand for
217 dnl --with-site-libraries=dir1/lib:dir2/lib
218 dnl --with-site-includes=dir1/include:dir2/include
219 ## Site prefixes take precedence over the standard places, but not over
220 ## with-site-includes and with-site-libraries.
221 SXE_COLON_TO_SPACE(with_site_prefixes)
222 if test -n "$with_site_prefixes"; then
223 for dir in $with_site_prefixes; do
225 inc_dir="${dir}/include"
226 if test ! -d "$dir"; then
227 SXE_DIE("Invalid site prefix \`$dir': no such directory")
228 elif test ! -d "$lib_dir"; then
229 SXE_DIE("Invalid site prefix \`$dir': no such directory \`$lib_dir'")
231 if test -d "$inc_dir"; then
232 SXE_APPEND(["-I$inc_dir"], [CPPFLAGS])
234 SXE_APPEND(["-L$lib_dir"], [LDFLAGS])
239 dnl GNU software installs by default into /usr/local/{include,lib}
240 if test -d "/usr/local/include" -a -d "/usr/local/lib"; then
241 SXE_APPEND(["-L/usr/local/lib"], [LDFLAGS])
242 SXE_APPEND(["-I/usr/local/include"], [CPPFLAGS])
245 dnl Extra system-specific library directories - please add to list
246 for dir in "/usr/ccs/lib"; do
247 dnl test -d "$dir" && SXE_APPEND(-L${dir}, ld_switch_system)
248 if test -d "$dir"; then
249 SXE_APPEND([-L${dir}], [LDFLAGS])
252 ])dnl SXE_COMPUTE_SITE_PREFIXES
255 AC_DEFUN([SXE_EXPLORE_BUILD_ENVIRONMENT], [dnl
261 test "x$prefix" = xNONE && prefix=$ac_default_prefix
262 # Let make expand exec_prefix.
263 if test "x$exec_prefix" = xNONE; then
264 exec_prefix='${prefix}'
266 AC_DEFINE([EXEC_PREFIX_USER_DEFINED], [1],
267 [exec-prefix has been specified on the configure line.])
269 ##datarootdir='${prefix}/share'
270 if test "x$datadir" != 'x${prefix}/share' && \
271 test "x$datadir" != 'x${datarootdir}'; then
272 AC_DEFINE([INFODIR_USER_DEFINED], [1], [Description here!])
273 AC_DEFINE([LISPDIR_USER_DEFINED], [1], [Description here!])
274 AC_DEFINE([ETCDIR_USER_DEFINED], [1], [Description here!])
275 AC_DEFINE([DOCDIR_USER_DEFINED], [1], [Description here!])
277 ## datadir='${prefix}/share'
280 if test "x$libdir" != 'x${exec_prefix}/lib'; then
281 AC_DEFINE([ARCHLIBDIR_USER_DEFINED], [1], [Description here!])
282 AC_DEFINE([MODULEDIR_USER_DEFINED], [1], [Description here!])
283 AC_DEFINE([SITEMODULEDIR_USER_DEFINED], [1], [Description here!])
285 ##if test "x$mandir" = 'x${prefix}/man' || \
286 ## test "x$mandir" = 'x${datarootdir}/man'; then
287 ## mandir='${prefix}/man/man1'
289 if test "x$infodir" != 'x${prefix}/info' -a \
290 "x$infodir" != 'x${datarootdir}/info'; then
291 AC_DEFINE([INFODIR_USER_DEFINED], [1], [Description here!])
292 elif test "x$infodir" = 'x${prefix}/info'; then
293 ## use new convention
294 infodir='${prefix}/share/info'
297 inststaticdir='${PROGNAME}'
298 instvardir='${PROGNAME}-${old_version}'
299 instvarsepdir='${PROGNAME}/${old_version}'
300 sitemoduledir='${libdir}/${inststaticdir}/${configuration}/site-modules'
302 dnl until someone explains what this is for!!!
303 dnl AC_SUBST([statedir], [$with_statedir])
305 ## Calculate canonical name for sxe_blddir (i.e. current directory)
307 ## ... and sxe_srcdir
309 ## general health checking
310 SXE_CHECK_SRCDIR_HEALTH
312 ## derive emodblddir from this
313 emodblddir=$sxe_blddir/modules
314 ## derivate emodsrcdir from srcdir
315 emodsrcdir=$sxe_srcdir/modules
316 ])dnl SXE_EXPLORE_BUILD_ENVIRONMENT
318 dnl sxe-bldenv.m4 ends here