`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
247 lines
6.2 KiB
C
247 lines
6.2 KiB
C
/***************************************************************************
|
|
* _ _ ____ _
|
|
* 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
|
|
*
|
|
***************************************************************************/
|
|
|
|
#include "curl_setup.h"
|
|
|
|
#ifdef __AMIGA__
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include "hostip.h"
|
|
#include "amigaos.h"
|
|
|
|
#ifdef HAVE_PROTO_BSDSOCKET_H
|
|
# if defined(__amigaos4__)
|
|
# include <bsdsocket/socketbasetags.h>
|
|
# elif !defined(USE_AMISSL)
|
|
# include <amitcp/socketbasetags.h>
|
|
# endif
|
|
# ifdef __libnix__
|
|
# include <stabs.h>
|
|
# endif
|
|
#endif
|
|
|
|
/* The last #include files should be: */
|
|
#include "curl_memory.h"
|
|
#include "memdebug.h"
|
|
|
|
#ifdef HAVE_PROTO_BSDSOCKET_H
|
|
|
|
#ifdef __amigaos4__
|
|
/*
|
|
* AmigaOS 4.x specific code
|
|
*/
|
|
|
|
/*
|
|
* hostip4.c - Curl_ipv4_resolve_r() replacement code
|
|
*
|
|
* Logic that needs to be considered are the following build cases:
|
|
* - newlib networking
|
|
* - clib2 networking
|
|
* - direct bsdsocket.library networking (usually AmiSSL builds)
|
|
* Each with the threaded resolver enabled or not.
|
|
*
|
|
* With the threaded resolver enabled, try to use gethostbyname_r() where
|
|
* available, otherwise (re)open bsdsocket.library and fallback to
|
|
* gethostbyname().
|
|
*/
|
|
|
|
#include <proto/bsdsocket.h>
|
|
|
|
static struct SocketIFace *__CurlISocket = NULL;
|
|
static uint32 SocketFeatures = 0;
|
|
|
|
#define HAVE_BSDSOCKET_GETHOSTBYNAME_R 0x01
|
|
#define HAVE_BSDSOCKET_GETADDRINFO 0x02
|
|
|
|
CURLcode Curl_amiga_init(void)
|
|
{
|
|
struct SocketIFace *ISocket;
|
|
struct Library *base = OpenLibrary("bsdsocket.library", 4);
|
|
|
|
if(base) {
|
|
ISocket = (struct SocketIFace *)GetInterface(base, "main", 1, NULL);
|
|
if(ISocket) {
|
|
ULONG enabled = 0;
|
|
|
|
SocketBaseTags(SBTM_SETVAL(SBTC_CAN_SHARE_LIBRARY_BASES), TRUE,
|
|
SBTM_GETREF(SBTC_HAVE_GETHOSTADDR_R_API), (ULONG)&enabled,
|
|
TAG_DONE);
|
|
|
|
if(enabled) {
|
|
SocketFeatures |= HAVE_BSDSOCKET_GETHOSTBYNAME_R;
|
|
}
|
|
|
|
__CurlISocket = ISocket;
|
|
|
|
atexit(Curl_amiga_cleanup);
|
|
|
|
return CURLE_OK;
|
|
}
|
|
CloseLibrary(base);
|
|
}
|
|
|
|
return CURLE_FAILED_INIT;
|
|
}
|
|
|
|
void Curl_amiga_cleanup(void)
|
|
{
|
|
if(__CurlISocket) {
|
|
struct Library *base = __CurlISocket->Data.LibBase;
|
|
DropInterface((struct Interface *)__CurlISocket);
|
|
CloseLibrary(base);
|
|
__CurlISocket = NULL;
|
|
}
|
|
}
|
|
|
|
#ifdef CURLRES_AMIGA
|
|
/*
|
|
* Because we need to handle the different cases in hostip4.c at runtime,
|
|
* not at compile-time, based on what was detected in Curl_amiga_init(),
|
|
* we replace it completely with our own as to not complicate the baseline
|
|
* code. Assumes malloc/calloc/free are thread safe because Curl_he2ai()
|
|
* allocates memory also.
|
|
*/
|
|
|
|
struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
|
int port)
|
|
{
|
|
struct Curl_addrinfo *ai = NULL;
|
|
struct hostent *h;
|
|
struct SocketIFace *ISocket = __CurlISocket;
|
|
|
|
if(SocketFeatures & HAVE_BSDSOCKET_GETHOSTBYNAME_R) {
|
|
LONG h_errnop = 0;
|
|
struct hostent *buf;
|
|
|
|
buf = calloc(1, CURL_HOSTENT_SIZE);
|
|
if(buf) {
|
|
h = gethostbyname_r((STRPTR)hostname, buf,
|
|
(char *)buf + sizeof(struct hostent),
|
|
CURL_HOSTENT_SIZE - sizeof(struct hostent),
|
|
&h_errnop);
|
|
if(h) {
|
|
ai = Curl_he2ai(h, port);
|
|
}
|
|
free(buf);
|
|
}
|
|
}
|
|
else {
|
|
#ifdef CURLRES_THREADED
|
|
/* gethostbyname() is not thread safe, so we need to reopen bsdsocket
|
|
* on the thread's context
|
|
*/
|
|
struct Library *base = OpenLibrary("bsdsocket.library", 4);
|
|
if(base) {
|
|
ISocket = (struct SocketIFace *)GetInterface(base, "main", 1, NULL);
|
|
if(ISocket) {
|
|
h = gethostbyname((STRPTR)hostname);
|
|
if(h) {
|
|
ai = Curl_he2ai(h, port);
|
|
}
|
|
DropInterface((struct Interface *)ISocket);
|
|
}
|
|
CloseLibrary(base);
|
|
}
|
|
#else
|
|
/* not using threaded resolver - safe to use this as-is */
|
|
h = gethostbyname(hostname);
|
|
if(h) {
|
|
ai = Curl_he2ai(h, port);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
return ai;
|
|
}
|
|
#endif /* CURLRES_AMIGA */
|
|
|
|
#ifdef USE_AMISSL
|
|
#include <signal.h>
|
|
int Curl_amiga_select(int nfds, fd_set *readfds, fd_set *writefds,
|
|
fd_set *errorfds, struct timeval *timeout)
|
|
{
|
|
int r = WaitSelect(nfds, readfds, writefds, errorfds, timeout, 0);
|
|
/* Ensure Ctrl-C signal is actioned */
|
|
if((r == -1) && (SOCKERRNO == EINTR))
|
|
raise(SIGINT);
|
|
return r;
|
|
}
|
|
#endif /* USE_AMISSL */
|
|
|
|
#elif !defined(USE_AMISSL) /* __amigaos4__ */
|
|
/*
|
|
* Amiga OS3 specific code
|
|
*/
|
|
|
|
struct Library *SocketBase = NULL;
|
|
|
|
#ifdef __libnix__
|
|
void __request(const char *msg);
|
|
#else
|
|
# define __request(msg) Printf((const unsigned char *)(msg "\n\a"), 0)
|
|
#endif
|
|
|
|
void Curl_amiga_cleanup(void)
|
|
{
|
|
if(SocketBase) {
|
|
CloseLibrary(SocketBase);
|
|
SocketBase = NULL;
|
|
}
|
|
}
|
|
|
|
CURLcode Curl_amiga_init(void)
|
|
{
|
|
if(!SocketBase)
|
|
SocketBase = OpenLibrary((const unsigned char *)"bsdsocket.library", 4);
|
|
|
|
if(!SocketBase) {
|
|
__request("No TCP/IP Stack running!");
|
|
return CURLE_FAILED_INIT;
|
|
}
|
|
|
|
if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (ULONG) &errno,
|
|
SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG) "curl",
|
|
TAG_DONE)) {
|
|
__request("SocketBaseTags ERROR");
|
|
return CURLE_FAILED_INIT;
|
|
}
|
|
|
|
#ifndef __libnix__
|
|
atexit(Curl_amiga_cleanup);
|
|
#endif
|
|
|
|
return CURLE_OK;
|
|
}
|
|
|
|
#ifdef __libnix__
|
|
ADD2EXIT(Curl_amiga_cleanup, -50);
|
|
#endif
|
|
|
|
#endif /* !USE_AMISSL */
|
|
|
|
#endif /* HAVE_PROTO_BSDSOCKET_H */
|
|
|
|
#endif /* __AMIGA__ */
|