Makefile.am:如何在configure.ac中使用curl-config和xml2-config?

Vir*_*ren 3 autoconf

我想在configure.ac中给定一个现有的Makefile(下面)设置include和lib路径.但我不知道如何在configure.ac中使用$(shell XYZ-config --libs)命令.

有人可以帮忙吗?谢谢!!

# --------------------------------------------------------------------------
# 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
Run Code Online (Sandbox Code Playgroud)

jør*_*sen 5

我保证实际上使用pkgconfig而不是笨拙的*-config脚本,这使得每个包的单行:

# 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}
Run Code Online (Sandbox Code Playgroud)

*-config脚本倾向于成为大量冗余代码(例如syvVinit脚本与systemd单元文件),具有偏离行为:某些-config脚本使用--ccflags,其他--cflags.一些使用--libs,其他人使用--ldflags- 最好避免可怕的混乱.