GNU autoconf/automake 的帮助脚本应该放在哪里?

发布于 2024-07-05 08:54:43 字数 233 浏览 12 评论 0原文

我正在开发一个将与 GNU autoconf/automake 一起分发的项目,并且我有一组调用 awk 脚本的 bash 脚本。 我希望 bash 脚本最终出现在 $PATH 中,而不是 awk 脚本中。 我应该如何将它们插入到项目中? 它们应该与其他二进制文件放在一起吗?

另外,有没有办法确定安装后文件的最终位置? 我认为 /usr/local/bin 并不总是可执行文件最终所在的位置...

I'm working on a project that will be distributed with GNU autoconf/automake, and I have a set of bash scripts which call awk scripts. I would like the bash scripts to end up in the $PATH, but not the awk scripts. How should I insert these into the project? Should they be put in with other binaries?

Also, is there a way to determine the final location of the file after installation? I presume that /usr/local/bin isn't always where the executables end up...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

把回忆走一遍 2024-07-12 08:54:43

将类似的内容添加到 Makefile.am

scriptsdir = $(prefix)/bin
scripts_DATA = awkscript1 awkscript2

在这种情况下,它将在 $(prefix)/bin 中安装 awkscript(您也可以使用 $(bindir))。

注意:不要忘记第一个应该命名为 name + dir (scripts -> scriptdir),第二个应该命名为 name + _DATA (scripts -> script_DATA)。

Add something like this to Makefile.am

scriptsdir = $(prefix)/bin
scripts_DATA = awkscript1 awkscript2

In this case it will install awkscript in $(prefix)/bin (you can also use $(bindir)).

Note: Dont forget that the first should be named name + dir (scripts -> scriptsdir) and the second should be name + _DATA (scripts -> scripts_DATA).

稀香 2024-07-12 08:54:43

您可以只在 Makefile.am 中列出要安装的脚本:

bin_SCRIPTS = foo bar

这将导致 foo 和 bar 在 make install 期间安装。 要获取最终位置的路径,您可以在 foo.in 中使用 @bindir@ 并让 configure build foo 为您服务。 例如,在configure.ac:中

AC_CONFIG_FILES([foo bar])

,然后在foo.in:中,

#!/bin/sh

prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
echo bindir = $bindir

请记住,运行configure的人可以指定--prefix、--exec_prefix或中的任何一个
--bindir,并且可以使用 DESTDIR 重定向安装。 使用此处描述的技术,将不考虑 DESTDIR,并且脚本将安装在它将回显的路径之外的位置。 这是设计使然,并且是正确的行为,因为通常使用 DESTDIR 安装来创建 tarball,该 tarball 最终将解压到文件系统中,以使脚本中的 bindir 变得有效。

You can just list the scripts that you want to be installed in Makefile.am:

bin_SCRIPTS = foo bar

This will cause foo and bar to be installed during make install. To get the path to their final location, you can use @bindir@ in foo.in and let configure build foo for you. For example, in configure.ac:

AC_CONFIG_FILES([foo bar])

and then in foo.in:

#!/bin/sh

prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
echo bindir = $bindir

Keep in mind that the person running configure may specify any of --prefix, --exec_prefix, or
--bindir, and the installation may be redirected with a DESTDIR. Using the technique described here, DESTDIR will not be taken into account and the script will be installed in a location other than the path that it will echo. This is by design, and is the correct behavior, as usually a DESTDIR installation is used to create a tarball that will eventually be unpacked into the filesystem in such a way that the bindir in the script becomes valid.

云朵有点甜 2024-07-12 08:54:43

乔纳森,回答您的附加问题:如果您想在构建时替换前缀的值,您将需要:

  1. 将脚本“myscript”重命名为“myscript.in”,
  2. 向configure.ac添加一条规则以生成它在底部
  3. 使用我制作的宏 AS_AC_EXPAND
  4. 像这样使用它:

    AS_AC_EXPAND(BINDIR, $bindir)

  5. 在你的'myscript.in'中,你现在可以使用@BINDIR@,它将扩展为最终安装脚本的完整路径。

请注意,您不应该直接使用 PREFIX,任何安装目录都可能会更改,因此您确实希望使用传递给 bindir 配置的值并展开它。

Jonathan, in response to your additional question: if you want to replace the value of prefix at the time of build, you will need to:

  1. rename your script 'myscript' to 'myscript.in'
  2. add a rule to configure.ac to generate it at the bottom
  3. use a macro I made called AS_AC_EXPAND
  4. use it like this:

    AS_AC_EXPAND(BINDIR, $bindir)

  5. in your 'myscript.in', you can now use @BINDIR@ and it will get expanded to the full path where the script will end up being installed.

Note that you shouldn't use PREFIX directly, any of the installation directories can potentially be changed so you really want to use the value passed to configure for bindir and expand that.

赏烟花じ飞满天 2024-07-12 08:54:43

如果 awk 脚本不会进入主 bin 目录(prefix/bin),那么您需要将它们放在适当的子目录中 - 可能是 lib,但也可能是 libexec 或 share(因为 awk 脚本可能是平台中立的) 。

正确:软件不一定最终位于 /usr/local/bin 中; 在我的机器上,/usr/local/bin 由 MIS 管理,因此我安装的所有软件都位于 /usr/gnu/ 下。 我使用: ./configure --prefix=/usr/gnu 将软件安装在我想要的位置。

您可以将 PREFIX 的值嵌入到 bash 脚本中——实际上,您将“编译”脚本以包含安装位置。 请注意构建测试期间的问题 - 您可能需要先相对于当前目录定位脚本,然后再相对于 PREFIX 定位脚本。

If the awk scripts won't go into the main bin directory (prefix/bin), then you need to place them in an appropriate sub-directory - probably of lib but possibly libexec or share (since the awk scripts are probably platform neutral).

Correct: software won't necessarily end up in /usr/local/bin; on my machine, /usr/local/bin is managed by MIS and all the software I install therefore goes under /usr/gnu/. I use: ./configure --prefix=/usr/gnu to get the software installed where I want it.

You can embed the value of PREFIX in the bash scripts -- effectively, you will 'compile' the scripts to include the install location. Be aware of problems during the build testing - you may need to locate the scripts relative to the current directory first and relative to PREFIX later.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文