获取libtool库输出文件名 [英] Get libtool library output filename
问题描述
我正在尝试定义一个自动生成规则,该规则将生成一个文本文件,其中包含将由同一Makefile构建和安装的libtool库的完整路径.是否有一种简单的方法来检索libtool库的输出文件名(具有用于构建程序的平台的正确扩展名)?
I'm trying to define an Automake rule that will generate a text file containing the full path to a libtool library that will be built and installed by the same Makefile. Is there a straightforward way of retrieving the output filename for a libtool library (with the correct extension for the platform the program is being built on)?
例如,我正在尝试编写如下内容:
For example, I am trying to write something like this:
lib_LTLIBRARIES = libfoo.la
bar.txt:
echo $(prefix)/lib/$(libfoo_la) >$@
根据平台的不同,$(libfoo_la)
会扩展为libfoo.so
,libfoo.dylib
或libfoo.dll
(或其他任何内容).这实际上是生成的libtool库文件中dlname
参数的值.我可以直接从中提取文件名,但是我希望有一种更简单的方法来实现.
Where $(libfoo_la)
would expand to libfoo.so
, libfoo.dylib
or libfoo.dll
(or whatever else), depending on the platform. This is essentially the value of the dlname
parameter in the resulting libtool library file. I could potentially extract the filename directly from that, but I was hoping there was a simpler way of achieving this.
推荐答案
不幸的是,我找不到执行此操作的方法. 幸运的是,对您来说,我确实有一个sed脚本被黑了,确实 并对其进行黑客攻击,以便它确实可以满足您的要求.
Unfortunately, there's not a way I've found of doing this. Fortunately, for you, I did have a little sed script hacked together that did kind of what you want, and hacked it so it does do what you want.
foo.sed
# kill non-dlname lines
/^\(dlname\|libdir\)=/! { d }
/^dlname=/ {
# kill leading/trailing junk
s/^dlname='//
# kill from the last quote to the end
s/'.*$//
# kill blank lines
/./!d
# write out the lib on its own line
s/.*/\/&\n/g
# kill the EOL
s/\n$//
# hold it
h
}
/^libdir=/ {
# kill leading/trailing junk
s/^libdir='//
# kill from the last quote to the end
s/'.*$//
# paste
G
# kill the EOL
s/\n//
p
}
Makefile.am
lib_LTLIBRARIES = libfoo.la
bar.txt: libfoo.la foo.sed
sed -n -f foo.sed $< > $@
这篇关于获取libtool库输出文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!