Boost logo

Boost-Build :

From: Jorge Suit Perez Ronda (josp.jorge_at_[hidden])
Date: 2006-12-27 18:00:55


Hi, to many questions, I'm newbie but I'm also facing you migration
process. I really like BJAM, it worth moving to it!

I also have ubuntu but do not use its bjam package, instead I use the
Nightly build: http://boost.org/boost-build2/boost-build.tar.bz2 , now
I'm using the source code corresponding to Tue Dec 12 17:36:45 MSK 2006
which report me:

Boost.Build V2 (Milestone 11)
Boost.Jam 03.1.14

You can learn a lot looking at tools/ utils/ and kernel/ they are the
perfect complement to the documentation for BJAM which (I think IMHO )
needs to be improved (at least for a newbie).

Regarding configure migration what I'm doing now is implementing
(experimenting) a set of rules for doing --with-xxx and --enable-xxx.

module config
{
  import path ;

  rule config ( pkg : prefix ? : incls ? : libs ? )
  {
    ECHO configuring package $(pkg) ;
    all-pkgs += $(pkg) ;
    if $(incls) {
      --with-$(pkg)-incls = $(incls) ;
    }
    if $(libs)
    {
      --with-$(pkg)-libs = $(libs) ;
    }
    if $(prefix)
    {
      --with-$(pkg)-incls ?= [ path.join $(prefix) include ] ;
      --with-$(pkg)-libs ?= [ path.join $(prefix) lib ] ;
    }
  }
  local export-rules = config ;

  rule configured ( pkg )
  {
    if $(pkg) in $(all-pkgs) { return yes ; }
  }
  export-rules += configured ;

  rule inc-path ( pkg ? )
  {
    if $(pkg)
    {
      if $(--with-$(pkg)-incls)
      {
        return <include>$(--with-$(pkg)-incls) ;
      }
    }
    else
    {
      local incls ;
      for local p in $(all-pkgs)
      {
        incls += <include>$(--with-$(p)-incls) ;
      }
      return $(incls) ;
    }
  }
  export-rules += inc-path ;

  rule lib-path ( pkg )
  {
    if $(--with-$(pkg)-libs)
    {
      return <search>$(--with-$(pkg)-libs) ;
    }
  }
  export-rules += lib-path ;

  rule enable ( feature : define ? )
  {
    all-enabled += $(feature) ;
    if $(define)
    {
      enable-$(feature)-define = $(define) ;
    } else
    {
      enable-$(feature)-define = _USE_$(feature)_ ;
    }
  }
  export-rules += enable ;

  rule is-enabled ( feature )
  {
    return $(enable-$(feature)-define) ;
  }
  export-rules += is-enabled ;

  rule define-enabled ( )
  {
    local defines ;
    for local f in $(all-enabled)
    {
      defines += <define>$(enable-$(f)-define) ;
    }
    return $(defines) ;
  }
  export-rules += define-enabled ;

  for local r in $(export-rules)
  {
    EXPORT config : $(r) ;
    IMPORT config : $(r) : : $(r) ;
  }
}

now in my Jamroot I include a configuration file, for instance

include prj-config.jam ;

the contents of that file could be:

config gsl ;
config cholmod : /usr/local/cholmod ;
enable dbdrivers ;
config unixodbc ;
config pgsql ;
config mysql : : /usr/include/mysql ;
config bz2 ;

then in my Jamroot and Jamfile(s) I can do:

[ inc-path ] to get the list of <include> properties to be used as
requirements in the project, or

if [ is-enabled dbdrivers ]
{
  local odbc-support ;
  if [ configured unixodbc ]
  {
    local odbc_inc = [ inc-path unixodbc ] ;
    lib odbc : : <name>odbc [ lib-path unixodbc ] ;
    odbc-support = yes ;
  }
  else if [ configured iodbc ]
  {
    local odbc_inc = [ inc-path iodbc ] ;
    lib odbc : : <name>iodbc [ lib-path iodbc ] ;
    odbc-support = yes ;
  }
  if $(odbc-support) = yes
  {
    lib tolodbc
        : libtolodbc.c odbc
        : $(odbc_inc)
        ;
  }

  if [ configured mysql ]
  {
    lib mysql : : <name>mysqlclient [ lib-path mysql ] ;
    lib tolmysql
        : libtolmysql.c mysql
        : [ inc-path mysql ]
        ;
  }

  if [ configured pgsql ]
  {
    lib pgsql : : <name>pq [ lib-path pgsql ] ;
    lib tolpgsql
        : libtolpgsql.c pgsql
        : [ inc-path pgsql ]
        ;
  }
}

now I'm doing that approach but comparing with what is implemented into
boost-build I'm sure it is far from what can be achieved.

Any way, hope it helps.

regards,

Jorge

On Wed, 2006-12-27 at 15:47 +0100, Mateusz Loskot wrote:
> Hi,
>
> I'm a kind of Boost.Build newbie and I'm going to migrate a few projects
> based on GNU Autoconf/Automake/Libtool to Boost.Build v2.
> So, I'd like to ask for some guidelines, best practices and
> URLs/pointers where I should look first.
>
> So far, I've read and exercised following documents:
> - manual, sections 21 - 24
> http://www.boost.org/tools/build/v2/index.html
> - Getting Started on the Wiki
>
> After this reading, the BB2 looks very promising to me and
> I'd like to move on.
> Here are some of questions I'd like to ask here:
>
> 0. Is bjam 3.1.11 a good version to start with Boost.Build.2 ?
> This version is currently available in Ubuntu 6.10.
> I'm asking, because I'm experiencing some strange problems when trying
> to run bjam --v2 command.
>
> Below I'm trying to summary my configuration and steps I'm taking to
> use bjam on my Ubuntu 6.10 box:
>
>
> a) echo $BOOST_BUILD_PATH
> /usr/share/boost-build
>
>
> b) Trying to build boost/tools/build/v2/example/hello but not from
> BOOST_ROOT location. I copied 'example' directory to another directory.
>
> $ ls
> hello.cpp Jamroot
> $ bjam --v2
> Failed to find the project root for directory '.'.
> Did not find a project-root.jam file there or in any of its parent
> directories.
> Please consult the documentation at 'http://www.boost.org'.
>
>
> c) Trying to fix, but I'm not sure about these steps,
> it's just my intuition:
>
> $ touch project-root.jam
> $ ls
> hello.cpp Jamroot project-root.jam
> $ bjam --v2
> /usr/share/boost-build/build/project.jam:213: in load-jamfile from
> module project
> error: Unable to load Jamfile.
> error: Could not find a Jamfile in directory '.'.
> error: Attempted to find it with pattern '[Jj]amfile.v2 [Jj]amfile
> [Jj]amfile.jam'.
> error: Please consult the documentation at 'http://www.boost.org'.
> /usr/share/boost-build/build/project.jam:67: in project.load from module
> project
> /usr/share/boost-build/build-system.jam:75: in load from module build-system
> /usr/share/boost-build/kernel/modules.jam:259: in import from module modules
> /usr/share/boost-build/kernel/bootstrap.jam:120: in boost-build from module
> /home/mloskot/workshop/boost/bb2/example/boost-build.jam:2: in module
> scope from module
>
>
> d) ...following on what my intuition is telling me:
>
> $ ls
> hello.cpp Jamroot project-root.jam
> $ mv Jamroot Jamfile
> $ ls
> hello.cpp Jamfile project-root.jam
> $ bjam --v2
> ...found 9 targets...
> ...updating 5 targets...
> MkDir1 bin
> MkDir1 bin/gcc
> MkDir1 bin/gcc/debug
> gcc.compile.c++ bin/gcc/debug/hello.o
> gcc.link bin/gcc/debug/hello
> ...updated 5 targets...
>
>
> e) I'm not sure:
> - if BOOST_BUILD_PATH is working for me, becasue...
> - why I need to create empty project-root.jam?
> - why I need to rename Jamroot to Jamfile?
> - is Jamroot appropriate for multi-subprojects project and
> Jamfile for flat / one-level project?
>
> I'd be thankful for pointing what I'm doing wrong here.
>
> 1. How to migrate ./configure based steps to BB2?
> Here, I'd like to learn how to enable users to enable/disable optional
> features in my software. For example, my ./configure supports
> --with-pgsql option that enables/disables PostgreSQL support in my
> software. What is the equivalent of such configuration/options in BB2?
>
>
> 2. How can I tell bjam to compile using 'gcc' instead of 'g++'?
> I'd like to compile C sources with lib rule defined as follows:
>
> lib mylib : a.c b.c
>
> As I see, bjam calls g++ what causes errors flood about missing
> declarations, etc.
> How can I control selection of gcc/g++ command?
> or better:
> How can I control selection of C or C++ compilation mode?
>
>
> 3. Is there any repository of predefined/custom rules for Boost.Build?
> Here, I mean something like http://autoconf-archive.cryp.to/
> where I can find existing or publish my own macros ie. detecting various
> DBMS client libraries, etc.
> Is there anything like that for Boost.Build?
>
> Thanks for any help in advance.
>
> Cheers


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk