diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-04-02 11:52:47 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-05 05:42:38 -0400 |
commit | 7ffbdc3fa603c6411249ba9b758cf8f109c5fb30 (patch) | |
tree | 8a05d6e03ce2790e6e59651c824e569fee088d33 /m4/fp_leading_underscore.m4 | |
parent | 6acadb79afe685c635fd255f90551a0fbfcbe3dc (diff) | |
download | haskell-7ffbdc3fa603c6411249ba9b758cf8f109c5fb30.tar.gz |
Break up aclocal.m4
Diffstat (limited to 'm4/fp_leading_underscore.m4')
-rw-r--r-- | m4/fp_leading_underscore.m4 | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/m4/fp_leading_underscore.m4 b/m4/fp_leading_underscore.m4 new file mode 100644 index 0000000000..5fac9f9624 --- /dev/null +++ b/m4/fp_leading_underscore.m4 @@ -0,0 +1,56 @@ +# FP_LEADING_UNDERSCORE +# --------------------- +# Test for determining whether symbol names have a leading underscore. We assume +# that they _haven't_ if anything goes wrong. Sets the output variable +# LeadingUnderscore to YES or NO and defines LEADING_UNDERSCORE correspondingly. +# +# Some nlist implementations seem to try to be compatible by ignoring a leading +# underscore sometimes (eg. FreeBSD). We therefore have to work around this by +# checking for *no* leading underscore first. Sigh. --SDM +# +# Similarly on OpenBSD, but this test doesn't help. -- dons +# +AC_DEFUN([FP_LEADING_UNDERSCORE], +[AC_CHECK_LIB([elf], [nlist], [LIBS="-lelf $LIBS"]) +AC_CACHE_CHECK([leading underscore in symbol names], [fptools_cv_leading_underscore], [ +# Hack!: nlist() under Digital UNIX insist on there being an _, +# but symbol table listings shows none. What is going on here?!? +case $TargetPlatform in + # Apples mach-o platforms use leading underscores + *-apple-*) fptools_cv_leading_underscore=yes;; + *linux-android*) fptools_cv_leading_underscore=no;; + *openbsd*) # x86 openbsd is ELF from 3.4 >, meaning no leading uscore + case $build in + i386-*2\.@<:@0-9@:>@ | i386-*3\.@<:@0-3@:>@ ) fptools_cv_leading_underscore=yes ;; + *) fptools_cv_leading_underscore=no ;; + esac ;; + i386-unknown-mingw32) fptools_cv_leading_underscore=yes;; + x86_64-unknown-mingw32) fptools_cv_leading_underscore=no;; + *) AC_RUN_IFELSE([AC_LANG_SOURCE([[#if defined(HAVE_NLIST_H) +#include <nlist.h> +struct nlist xYzzY1[] = {{"xYzzY1", 0},{0}}; +struct nlist xYzzY2[] = {{"_xYzzY2", 0},{0}}; +#endif + +int main(argc, argv) +int argc; +char **argv; +{ +#if defined(HAVE_NLIST_H) + if(nlist(argv[0], xYzzY1) == 0 && xYzzY1[0].n_value != 0) + exit(1); + if(nlist(argv[0], xYzzY2) == 0 && xYzzY2[0].n_value != 0) + exit(0); +#endif + exit(1); +}]])],[fptools_cv_leading_underscore=yes],[fptools_cv_leading_underscore=no],[fptools_cv_leading_underscore=no]) +;; +esac]); +AC_SUBST([LeadingUnderscore], [`echo $fptools_cv_leading_underscore | sed 'y/yesno/YESNO/'`]) +if test x"$fptools_cv_leading_underscore" = xyes; then + AC_SUBST([CabalLeadingUnderscore],[True]) + AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.]) +else + AC_SUBST([CabalLeadingUnderscore],[False]) +fi +])# FP_LEADING_UNDERSCORE |