views:

454

answers:

1

I'm a boost.build newby and while bjam is quite easy to use for most compiling tasks and I didn't figured out how to do something that should be really simple : installing my application in the system.

Say I have a very simple project with two files in tree (besides Jamroot).

  • hello.cpp : a C++ program say it prints the content of /etc/hello.conf

  • hello.conf : a default hello.conf

What I want to do is:

  • be able to to compile and link hello.cpp without installing anything system wide
  • when called with an install target (and only then) :
    • copy executable hello to /usr/bin
    • copy hello.conf to /etc.

Below is the bjam I started to write:

exe hello : hello.cpp ;
alias install : install-bin  install-etc ;
install install-bin : hello : <location>/usr/bin ;
install install-etc : hello.conf : <location>/etc ;

My problem is that as a user I can't write to /etc nor /usr/bin and I want this to be done only when explicitely calling the install target, not everytime I type bjam.

It is quite important to me to separate the install and the building stages as building stage should be done using user rights and install stage using administrator rights.

+1  A: 

What you wrote seems fine, except for two issues. First, the last line should read:

install install-etc : hello.conf : <location>/etc ;
explicit install install-bin install-etc ;

Second, the install alias should refer to both install-bin and install-etc. When you make those changes, do things work?

Vladimir Prus
Thanks. It solve the "how to copy config file part" (as you pointed out, after all it was just a kind of typo from me forgetting to type install as target :-( I removed this part of the question). It does not solve the other problem : How to perform install only when explicitly calling a given target and not doing it by default. It's probably also as simple as some rule to add :-(
kriss
add "explicit install install-bin install-etc ; " anywhere in Jamfile
Vladimir Prus
OK, that's definitely what I was looking for. (if you can edit your answer it would be nice because the answer is only in comment). I still wonder why bjam perform a link to install instead of copying the file when it allready exists, but it's not really an issue (it also avoid having to stop and restart running exe on Linux, but I'm not sure it's by design, looks like a side effect).
kriss