automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to check 64bit or 32 bit machine?


From: Ralf Wildenhues
Subject: Re: how to check 64bit or 32 bit machine?
Date: Thu, 22 Nov 2007 08:05:46 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Hello Ting,

* susan xie wrote on Thu, Nov 22, 2007 at 04:10:27AM CET:
> 
> > I want to use a third-party library in my Makefile.am. The static
> > third party library is put in a directory with 2 sub-directories:
> > 'linux' and 'linux64'.  On 64bit machine, my code needs to link with
> > the static library in 'linux64' directory. While on 32 bit machine,
> > it needs to link with the static library in 'linux' directory.  Do
> > you know how to check 64bit machine or 32 bit machine to finish this
> > task? 
[...]
> Currently I have 2 ways to finish this. If you happen to know the
> details, please let me know. Thanks very much. 
> 
> 1. AC_CHECK_SIZEOF(void*) ,  but how to catch the result of this
> checking MACRO,  i.e., checking result of (sizeof(void*)  =4) : yes or
> no ? I thought of  SIZEOF_VOIDP, but then how to use this variable ? 
> 
> 2.  AC_CANONICAL_BUILD ,   May you show me an example to use this Macro ?  

Both methods assume more knowledge than you need.  Why not just try to
link against each, and use whichever succeeds?  Something like

  save_LDFLAGS=$LDFLAGS
  found=no
  for try in "" -L.../linux -L.../linux64; do
    AC_LINK_IFELSE([AC_LANG_PROGRAM([PROLOGUE...], [BODY...])],
                   [found=$try])
    if "X$found" != Xno; then break; fi
  done
  # do something with $found here, for example just keep it in LDFLAGS.
  LDFLAGS=$save_LDFLAGS

In this example, you should replace PROLOGUE... and BODY... with
headers needed to include, and some function call or so that needs the
specific library.

Hope that helps.  For more information, see for example
  info --index-search=AC_LINK_IFELSE Autoconf

Cheers,
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]