我想在configure.in腳本中測試某些軟件包(例如PCRE)的版本,並相應地在Makefile中定義C++變量。我認爲autoconf函數m4_version_compare可以做到這一點,但我無法讓它工作。我相信我沒有正確使用它。 我在configure.in如下:m4_version_compare沒有看到變量
AC_INIT([MyPackage], 0.4)
# Checks for common programs using default macros
AC_PROG_CC
PCREVERSION=`pcre-config --version`
AC_MSG_RESULT([Detected PCRE version ${PCREVERSION}])
PCRE_POST_8_0=m4_version_compare([PCREVERSION], [8.0])
AC_MSG_RESULT([PCRE version >= 8.0: ${PCRE_POST_8_0}])
AC_SUBST(PCRE_POST_8_0)
AC_OUTPUT(src/Makevars)
隨後的autoconf +的./configure產生以下輸出:
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
Detected PCRE version 8.12
PCRE version >= 8.0: -1
configure: creating ./config.status
config.status: creating src/Makevars
我在做什麼錯?看來,m4_version_compare將變量PCREVERSION看作是0.我應該用另一種方式定義這個變量嗎?怎麼樣? 謝謝。
雷諾
我正要更新我的問題。感謝您的解釋,我最終使用AS_VERSION_COMPARE工作。現在將發佈我的答案。 – Renaud