在makefile.am(自动工具)中使用sed

发布于 2025-02-09 00:39:35 字数 402 浏览 1 评论 0原文

我正在使用Autotools打包程序(我没有太多经验)。

我有一个gnome .desktop文件,该文件引用了可执行文件和图标的位置。 这需要是/usr/share/usr/local/share,具体取决于@prefix@。 我如何在data/makefile.am上在此文件上运行sed配置为?

我的makefile.am目前很简单

wombatdir = $(prefix)/share/
wombat_DATA = applications/wombat.desktop pixmaps/wombat.svg

I'm packaging up a program using autotools (which I don't have much experience with).

I have a gnome .desktop file that references the location of the executable and the icon.
This needs to be /usr/share or /usr/local/share depending upon the @PREFIX@.
How can I run sed on this file in the data/Makefile.am so that the installed file works no mater what the @PREFIX@ is configured to?

My Makefile.am is pretty simple at the moment ..

wombatdir = $(prefix)/share/
wombat_DATA = applications/wombat.desktop pixmaps/wombat.svg

Michael

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

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

发布评论

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

评论(1

雪化雨蝶 2025-02-16 00:39:35

这是关于我要做的。

configure.ac中,添加ac_prog_sed

makefile.am中,添加

[…]
xdgdesktopdir = $(datadir)/applications
pixmapsdir    = $(datadir)/pixmaps

SED_CMDS  =
SED_CMDS += 's|[@]bindir@|$(bindir)|g'
SED_CMDS += 's|[@]pixmapsdir@|$(pixmapsdir)|g'

xdgdesktop_DATA += wombat.desktop
EXTRA_DIST      += wombat.desktop.in
CLEANFILES      += wombat.desktop
wombat.desktop: wombat.desktop.in Makefile
        $(SED) $(SED_CMDS) $(srcdir)/wombat.desktop.in > wombat.desktop
[…]

然后将您的wombat.desktop重命名为wombat.desktop.in and write

[…]
Exec=@bindir@/wombat
Icon=@pixmapsdir@/wombat.svg
[…]

(不确定PixMaps/是否是正确的不过,安装SVG文件的位置)

wombat.desktop.in将受到版本的控制。 wombat.desktop将不受控制,并且很可能会添加到.gitignore

/data/wombat.desktop

This is about what I would do.

In configure.ac, add AC_PROG_SED.

In Makefile.am, add

[…]
xdgdesktopdir = $(datadir)/applications
pixmapsdir    = $(datadir)/pixmaps

SED_CMDS  =
SED_CMDS += 's|[@]bindir@|$(bindir)|g'
SED_CMDS += 's|[@]pixmapsdir@|$(pixmapsdir)|g'

xdgdesktop_DATA += wombat.desktop
EXTRA_DIST      += wombat.desktop.in
CLEANFILES      += wombat.desktop
wombat.desktop: wombat.desktop.in Makefile
        $(SED) $(SED_CMDS) $(srcdir)/wombat.desktop.in > wombat.desktop
[…]

Then rename your wombat.desktop to wombat.desktop.in and write

[…]
Exec=@bindir@/wombat
Icon=@pixmapsdir@/wombat.svg
[…]

(not sure whether pixmaps/ is the correct place to install an SVG file, though)

wombat.desktop.in will be version controlled. wombat.desktop will not be version controlled, and might very well be added to .gitignore:

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