问题描述
我想在configure.ac中设置给定现有Makefile(如下)的include和lib路径.但是我不知道如何在configure.ac中使用$(shell XYZ-config --libs)命令.
I want to set include and lib paths given an existing Makefile (below) in configure.ac. But I don't know how can I use $(shell XYZ-config --libs) command in configure.ac.
有人可以帮忙吗?谢谢!
Could anyone help please? Thanks!!
# --------------------------------------------------------------------------
# Acquire configuration information for libraries that libs3 depends upon
ifndef CURL_LIBS
CURL_LIBS := $(shell curl-config --libs)
endif
ifndef CURL_CFLAGS
CURL_CFLAGS := $(shell curl-config --cflags)
endif
ifndef LIBXML2_LIBS
LIBXML2_LIBS := $(shell xml2-config --libs)
endif
ifndef LIBXML2_CFLAGS
LIBXML2_CFLAGS := $(shell xml2-config --cflags)
endif
推荐答案
我保证实际使用pkgconfig而不是笨拙的* -config脚本,这使得每个软件包只能使用一种格式:
I'd vouch for actually using pkgconfig instead of clumsy *-config scripts, which makes this a one-liner per package:
# configure.ac
PKG_CHECK_MODULES([libcurl], [curl])
PKG_CHECK_MODULES([libxml2], [libxml-2.0])
# Makefile.am
AM_CPPFLAGS = ${libcurl_CFLAGS} ${libxml2_CFLAGS}
bin_PROGRAMS = foo
foo_LDADD = ${libcurl_LIBS} ${libxml2_LIBS}
*-config脚本趋向于变成大块的冗余代码(例如,就像syvVinit脚本与systemd单元文件一样),并且行为有所偏离:某些-config脚本使用--ccflags
,另一些-c脚本使用--ccflags
.有些使用--libs
,有些使用--ldflags
-最好避免这种可怕的混乱局面.
*-config scripts have a tendency to become large pieces of redundant code (just like syvVinit scripts vs. systemd unit files, for example) with deviating behavior: some -config scripts use --ccflags
, others --cflags
. Some use --libs
, others use --ldflags
—a terrible mess best avoided.
这篇关于Makefile.am:如何在configure.ac中使用curl-config和xml2-config?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!