libssh2

Форк
0
/
configure.ac 
453 строки · 12.5 Кб
1
# Copyright (C) The libssh2 project and its contributors.
2
#
3
# SPDX-License-Identifier: BSD-3-Clause
4
#
5

6
# AC_PREREQ(2.59)
7
AC_INIT([libssh2],[-],[libssh2-devel@lists.haxx.se])
8
AC_CONFIG_MACRO_DIR([m4])
9
AC_CONFIG_SRCDIR([src])
10
AC_CONFIG_HEADERS([src/libssh2_config.h])
11
AC_REQUIRE_AUX_FILE([tap-driver.sh])
12
AM_MAINTAINER_MODE
13
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
14

15
dnl SED is needed by some of the tools
16
AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure,
17
              $PATH:/usr/bin:/usr/local/bin)
18
AC_SUBST(SED)
19

20
if test "x$SED" = "xsed-was-not-found-by-configure"; then
21
  AC_MSG_WARN([sed was not found, this may ruin your chances to build fine])
22
fi
23

24
dnl figure out the libssh2 version
25
LIBSSH2_VERSION=`$SED -ne 's/^#define LIBSSH2_VERSION *"\(.*\)"/\1/p' ${srcdir}/include/libssh2.h`
26
AM_INIT_AUTOMAKE
27
AC_MSG_CHECKING([libssh2 version])
28
AC_MSG_RESULT($LIBSSH2_VERSION)
29

30
AC_SUBST(LIBSSH2_VERSION)
31

32
# Check for the OS.
33
# Daniel's note: this should not be necessary and we need to work to
34
# get this removed.
35
AC_CANONICAL_HOST
36
case "$host" in
37
    *-mingw*)
38
    LIBS="$LIBS -lws2_32"
39
    ;;
40
    *darwin*)
41
    ;;
42
    *hpux*)
43
    ;;
44
    *osf*)
45
    CFLAGS="$CFLAGS -D_POSIX_PII_SOCKET"
46
    ;;
47
    *)
48
    ;;
49
esac
50

51
dnl Our configure and build reentrant settings
52
CURL_CONFIGURE_REENTRANT
53

54
# Some systems (Solaris?) have socket() in -lsocket.
55
AC_SEARCH_LIBS(socket, socket)
56

57
# Solaris has inet_addr() in -lnsl.
58
AC_SEARCH_LIBS(inet_addr, nsl)
59

60
AC_SUBST(LIBS)
61

62
AC_PROG_CC
63
AC_PROG_CXX
64
AC_PROG_INSTALL
65
AC_PROG_LN_S
66
AC_PROG_MAKE_SET
67
AC_PATH_PROGS(SSHD, [sshd], [],
68
     [$PATH$PATH_SEPARATOR/usr/libexec$PATH_SEPARATOR]dnl
69
     [/usr/sbin$PATH_SEPARATOR/usr/etc$PATH_SEPARATOR/etc])
70
AM_CONDITIONAL(SSHD, test -n "$SSHD")
71
m4_ifdef([LT_INIT],
72
[dnl
73
LT_INIT([win32-dll])
74
],[dnl
75
AC_LIBTOOL_WIN32_DLL
76
AC_PROG_LIBTOOL
77
])
78
AC_C_BIGENDIAN
79

80
LT_LANG([Windows Resource])
81

82
dnl check for windows.h
83
case $host in
84
  *-*-msys | *-*-cygwin* | *-*-cegcc*)
85
    # These are POSIX-like systems using BSD-like sockets API.
86
    ;;
87
  *)
88
    AC_CHECK_HEADERS([windows.h], [have_windows_h=yes], [have_windows_h=no])
89
    ;;
90
esac
91

92
dnl check for how to do large files
93
AC_SYS_LARGEFILE
94

95
# Crypto backends
96

97
found_crypto=none
98
found_crypto_str=""
99
crypto_errors=""
100

101
m4_set_add([crypto_backends], [openssl])
102
m4_set_add([crypto_backends], [libgcrypt])
103
m4_set_add([crypto_backends], [mbedtls])
104
m4_set_add([crypto_backends], [wincng])
105
m4_set_add([crypto_backends], [wolfssl])
106

107
AC_ARG_WITH([crypto],
108
  AS_HELP_STRING([--with-crypto=auto|]m4_set_contents([crypto_backends], [|]),
109
    [Select crypto backend (default: auto)]),
110
  use_crypto=$withval,
111
  use_crypto=auto
112
)
113

114
case "${use_crypto}" in
115
  auto|m4_set_contents([crypto_backends], [|]))
116
    m4_set_map([crypto_backends], [LIBSSH2_CHECK_CRYPTO])
117
    ;;
118
  yes|"")
119
    crypto_errors="No crypto backend specified."
120
    ;;
121
  *)
122
    crypto_errors="Unknown crypto backend '${use_crypto}' specified."
123
    ;;
124
esac
125

126
if test "$found_crypto" = "none"; then
127
  crypto_errors="${crypto_errors}
128
Specify --with-crypto=\$backend and/or the necessary library search prefix.
129

130
Known crypto backends: auto, m4_set_contents([crypto_backends], [, ])"
131
  AS_MESSAGE([ERROR: ${crypto_errors}])
132
else
133
  test "$found_crypto_str" = "" && found_crypto_str="$found_crypto"
134
fi
135

136
# ECDSA support with WinCNG
137
AC_ARG_ENABLE(ecdsa-wincng,
138
  AS_HELP_STRING([--enable-ecdsa-wincng],
139
    WinCNG ECDSA support (requires Windows 10 or later)),
140
  [wincng_ecdsa=$enableval])
141
if test "$wincng_ecdsa" = yes; then
142
  AC_DEFINE(LIBSSH2_ECDSA_WINCNG, 1, [Enable WinCNG ECDSA support])
143
else
144
  wincng_ecdsa=no
145
fi
146

147
# libz
148

149
AC_ARG_WITH([libz],
150
  AS_HELP_STRING([--with-libz],[Use libz for compression]),
151
  use_libz=$withval,
152
  use_libz=auto)
153

154
found_libz=no
155
libz_errors=""
156

157
if test "$use_libz" != no; then
158
  AC_LIB_HAVE_LINKFLAGS([z], [], [#include <zlib.h>])
159
  if test "$ac_cv_libz" != yes; then
160
    if test "$use_libz" = auto; then
161
      AC_MSG_NOTICE([Cannot find libz, disabling compression])
162
      found_libz="disabled; no libz found"
163
    else
164
      libz_errors="No libz found.
165
Try --with-libz-prefix=PATH if you know that you have it."
166
      AS_MESSAGE([ERROR: $libz_errors])
167
    fi
168
  else
169
    AC_DEFINE(LIBSSH2_HAVE_ZLIB, 1, [Compile in zlib support])
170
    LIBSSH2_PC_REQUIRES_PRIVATE="$LIBSSH2_PC_REQUIRES_PRIVATE${LIBSSH2_PC_REQUIRES_PRIVATE:+,}zlib"
171
    found_libz="yes"
172
  fi
173
fi
174

175
AC_SUBST(LIBSSH2_PC_REQUIRES_PRIVATE)
176

177
#
178
# Optional Settings
179
#
180
AC_ARG_ENABLE(clear-memory,
181
  AS_HELP_STRING([--disable-clear-memory],[Disable clearing of memory before being freed]),
182
  [CLEAR_MEMORY=$enableval])
183
if test "$CLEAR_MEMORY" = "no"; then
184
  AC_DEFINE(LIBSSH2_NO_CLEAR_MEMORY, 1, [Disable clearing of memory before being freed])
185
  enable_clear_memory=no
186
else
187
  enable_clear_memory=yes
188
fi
189

190
LIBSSH2_CFLAG_EXTRAS=""
191

192
LIBSSH2_CHECK_OPTION_WERROR
193

194
dnl ************************************************************
195
dnl option to switch on compiler debug options
196
dnl
197
AC_MSG_CHECKING([whether to enable pedantic and debug compiler options])
198
AC_ARG_ENABLE(debug,
199
AS_HELP_STRING([--enable-debug],[Enable pedantic and debug options])
200
AS_HELP_STRING([--disable-debug],[Disable debug options]),
201
[ case "$enable_debug" in
202
  no)
203
       AC_MSG_RESULT(no)
204
       CPPFLAGS="$CPPFLAGS -DNDEBUG"
205
       ;;
206
  *)   AC_MSG_RESULT(yes)
207
    enable_debug=yes
208
    CPPFLAGS="$CPPFLAGS -DLIBSSH2DEBUG"
209
    CFLAGS="$CFLAGS -g"
210

211
    dnl set compiler "debug" options to become more picky, and remove
212
    dnl optimize options from CFLAGS
213
    CURL_CC_DEBUG_OPTS
214
       ;;
215
  esac
216
 ],
217
       enable_debug=no
218
       AC_MSG_RESULT(no)
219
)
220

221
AC_SUBST(LIBSSH2_CFLAG_EXTRAS)
222

223
dnl ************************************************************
224
dnl Enable hiding of internal symbols in library to reduce its size and
225
dnl speed dynamic linking of applications.  This currently is only supported
226
dnl on gcc >= 4.0 and SunPro C.
227
dnl
228
AC_MSG_CHECKING([whether to enable hidden symbols in the library])
229
AC_ARG_ENABLE(hidden-symbols,
230
AS_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library])
231
AS_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library (default)]),
232
[ case "$enableval" in
233
  no)
234
       AC_MSG_RESULT(no)
235
       ;;
236
  *)
237
       AC_MSG_CHECKING([whether $CC supports it])
238
       if test "$GCC" = yes ; then
239
         if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
240
           AC_MSG_RESULT(yes)
241
           AC_DEFINE(LIBSSH2_API, [__attribute__ ((visibility ("default")))], [to make a symbol visible])
242
           CFLAGS="$CFLAGS -fvisibility=hidden"
243
         else
244
            AC_MSG_RESULT(no)
245
          fi
246

247
       else
248
         dnl Test for SunPro cc
249
         if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
250
           AC_MSG_RESULT(yes)
251
           AC_DEFINE(LIBSSH2_API, [__global], [to make a symbol visible])
252
           CFLAGS="$CFLAGS -xldscope=hidden"
253
         else
254
           AC_MSG_RESULT(no)
255
         fi
256
       fi
257
       ;;
258
  esac ],
259
       AC_MSG_RESULT(no)
260
)
261

262
dnl Build without deprecated APIs?
263
AC_ARG_ENABLE([deprecated],
264
  [AS_HELP_STRING([--disable-deprecated], [Build without deprecated APIs @<:@default=no@:>@])],
265
  [case "$enableval" in
266
    *)
267
      with_deprecated="no"
268
      CPPFLAGS="$CPPFLAGS -DLIBSSH2_NO_DEPRECATED"
269
      ;;
270
  esac],
271
  [with_deprecated="yes"])
272

273
# Run Docker tests?
274
AC_ARG_ENABLE([docker-tests],
275
  [AS_HELP_STRING([--disable-docker-tests],
276
    [Do not run tests requiring Docker])],
277
  [run_docker_tests=no], [run_docker_tests=yes])
278
AM_CONDITIONAL([RUN_DOCKER_TESTS], [test "x$run_docker_tests" != "xno"])
279

280
# Run sshd tests?
281
AC_ARG_ENABLE([sshd-tests],
282
  [AS_HELP_STRING([--disable-sshd-tests],
283
    [Do not run tests requiring sshd])],
284
  [run_sshd_tests=no], [run_sshd_tests=yes])
285
AM_CONDITIONAL([RUN_SSHD_TESTS], [test "x$run_sshd_tests" != "xno"])
286

287
# Build example applications?
288
AC_MSG_CHECKING([whether to build example applications])
289
AC_ARG_ENABLE([examples-build],
290
AS_HELP_STRING([--enable-examples-build], [Build example applications (this is the default)])
291
AS_HELP_STRING([--disable-examples-build], [Do not build example applications]),
292
[case "$enableval" in
293
  no | false)
294
    build_examples='no'
295
    ;;
296
  *)
297
    build_examples='yes'
298
    ;;
299
esac], [build_examples='yes'])
300
AC_MSG_RESULT($build_examples)
301
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != "xno"])
302

303

304
# Build OSS fuzzing targets?
305
AC_ARG_ENABLE([ossfuzzers],
306
  [AS_HELP_STRING([--enable-ossfuzzers],
307
    [Whether to generate the fuzzers for OSS-Fuzz])],
308
  [have_ossfuzzers=yes], [have_ossfuzzers=no])
309
AM_CONDITIONAL([USE_OSSFUZZERS], [test "x$have_ossfuzzers" = "xyes"])
310

311

312
# Set the correct flags for the given fuzzing engine.
313
AC_SUBST([LIB_FUZZING_ENGINE])
314
AM_CONDITIONAL([USE_OSSFUZZ_FLAG], [test "x$LIB_FUZZING_ENGINE" = "x-fsanitize=fuzzer"])
315
AM_CONDITIONAL([USE_OSSFUZZ_STATIC], [test -f "$LIB_FUZZING_ENGINE"])
316

317

318
# Checks for header files.
319
AC_CHECK_HEADERS([errno.h fcntl.h stdio.h unistd.h sys/param.h sys/uio.h])
320
AC_CHECK_HEADERS([sys/select.h sys/socket.h sys/ioctl.h sys/time.h])
321
AC_CHECK_HEADERS([arpa/inet.h netinet/in.h])
322
AC_CHECK_HEADERS([sys/un.h])
323

324
case $host in
325
  *darwin*|*interix*)
326
    dnl poll() does not work on these platforms
327
    dnl Interix: "does provide poll(), but the implementing developer must
328
    dnl have been in a bad mood, because poll() only works on the /proc
329
    dnl filesystem here"
330
    dnl macOS poll() has funny behaviors, like:
331
    dnl not being able to do poll on no fildescriptors (10.3?)
332
    dnl not being able to poll on some files (like anything in /dev)
333
    dnl not having reliable timeout support
334
    dnl inconsistent return of POLLHUP where other implementations give POLLIN
335
    AC_MSG_NOTICE([poll use is disabled on this platform])
336
    ;;
337
  *)
338
    AC_CHECK_FUNCS(poll)
339
    ;;
340
esac
341

342
AC_CHECK_FUNCS(gettimeofday select strtoll explicit_bzero explicit_memset memset_s snprintf)
343

344
dnl Check for select() into ws2_32 for Msys/Mingw
345
if test "$ac_cv_func_select" != "yes"; then
346
  AC_MSG_CHECKING([for select in ws2_32])
347
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
348
#ifdef HAVE_WINDOWS_H
349
#ifndef WIN32_LEAN_AND_MEAN
350
#define WIN32_LEAN_AND_MEAN
351
#endif
352
#include <winsock2.h>
353
#endif
354
    ]], [[
355
      select(0,(fd_set *)NULL,(fd_set *)NULL,(fd_set *)NULL,(struct timeval *)NULL);
356
    ]])],[
357
      AC_MSG_RESULT([yes])
358
      HAVE_SELECT="1"
359
      AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
360
        [Define to 1 if you have the select function.])
361
    ],[
362
      AC_MSG_RESULT([no])
363
  ])
364
fi
365

366
AC_FUNC_ALLOCA
367

368
# Checks for typedefs, structures, and compiler characteristics.
369
AC_C_CONST
370
AC_C_INLINE
371

372
CURL_CHECK_NONBLOCKING_SOCKET
373

374
missing_required_deps=0
375

376
if test "${libz_errors}" != ""; then
377
  AS_MESSAGE([ERROR: ${libz_errors}])
378
  missing_required_deps=1
379
fi
380

381
if test "$found_crypto" = "none"; then
382
  AS_MESSAGE([ERROR: ${crypto_errors}])
383
  missing_required_deps=1
384
fi
385

386
if test $missing_required_deps = 1; then
387
  AC_MSG_ERROR([Required dependencies are missing.])
388
fi
389

390
AM_CONDITIONAL([HAVE_WINDRES],
391
  [test "x$have_windows_h" = "xyes" && test "x${enable_shared}" = "xyes" && test -n "${RC}"])
392

393
AM_CONDITIONAL([HAVE_LIB_STATIC], [test "x$enable_static" != "xno"])
394

395
# Configure parameters
396

397
# Append crypto lib
398
if   test "$found_crypto" = "openssl"; then
399
  LIBS="${LIBS} ${LTLIBSSL}"
400
elif test "$found_crypto" = "wolfssl"; then
401
  LIBS="${LIBS} ${LTLIBWOLFSSL}"
402
elif test "$found_crypto" = "libgcrypt"; then
403
  LIBS="${LIBS} ${LTLIBGCRYPT}"
404
elif test "$found_crypto" = "wincng"; then
405
  LIBS="${LIBS} ${LTLIBBCRYPT}"
406
elif test "$found_crypto" = "mbedtls"; then
407
  LIBS="${LIBS} ${LTLIBMBEDCRYPTO}"
408
fi
409

410
LIBS="${LIBS} ${LTLIBZ}"
411

412
LIBSSH2_PC_LIBS_PRIVATE=$LIBS
413
AC_SUBST(LIBSSH2_PC_LIBS_PRIVATE)
414

415
dnl merge the pkg-config private fields into public ones when static-only
416
if test "x$enable_shared" = "xyes"; then
417
  LIBSSH2_PC_REQUIRES=
418
  LIBSSH2_PC_LIBS=
419
else
420
  LIBSSH2_PC_REQUIRES=$LIBSSH2_PC_REQUIRES_PRIVATE
421
  LIBSSH2_PC_LIBS=$LIBSSH2_PC_LIBS_PRIVATE
422
fi
423
AC_SUBST(LIBSSH2_PC_REQUIRES)
424
AC_SUBST(LIBSSH2_PC_LIBS)
425

426
AC_CONFIG_FILES([Makefile
427
                 src/Makefile
428
                 tests/Makefile
429
                 tests/ossfuzz/Makefile
430
                 example/Makefile
431
                 docs/Makefile
432
                 libssh2.pc])
433
AC_OUTPUT
434

435
AC_MSG_NOTICE([summary of build options:
436

437
  version:          ${LIBSSH2_VERSION}
438
  Host type:        ${host}
439
  Install prefix:   ${prefix}
440
  Compiler:         ${CC}
441
  Compiler flags:   ${CFLAGS}
442
  Library types:    Shared=${enable_shared}, Static=${enable_static}
443
  Crypto library:   ${found_crypto_str}
444
  WinCNG ECDSA:     $wincng_ecdsa
445
  zlib compression: ${found_libz}
446
  Clear memory:     $enable_clear_memory
447
  Deprecated APIs:  $with_deprecated
448
  Debug build:      $enable_debug
449
  Build examples:   $build_examples
450
  Run Docker tests: $run_docker_tests
451
  Run sshd tests:   $run_sshd_tests
452
  Path to sshd:     $ac_cv_path_SSHD (only for self-tests)
453
])
454

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.