`Makefile.mk` supported MS-DOS and Amiga, but `./configure` also
supported them in a better tested and more flexible way.
This patch also adds CMake support for MS-DOS/DJGPP and Amiga OS 3.
`Makefile.mk` was not maintained. Delete it in favour of first-tier
build methods.
Also include some non-MS-DOS/AmigaOS-specific tidy-up, see details at
the end of this message.
Details:
- fix/silence all MS-DOS/DJGPP build warnings and issues.
- add MS-DOS support to cmake.
- default to `ENABLE_THREADED_RESOLVER=OFF` for MS-DOS.
- add support for `WATT_ROOT`.
- use static libcurl with MS-DOS.
- fixup default CMake suffixes/prefixes for DJGPP.
- disable hidden symbols for MS-DOS. Not supported on MS-DOS.
- opt-in MS-DOS into `USE_UNIX_SOCKETS`.
- improve MS-DOS support in autotools.
- default to `--disable-threaded-resolver` for MS-DOS.
- make sure to use `close_s()` (from Watt-32) with autotools and cmake.
`Makefile.mk` used it before this patch.
- GHA: add DJGPP cmake (~30s) and autotools (~60s) build jobs.
Also build tests and examples with cmake.
- improve AmigaOS support in autotools:
- configure: detect `CloseSocket()` when it's a macro.
- configure: fix `IoctlSocket` detection on AmigaOS.
- curl-amissl.m4: pass AmiSSL libs to tests/servers.
- add AmigaOS3 support to cmake:
- cmake: fix `HAVE_IOCTLSOCKET_CAMEL` and
`HAVE_IOCTLSOCKET_CAMEL_FIONBIO` detections.
- set necessary system libs.
- add AmiSSL support.
- inet_ntop, inet_pton: fix using it for AmigaOS. cmake detects them,
and they did not compile with AmigaOS.
- cmake: better sync `gethostname` detection with autotools.
Fixes detection for AmigaOS, where `gethostname` is a macro.
- cmake: fix `sys/utime.h` detection on AmigaOS.
- cmake: force-disable `getaddrinfo` for AmigaOS.
- cmake: tweak threading and static/shared default for AmigaOS.
- cmake: rely on manual variable `AMIGA` to enable the platform.
- GHA: add AmigaOS cmake and autotools (~45s) jobs.
Also build tests and examples with cmake.
- INSTALL: update MS-DOS and AmigaOS build instructions.
- amigaos: fix `-Wpointer-sign` and
`zero or negative size array '_args'` in `Printf()`.
- amigaos: fix `-Wpointer-sign`
- amigaos: fix `-Wredundant-decls` `errno` and `h_errno`.
- amigaos: brute-force silence `lseek()` size warnings.
- amigaos: server/resolve: silence `-Wdiscarded-qualifiers`.
- amigaos: server/resolve: fix `-Wpointer-sign`.
- amigaos: fix `CURL_SA_FAMILY_T` type.
- nonblock: prefer `HAVE_IOCTLSOCKET_CAMEL_FIONBIO` for AmigaOS.
`ioctl` is also detected, but fails when used. Make the above override
it for a successful build.
Authored-by: Darren Banfi
Fixes #15537
Closes #15603
- tftpd: prefer `HAVE_IOCTLSOCKET_CAMEL_FIONBIO` for AmigaOS.
- tftpd: tidy-up conditional code.
- curl: set stack size to 16384 for AmigaOS3/4
Overriding the default 4096.
Suggested-by: Darren Banfi
Ref: https://github.com/curl/curl/pull/15543#issuecomment-2498783123
Ref: https://wiki.amigaos.net/wiki/Controlling_Application_Stack
- functypes.h: fix `SEND_QUAL_ARG2` for AmigaOS.
- tftp: add missing cast in sendto() call for AmigaOS.
- getinfo: fix warning with AmigaOS.
- tool_operate: silence warning with AmigaOS
- amigaos: fix building libtests due to missing `RLIMIT_NOFILE`.
- curl_gethostname: silence warning for AmigaOS.
- ftp: silence `-Wtype-limits` for AmigaOS.
- libtest: fix timeval initialization for AmigaOS.
- examples: fix `timeval` initialization for AmigaOS.
- examples: silence warning for AmigaOS.
- configure: fix IPv6 detection for cross-builds.
- netrc: fix to build with AmigaOS cleanly.
- buildinfo: detect and add `DOS` tag for MS-DOS builds.
- buildinfo: add `AMIGA` to buildinfo.txt in auttools.
- build: move `USE_WATT32` macro definition to cmake/configure.
Non-MS-DOS/AmigeOS-specific tidy-ups:
- configure: sync `sa_family_t` detection with cmake.
- configure: sync `ADDRESS_FAMILY` detection signals with cmake.
- doh: use `CURL_SA_FAMILY_T`.
- lib: drop mingw-specific `CURL_SA_FAMILY_T` workaround.
- cmake: extend instead of override check-specific
configurations/requirements.
This allows to honor global requirements added earlier.
Necessary for AmigaOS for example.
- cmake: omit warning on disabled IPv6 for MS-DOS and AmigaOS.
No IPv6 support on these platforms. Also sync with autotools.
- lib1960: use libcurl `inet_pton()` wrapper.
- cmake: detect LibreSSL (to match autotools).
- cmake: say the specific OpenSSL flavour detected.
- hostip: add missing `HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID` guard.
- lib: simplify classic mac feature guards.
Follow-up to a8861b6ccd #9764
Closes #15543
407 lines
11 KiB
C
407 lines
11 KiB
C
#ifndef HEADER_CURL_SETUP_ONCE_H
|
|
#define HEADER_CURL_SETUP_ONCE_H
|
|
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
*
|
|
* This software is licensed as described in the file COPYING, which
|
|
* you should have received as part of this distribution. The terms
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
*
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
* SPDX-License-Identifier: curl
|
|
*
|
|
***************************************************************************/
|
|
|
|
|
|
/*
|
|
* Inclusion of common header files.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdarg.h>
|
|
#include <time.h>
|
|
#include <errno.h>
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
#include <sys/types.h>
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
#include <sys/stat.h>
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
#include <sys/time.h>
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
#include <io.h>
|
|
#include <fcntl.h>
|
|
#endif
|
|
|
|
#if defined(HAVE_STDBOOL_H) && defined(HAVE_BOOL_T)
|
|
#include <stdbool.h>
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#ifdef USE_WOLFSSL
|
|
#include <stdint.h>
|
|
#endif
|
|
|
|
#ifdef USE_SCHANNEL
|
|
/* Must set this before <schannel.h> is included directly or indirectly by
|
|
another Windows header. */
|
|
# define SCHANNEL_USE_BLACKLISTS 1
|
|
#endif
|
|
|
|
#ifdef __hpux
|
|
# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
|
|
# ifdef _APP32_64BIT_OFF_T
|
|
# define OLD_APP32_64BIT_OFF_T _APP32_64BIT_OFF_T
|
|
# undef _APP32_64BIT_OFF_T
|
|
# else
|
|
# undef OLD_APP32_64BIT_OFF_T
|
|
# endif
|
|
# endif
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
#include <sys/socket.h>
|
|
#endif
|
|
|
|
#include "functypes.h"
|
|
|
|
#ifdef __hpux
|
|
# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
|
|
# ifdef OLD_APP32_64BIT_OFF_T
|
|
# define _APP32_64BIT_OFF_T OLD_APP32_64BIT_OFF_T
|
|
# undef OLD_APP32_64BIT_OFF_T
|
|
# endif
|
|
# endif
|
|
#endif
|
|
|
|
/*
|
|
* Definition of timeval struct for platforms that do not have it.
|
|
*/
|
|
|
|
#ifndef HAVE_STRUCT_TIMEVAL
|
|
struct timeval {
|
|
long tv_sec;
|
|
long tv_usec;
|
|
};
|
|
#endif
|
|
|
|
|
|
/*
|
|
* If we have the MSG_NOSIGNAL define, make sure we use
|
|
* it as the fourth argument of function send()
|
|
*/
|
|
|
|
#ifdef HAVE_MSG_NOSIGNAL
|
|
#define SEND_4TH_ARG MSG_NOSIGNAL
|
|
#else
|
|
#define SEND_4TH_ARG 0
|
|
#endif
|
|
|
|
|
|
#if defined(__minix)
|
|
/* Minix does not support recv on TCP sockets */
|
|
#define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \
|
|
(RECV_TYPE_ARG2)(y), \
|
|
(RECV_TYPE_ARG3)(z))
|
|
|
|
#elif defined(HAVE_RECV)
|
|
/*
|
|
* The definitions for the return type and arguments types
|
|
* of functions recv() and send() belong and come from the
|
|
* configuration file. Do not define them in any other place.
|
|
*
|
|
* HAVE_RECV is defined if you have a function named recv()
|
|
* which is used to read incoming data from sockets. If your
|
|
* function has another name then do not define HAVE_RECV.
|
|
*
|
|
* If HAVE_RECV is defined then RECV_TYPE_ARG1, RECV_TYPE_ARG2,
|
|
* RECV_TYPE_ARG3, RECV_TYPE_ARG4 and RECV_TYPE_RETV must also
|
|
* be defined.
|
|
*
|
|
* HAVE_SEND is defined if you have a function named send()
|
|
* which is used to write outgoing data on a connected socket.
|
|
* If yours has another name then do not define HAVE_SEND.
|
|
*
|
|
* If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2,
|
|
* SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and
|
|
* SEND_TYPE_RETV must also be defined.
|
|
*/
|
|
|
|
#define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
|
|
(RECV_TYPE_ARG2)(y), \
|
|
(RECV_TYPE_ARG3)(z), \
|
|
(RECV_TYPE_ARG4)(0))
|
|
#else /* HAVE_RECV */
|
|
#ifndef sread
|
|
#error "Missing definition of macro sread!"
|
|
#endif
|
|
#endif /* HAVE_RECV */
|
|
|
|
|
|
#if defined(__minix)
|
|
/* Minix does not support send on TCP sockets */
|
|
#define swrite(x,y,z) (ssize_t)write((SEND_TYPE_ARG1)(x), \
|
|
(SEND_TYPE_ARG2)(y), \
|
|
(SEND_TYPE_ARG3)(z))
|
|
|
|
#elif defined(HAVE_SEND)
|
|
#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
|
|
(SEND_QUAL_ARG2 SEND_TYPE_ARG2)(y), \
|
|
(SEND_TYPE_ARG3)(z), \
|
|
(SEND_TYPE_ARG4)(SEND_4TH_ARG))
|
|
#else /* HAVE_SEND */
|
|
#ifndef swrite
|
|
#error "Missing definition of macro swrite!"
|
|
#endif
|
|
#endif /* HAVE_SEND */
|
|
|
|
|
|
/*
|
|
* Function-like macro definition used to close a socket.
|
|
*/
|
|
|
|
#if defined(HAVE_CLOSESOCKET)
|
|
# define sclose(x) closesocket((x))
|
|
#elif defined(HAVE_CLOSESOCKET_CAMEL)
|
|
# define sclose(x) CloseSocket((x))
|
|
#elif defined(MSDOS) /* Watt-32 */
|
|
# define sclose(x) close_s((x))
|
|
#elif defined(USE_LWIPSOCK)
|
|
# define sclose(x) lwip_close((x))
|
|
#else
|
|
# define sclose(x) close((x))
|
|
#endif
|
|
|
|
/*
|
|
* Stack-independent version of fcntl() on sockets:
|
|
*/
|
|
#if defined(USE_LWIPSOCK)
|
|
# define sfcntl lwip_fcntl
|
|
#else
|
|
# define sfcntl fcntl
|
|
#endif
|
|
|
|
/*
|
|
* 'bool' stuff compatible with HP-UX headers.
|
|
*/
|
|
|
|
#if defined(__hpux) && !defined(HAVE_BOOL_T)
|
|
typedef int bool;
|
|
# define false 0
|
|
# define true 1
|
|
# define HAVE_BOOL_T
|
|
#endif
|
|
|
|
|
|
/*
|
|
* 'bool' exists on platforms with <stdbool.h>, i.e. C99 platforms.
|
|
* On non-C99 platforms there is no bool, so define an enum for that.
|
|
* On C99 platforms 'false' and 'true' also exist. Enum uses a
|
|
* global namespace though, so use bool_false and bool_true.
|
|
*/
|
|
|
|
#ifndef HAVE_BOOL_T
|
|
typedef enum {
|
|
bool_false = 0,
|
|
bool_true = 1
|
|
} bool;
|
|
|
|
/*
|
|
* Use a define to let 'true' and 'false' use those enums. There
|
|
* are currently no use of true and false in libcurl proper, but
|
|
* there are some in the examples. This will cater for any later
|
|
* code happening to use true and false.
|
|
*/
|
|
# define false bool_false
|
|
# define true bool_true
|
|
# define HAVE_BOOL_T
|
|
#endif
|
|
|
|
/* the type we use for storing a single boolean bit */
|
|
#ifdef _MSC_VER
|
|
typedef bool bit;
|
|
#define BIT(x) bool x
|
|
#else
|
|
typedef unsigned int bit;
|
|
#define BIT(x) bit x:1
|
|
#endif
|
|
|
|
/*
|
|
* Redefine TRUE and FALSE too, to catch current use. With this
|
|
* change, 'bool found = 1' will give a warning on MIPSPro, but
|
|
* 'bool found = TRUE' will not. Change tested on IRIX/MIPSPro,
|
|
* AIX 5.1/Xlc, Tru64 5.1/cc, w/make test too.
|
|
*/
|
|
|
|
#ifndef TRUE
|
|
#define TRUE true
|
|
#endif
|
|
#ifndef FALSE
|
|
#define FALSE false
|
|
#endif
|
|
|
|
#include "curl_ctype.h"
|
|
|
|
|
|
/*
|
|
* Macro used to include code only in debug builds.
|
|
*/
|
|
|
|
#ifdef DEBUGBUILD
|
|
#define DEBUGF(x) x
|
|
#else
|
|
#define DEBUGF(x) do { } while(0)
|
|
#endif
|
|
|
|
|
|
/*
|
|
* Macro used to include assertion code only in debug builds.
|
|
*/
|
|
|
|
#undef DEBUGASSERT
|
|
#if defined(DEBUGBUILD)
|
|
#define DEBUGASSERT(x) assert(x)
|
|
#else
|
|
#define DEBUGASSERT(x) do { } while(0)
|
|
#endif
|
|
|
|
|
|
/*
|
|
* Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno
|
|
* (or equivalent) on this platform to hide platform details to code using it.
|
|
*/
|
|
|
|
#ifdef USE_WINSOCK
|
|
#define SOCKERRNO ((int)WSAGetLastError())
|
|
#define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
|
|
#else
|
|
#define SOCKERRNO (errno)
|
|
#define SET_SOCKERRNO(x) (errno = (x))
|
|
#endif
|
|
|
|
|
|
/*
|
|
* Portable error number symbolic names defined to Winsock error codes.
|
|
*/
|
|
|
|
#ifdef USE_WINSOCK
|
|
#undef EBADF /* override definition in errno.h */
|
|
#define EBADF WSAEBADF
|
|
#undef EINTR /* override definition in errno.h */
|
|
#define EINTR WSAEINTR
|
|
#undef EINVAL /* override definition in errno.h */
|
|
#define EINVAL WSAEINVAL
|
|
#undef EWOULDBLOCK /* override definition in errno.h */
|
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
|
#undef EINPROGRESS /* override definition in errno.h */
|
|
#define EINPROGRESS WSAEINPROGRESS
|
|
#undef EALREADY /* override definition in errno.h */
|
|
#define EALREADY WSAEALREADY
|
|
#undef ENOTSOCK /* override definition in errno.h */
|
|
#define ENOTSOCK WSAENOTSOCK
|
|
#undef EDESTADDRREQ /* override definition in errno.h */
|
|
#define EDESTADDRREQ WSAEDESTADDRREQ
|
|
#undef EMSGSIZE /* override definition in errno.h */
|
|
#define EMSGSIZE WSAEMSGSIZE
|
|
#undef EPROTOTYPE /* override definition in errno.h */
|
|
#define EPROTOTYPE WSAEPROTOTYPE
|
|
#undef ENOPROTOOPT /* override definition in errno.h */
|
|
#define ENOPROTOOPT WSAENOPROTOOPT
|
|
#undef EPROTONOSUPPORT /* override definition in errno.h */
|
|
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
|
|
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
|
|
#undef EOPNOTSUPP /* override definition in errno.h */
|
|
#define EOPNOTSUPP WSAEOPNOTSUPP
|
|
#define EPFNOSUPPORT WSAEPFNOSUPPORT
|
|
#undef EAFNOSUPPORT /* override definition in errno.h */
|
|
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
|
#undef EADDRINUSE /* override definition in errno.h */
|
|
#define EADDRINUSE WSAEADDRINUSE
|
|
#undef EADDRNOTAVAIL /* override definition in errno.h */
|
|
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
|
|
#undef ENETDOWN /* override definition in errno.h */
|
|
#define ENETDOWN WSAENETDOWN
|
|
#undef ENETUNREACH /* override definition in errno.h */
|
|
#define ENETUNREACH WSAENETUNREACH
|
|
#undef ENETRESET /* override definition in errno.h */
|
|
#define ENETRESET WSAENETRESET
|
|
#undef ECONNABORTED /* override definition in errno.h */
|
|
#define ECONNABORTED WSAECONNABORTED
|
|
#undef ECONNRESET /* override definition in errno.h */
|
|
#define ECONNRESET WSAECONNRESET
|
|
#undef ENOBUFS /* override definition in errno.h */
|
|
#define ENOBUFS WSAENOBUFS
|
|
#undef EISCONN /* override definition in errno.h */
|
|
#define EISCONN WSAEISCONN
|
|
#undef ENOTCONN /* override definition in errno.h */
|
|
#define ENOTCONN WSAENOTCONN
|
|
#define ESHUTDOWN WSAESHUTDOWN
|
|
#define ETOOMANYREFS WSAETOOMANYREFS
|
|
#undef ETIMEDOUT /* override definition in errno.h */
|
|
#define ETIMEDOUT WSAETIMEDOUT
|
|
#undef ECONNREFUSED /* override definition in errno.h */
|
|
#define ECONNREFUSED WSAECONNREFUSED
|
|
#undef ELOOP /* override definition in errno.h */
|
|
#define ELOOP WSAELOOP
|
|
#ifndef ENAMETOOLONG /* possible previous definition in errno.h */
|
|
#define ENAMETOOLONG WSAENAMETOOLONG
|
|
#endif
|
|
#define EHOSTDOWN WSAEHOSTDOWN
|
|
#undef EHOSTUNREACH /* override definition in errno.h */
|
|
#define EHOSTUNREACH WSAEHOSTUNREACH
|
|
#ifndef ENOTEMPTY /* possible previous definition in errno.h */
|
|
#define ENOTEMPTY WSAENOTEMPTY
|
|
#endif
|
|
#define EPROCLIM WSAEPROCLIM
|
|
#define EUSERS WSAEUSERS
|
|
#define EDQUOT WSAEDQUOT
|
|
#define ESTALE WSAESTALE
|
|
#define EREMOTE WSAEREMOTE
|
|
#endif
|
|
|
|
/*
|
|
* Macro argv_item_t hides platform details to code using it.
|
|
*/
|
|
|
|
#ifdef __VMS
|
|
#define argv_item_t __char_ptr32
|
|
#elif defined(_UNICODE)
|
|
#define argv_item_t wchar_t *
|
|
#else
|
|
#define argv_item_t char *
|
|
#endif
|
|
|
|
|
|
/*
|
|
* We use this ZERO_NULL to avoid picky compiler warnings,
|
|
* when assigning a NULL pointer to a function pointer var.
|
|
*/
|
|
|
|
#define ZERO_NULL 0
|
|
|
|
|
|
#endif /* HEADER_CURL_SETUP_ONCE_H */
|