如何从LIB告诉Autoconf“需要符号A或B”?

时间:2016-09-02 06:34:29

标签: symbols autoconf

我正在尝试配置Postgres 9.5.4 for OpenSSL 1.1.0。配置正在死亡,因为它在OpenSSL 1.1.0中找不到SSL_library_init。 OpenSSL 1.1.0提供OPENSSL_init_ssl而不是SSL_library_init。因此,Autoconf需要检查SSL_library_initOPENSSL_init_ssl

Postgres使用以下测试:

AC_CHECK_LIB(ssl, SSL_library_init, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])

如何修改[规则?]以查找SSL_library_initOPENSSL_init_ssl

天真地,我将configure.in改为以下,但没有用。我能说的最好,我的更改被忽略了(即使在运行autoreconf之后):

AC_CHECK_LIB(ssl, SSL_library_init|OPENSSL_init_ssl, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])

这是Postgrs配置命令:

$ ./configure --with-openssl --with-includes=/usr/local/ssl/include --with-libraries=/usr/local/ssl/lib

以下是config.log的相关条目:

configure:8732: gcc -o conftest -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv
-Wno-unused-command-line-argument -I/usr/local/ssl/include
-L/usr/local/ssl/lib   -I/usr/local/ssl/include   -L/usr/local/ssl/lib
conftest.c -lssl  -lcrypto -lz -lreadline -lm  >&5
Undefined symbols for architecture x86_64:
  "_SSL_library_init", referenced from:
      _main in conftest-c0c2a1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
configure:8732: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "PostgreSQL"
| #define PACKAGE_TARNAME "postgresql"
| #define PACKAGE_VERSION "9.5.4"
| #define PACKAGE_STRING "PostgreSQL 9.5.4"
| #define PACKAGE_BUGREPORT "pgsql-bugs(at)postgresql(dot)org"
| #define PACKAGE_URL ""
| #define PG_MAJORVERSION "9.5"
| #define PG_VERSION "9.5.4"
| #define USE_INTEGER_DATETIMES 1
| #define DEF_PGPORT 5432
| #define DEF_PGPORT_STR "5432"
| #define BLCKSZ 8192
| #define RELSEG_SIZE 131072
| #define XLOG_BLCKSZ 8192
| #define XLOG_SEG_SIZE (16 * 1024 * 1024)
| #define ENABLE_THREAD_SAFETY 1
| #define PG_KRB_SRVNAM "postgres"
| #define USE_OPENSSL 1
| #define HAVE_LIBM 1
| #define HAVE_LIBREADLINE 1
| #define HAVE_LIBZ 1
| #define HAVE_SPINLOCKS 1
| #define HAVE_ATOMICS 1
| #define HAVE_LIBCRYPTO 1
| /* end confdefs.h.  */
| 
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char SSL_library_init ();
| int
| main ()
| {
| return SSL_library_init ();
|   ;
|   return 0;
| }
configure:8741: result: no
configure:8751: error: library 'ssl' is required for OpenSSL

2 个答案:

答案 0 :(得分:1)

这样的事情应该适合你:

ACCEPT_SSL_LIB="no"
AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [ACCEPT_SSL_LIB="yes"])
AC_CHECK_LIB(ssl, SSL_library_init, [ACCEPT_SSL_LIB="yes"])
AS_IF([test "x$ACCEPT_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])

您可能需要另一个变量来告诉您要调用的init函数,以设置SSL,除非头文件中存在一些实际将其修复到正确值的宏魔术。

答案 1 :(得分:0)

要构建@ ldav1s'的答案,以下是获得过去配置所需的configure.in更改。修改configure.in后,应运行autoreconf

$ git diff configure.in > configure.in.diff

$ cat configure.in.diff 
diff --git a/configure.in b/configure.in
index c878b4e..7ba7538 100644
--- a/configure.in
+++ b/configure.in
@@ -1112,10 +1112,16 @@ if test "$with_openssl" = yes ; then
   dnl Order matters!
   if test "$PORTNAME" != "win32"; then
      AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
-     AC_CHECK_LIB(ssl,    SSL_library_init, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
+     FOUND_SSL_LIB="no"
+     AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [FOUND_SSL_LIB="yes"])
+     AC_CHECK_LIB(ssl, SSL_library_init, [FOUND_SSL_LIB="yes"])
+     AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
   else
      AC_SEARCH_LIBS(CRYPTO_new_ex_data, eay32 crypto, [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
-     AC_SEARCH_LIBS(SSL_library_init, ssleay32 ssl, [], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
+     FOUND_SSL_LIB="no"
+     AC_SEARCH_LIBS(OPENSSL_init_ssl, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
+     AC_SEARCH_LIBS(SSL_library_init, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
+     AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
   fi
   AC_CHECK_FUNCS([SSL_get_current_compression])
 fi