[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Darwin universal binaries and LDFLAGS conundrum
From: |
Keith MARSHALL |
Subject: |
Re: Darwin universal binaries and LDFLAGS conundrum |
Date: |
Wed, 23 May 2007 15:50:16 +0100 |
Martin-Gilles Lavoie wrote:
> At the strict minimum, I need to have the following flags set
> in the generated makefile:
>
> CFLAGS = -c $(CPPFLAGS) -O3 -isysroot \
> /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc
> LDFLAGS = -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk
>
> The problem is, whatever I set for LDFLAGS or CFLAGS in the .ac file
> passed to autoconf, the output Makefile is invariably stripped down
> to an empty LDFLAGS declaration and a CFLAGS devoid of the -isysroot
> and -arch parameters.
Well, firstly I wouldn't embed $(CPPFLAGS) within the CFLAGS definition;
neither would I add the `-c' flag at this point -- both are better placed
in the commands section of any rules in which they are required.
Now, consider this trivial example:
$ cat configure.ac
AC_INIT
pop_CFLAGS="$CFLAGS" pop_LDFLAGS="$LDFLAGS"
CFLAGS="" LDFLAGS=""
AC_PROG_CC
CFLAGS="$pop_CFLAGS" LDFLAGS="$pop_LDFLAGS"
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
$ cat Makefile.in
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
Note that your CFLAGS/LDFLAGS combination is invalid for my compiler;
(I'm running GCC on Woe32). Thus, this example kludges them away, for
the purpose of the AC_PROG_CC test, since they would cause it to fail,
and `configure' would die. In your case, they *should* work within
AC_PROG_CC, so the real example reduces to:
$ cat configure.ac
AC_INIT
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
Now, if I run:
$ autoconf
$ ./configure \
CFLAGS='-O3 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc'\
LDFLAGS='-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk'
I see:
checking for gcc... gcc
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
configure: creating ./config.status
config.status: creating Makefile
and finally:
$ cat makefile
CFLAGS = -O3 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc
LDFLAGS = -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk
which seems to have the flags you require, propagated into the Makefile.
HTH,
Keith.