mirror of
https://github.com/libssh2/libssh2.git
synced 2025-08-07 08:02:56 +03:00
build: hand-crafted config rework & header tidy-up
- introduce the concept of a project level setup header `src/libssh2_setup.h`, that is used by `src`, `example` and `tests` alike. Move there all common platform/compiler configuration from `src/libssh2_priv.h`, individual sources and `CMakeFiles.txt` files. Also move there our hand-crafted (= not auto-generated by CMake or autotools) configuration `win32/libssh2-config.h`. - `win32` directory is empty now, delete it. - `Makefile.mk`: adapt to the above. Build-directory is the target triplet, or any custom name set via `BLD_DIR`. - sync header path order between build systems: build/src -> source/src -> source/include - delete redundant references to `windows.h`, `winsock2.h`, `ws2tcpip.h`. - delete unnecessary #includes, update order (`libssh2_setup.h` first, `winsock2.h` first), simplify where possible. This makes the code warning-free without `WIN32_LEAN_AND_MEAN`. At the same time this patch applies this macro globally, to avoid header bloat. - example: add missing *nix header guards. - example: fix misindented `HAVE_UNISTD_H` `#ifdef`s. - set `WIN32` with all build-tools. - set `HAVE_SYS_PARAM_H` in the hand-crafted config for MinGW. To match auto-detection. - move a source-specific macro to `misc.c` from `libssh2_priv.h`. See the PR's individual commits for step-by-step updates. Closes #932
This commit is contained in:
@@ -87,7 +87,12 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
#define _LIBSSH2_WIN32
|
||||
#endif
|
||||
|
||||
#ifdef _LIBSSH2_WIN32
|
||||
# include <basetsd.h>
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
@@ -99,7 +104,7 @@ extern "C" {
|
||||
|
||||
/* Allow alternate API prefix from CFLAGS or calling app */
|
||||
#ifndef LIBSSH2_API
|
||||
# ifdef WIN32
|
||||
# ifdef _LIBSSH2_WIN32
|
||||
# if defined(LIBSSH2_EXPORTS) || defined(DLL_EXPORT) || \
|
||||
defined(_WINDLL) || defined(libssh2_shared_EXPORTS)
|
||||
# ifdef LIBSSH2_LIBRARY
|
||||
@@ -110,9 +115,9 @@ extern "C" {
|
||||
# else
|
||||
# define LIBSSH2_API
|
||||
# endif
|
||||
# else /* !WIN32 */
|
||||
# else /* !_LIBSSH2_WIN32 */
|
||||
# define LIBSSH2_API
|
||||
# endif /* WIN32 */
|
||||
# endif /* _LIBSSH2_WIN32 */
|
||||
#endif /* LIBSSH2_API */
|
||||
|
||||
#ifdef HAVE_SYS_UIO_H
|
||||
@@ -138,13 +143,13 @@ typedef unsigned long long libssh2_uint64_t;
|
||||
typedef long long libssh2_int64_t;
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _LIBSSH2_WIN32
|
||||
typedef SOCKET libssh2_socket_t;
|
||||
#define LIBSSH2_INVALID_SOCKET INVALID_SOCKET
|
||||
#else /* !WIN32 */
|
||||
#else /* !_LIBSSH2_WIN32 */
|
||||
typedef int libssh2_socket_t;
|
||||
#define LIBSSH2_INVALID_SOCKET -1
|
||||
#endif /* WIN32 */
|
||||
#endif /* _LIBSSH2_WIN32 */
|
||||
|
||||
/*
|
||||
* Determine whether there is small or large file support on windows.
|
||||
@@ -170,7 +175,7 @@ typedef int libssh2_socket_t;
|
||||
# undef LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES) && \
|
||||
#if defined(_LIBSSH2_WIN32) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES) && \
|
||||
!defined(LIBSSH2_USE_WIN32_SMALL_FILES)
|
||||
# define LIBSSH2_USE_WIN32_SMALL_FILES
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user