Makefile.am:如何在configure.ac中使用curl-config和xml2-config? [英] Makefile.am: How to use curl-config and xml2-config in configure.ac?

查看:86
本文介绍了Makefile.am:如何在configure.ac中使用curl-config和xml2-config?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆