Makefile.am:如何在configure.ac 中使用curl-config 和xml2-config? [英] Makefile.am: How to use curl-config and xml2-config in configure.ac?
问题描述
我想在 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
, 其他--cflags
.有些使用 --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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!