Thanks,
first:
The "too late" was just an assumption because the "ac_XXX" definition
use the CFLAGS
before the CFLAGS is set by me, I understand that my try to force 32 bit
is not
quite common but if the source-code is ONLY written and tested for 32bit
it would
be quite "unfriendly" to let the user build 64bit code which is probably
broken.
second:
I think the hint about -m32 and -mx32 is good because -mx32 is probably
the thing I really
want. A "autoconf" option is a good approach to let the used decide
between -m32 and
-mx32
third:
The alternative would be to write a "wrapper-script" for "configure" to
force the thing
I want, I think this would be the most-worse thing.
what I really missing is the proper (--host or --target) option which
set the 32bit code
correct and portable. Any --host option seems to search for compiler
with "host" prefix
-> this does not work together with gnu "gcc" because the option
approach uses the same
compiler front-end as 64bit.
If I use my second approach the configure output start with:
configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
> there is NOTHING about 32 bit, even the -m32/-mx32 flag is not recognized
> in the "host/target system type message.
I feel uncomfortable about the "32bit" support in autoconf.
mfg
On 07.05.21 01:32, Thomas Jahns wrote:
Hello,
On 5/6/21 7:45 PM, 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.
I know that a user can do "configure CC="gcc -m32"... etc but this is
NOT what I want.
I want that the 'configure' script set the 32bin once at start and fix.
I think that's a bad use of autoconf which is meant to provide a
portability shim for any kind of system, be it 32 or 64 bits. Also,
specifically on Linux there are two 32 bit modes (i386 and x32).
Regarding your problem: your first try uses commands that precede the
AC_INIT and will consequently be ignored by autoconf. You should
probably put those before AC_PROG_CC, but after AC_INIT. What do you
mean by being too late in the second attempt?
Still: I very much recommend against trying to force a particular
system property that might easily go away (modern x86_64 Linux
installations often don't include 32 bit headers anymore, Ubuntu for
example has stopped support of its i386 variant).
Better invest your time in creating software that works with any
number of address bits.
Kind regards, Thomas
---------------------------------------
my SECOND try fails to, the "CCT-MARK" show up but too late :
# set CCT3 VERSION information also in:
AC_INIT(....)
# CCT-MARK
#
https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html
# force 32 bit only
export CFLAGS="$CFLAGS -m32 -O2"
export CXXFLAGS="$CXXFLAGS -m32 -O2"
export LDFLAGS="$LDFLAGS -m32 -O2"
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([gnu tar-ustar no-dist-gzip dist-bzip2
-Wno-portability subdir-objects])
The "CCT-MARK" section is AFTER the ac_XXXX definition, I think this
mean that tests are done
with 64 bit.
created 'configure' script
===============================================
...
## -------------------- ##
## Main body of script. ##
## -------------------- ##
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS
conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
# CCT-MARK
#
https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html
# force 32 bit only
export CFLAGS="$CFLAGS -m32 -O2"
export CXXFLAGS="$CXXFLAGS -m32 -O2"
export LDFLAGS="$LDFLAGS -m32 -O2"
...
=================================================
> Question, what I have to do to force 32 bit ?
mfg.