Discussion:
Arguemnts to configure
Sébastien Hinderer
2018-10-02 15:15:51 UTC
Permalink
Dear all,

Is there a way to add a new "directory category", in addition to bindir,
libdir, etc.?

And, more generally, is there a way to make a configure script accept
arguments that have a shape different from --with, --without, --enable
and --disalbe?

Many thanks in advance for any help!

Sébastien.
Eric Blake
2018-10-02 15:40:36 UTC
Permalink
Post by Sébastien Hinderer
Dear all,
Is there a way to add a new "directory category", in addition to bindir,
libdir, etc.?
Which directory are you thinking? Is it standardized somewhere, like GNU
Coding Standards, Linux File System, or similar? If it is worthwhile,
autoconf should be providing that directory for everyone rather than you
having to add custom code to support it. Otherwise, why is your project
special that it needs a directory that is not standardized, and can you
fully justify why the existing directories are insufficient for your needs?

That said, commit a19743141 shows the addition of --runstatedir, as once
such example of a globally-useful directory worth supporting, in
response to GNU Coding Standards adding a variable for this directory in
reaction to many distros preferring /run over /var/run when installing
into /. And, I'm woefully low on free time, as that commit has not yet
appeared in a released version of autoconf (2.69 predates it, and I
really need to get 2.70 out the door).
Post by Sébastien Hinderer
And, more generally, is there a way to make a configure script accept
arguments that have a shape different from --with, --without, --enable
and --disalbe?
No, not without going against the GNU Coding Standards, which state that
a configure script shouldn't need any other option prefixes. Again,
what is the exact semantics you are hoping to add, and why are the
existing mechanisms inappropriate for those semantics? A strong
justification is needed, at which point maybe we can work on amending
the GNU Coding Standards to document your use case for everyone to be
able to share it.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
Vivien Kraus
2018-10-02 18:50:59 UTC
Permalink
Hello,
Post by Eric Blake
Post by Sébastien Hinderer
And, more generally, is there a way to make a configure script accept
arguments that have a shape different from --with, --without, --enable
and --disalbe?
No, not without going against the GNU Coding Standards, which state that
a configure script shouldn't need any other option prefixes. Again,
what is the exact semantics you are hoping to add, and why are the
existing mechanisms inappropriate for those semantics? A strong
justification is needed, at which point maybe we can work on amending
the GNU Coding Standards to document your use case for everyone to be
able to share it.
I had once this problem myself, and while the answer that "you should
tell us more because it may be interesting for everyone" is important to
answer, don't forget that you can still use environment variables with
arbitrary names and values: AC_ARG_VAR
(https://www.gnu.org/software/autoconf/manual/autoconf-2.64/html_node/Setting-Output-Variables.html,
https://autotools.io/autoconf/arguments.html)

So maybe you could use ./configure NUMBER_OF_BANANAS=42 CFLAGS="-g" ...

--

However this example may be more standard in
./configure --enable-banana-limit=42 CFLAGS="-g"

(By the way, is it correct?)

Best regards,
Vivien
Sébastien Hinderer
2018-10-03 10:13:56 UTC
Permalink
Many thanks for your response, Vivien!

I agree environment variables can help, too, althought it's not my
preferred way, but thanks for having mentionned them anyway!

Sébastien.
Sébastien Hinderer
2018-10-03 10:10:49 UTC
Permalink
Dear Eric,

First of all, many thanks for your prompt and precise response, warmly
appreciated.
Post by Eric Blake
Post by Sébastien Hinderer
Dear all,
Is there a way to add a new "directory category", in addition to bindir,
libdir, etc.?
Which directory are you thinking? Is it standardized somewhere, like GNU
Coding Standards, Linux File System, or similar? If it is worthwhile,
autoconf should be providing that directory for everyone rather than you
having to add custom code to support it. Otherwise, why is your project
special that it needs a directory that is not standardized, and can you
fully justify why the existing directories are insufficient for your needs?
I don't have any definitive answers to your questions so let me give the
context and perhaps we will be able to figure them out together.

I am working on the compiler for the OCaml language
(http://www.ocaml.org). For those who don't know, OCaml is a functional
programming language. It can be compiled either to bytecode which is
then executed by a bytecode interpreter written in C and called
ocamlrun, or to native code for different architectures.

So far, the OCaml compiler is configured with a handwritten 'configure'
shell script which behaves a bit similarly to an autoconf-generated
script, but not completely. My current task is to replace this
handwritten shell script by an autoconf-generated one and to make it
possible to use the compiler for doing cross-compilation.


Coming to the directory I was talking about, it is currently called
"target-bindir" and is used to define where the bytecode interpreter,
ocamlrun, will reside on the target system. This is something the
compiler running on the host needs to know because it adds a line like
#!/path/to/ocamlrun/on/target/system
at the beginning of the bytecode executables it produces, so that they
can then be run as regular executable programs on the target. Does all
this make sense? Perhaps autoconf has a different way of handling such
settings?

I may also add that target-bindir could be considered as just one
particular instance of things one may want to specify at configure time.
How, for instance, would one deal with a situation where the libdir
differs between host and target?

In the same vein, I was wondering why the 'AC_SYS_INTERPRETER' macro
doesn't come in three variants, one for build, one for host and one for
target because I imagine that one may want to know whether #! is
supported on each of these platforms. Well perhaps not on the build
system, but, at least for us, that would matter for both host and
target.

Coming back to the original directory problem, I think I can handle it
with an argument like '--with-target-bindir=' but that's perhaps not the
best / recommended way?
Post by Eric Blake
That said, commit a19743141 shows the addition of --runstatedir, as once
such example of a globally-useful directory worth supporting, in response to
GNU Coding Standards adding a variable for this directory in reaction to
many distros preferring /run over /var/run when installing into /. And, I'm
woefully low on free time, as that commit has not yet appeared in a released
version of autoconf (2.69 predates it, and I really need to get 2.70 out the
door).
No problem! Many thanks for the pointer to that commit! It can indeed
help since, I think, we will distribute a generated configure, although
I don't like this approach too much, well that would give a reason to do
so. Perhaps not the best reason, but still, a reason. :)
Post by Eric Blake
Post by Sébastien Hinderer
And, more generally, is there a way to make a configure script accept
arguments that have a shape different from --with, --without, --enable
and --disalbe?
No, not without going against the GNU Coding Standards, which state that a
configure script shouldn't need any other option prefixes. Again, what is
the exact semantics you are hoping to add, and why are the existing
mechanisms inappropriate for those semantics? A strong justification is
needed, at which point maybe we can work on amending the GNU Coding
Standards to document your use case for everyone to be able to share
it.
Many thanks for your openness. Well beyond the particular semantics we
are trying to achieve, I think one reason for being more permissive
about the syntax of arguments would be to help people in situation
similar to mine maintaining backwards compatibility. Indeed, even in the
cases where the arguments have been poorly named, I think it would help
to be able to still use them and then deprecate them slowly, rather than
being forced to change them brutally.

Now coming to the needs we may have and where the existing possibilities
might perhaps not be enough, well while building the compiler we build
most of its programs in both bytecode and native format. Until recently,
we installed both forms, the native ones being more efficient but the
bytecode ones being more easy to debug. Then recently it has been
decided not to install the bytecode versions by default and a configure
option has been default to request them to be installed. This option has
been called '--install-bytecode-programs', which in my opinion makes
sense. So we could use e.g. '--enable-installing-bytecode-programs' but
again we have no way to deprecate the old name slowly. And there are a
few other options of this kind, plus some others which take values but
for them I guess we can use the '--wit-some-variable=value', although I
undrstand that the '--with' options are here for dependencies on
external packages. Perhaps it would be interesting to extend the meaning
of such options to allow the usecase I just described.

And finally, our current, legacy configure script has the tendency to
accept arguments no matter whether they start with one or two dashes, so
for example for the argument given above, both
'--install-bytecode-programs' and '-install-bytecode-programs' are
accepted, but I think it's okay to drop the single-dash version so I
mention this part just to try to be complete.

Sébastien.
SF Markus Elfring
2018-10-03 11:55:13 UTC
Permalink
Post by Sébastien Hinderer
So far, the OCaml compiler is configured with a handwritten 'configure'
shell script which behaves a bit similarly to an autoconf-generated
script, but not completely. My current task is to replace this
handwritten shell script by an autoconf-generated one and to make it
possible to use the compiler for doing cross-compilation.
I find such a software transformation also interesting.
Would you like to consider the possibility that such configuration scripts
can be generated by other software build systems, too?
Post by Sébastien Hinderer
Coming to the directory I was talking about, it is currently called
"target-bindir" and is used to define where the bytecode interpreter,
ocamlrun, will reside on the target system.
How many compreters do need a separate directory selection parameter
for their executable files?
https://en.wikipedia.org/wiki/Bytecode#Examples
Post by Sébastien Hinderer
This is something the compiler running on the host needs to know
because it adds a line like
#!/path/to/ocamlrun/on/target/system
at the beginning of the bytecode executables it produces, so that they
can then be run as regular executable programs on the target.
Will any more configuration arguments become relevant for the construction
of the desired shebang?
Post by Sébastien Hinderer
I may also add that target-bindir could be considered as just one
particular instance of things one may want to specify at configure time.
I guess that you will try this design variant out before you can move
this setting into other scripts.
How do you think about any software extensions for the GNU autoconf archive?
https://www.gnu.org/software/autoconf-archive/
Post by Sébastien Hinderer
Coming back to the original directory problem, I think I can handle it
with an argument like '--with-target-bindir=' but that's perhaps not the
best / recommended way?
Why did you become concerned for such a software design direction?
Post by Sébastien Hinderer
Then recently it has been decided not to install the bytecode versions
by default and a configure option has been default to request them
to be installed. This option has been called '--install-bytecode-programs',
which in my opinion makes sense. So we could use e.g.
'--enable-installing-bytecode-programs' but again we have no way
to deprecate the old name slowly.
You describe effects from usual software evolution. Now it seems
that you stumble on a conflict because of the GNU Coding Standards.
Would you like to comply with them completely?

How do you think about to pass the parameter “foreign” to
the macro “AM_INIT_AUTOMAKE”?
https://www.gnu.org/software/automake/manual/html_node/List-of-Automake-options.html

Regards,
Markus
Vivien Kraus
2018-10-03 16:33:46 UTC
Permalink
Post by Sébastien Hinderer
Coming to the directory I was talking about, it is currently called
"target-bindir" and is used to define where the bytecode interpreter,
ocamlrun, will reside on the target system. This is something the
compiler running on the host needs to know because it adds a line like
#!/path/to/ocamlrun/on/target/system
at the beginning of the bytecode executables it produces, so that they
can then be run as regular executable programs on the target. Does all
this make sense? Perhaps autoconf has a different way of handling such
settings?
I like OCaml very much, so I could not help but reply again to the
thread :) Sorry if it's uninformative / not the proper way to do it.

Can this target-bindir be configured when running the program? Like:

ocamlc --target-bindir="/whatever/bin" myapp.ml

I could not find such an option in ocamlc options, but maybe it's under
a different name. Or deep down in a to-do list.

Anyway, it looks like a default hard-coded value for a run-time option
of the program that the user / distribution might wish to change. I would
put it in a --enable-default-target-bindir="/whatever/bin" option or
DEFAULT_TARGET_BINDIR="/whatever/bin" variable, and then in the program
code use a command-line option to override it. (see autogen / autoopts
which is great if you want more:
https://www.gnu.org/software/autogen/manual/html_node/AutoOpts.html#AutoOpts).

I think it is different from the other target-specific options like what
kind of code the program should produce, which is not something that the
user would like to change when running the program.

Anyway, this is what I would do, with my limited knowledge about
cross-compilers :)

Vivien
Nick Bowler
2018-10-03 18:19:11 UTC
Permalink
Hello,

Responding to part of your message...
Post by Sébastien Hinderer
In the same vein, I was wondering why the 'AC_SYS_INTERPRETER' macro
doesn't come in three variants, one for build, one for host and one for
target because I imagine that one may want to know whether #! is
supported on each of these platforms. Well perhaps not on the build
system, but, at least for us, that would matter for both host and
target.
I would imagine that it's simply impossible for configure to determine
whether #! scripts work on anything other the build system.

So in the cross-compilation case, if your goal is to portably install
scripts that run on the host or target system, you will presumably need
to use a pessimistic default: that is, you must assume that #! scripts
are not supported. You could add an option to override this behaviour
(typically configure scripts implement these sorts of overrides via the
cache variable mechanism).

POSIX demands that when any command is executed (by the shell, anyway),
if it does not start with #! and is not recognized as an executable
binary file then it is executed as a shell script. So in the portable
pessimistic default case the only kinds of scripts you can install are
shell scripts that do not start with #!. The same behaviour is also
mandated in recent editions for the execvp and execlp functions (I
imagine this was standardizing widespread practice at the time).

In practice I imagine (without proof) that something like #!/bin/sh is
widely portable: that is implementations will either not support #! at
all (and thus execute it as a shell script) or they will support it in
the expected manner (also executing it as a shell script).

Cheers,
Nick
Gavin Smith
2018-10-04 18:10:18 UTC
Permalink
Post by Sébastien Hinderer
Coming to the directory I was talking about, it is currently called
"target-bindir" and is used to define where the bytecode interpreter,
ocamlrun, will reside on the target system. This is something the
compiler running on the host needs to know because it adds a line like
#!/path/to/ocamlrun/on/target/system
at the beginning of the bytecode executables it produces, so that they
can then be run as regular executable programs on the target. Does all
this make sense? Perhaps autoconf has a different way of handling such
settings?
Could this be a subdirectory of one of the standard installation
directories?

https://www.gnu.org/prep/standards/html_node/Directory-Variables.html

For example, your "target-bindir" could be set from libexecdir, and
be /usr/local/libexec/ocamalrun by default.
Sébastien Hinderer
2018-10-05 06:14:43 UTC
Permalink
Dear Gavin,

Many thanks for your response!
Post by Gavin Smith
Post by Sébastien Hinderer
Coming to the directory I was talking about, it is currently called
"target-bindir" and is used to define where the bytecode interpreter,
ocamlrun, will reside on the target system. This is something the
compiler running on the host needs to know because it adds a line like
#!/path/to/ocamlrun/on/target/system
at the beginning of the bytecode executables it produces, so that they
can then be run as regular executable programs on the target. Does all
this make sense? Perhaps autoconf has a different way of handling such
settings?
Could this be a subdirectory of one of the standard installation
directories?
https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
For example, your "target-bindir" could be set from libexecdir, and
be /usr/local/libexec/ocamalrun by default.
Well to be honest I have so far not been able to discuss with the
developers who are actually using this feature. However, at first sight
I'd say I don't think this is something we want to enforce.

Thanks agian for your suggestion!

Sébastien.

Gavin Smith
2018-10-04 18:14:59 UTC
Permalink
Post by Sébastien Hinderer
Many thanks for your openness. Well beyond the particular semantics we
are trying to achieve, I think one reason for being more permissive
about the syntax of arguments would be to help people in situation
similar to mine maintaining backwards compatibility. Indeed, even in the
cases where the arguments have been poorly named, I think it would help
to be able to still use them and then deprecate them slowly, rather than
being forced to change them brutally.
I don't think there is much to gain by being more permissive. I doubt
there are many configure scripts like yours that people want to rewrite
with autoconf. I'd suggest only allowing different kinds of arguments if
this would actually allow a better interface - otherwise, it's allowing
worse interfaces, which wouldn't ever be deprecated in practice.
Loading...