Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Makefile.am: How to use curl-config and xml2-config in configure.ac?

Tags:

autoconf

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
like image 533
Viren Avatar asked Jan 24 '26 10:01

Viren


1 Answers

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 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.

like image 143
jørgensen Avatar answered Jan 27 '26 01:01

jørgensen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!