1 # FP_LEADING_UNDERSCORE
2 # ---------------------
3 # Test for determining whether symbol names have a leading underscore. We assume
4 # that they _haven't_ if anything goes wrong. Sets the output variable
5 # LeadingUnderscore to YES or NO and defines LEADING_UNDERSCORE correspondingly.
7 # Some nlist implementations seem to try to be compatible by ignoring a leading
8 # underscore sometimes (eg. FreeBSD). We therefore have to work around this by
9 # checking for *no* leading underscore first. Sigh. --SDM
11 # Similarly on OpenBSD, but this test doesn't help. -- dons
13 AC_DEFUN([FP_LEADING_UNDERSCORE],
14 [AC_CHECK_LIB([elf], [nlist], [LIBS="-lelf $LIBS"])
15 AC_CACHE_CHECK([leading underscore in symbol names], [fptools_cv_leading_underscore], [
16 # Hack!: nlist() under Digital UNIX insist on there being an _,
17 # but symbol table listings shows none. What is going on here?!?
18 case $TargetPlatform in
19 # Apples mach-o platforms use leading underscores
20 *-apple-*) fptools_cv_leading_underscore=yes;;
21 *linux-android*) fptools_cv_leading_underscore=no;;
22 *openbsd*) # x86 openbsd is ELF from 3.4 >, meaning no leading uscore
24 i386-*2\.@<:@0-9@:>@ | i386-*3\.@<:@0-3@:>@ ) fptools_cv_leading_underscore=yes ;;
25 *) fptools_cv_leading_underscore=no ;;
27 x86_64-unknown-mingw32) fptools_cv_leading_underscore=no;;
28 *) AC_RUN_IFELSE([AC_LANG_SOURCE([[#if defined(HAVE_NLIST_H)
30 struct nlist xYzzY1[] = {{"xYzzY1", 0},{0}};
31 struct nlist xYzzY2[] = {{"_xYzzY2", 0},{0}};
34 int main(int argc, char **argv)
36 #if defined(HAVE_NLIST_H)
37 if(nlist(argv[0], xYzzY1) == 0 && xYzzY1[0].n_value != 0)
39 if(nlist(argv[0], xYzzY2) == 0 && xYzzY2[0].n_value != 0)
43 }]])],[fptools_cv_leading_underscore=yes],[fptools_cv_leading_underscore=no],[fptools_cv_leading_underscore=no])
46 ])# FP_LEADING_UNDERSCORE