[Python-Dev] autoconf question: howto add to CFLAGS and LDFLAGS? (original) (raw)

Thomas Wouters thomas@xs4all.net
Thu, 17 Aug 2000 08:55:41 +0200


On Wed, Aug 16, 2000 at 04:55:42PM -0700, Trent Mick wrote:

I am currently trying to port Python to Monterey (64-bit AIX) and I need to add a couple of Monterey specific options to CFLAGS and LDFLAGS (or to whatever appropriate variables for all 'cc' and 'ld' invocations) but it is not obvious at all how to do that in configure.in. Can anybody helpme on that?

You'll have to write a shell 'case' for AIX Monterey, checking to make sure it is monterey, and setting LDFLAGS accordingly. If you look around in configure.in, you'll see a few other 'special cases', all to tune the way the compiler is called. Depending on what you need to do to detect monterey, you could fit it in one of those. Just search for 'Linux' or 'bsdos' to find a couple of those cases.

ANother issue that I am having. This is how the python executable is linked on Linux with gcc:

gcc -Xlinker -export-dynamic python.o ../libpython2.0.a -lpthread -ldl -lutil -lm -o python

It, of course, works fine, but shouldn't the proper (read "portable") invocation to include the python2.0 library be

gcc -Xlinker -export-dynamic python.o -L.. -lpython2.0 -lpthread -ldl -lutil -lm -o python

That invocation form (i.e. with the '-L.. -lpython2.0') works on Linux, and is required on Monterey. Does this problem not show up with other Unix compilers. My hunch is that simply listing library (*.a) arguments on the gcc command line is a GNU gcc/ld shortcut to the more portable usage of -L and -l. Any opinions. I would either like to change the form to the latter or I'll have to special case the invocation for Monterey. ANy opinions on which is worse.

Well, as far as I know, '-L.. -lpython2.0' does something different than just '../libpython2.0.a' ! When supplying the static library on the command line, the library is always statically linked. When using -L/-l, it is usually dynamically linked, unless a dynamic library doesn't exist. We currently don't have a libpython2.0.so, but a patch to add it is on Barry's plate. Also, I'm not entirely sure about the search order in such a case: gcc's docs seem to suggest that the systemwide library directories are searched before the -L directories. I'm not sure on that, though.

Also, listing the library on the command line is not a gcc shortcut, but other people already said that :) I'd be suprised if AIX removed it (but not especially so; my girlfriend works with AIX machines a lot, and she already showed me some suprising things ;) but perhaps there is another workaround ?

-- Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!