How to configure makefile for different build platforms

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

How to configure makefile for different build platforms

David Aldrich

Hi

 

I have a C++ application that uses Boost.Python.  We build it on Centos 5.3, with Python 2.4 and Boost 1.34.

 

Our makefile uses explicit paths to find Python and Boost. For the headers we use:

 

PYTHON = /usr/include/python2.4

BOOST_INC = /usr/include/boost

 

INCPATH=$(PYTHON)

INCPATH+=$(BOOST_INC)

 

CXXFLAGS += $(patsubst %,-I%,$(INCPATH))

 

$(CXX) -c $(CXXFLAGS) sourcefile etc

 

Now I need to support building on Ubuntu 10.04 which has Python 2.6, not 2.4, installed.

 

Please can someone suggest how I can modify the makefile to conveniently handle the different Python paths according to the build platform.

 

Should I simply require the user to define PYTHON as an environment variable, or is there a better way without resorting to something complex like autoconf?

 

Best regards

 

David

 


_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

Wichert Akkerman
On 2011-10-5 18:12, David Aldrich wrote:

> Hi
>
> I have a C++ application that uses Boost.Python. We build it on Centos
> 5.3, with Python 2.4 and Boost 1.34.
>
> Our makefile uses explicit paths to find Python and Boost. For the
> headers we use:
>
> PYTHON = /usr/include/python2.4
>
> BOOST_INC = /usr/include/boost
>
> INCPATH=$(PYTHON)
>
> INCPATH+=$(BOOST_INC)
>
> CXXFLAGS += $(patsubst %,-I%,$(INCPATH))
>
> $(CXX) -c $(CXXFLAGS) sourcefile etc
>
> Now I need to support building on Ubuntu 10.04 which has Python 2.6, not
> 2.4, installed.
>
> Please can someone suggest how I can modify the makefile to conveniently
> handle the different Python paths according to the build platform.

On Ubuntu you can call pkg-config to figure out the right compiler and
linker options for both Boost and Python. I would expect CentOS to
support that as well.

Wichert.

--
Wichert Akkerman <[hidden email]>   It is simple to make things.
http://www.wiggy.net/                  It is hard to make things simple.
_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

David Aldrich
> On Ubuntu you can call pkg-config to figure out the right compiler and linker
> options for both Boost and Python. I would expect CentOS to support that as
> well.


Hi Wichert

Thanks for your suggestion. However, on my Ubuntu system:

pkg-config --list-all

lists neither python-dev not libboost-all-dev

which are what my makefile needs to reference.

David
_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

Wichert Akkerman
On 10/06/2011 02:55 PM, David Aldrich wrote:

>> On Ubuntu you can call pkg-config to figure out the right compiler and linker
>> options for both Boost and Python. I would expect CentOS to support that as
>> well.
>
> Hi Wichert
>
> Thanks for your suggestion. However, on my Ubuntu system:
>
> pkg-config --list-all
>
> lists neither python-dev not libboost-all-dev
>
> which are what my makefile needs to reference.

pkg-config does not use Debian packages names. Try using "python" for
the current standard python 2 version, or pythonX.Y for specific
versions. Boost appears to be installed in a standard location, so
doesn't need any special compiler or linker options.

Wichert.


_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

David Aldrich
> pkg-config does not use Debian packages names. Try using "python" for the
> current standard python 2 version, or pythonX.Y for specific versions. Boost
> appears to be installed in a standard location, so doesn't need any special
> compiler or linker options.

Thanks but --list-all only lists notify-python and  dbus-python.

David
_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

Wichert Akkerman
On 10/06/2011 03:09 PM, David Aldrich wrote:
>> pkg-config does not use Debian packages names. Try using "python" for the
>> current standard python 2 version, or pythonX.Y for specific versions. Boost
>> appears to be installed in a standard location, so doesn't need any special
>> compiler or linker options.
> Thanks but --list-all only lists notify-python and  dbus-python.

Odd. Try python2.6-config.


_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

David Aldrich


> -----Original Message-----
> From: cplusplus-sig-bounces+david.aldrich=[hidden email]
> [mailto:cplusplus-sig-bounces+david.aldrich=[hidden email]]
> On Behalf Of Wichert Akkerman
> Sent: 06 October 2011 14:51
> To: [hidden email]
> Subject: Re: [C++-sig] How to configure makefile for different build platforms
>
> On 10/06/2011 03:09 PM, David Aldrich wrote:
> >> pkg-config does not use Debian packages names. Try using "python" for
> >> the current standard python 2 version, or pythonX.Y for specific
> >> versions. Boost appears to be installed in a standard location, so
> >> doesn't need any special compiler or linker options.
> > Thanks but --list-all only lists notify-python and  dbus-python.
>
> Odd. Try python2.6-config.

No, that's not there either.

http://bugs.python.org/issue3585  suggests that pkg-config support in Python was not added until at least 2.6.  Perhaps it did not make it in the version I have.  Besides, I also wanted it to detect Python 2.4. So this method won't work unfortunately.
_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

Jim Bosch-2
On 10/06/2011 10:02 AM, David Aldrich wrote:

>
>
>> -----Original Message-----
>> From: cplusplus-sig-bounces+david.aldrich=[hidden email]
>> [mailto:cplusplus-sig-bounces+david.aldrich=[hidden email]]
>> On Behalf Of Wichert Akkerman
>> Sent: 06 October 2011 14:51
>> To: [hidden email]
>> Subject: Re: [C++-sig] How to configure makefile for different build platforms
>>
>> On 10/06/2011 03:09 PM, David Aldrich wrote:
>>>> pkg-config does not use Debian packages names. Try using "python" for
>>>> the current standard python 2 version, or pythonX.Y for specific
>>>> versions. Boost appears to be installed in a standard location, so
>>>> doesn't need any special compiler or linker options.
>>> Thanks but --list-all only lists notify-python and  dbus-python.
>>
>> Odd. Try python2.6-config.
>
> No, that's not there either.
>
> http://bugs.python.org/issue3585  suggests that pkg-config support in Python was not added until at least 2.6.  Perhaps it did not make it in the version I have.  Besides, I also wanted it to detect Python 2.4. So this method won't work unfortunately.

You can also extract this information from various methods in the
distutils package.  Even if you aren't using distutils to control the
build, you could ask Python itself to print out the configuration
variables.  For instance:

python -c "import distutils.sysconfig; print
distutils.sysconfig.get_python_inc()"

That should give you the Python include directory.  There are other
methods to get library names, compiler flags, and other things.

Jim
_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

David Aldrich
In reply to this post by David Aldrich
 
> You can also extract this information from various methods in the distutils
> package.  Even if you aren't using distutils to control the build, you could ask
> Python itself to print out the configuration variables.  For instance:
>
> python -c "import distutils.sysconfig; print
> distutils.sysconfig.get_python_inc()"
>
> That should give you the Python include directory.  There are other methods
> to get library names, compiler flags, and other things.

Hi Jim

That is very useful. Thank you.

How could I get the major version number (e.g. 2.4) so that I can build the library type:

    EXTRA_LIBS_R+=-lpython2.4

BR

David
_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

Wichert Akkerman
On 10/06/2011 05:08 PM, David Aldrich wrote:

>
>> You can also extract this information from various methods in the distutils
>> package.  Even if you aren't using distutils to control the build, you could ask
>> Python itself to print out the configuration variables.  For instance:
>>
>> python -c "import distutils.sysconfig; print
>> distutils.sysconfig.get_python_inc()"
>>
>> That should give you the Python include directory.  There are other methods
>> to get library names, compiler flags, and other things.
> Hi Jim
>
> That is very useful. Thank you.
>
> How could I get the major version number (e.g. 2.4) so that I can build the library type:
>
>      EXTRA_LIBS_R+=-lpython2.4

sys.version_info


_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

David Aldrich
 > sys.version_info

How would I get that from the command line please?
_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

Wichert Akkerman
On 10/06/2011 05:17 PM, David Aldrich wrote:
>   >  sys.version_info
>
> How would I get that from the command line please?

python -c "import sys; print '%d.%d' % sys.version_info[:2]"

_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: How to configure makefile for different build platforms

David Aldrich
> > How would I get that from the command line please?
>
> python -c "import sys; print '%d.%d' % sys.version_info[:2]"

Fantastic. Thank you very much.

David
_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig