RE: Force 32 bit build

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

 



On Thu, 6 May 2021 19:45:45 +0200, aotto wrote:
> I want to write a "autoconf/automake" script for an application ONLY for
> 32 bit on 64 bit Linux.
> This meant that the default for configure must be 32 bit and nothing else.

Best is to check the bitness with the compiler itself instead of using triplet strings or compiler flags which might or might not exist. Autoconf provides a vast of techniques of how to check things.  So here the idea is to calculate CHAR_BIT*sizeof(void*) to produce the compiler's bitness. 

A snippet below you might want to plug into your configure.ac which I believe is portable.  The corresponding script configure then runs into an emergency stop when the current compiler is checked not to be 32bit. It applies to cross-compiling, too. 

AS_VAR_PUSHDEF([bitness],[ac_cv_prog_[]_AC_LANG_ABBREV[]_bitness])
AC_MSG_CHECKING([for compiler bitness])
AC_COMPUTE_INT([bitness],
  [CHAR_BIT*sizeof(void*)],[[#include <limits.h>]],
  [AC_MSG_RESULT([failed])
   AC_MSG_ERROR([check for bitness of compiler '$CC' failed],[99])])
AC_MSG_RESULT([${bitness}bit])
AS_CASE([$bitness],[32],[],
  [AC_MSG_ERROR([Package compiles cleanly only for 32bit compilers. Abortion for compiler '$CC'.])])
AS_VAR_POPDEF([bitness])

HTH.
J.






[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux