1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-10-24 03:48:58 +03:00
Commit Graph

75 Commits

Author SHA1 Message Date
Viktor Szakats
952fb88fa5 tidy-up: FILE * variable names, configure warning option guard, printf mask
- configure: fix wrong guard for `-Wno-c++-keyword`.
  Follow-up to 04ecdb22fe #1972

- sync most outlier `FILE *` variables names with rest of code.

- agent: replace cast with accurate printf mask when forming
  `PageantRequest` map name.
  Follow-up to 7b351eed36

Closes #2317
2026-07-15 13:35:18 +02:00
Viktor Szakats
787e9bfec2 session: drop alloca() use from libssh2_poll()
Use fixed stack buffer when requested 256 sockets or less. Allocate from
heap otherwise.

There is no other `alloca()` user, so drop detecting it via autotools
(CMake never got support for this). Also re-enable a warning option that
was incompatible with autotools's `AC_FUNC_ALLOCA` code.

This patch may reduce performance when polling 257+ sockets (due to
calloc/free), and comes with higher stack use ('256 * sizeof(struct
pollfd)') than before this patch, when using `poll()` (typically on Unix
platforms except Darwin and Interix).

Note: `libssh2_poll()` is deprecated since v1.2.0 (2009-08-10).

Follow-up to 209d06d6c9

Closes #2041
2026-06-12 11:36:57 +02:00
Viktor Szakats
b90a38c1c9 tidy-up: miscellaneous
- configure: use `dnl`-style comments consistently (where possible).
- configure: drop stray spaces.
- wincng: replace Windows-specific type in `memcpy()` casts.
- drop FIXME added incorrectly in a recent commit.
  Follow-up to ecf39b3634 #1984
  Follow-up to ff50682c23 #1679
- replace more synonyms with 'null-terminated'.
- unfold strings, comments and code lines.
- reflow lines, fix indent.

Closes #1995
2026-06-07 17:55:08 +02:00
Viktor Szakats
7071b7680a configure: detect OpenSSL via a header the code actually uses
Closes #1994
2026-06-07 17:55:08 +02:00
Viktor Szakats
a981d10c32 configure: drop redundant gcc-specific -isystem logic
Turns out the logic was there but for gcc only. Drop in favor of the
more generic solution merged recently.

Follow-up to 04ecdb22fe #1972

Closes #1993
2026-06-07 17:29:56 +02:00
Viktor Szakats
04ecdb22fe build: update picky warning options, fix fallouts
- sync picky compiler warning options with curl:
  - update version mappings for latest Apple clang.
  - replace `-pedantic` with `-Wpedantic` on newer toolchains.
  - adjust warning cutoff versions.
  - enable new picky warnings.
  - unlock picky warnings for most recent MSVC.
- GHA: bump some MSVC jobs to to VS2026.

Fix fallouts:
- configure: replace `-I` with `-isystem` for dependency headers.
  Notably it silences picky warnings otherwise found in 3rd-party
  headers, e.g. `-Wreserved-identifier` in `gpg-error.h`,
  `openssl/lhash.h`, `wolfssl/wolfcrypt/hmac.h`, or
  `-Wcast-function-type-strict` in `openssl/rsa.h`.
  It also aligns autotools builds with CMake (and curl builds).
  Logic copied from curl.
- example/x11: fix to not use reserved symbols.
- include, src/libssh2_priv.h: silence `-Wreserved-identifier` locally.
  May be fixed for real in a future patch.
- avoid using reserved C++ keyword `public`.
- openssl: silence `-Wcast-function-type-strict` locally for
  non-OpenSSL3 builds.
- mbedtls, openssl: fix potentially uninitialized variable warnings.
  (extend to all compilers from MSVC in openssl)
- fix `LIBSSH2_SOCKET_MASK` signedness on Windows.
- wincng: apply casts from `int` to `enum` to silence
  `-Wimplicit-int-enum-cast`.
- configure: disable `-Wleading-whitespace=spaces` to due
  incompatibility with `AC_FUNC_ALLOCA`.
- packet: fix to pass `int` as mask length.
- fix `-Wformat-signedness`.
- src/libssh2_priv.h: silence `-Wreserved-macro-identifier` locally for
  mingw-w64 builds.
- GHA: add workaround for missing NSIS on windows-2025 runner images.

Closes #1972
2026-06-07 15:19:19 +02:00
Viktor Szakats
9538c99fc4 badwords: add checker script, fix issues found
Checker script and wordlist comes from curl.

Also:
- checksrc.pl: sync up with curl.
- unfold an IETF URL.
- update all IETF URLs where missing.

Closes #1959
2026-06-01 13:22:40 +02:00
Viktor Szakats
57e4316b68 build: enable -Wlogical-op for GCC 4.4+
Closes #1941
2026-05-14 19:33:05 +02:00
Viktor Szakats
9f4a270857 configure: drop old, vendored, ld detection code, merge and rename rest
Keep `lib-link.m4`, rename to `libssh2-link.m4`, namespace its content
to `LIBSSH2_`. Also copy 3 lower-level functions from another `.m4`.
Drop using vendored `AC_LIB_PROG_LD`, which served the purpose of
detecting `LD` and `with_gnu_ld`.

To reduce amount of old, complex vendored code and also to avoid
autoreconf auto-updating these in-repo files locally.

Follow-up to 0443145a75 #1920
Follow-up to bcc9292aab #1921

Closes #1916
2026-05-11 14:27:13 +02:00
Viktor Szakats
cbf39eeb7e build: fix to omit libcrypto.pc from libssh2.pc for BoringSSL
BoringSSL does not provide .pc files.

Closes #1915
2026-05-01 15:31:16 +02:00
Viktor Szakats
3d4ff6b240 tidy-up: miscellaneous
- configure: fix indent, whitespace, drop empty comments.
- .gitignore: drop `.DS_Store` (again)
  Keep this list for files created by libssh2. For other files, the
  per-machine global Git ignore file is a better place, and it fixes
  this for all repos, not just libssh2.

Closes #1842
2026-04-10 18:39:11 +02:00
Viktor Szakats
e8e6bc2c50 build: improve building in ISO and C89 modes, test in CI
Note: On Linux with glibc, ISO mode also requires setting
the `_DEFAULT_SOURCE` macro to enable necessary POSIX features when
building tests (for `popen()`, `pclose()` and examples (for `fileno()`,
`tcsetattr()`). On other platforms and environments it may require
something else.

- replace `strdup()` with local implementation.
- replace `getline()` with C89 `fgets()`.
- replace `u_char`, `u_int` with C89 types.
- fix type mismatches in chacha-poly1305 code.
- silence `-Wno-format-nonliteral` locally. The global method was not
  effective (like because it was overridden by `-Wformat=2`) and caused
  these warnings when building in C89 mode.
- GHA: test ISO C89 in zlib-enabled Linux jobs with all crypto backends.
- fix formatting nits along the way.
- configure, cmake: silence silly `-Wno-comma` warnings with clang in
  C89 mode.
- examples: include `select.h` again, where `select()` is used. As its
  canonical header. Seen required on Linux glibc non-GNU/ISO builds.
  Follow-up to a683133dfe #999

Assisted-by: Raul Tambre
Ref: #1674

Closes #1688
2026-04-08 15:30:16 +02:00
Viktor Szakats
6e56a8bdca tidy-up: drop duplicate newlines, fix non-ASCII chars, other formatting, check in CI
Closes #1766
2025-12-25 22:24:13 +01:00
Viktor Szakats
664d7654c5 build: fix/extend Apple clang and mainline llvm version translations
Ref: https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
Ref: https://github.com/curl/curl/pull/18477

Closes #1658
2025-09-14 12:43:29 +02:00
Viktor Szakats
72982d1589 build: sync up picky warnings with curl, fix fallouts
- cmake: sync `-ftree-vrp` behavior with autotools.
- build: enable `-Wjump-misses-init` for GCC 4.5+.
  Credits-to: Marcel Raad
- packet: fix `-Wjump-misses-init` warnings.
  ```
  src/packet.c: In function ‘_libssh2_packet_add’:
  src/packet.c:671:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  src/packet.c:920:31: note: ‘want_reply’ declared here
  src/packet.c:671:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  src/packet.c:919:26: note: ‘len’ declared here
  src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  src/packet.c:1121:31: note: ‘want_reply’ declared here
  src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  src/packet.c:1120:26: note: ‘len’ declared here
  src/packet.c:669:9: error: jump skips variable initialization [-Werror=jump-misses-init]
  src/packet.c:1119:26: note: ‘channel’ declared here
  ```
- build: enable gcc-12/13+, clang-10+ picky warnings
- acinclude.m4: sync formatting/comments with curl.
- autotools: fix `-Wtrampolines` picky warning for gcc 4.x versions.
  Follow-up to 854cfa8292 #1524
- cmake: enable `-Wall` for MSVC when `PICKY_COMPILER=ON`.
- MSVC: fix `-Wall` warnings.
  Seen on VS2015. Not seen on VS2022. Unknown for other versions.
  ```
  tests\test_simple.c(60): warning C4777: 'fprintf' : format string '%d' requires an argument of type 'int', but variadic argument 1 has type 'std::size_t'
  tests\test_simple.c(60): warning C4777: 'fprintf' : format string '%.*s' requires an argument of type 'int', but variadic argument 2 has type 'std::size_t'
  ```
- mbedtls: stop silencing warnings in 3rd-party header.
  Follow-up to a3aa6b4ca8 #1525
- cmake: stop deleting `-W<n>` from `CMAKE_C_FLAGS` (MSVC)
  1. `CMAKE_C_FLAGS` may apply to other projects, and deleting/altering it
     may be unexpected.
  2. We pass `-W4`/`-Wall` internally now, which do override custom
     `-W<n>` options as tested with VS2008 and newer VS generators.

Closes #1588
2025-05-07 23:24:41 +02:00
Viktor Szakats
606c102e52 build: enable -Wcast-qual, fix fallouts
- enable compiler warning `-Wcast-qual`.
- add `LIBSSH2_UNCONST()` macro to strip const where absolutely
  necessary to avoid compiler warnings.
- fix const stripping by constifying where necessary.
- fix const stripping by using `LIBSSH2_UNCONST()`.
- libgcrypt.h: drop unnecessary casts.
- openssl: fix to use new `BIO_new_mem_buf()` parameter types
  with wolfSSL.

Cherry-picked from #1484
Closes #1527
2025-01-31 00:57:26 +01:00
Viktor Szakats
ffd0c982a5 configure: fix --without-lib*-prefix when lib* is detected anyway
Do not test the prefix when set to `no`.
(as with `--without-lib*-prefix`)

Before this patch this test was always made and when detected despite
the wrong prefix, the `no` prefix remained in `LDFLAGS` causing a build
failure later in `libtool`.

Fixes:
```
$ ../configure --without-libssl-prefix
[...]
../libtool: line 7756: cd: no/lib: No such file or directory
libtool:   error: cannot determine absolute directory name of 'no/lib'
make[2]: *** [libssh2.la] Error 1
```

Follow-up to d19b619070 #1384

Reported-by: Christoph Reiter
Fixes #1505
Closes #1506
2025-01-02 22:34:21 +01:00
Viktor Szakats
bd8caa1983 configure: drop duplicate -lmbedcrypto from LIBS
Closes #1507
2025-01-02 14:19:44 +01:00
Viktor Szakats
4844e36840 build: disable warning -Wunreachable-code-break
This warning remains silent in unity builds. Since we're using unity
in CI for most jobs, warnings remain undetected there.
Disable them for all builds to avoid a surprise warning outside our CI.

It also doesn't work in any #included `.c` sources, like the crypto
backend sources.

The issue caught by the warning is useful for a tidy codebase, but
doesn't affect executed code. It was enabled in
84338c4de2d7c798e3c270c9610d51a4ad18a90b #12331 (2023-11-15).

llvm source: fee2953f23/clang/lib/Sema/AnalysisBasedWarnings.cpp (L125-L134)
llvm issue: https://github.com/llvm/llvm-project/issues/71046

Follow-up to 7ecc309cd1 #1224
Closes #1481
2024-10-28 12:30:02 +01:00
Viktor Szakats
8ae1b2d742 wolfssl: drop header path hack
The wolfSSL OpenSSL headers reside in `wolfssl/openssl/*.h`.

Before this patch the wolfSSL OpenSSL compatibilty header includes were
shared with the native OpenSSL codepath, and used `openssl/*h`. For
wolfSSL builds this required a hack to append the
`<wolfssl-prefix>/wolfssl` directory to the header search path, to find
the headers.

This patch changes the source to use the correct header references,
allowing to drop the header path hack.

Also fix to use the correct variable to set up the header path in CMake:
`WOLFSSL_INCLUDE_DIRS` (was: `WOLFSSL_INCLUDE_DIR`, without the `S`)

Closes #1439
2024-08-06 10:56:22 +02:00
Viktor Szakats
706ec36dc3 tidy-up: fix typo found by codespell
Ref: https://github.com/libssh2/libssh2/actions/runs/9224795055/job/25380857082?pr=1393#step:4:5
2024-05-24 15:39:23 +02:00
Viktor Szakats
d19b619070 autotools: fix to update LDFLAGS for each detected dependency
autotools lib detection routine failed to extend LDFLAGS for each
detection. This could cause successful detection of a dependency, but
later failing to use it. This did not cause an issue as long as all
dependencies lived under the same prefix, but started breaking on macOS
ARM + Homebrew where this was no longer true for mbedTLS and zlib in
particular.

Follow-up to 844115393b #1381
Follow-up to ae2770de25 #1377
Closes #1384
2024-05-08 23:44:14 +02:00
Viktor Szakats
3ec53f3ea2 build: enable -pedantic-errors
According to the manual, this isn't the same as `-Werror -pedantic`.
Enable it together with `-Werror`.

https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-errors-1

This option results in autotools feature detection going into crazies.
To avoid this, we add it to `CFLAGS` late. Idea copied from curl.

This option has an effect only with gcc 5.0 and newer as of this commit.
Let's enable it for clang and older versions too for simplicity. Ref:
d5c0351055
https://github.com/curl/curl/pull/2747

Closes #1286
2023-12-17 15:15:34 +00:00
Viktor Szakats
ac68fbe475 build: FIXME -Wsign-conversion to be errors [ci skip] 2023-12-13 06:33:54 +00:00
Viktor Szakats
afa6b86560 build: enable missing OpenSSF-recommended warnings, with fixes
Ref:
https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html
(2023-11-29)

Enable new warnings:

- replace `-Wno-sign-conversion` with `-Wsign-conversion`.

  Fix them in example, tests and wincng. There remain about 360 of these
  warnings in `src`. Add a TODO item for those and disable `-Werror` for
  this particular warning.

- enable `-Wformat=2` for clang (in both cmake and autotools).

- enable `__attribute__((format))` for `_libssh2_debug()`,
  `_libssh2_snprintf()` and in tests for `run_command()`.

  `LIBSSH2_PRINTF()` copied from `CURL_TEMP_PRINTF()` in curl.

- enable `-Wimplicit-fallthrough`.

- enable `-Wtrampolines`.

Fix them:

- src: replace obsolete fall-through-comments with
  `__attribute__((fallthrough))`.

- wincng: fix `-Wsign-conversion` warnings.

- tests: fix `-Wsign-conversion` warnings.

- example: fix `-Wsign-conversion` warnings.

- src: fix `-Wformat` issues in trace calls.

  Also, where necessary fix `int` and `unsigned char` casts to
  `unsigned int` and adjust printf format strings. These were not
  causing compiler warnings.

  Cast large types to `long` to avoid dealing with printf masks for
  `size_t` and other C99 types. Existing code often used `int` for this.
  I'll update them to `long` in an upcoming commit.

- tests: fix `-Wformat` warning.

- silence `-Wformat-nonliteral` warnings.

- mbedtls: silence `-Wsign-conversion`/`-Warith-conversion`
  in external header.

Closes #1257
2023-12-03 01:32:20 +00:00
Viktor Szakats
ecdf519911 autotools: enable -Wunused-macros with gcc
It works with gcc without the libtool warnings seen with clang
on Windows in 96682bd5e1 #1227.

Sync usage of of this macro with CMake and
autotools + clang + non-Windows. Making it enabled everywhere except
autotools + clang + Windows due to the libtool stub issue.

Follow-up to 7ecc309cd1 #1224

Closes #1262
2023-12-02 09:51:59 +00:00
Viktor Szakats
744e059f31 example, tests: fix/silence -Wformat-truncation=2 gcc warnings
Then sync this warning option with curl.

Seems like a false positive and/or couldn't figure how to fix it, so silence:
```
example/ssh2.c:227:38: error: '%s' directive output may be truncated writing likely 1 or more bytes into a region of size 0 [-Werror=format-truncation=]
  227 |             snprintf(fn1, fn1sz, "%s/%s", h, pubkey);
      |                                      ^~
example/ssh2.c:227:34: note: assuming directive output of 1 byte
  227 |             snprintf(fn1, fn1sz, "%s/%s", h, pubkey);
      |                                  ^~~~~~~
example/ssh2.c:227:13: note: 'snprintf' output 3 or more bytes (assuming 4) into a destination of size 2
  227 |             snprintf(fn1, fn1sz, "%s/%s", h, pubkey);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
example/ssh2.c:228:38: error: '%s' directive output may be truncated writing likely 1 or more bytes into a region of size 0 [-Werror=format-truncation=]
  228 |             snprintf(fn2, fn2sz, "%s/%s", h, privkey);
      |                                      ^~
example/ssh2.c:228:34: note: assuming directive output of 1 byte
  228 |             snprintf(fn2, fn2sz, "%s/%s", h, privkey);
      |                                  ^~~~~~~
example/ssh2.c:228:13: note: 'snprintf' output 3 or more bytes (assuming 4) into a destination of size 2
  228 |             snprintf(fn2, fn2sz, "%s/%s", h, privkey);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Ref: https://github.com/libssh2/libssh2/actions/runs/7055480458/job/19205970397#step:10:98

Fix:
```
tests/openssh_fixture.c:116:38: error: ' 2>&1' directive output may be truncated writing 5 bytes into a region of size between 1 and 1024 [-Werror=format-truncation=]
tests/openssh_fixture.c:116:11: note: 'snprintf' output between 6 and 1029 bytes into a destination of size 1024
```
Ref: https://github.com/libssh2/libssh2/actions/runs/7055480458/job/19205969221#step:10:51

Tested via #1257
2023-12-01 13:31:47 +00:00
Viktor Szakats
6c53815aa7 autotools: fix missed -pedantic and -Wall options for gcc
Follow-up to 5996fefe2b #1223

Tested via #1257
2023-12-01 05:50:12 +00:00
Viktor Szakats
89ccc83c7d autotools: fix dotless gcc and Apple clang version detections
- fix parsing dotless (major-only) gcc versions.
  Follow-up to 00a3b88c51 #1187

- sync gcc detection variable names with curl.

- fix Apple clang version detection for releases between
  'Apple LLVM version 7.3.0' and 'Apple LLVM version 10.0.1' where the
  version was under-detected as 3.7 llvm/clang equivalent.

- fix Apple clang version detection for 'Apple clang version 11.0.0'
  and newer where the Apple clang version was detected, instead of its
  llvm/clang equivalent.

- revert to show `clang` instead of `Apple clang`, because we follow it
  with an llvm/clang version number. (Apple-ness still visible in raw
  version.)

Used this collection for Apple clang / llvm/clang translation and test
inputs: https://gist.github.com/yamaya/2924292

Closes #1232
2023-11-20 20:04:56 +00:00
Viktor Szakats
fb58016180 autotools: show more clang/gcc version details
Also:
- show if we detected Apple clang.
- delete duplicate version detection for clang.

Closes #1230
2023-11-19 22:42:31 +00:00
Viktor Szakats
8c320a93a4 acinclude.m4: re-sync with curl [ci skip] 2023-11-18 16:04:53 +00:00
Viktor Szakats
96682bd5e1 autotools: avoid warnings in libtool stub code
Seen on Windows with clang64, in libtool-generated stub code for
examples and tests.

The error didn't break the CI job for some reason.

msys2 (autotools, clang64, clang-x86_64:
```
[...]
2023-11-17T20:14:17.8639574Z ./.libs/lt-test_read.c:91:10: error: macro is not used [-Werror,-Wunused-macros]
[...]
2023-11-17T20:14:39.8729255Z ./.libs/lt-sftp_write_nonblock.c:91:10: error: macro is not used [-Werror,-Wunused-macros]
[...]
```
Ref: https://github.com/libssh2/libssh2/actions/runs/6908585056/job/18798193405?pr=1226#step:8:474

Follow-up to 7ecc309cd1 #1224

Closes #1227
2023-11-17 22:24:34 +00:00
Viktor Szakats
7ecc309cd1 build: enable more compiler warnings and fix them
Enable more picky compiler warnings. I've found these options in the
nghttp3 project when implementing the CMake quick picky warning
functionality for it.

Fix issues found along the way:

- wincng, mbedtls: delete duplicate function declarations.
  Most of this was due to re-#defining crypto functions to
  crypto-backend specific implementations These redefines also remapped
  the declarations in `crypto.h`, making the backend-specific
  declarations duplicates.
  This patch deletes the backend-specific declarations.

- wincng mapped two crypto functions to the same local function.
  Also causing double declarations.
  Fix this by adding two disctinct wrappers and moving
  the common function to a static one.

- delete unreachable `break;` statements.

- kex: disable macros when unused.

- agent: disable unused constants.

- mbedtls: disable double declaration warnings because public mbedTLS
  headers trigger it. (with function `psa_set_key_domain_parameters`)

- crypto.h: formatting.

Ref: a70edb08e9/cmake/PickyWarningsC.cmake

Closes #1224
2023-11-16 14:35:23 +00:00
Viktor Szakats
5996fefe2b autotools: sync warning enabler code with curl
Tiny changes and minor updates to bring this code closer
to curl's `m4/curl-compilers.m4`.

Closes #1223
2023-11-16 00:51:32 +00:00
Viktor Szakats
e645fa95f3 acinclude.m4: fix indentation [ci skip]
Also match indentation of curl's `m4/curl-compilers.m4` for
easier syncing.
2023-11-15 23:13:51 +00:00
Viktor Szakats
ce5f208a55 autotool: rename variable
`WARN` -> `tmp_CFLAGS`

To match curl and make syncing this code easier.

Ref: d1820768cc/m4/curl-compilers.m4 (L479)

Closes #1222
2023-11-15 22:40:55 +00:00
Viktor Szakats
cdca8cff88 autotools: picky warning options tidy-up
- sync clang warning version limits with CMake.
- make `WARN=` vs. `CURL_ADD_COMPILER_WARNINGS()` consistent with curl
  and between clang and gcc (`WARN=` is for `no-` options in general).

Closes #1221
2023-11-15 20:25:31 +00:00
Viktor Szakats
328a96b3da build: picky warning updates
- cmake, autotools: sync picky gcc warnings with curl.
- cmake, autotools: add `-Wold-style-definition` for clang too.
- cmake, autotools: add comment for `-Wformat-truncation=1`.
- cmake: more precise version info for old clang options.

Closes #1219
2023-11-15 11:02:04 +00:00
Viktor Szakats
00a3b88c51 autotools: fix selecting wincng in cross-builds (and more)
- Fix explicitly selecting WinCNG in autotools cross-builds by moving
  `windows.h` header check before the WinCNG availability check.
  Follow-up to d43b8d9b0b

  Reported-by: Jack L
  Fixes #1186

- Add Linux -> mingw-w64 cross-builds for autotools and CMake. This
  doesn't detect #1186, because that happened when explicitly specifying
  WinCNG via `--with-crypto=wincng`, but not when falling back to WinCNG
  by default.

- autotools: fix to strip suffix from gcc version

  Before this patch we expected `n.n` `-dumpversion` output, but Ubuntu
  may return `n-win32` (also with `-dumpfullversion`). Causing these
  errors and failing to enable picky warnings:
  ```
  ../configure: line 23845: test: : integer expression expected
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/6263453828/job/17007893718#step:5:143

  Fix that by stripping any dash-suffix.

  gcc version detection is still half broken because we translate '10'
  to '10.10' because `cut -d. -f2` returns the first word if the
  delimiter missing.

  More possible `-dumpversion` output: `10-posix`, `10-win32`,
  `9.3-posix`, `9.3-win32`, `6`, `9.3.0`, `11`, `11.2`, `11.2.0`
  Ref: https://github.com/mamedev/mame/pull/9767

Closes #1187
2023-09-21 15:21:15 +00:00
Viktor Szakats
d43b8d9b0b ci: add MSYS builds (autotools and cmake)
Use existing MSYS2 section and extend it with builds for the MSYS
environment with both autotools and cmake.

MSYS builds resemble Cygwin ones: The env is Unixy, where Windows
headers are all available but we don't use them.

Also:

- extend existing autotools logic for Cygwin to skip detecting
  `windows.h` for MSYS targets too.

- require `windows.h` for the WinCNG backend in autotools. Before this
  patch, autotools allowed selecting WinCNG on the Cygwin and MSYS
  platforms, but the builds then fell apart due to the resulting mixed
  Unixy + Windowsy environment. The general expectation for Cygwin/MSYS
  builds is not to use the Windows API directly in them.

- stop manually selecting the `MSYS Makefiles` CMake generator for
  MSYS2-based GHA CI builds. mingw-w64 builds work fine without it, but
  it broke MSYS build which use `Unix Makefiles`. Deleting this setting
  fixes all build flavours.

Closes #1162
2023-08-14 23:10:15 +00:00
Viktor Szakats
c84745e34e build: stop requiring libssl from openssl
libssh2 does not use or need the TLS/SSL library of OpenSSL.
It only needs libcrypto.

Closes #1128
2023-07-21 12:21:54 +00:00
Viktor Szakats
5720dd9fe0 build: tidy-up libssh2.pc.in variable names
- prefix with `LIBSSH2_PC_`

- match with the names of `pkg-config` values.

- use the same names in autotools and CMake scripts.

- use `LIBSSH2_VERSION` for the version number in autotools scripts,
  to match the name used in CMake.

Closes #1125
2023-07-18 20:45:14 +00:00
Viktor Szakats
7f83de14a0 autotools: use comma separator in Requires.private of libssh2.pc
In `Requires*:`, the documented name separator is comma. We already used
it in the CMake-generated `libssh2.pc`. Adjust the autotools-generated
one to use it too, instead of spaces.

Ref: https://linux.die.net/man/1/pkg-config
Ref: d97db4fae4/pkg-config.1

Closes #1124
2023-07-14 21:08:44 +00:00
Viktor Szakats
ef538069a6 build: add/fix Requires.private packages in libssh2.pc
- autotools was using `libwolfssl`. CMake left it empty. wolfSSL
  provides `wolfssl.pc`. This patch sets `Requires.private: wolfssl`
  with both build tools.

- add `libgcrypt` to `Requires.private` with both autotools and CMake.
  Ref:
    e76e88eef7/src/libgcrypt.pc.in
  Present since 2005-04-22:
    32bf3f13e8
  Released in v1.3.0 2007-05-04:
    https://github.com/gpg/libgcrypt/releases/tag/libgcrypt-1.3.0

- also stop adding transitive `zlib` deps to `Requires.private`.
  The referenced crypto package is adding it as nedded.
  This makes deduplication of the list redundant, so stop doing it.
  Follow-up to 2fc3679007

(`libssh2.pc` not tested as a project dependency.)

Closes #1123
2023-07-14 18:36:25 +00:00
Daniel Stenberg
f6aa31f48f provide SPDX identifiers
- All files have prominent copyright and SPDX identifier
- If not embedded in the file, in the .reuse/dep5 file
- All used licenses are in LICENSES/ (not shipped in tarballs)
- A new REUSE CI job verify that all files are OK

Assisted-by: Viktor Szakats

Closes #1084
2023-06-07 08:18:55 +02:00
Viktor Szakats
7aab5bd6f9 build: fix autoreconf warnings
- update `AC_HELP_STRING' to 'AS_HELP_STRING`:
  ```
  configure.ac:[...]: warning: The macro `AC_HELP_STRING' is obsolete.
  ```
  "AC_HELP_STRING is deprecated in 2.70+ and I believe AS_HELP_STRING works
  already since 2.59 so bump the minimum required version to that."

  Ref: a59f046116

- simplify to avoid:
  ```
  src/Makefile.inc:48: warning: variable 'EXTRA_DIST_SOURCES' is defined but no program or
  src/Makefile.inc:48: library has 'DIST' as canonical name (possible typo)
  ```
  Regression from 2c18b6fc8d

- `AC_TRY_LINK`/`AC_TRY_COMPILE`:
  ```
  configure.ac:335: warning: The macro `AC_TRY_COMPILE' is obsolete.
  configure.ac:335: warning: The macro `AC_TRY_LINK' is obsolete.
  ```

- `libtool`-related ones:
  ```
  configure.ac:70: warning: The macro `AC_LIBTOOL_WIN32_DLL' is obsolete.
  configure.ac:70: warning: AC_LIBTOOL_WIN32_DLL: Remove this warning and the call to _LT_SET_OPTION when you
  configure.ac:70: put the 'win32-dll' option into LT_INIT's first parameter.
  configure.ac:71: warning: The macro `AC_PROG_LIBTOOL' is obsolete.
  ```
  Using code copied from curl:
  9ce7eee070/m4/xc-lt-iface.m4 (L157-L163)

- delete commented and obsolete `AC_HEADER_STDC`.

- formatting.

Most cherry-picked from `autoupdate` updates.

Cherry-picked from #1017
Closes #1021
2023-05-03 01:09:15 +00:00
Viktor Szakats
d67aaaffc4 tidy-up: text nits, English contractions [ci skip]
In input/output text and docs mostly.
2023-04-27 14:19:03 +00:00
Viktor Szakats
191c4e8c71 build: assume non-blocking I/O on Windows
Drop checks from Windows builds and enable it based on `WIN32`.

This saves detection time and also makes 3rd party builds simpler.

Also:

- delete `HAVE_DISABLED_NONBLOCKING`, that we used in build tools to
  explicitly disable an explicit `#error` in `session.c`.

- replace existing `WSAEWOULDBLOCK` check for Windows support with
  `WIN32`. Cleaner with the same result.

Follow-up to f1e80d8d8c
Follow-up to 5644eea216

Closes #980
2023-04-18 08:19:34 +00:00
Viktor Szakats
238def4da8 autotools: rename a variable
To match its counterpart we use for clang and to better match
the original code in curl.

Follow-up to ec0feae792

Closes #977
2023-04-16 19:18:40 +00:00
Viktor Szakats
16071c225f build: add -Wbad-function-cast picky warning
Also adjust minimum gcc versions in comment.

Closes #975
2023-04-16 17:22:10 +00:00