Makefile.mk: drop in favour of autotools and cmake (MS-DOS, AmigaOS3)

`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
This commit is contained in:
Viktor Szakats 2024-11-16 19:04:36 +01:00
parent 607bec04d9
commit a3585c9576
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
74 changed files with 734 additions and 1019 deletions

View file

@ -748,7 +748,14 @@ static bool incoming(curl_socket_t listenfd)
FD_ZERO(&fds_err);
/* there's always a socket to wait for */
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
do {
/* select() blocking behavior call on blocking descriptors please */

View file

@ -142,7 +142,11 @@ int main(int argc, char *argv[])
/* gethostbyname() resolve */
struct hostent *he;
#ifdef __AMIGA__
he = gethostbyname((unsigned char *)host);
#else
he = gethostbyname(host);
#endif
rc = !he;
}

View file

@ -996,7 +996,14 @@ static bool juggle(curl_socket_t *sockfdp,
FD_ZERO(&fds_write);
FD_ZERO(&fds_err);
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET((curl_socket_t)fileno(stdin), &fds_read);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
switch(*mode) {
@ -1005,7 +1012,14 @@ static bool juggle(curl_socket_t *sockfdp,
/* server mode */
sockfd = listenfd;
/* there's always a socket to wait for */
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
maxfd = (int)sockfd;
break;
@ -1019,7 +1033,14 @@ static bool juggle(curl_socket_t *sockfdp,
}
else {
/* there's always a socket to wait for */
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
maxfd = (int)sockfd;
}
break;
@ -1029,7 +1050,14 @@ static bool juggle(curl_socket_t *sockfdp,
sockfd = *sockfdp;
/* sockfd turns CURL_SOCKET_BAD when our connection has been closed */
if(CURL_SOCKET_BAD != sockfd) {
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
maxfd = (int)sockfd;
}
else {

View file

@ -717,16 +717,37 @@ static bool incoming(curl_socket_t listenfd)
FD_ZERO(&fds_err);
/* there's always a socket to wait for */
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sockfd, &fds_read);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
for(i = 0; i < 2; i++) {
if(c[i].used) {
curl_socket_t fd = c[i].clientfd;
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(fd, &fds_read);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
if((int)fd > maxfd)
maxfd = (int)fd;
fd = c[i].remotefd;
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(fd, &fds_read);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
if((int)fd > maxfd)
maxfd = (int)fd;
}

View file

@ -902,13 +902,21 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
int rc;
fd_set input;
fd_set output;
struct timeval timeout = {1, 0}; /* 1000 ms */
struct timeval timeout = {0};
timeout.tv_sec = 1; /* 1000 ms */
logmsg("Got EAGAIN from sread");
FD_ZERO(&input);
FD_ZERO(&output);
got = 0;
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(sock, &input);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
do {
logmsg("Wait until readable");
rc = select((int)sock + 1, &input, &output, NULL, &timeout);
@ -1375,10 +1383,18 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port)
error = SOCKERRNO;
if((error == EINPROGRESS) || (error == EWOULDBLOCK)) {
fd_set output;
struct timeval timeout = {1, 0}; /* 1000 ms */
struct timeval timeout = {0};
timeout.tv_sec = 1; /* 1000 ms */
FD_ZERO(&output);
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(serverfd, &output);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
while(1) {
rc = select((int)serverfd + 1, NULL, &output, NULL, &timeout);
if(rc < 0 && SOCKERRNO != EINTR)
@ -1488,9 +1504,10 @@ static void http_connect(curl_socket_t *infdp,
fd_set input;
fd_set output;
struct timeval timeout = {1, 0}; /* 1000 ms */
ssize_t rc;
curl_socket_t maxfd = (curl_socket_t)-1;
struct timeval timeout = {0};
timeout.tv_sec = 1; /* 1000 ms */
FD_ZERO(&input);
FD_ZERO(&output);
@ -1502,7 +1519,14 @@ static void http_connect(curl_socket_t *infdp,
/* listener socket is monitored to allow client to establish
secondary tunnel only when this tunnel is not established
and primary one is fully operational */
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(rootfd, &input);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
maxfd = rootfd;
}
@ -1512,14 +1536,28 @@ static void http_connect(curl_socket_t *infdp,
if(clientfd[i] != CURL_SOCKET_BAD) {
if(poll_client_rd[i]) {
/* unless told not to do so, monitor readability */
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(clientfd[i], &input);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
if(clientfd[i] > maxfd)
maxfd = clientfd[i];
}
if(poll_client_wr[i] && toc[i]) {
/* unless told not to do so, monitor writability
if there is data ready to be sent to client */
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(clientfd[i], &output);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
if(clientfd[i] > maxfd)
maxfd = clientfd[i];
}
@ -1528,14 +1566,28 @@ static void http_connect(curl_socket_t *infdp,
if(serverfd[i] != CURL_SOCKET_BAD) {
if(poll_server_rd[i]) {
/* unless told not to do so, monitor readability */
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(serverfd[i], &input);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
if(serverfd[i] > maxfd)
maxfd = serverfd[i];
}
if(poll_server_wr[i] && tos[i]) {
/* unless told not to do so, monitor writability
if there is data ready to be sent to server */
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(serverfd[i], &output);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
if(serverfd[i] > maxfd)
maxfd = serverfd[i];
}
@ -2323,9 +2375,10 @@ int main(int argc, char *argv[])
for(;;) {
fd_set input;
fd_set output;
struct timeval timeout = {0, 250000L}; /* 250 ms */
curl_socket_t maxfd = (curl_socket_t)-1;
int active;
struct timeval timeout = {0};
timeout.tv_usec = 250000L; /* 250 ms */
/* Clear out closed sockets */
for(socket_idx = num_sockets - 1; socket_idx >= 1; --socket_idx) {
@ -2347,7 +2400,14 @@ int main(int argc, char *argv[])
for(socket_idx = 0; socket_idx < num_sockets; ++socket_idx) {
/* Listen on all sockets */
#if defined(__DJGPP__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warith-conversion"
#endif
FD_SET(all_sockets[socket_idx], &input);
#if defined(__DJGPP__)
#pragma GCC diagnostic pop
#endif
if(all_sockets[socket_idx] > maxfd)
maxfd = all_sockets[socket_idx];
}

View file

@ -512,21 +512,20 @@ skipit:
static int synchnet(curl_socket_t f /* socket to flush */)
{
#if defined(HAVE_IOCTLSOCKET)
unsigned long i;
#else
int i;
#endif
int j = 0;
char rbuf[PKTSIZE];
srvr_sockaddr_union_t fromaddr;
curl_socklen_t fromaddrlen;
for(;;) {
#if defined(HAVE_IOCTLSOCKET)
#if defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO)
long i;
(void) IoctlSocket(f, FIONBIO, &i);
#elif defined(HAVE_IOCTLSOCKET)
unsigned long i;
(void) ioctlsocket(f, FIONREAD, &i);
#else
int i;
(void) ioctl(f, FIONREAD, &i);
#endif
if(i) {

View file

@ -40,6 +40,10 @@
#include <sys/poll.h>
#endif
#ifdef MSDOS
#include <dos.h> /* delay() */
#endif
#include "curlx.h" /* from the private lib dir */
#include "getpart.h"
#include "util.h"