Discussion:
Question on version number with configure.ac and bakefile
(too old to reply)
Stefano Antonelli
2010-12-15 18:57:59 UTC
Permalink
Raw Message
Hello,

Is there a way to keep the version number in only one location (ie. the
bakefile) and have configure.ac use it for the call to AC_INIT?

I've had a look at a number of projects using bakefile and autoconf and they
all seem to hardcode the version number in configure.ac so I'm guessing that
there currently isn't.

Thanks,
Stef
Václav Slavík
2010-12-16 08:00:24 UTC
Permalink
Raw Message
Hi,
Post by Stefano Antonelli
Is there a way to keep the version number in only one location (ie. the
bakefile) and have configure.ac use it for the call to AC_INIT?
Sorry, how does this make sense as a Bakefile question? Bakefile doesn't generate configure.ac to begin with and even if it did, it would be the only format with the notion of "version number", so it wouldn't make much sense to handle this at Bakefile level... Am I missing something?

Regards,
Vaclav
Warren Young
2010-12-16 15:44:05 UTC
Permalink
Raw Message
Post by Václav Slavík
Post by Stefano Antonelli
Is there a way to keep the version number in only one location (ie.
the bakefile) and have configure.ac use it for the call to
AC_INIT?
Sorry, how does this make sense as a Bakefile question?
Bakefile doesn't solve this problem now, but Bakefile is the right place
to solve it.

In my own Bakefile-based project, MySQL++, there are still two places
you have to change the version number for each release: configure.ac and
mysql++.bkl.

All the other places that need the version number are now .in files so
the configure script subs the version number into them. You can't do
that with mysql++.bkl because that creates chicken-and-egg problem.
configure.ac needs autoconf_inc.m4, generated by Bakefile, but if
mysql++.bkl is to be generated from a .in file by configure, configure
must already exist, which it can't because autoconf will fail to run if
the .m4 doesn't exist yet.

I've looked into it, and as far as I can tell, the keystone of the
problem is bakefile_gen. It currently requires the .bkl file to run,
and it creates both Makefile.in and autoconf_inc.m4. You could solve
the redundant version number problem if this were broken into two steps:
one that created autoconf_inc.m4 without needing the .bkl file (or at
least, could accept a .bkl.in file) and a separate step for creating
Makefile.in and all the other project files and Makefile variants.
Stefano Antonelli
2010-12-16 19:31:58 UTC
Permalink
Raw Message
Post by Václav Slavík
Post by Stefano Antonelli
Is there a way to keep the version number in only one location (ie.
the
bakefile) and have configure.ac use it for the call to AC_INIT?
Sorry, how does this make sense as a Bakefile question?
Bakefile doesn't generate configure.ac to begin with and even
if it did, it would be the only format with the notion of
"version number", so it wouldn't make much sense to handle
this at Bakefile level... Am I missing something?
The reply from Warren Young sums this up nicely. The only thing I would add
is that it seems possible to include an m4 file before the call to AC_INIT
as described here:

http://old.nabble.com/Re%3A-specify-AC_INIT-version-externally-p27066165.htm
l

./version.m4
m4_define([VERSION_NUMBER],[1.2.3])

./package/configure.ac
m4_include([../version.m4])
AC_INIT([package],VERSION_NUMBER)

If Bakefile could output some variables in a version.m4 then the version
number could be contained in the .bkl file only.

-Stef
Stefano Antonelli
2010-12-22 17:35:03 UTC
Permalink
Raw Message
Hi Vaclav,
Post by Stefano Antonelli
If Bakefile could output some variables in a version.m4 then the version
number could be contained in the .bkl file only.
Can Bakefile's built-in extensibility be used to write a piece of .bkl that could output to a file when autoconf_inc.m4 is created? If so, could you point me in the right direction with how to accomplish this? If not, where would be the right place to change this?

Thanks,
Stef
Stefano Antonelli
2010-12-22 23:54:10 UTC
Permalink
Raw Message
Post by Stefano Antonelli
Post by Stefano Antonelli
If Bakefile could output some variables in a version.m4 then the version
number could be contained in the .bkl file only.
Can Bakefile's built-in extensibility be used to write a piece of .bkl that could output to a file when autoconf_inc.m4 is created? If so, could you point me in the right direction with how to accomplish this? If not, where would be the right place to change this?
After some poking around, I think it can be done though I'm a little stuck. Without being a Bakefile expert, I think it's possible to use the <output> tag from the makefile to generate the file I want.

Consider the following snippet:

<output file="version.m4" writer="ac_version.empy"/>

This requires my custom ac_version.empy file and that means it must be installed in the bakefile program directory. That's obviously not very useful.

Is there any way to point the writer path to an arbitrary directory? If not, is there a better way to do this?

Thanks,
Stef
Václav Slavík
2010-12-27 18:06:45 UTC
Permalink
Raw Message
Hi,
Post by Stefano Antonelli
<output file="version.m4" writer="ac_version.empy"/>
This requires my custom ac_version.empy file and that means it must be installed in the bakefile program directory. That's obviously not very useful.
Is there any way to point the writer path to an arbitrary directory?
It's looked for on the same search path as <include>d files, so you can put it anywhere and use the -I flag to point Bakefile to it. (And you can put -I flags into your Bakefiles.bkgen file.)
Post by Stefano Antonelli
If not, is there a better way to do this?
No, I think this is the best approach.

Regards,
Vaclav
Stefano Antonelli
2010-12-27 21:36:30 UTC
Permalink
Raw Message
Hi Václav

Thanks for the response.
Post by Václav Slavík
Post by Stefano Antonelli
Is there any way to point the writer path to an arbitrary directory?
It's looked for on the same search path as <include>d files
I made a test.bkl (that only set a variable) in a subdirectory called bakefile. I also added my ac_version.empy file to that directory. I added

<include file="bakefile/test.bkl"/>

to main.bkl and when running the bakefile executable, test.bkl was included just fine. However, it failed to pick up ac_version.empy. Did I misunderstand this point?
Post by Václav Slavík
, so you can put it anywhere and use the -I flag to point Bakefile to it. (And you can put -I flags into your Bakefiles.bkgen file.)
bakefile -I bakefile -f autoconf main.bkl

This works, which is great. I think it would be more elegant to be able to point to the writer in main.bkl though. Is that possible?

Thanks,
Stef
Václav Slavík
2010-12-28 08:25:41 UTC
Permalink
Raw Message
Post by Stefano Antonelli
to main.bkl and when running the bakefile executable, test.bkl was included just fine
"." is part of the search path. "./bakefile" or "./whatever" are not.
Post by Stefano Antonelli
I think it would be more elegant to be able to point to the writer in main.bkl though. Is that possible?
All names of included files are relative to the search path. So yes, it is possible: by putting the .empy file on default search path.

Vaclav
Stefano Antonelli
2010-12-28 10:32:26 UTC
Permalink
Raw Message
Post by Václav Slavík
Post by Stefano Antonelli
to main.bkl and when running the bakefile executable, test.bkl was included just fine
"." is part of the search path. "./bakefile" or "./whatever" are not.
I tried this early on and it did not seem to work. Perhaps I still don't understand or misunderstand what you're saying.

If I place my .empy files in the same directory as main.bkl, bakefile still can't find them. Do you expect different, or does that make sense?
Post by Václav Slavík
Post by Stefano Antonelli
I think it would be more elegant to be able to point to the writer in main.bkl though. Is that possible?
All names of included files are relative to the search path. So yes, it is possible: by putting the .empy file on default search path.
The problem I have with this statement is "included files". The writer is not "included" anywhere in main.bkl. Is it treated differently?

Having a quick look at writer.py, it looks as though config.searchPath is used to look for the writer file. config.py only sets a few default paths based on the BAKEFILE_PATHS environment variable and the location of the bakefile executable. I don't see "." explicitly added. It looks to me as though the only other place config.searchPath is modified is in bakefile.py through the -I switch. Is any of this remotely correct? I don't know Python.

It appears as though "." is not in the default search path. The only way to include "." or any other arbitrary directory is through the -I switch or BAKEFILE_PATHS environment variable.

-Stef
Václav Slavík
2011-01-03 11:10:48 UTC
Permalink
Raw Message
Hi,
Post by Stefano Antonelli
It appears as though "." is not in the default search path.
Yes, I was wrong, sorry about that. It doesn't actually make sense to have "." on the path, it should be the directory where the input file is. Or the writer should be search in that directory first, then on the search path. I wouldn't mind a patch to that effect.

Vaclav
Stefano Antonelli
2011-01-04 03:54:32 UTC
Permalink
Raw Message
Post by Václav Slavík
Hi,
Post by Stefano Antonelli
It appears as though "." is not in the default search path.
Yes, I was wrong, sorry about that. It doesn't actually make sense to have "." on the path, it should be the directory where the input file is. Or the writer should be search in that directory first, then on the search path. I wouldn't mind a patch to that effect.
Good to know. Yes the behaviour you describe would be better, but specifying -I works too. A patch for that doesn't sound too hard, but I won't be attempting that until I'm actually using Bakefile more.

-Stef

Loading...