Skip to content

Commit

Permalink
Makefile.mk: drop in favour of autotools and cmake (MS-DOS, AmigaOS3)
Browse files Browse the repository at this point in the history
`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 curl#15537
  Closes curl#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: curl#15543 (comment)
  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 a8861b6 curl#9764

Closes curl#15543
  • Loading branch information
vszakats committed Dec 16, 2024
1 parent 607bec0 commit a3585c9
Show file tree
Hide file tree
Showing 74 changed files with 738 additions and 1,023 deletions.
1 change: 0 additions & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ build:
**/CMakeLists.txt,\
**/Makefile.am,\
**/Makefile.inc,\
**/Makefile.mk,\
**/*.m4,\
**/*.mk,\
*.m4,\
Expand Down
4 changes: 0 additions & 4 deletions .github/scripts/cmp-config.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@
'#define CURL_EXTERN_SYMBOL' => 1,
'#define CURL_OS "Linux"' => 1,
'#define CURL_OS "x86_64-pc-linux-gnu"' => 1,
'#define CURL_SA_FAMILY_T ADDRESS_FAMILY' => 1,
'#define CURL_SA_FAMILY_T sa_family_t' => 1,
'#define GETHOSTNAME_TYPE_ARG2 int' => 1,
'#define GETHOSTNAME_TYPE_ARG2 size_t' => 1,
'#define HAVE_ADDRESS_FAMILY 1' => 1,
'#define HAVE_BROTLI 1' => 1,
'#define HAVE_BROTLI_DECODE_H 1' => 1,
'#define HAVE_DECL_GETPWUID_R 0' => 1,
Expand Down Expand Up @@ -74,7 +71,6 @@
'#define HAVE_OPENSSL_SSL_H 1' => 1,
'#define HAVE_OPENSSL_X509_H 1' => 1,
'#define HAVE_QUICHE_H 1' => 1,
'#define HAVE_SA_FAMILY_T 1' => 1,
'#define HAVE_SETJMP_H 1' => 1,
'#define HAVE_SSL_ECH_SET1_ECHCONFIG 1' => 1,
'#define HAVE_SSL_SET1_ECH_CONFIG_LIST 1' => 1,
Expand Down
204 changes: 200 additions & 4 deletions .github/workflows/non-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ permissions: {}

jobs:
netbsd:
name: 'NetBSD (cmake, openssl, clang)'
name: 'NetBSD (CM, openssl, clang)'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
echo '::endgroup::'
openbsd:
name: 'OpenBSD (cmake, libressl, clang)'
name: 'OpenBSD (CM, libressl, clang)'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
echo '::endgroup::'
freebsd:
name: 'FreeBSD (${{ matrix.build }}, openssl, ${{ matrix.compiler }}, ${{ matrix.arch }})'
name: "FreeBSD (${{ matrix.build && 'CM' || 'AM' }}, openssl, ${{ matrix.compiler }}, ${{ matrix.arch }})"
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
Expand Down Expand Up @@ -194,7 +194,7 @@ jobs:
echo '::endgroup::'
omnios:
name: 'OmniOS (autotools, openssl, gcc, amd64)'
name: 'OmniOS (AM, openssl, gcc, amd64)'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand Down Expand Up @@ -224,3 +224,199 @@ jobs:
echo '::group::build examples'
gmake -j3 examples
echo '::endgroup::'
amiga:
name: "AmigaOS (${{ matrix.build == 'cmake' && 'CM' || 'AM' }}, AmiSSL, gcc, m68k)"
runs-on: 'ubuntu-24.04'
timeout-minutes: 30
env:
amissl-version: 5.18
strategy:
matrix:
build: [autotools, cmake]
fail-fast: false
steps:
- name: 'install compiler'
if: ${{ steps.cache-compiler.outputs.cache-hit != 'true' }}
run: |
cd "${HOME}" || exit 1
curl --disable --fail --silent --show-error --connect-timeout 15 --max-time 120 --retry 3 \
--location https://github.com/bebbo/amiga-gcc/releases/download/Mechen/amiga-gcc.tgz | tar -xz
cd opt/appveyor || exit 1
curl --disable --fail --silent --show-error --connect-timeout 15 --max-time 60 --retry 3 \
--location https://github.com/jens-maus/amissl/releases/download/${{ env.amissl-version }}/AmiSSL-${{ env.amissl-version }}-SDK.lha --output bin.lha
7z x -bd -y bin.lha
rm -f bin.lha
mv "$HOME/opt/appveyor" /opt
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: 'configure'
run: |
if [ '${{ matrix.build }}' = 'cmake' ]; then
cmake -B bld \
-DAMIGA=1 \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_SYSTEM_PROCESSOR=m68k \
-DCMAKE_C_COMPILER_TARGET=m68k-unknown-amigaos \
-DCMAKE_C_COMPILER=/opt/appveyor/build-agent/opt/amiga/bin/m68k-amigaos-gcc \
-DCMAKE_C_FLAGS='-O0 -msoft-float -mcrt=clib2' \
-DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
-DCURL_WERROR=ON \
-DCURL_USE_LIBPSL=OFF \
-DAMISSL_INCLUDE_DIR=/opt/appveyor/AmiSSL/Developer/include \
-DAMISSL_STUBS_LIBRARY=/opt/appveyor/AmiSSL/Developer/lib/AmigaOS3/libamisslstubs.a \
-DAMISSL_AUTO_LIBRARY=/opt/appveyor/AmiSSL/Developer/lib/AmigaOS3/libamisslauto.a
else
autoreconf -fi
mkdir bld && cd bld && ../configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
CC=/opt/appveyor/build-agent/opt/amiga/bin/m68k-amigaos-gcc \
AR=/opt/appveyor/build-agent/opt/amiga/bin/m68k-amigaos-ar \
RANLIB=/opt/appveyor/build-agent/opt/amiga/bin/m68k-amigaos-ranlib \
--host=m68k-amigaos \
--disable-shared \
--without-libpsl \
--with-amissl \
LDFLAGS=-L/opt/appveyor/AmiSSL/Developer/lib/AmigaOS3 \
CPPFLAGS=-I/opt/appveyor/AmiSSL/Developer/include \
CFLAGS='-O0 -msoft-float -mcrt=clib2' \
LIBS='-lnet -lm -latomic'
fi
- name: 'configure log'
if: ${{ !cancelled() }}
run: cat bld/config.log bld/CMakeFiles/CMake*.yaml 2>/dev/null || true

- name: 'curl_config.h'
run: |
echo '::group::raw'; cat bld/lib/curl_config.h || true; echo '::endgroup::'
grep -F '#define' bld/lib/curl_config.h | sort || true
- name: 'build'
run: |
if [ '${{ matrix.build }}' = 'cmake' ]; then
cmake --build bld --parallel 5
else
make -j5 -C bld
fi
- name: 'build tests'
if: ${{ matrix.build == 'cmake' }} # skip for autotools to save time
run: |
if [ '${{ matrix.build }}' = 'cmake' ]; then
cmake --build bld --parallel 5 --target testdeps
else
make -j5 -C bld -C tests
fi
- name: 'build examples'
if: ${{ matrix.build == 'cmake' }} # skip for autotools to save time
run: |
if [ '${{ matrix.build }}' = 'cmake' ]; then
cmake --build bld --parallel 5 --target curl-examples
else
make -j5 -C bld examples
fi
msdos:
name: "MS-DOS (${{ matrix.build == 'cmake' && 'CM' || 'AM' }}, openssl, djgpp, i586)"
runs-on: 'ubuntu-24.04'
timeout-minutes: 30
env:
toolchain-version: '3.4'
strategy:
matrix:
build: [autotools, cmake]
fail-fast: false
steps:
- name: 'install packages'
run: sudo apt-get --quiet 2 --option Dpkg::Use-Pty=0 install libfl2 ${{ matrix.build == 'cmake' && 'ninja-build' || '' }}

- name: 'cache compiler (djgpp)'
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
id: cache-compiler
with:
path: ~/djgpp
key: ${{ runner.os }}-djgpp-${{ env.toolchain-version }}-amd64

- name: 'install compiler (djgpp)'
if: ${{ steps.cache-compiler.outputs.cache-hit != 'true' }}
run: |
cd "${HOME}" || exit 1
curl --disable --fail --silent --show-error --connect-timeout 15 --max-time 120 --retry 3 \
--location 'https://github.com/andrewwutw/build-djgpp/releases/download/v${{ env.toolchain-version }}/djgpp-linux64-gcc1220.tar.bz2' | tar -xj
cd djgpp || exit 1
for f in wat3211b.zip zlb13b.zip ssl102ub.zip; do
curl --disable --fail --silent --show-error --connect-timeout 15 --max-time 60 --retry 3 \
"https://www.delorie.com/pub/djgpp/current/v2tk/$f" --output bin.zip
unzip -q bin.zip
rm -f bin.zip
done
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: 'configure'
run: |
if [ '${{ matrix.build }}' = 'cmake' ]; then
cmake -B bld -G Ninja \
-DCMAKE_SYSTEM_NAME=DOS \
-DCMAKE_SYSTEM_PROCESSOR=x86 \
-DCMAKE_C_COMPILER_TARGET=i586-pc-msdosdjgpp \
-DCMAKE_C_COMPILER=$HOME/djgpp/bin/i586-pc-msdosdjgpp-gcc \
-DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
-DCURL_WERROR=ON \
-DCURL_USE_LIBPSL=OFF \
-DOPENSSL_INCLUDE_DIR=$HOME/djgpp/include \
-DOPENSSL_SSL_LIBRARY=$HOME/djgpp/lib/libssl.a \
-DOPENSSL_CRYPTO_LIBRARY=$HOME/djgpp/lib/libcrypto.a \
-DZLIB_INCLUDE_DIR=$HOME/djgpp/include" \
-DZLIB_LIBRARY=$HOME/djgpp/lib/libz.a" \
-DWATT_ROOT=$HOME/djgpp/net/watt
else
autoreconf -fi
mkdir bld && cd bld && ../configure --disable-dependency-tracking --enable-unity --enable-test-bundles --enable-warnings --enable-werror \
CC=$HOME/djgpp/bin/i586-pc-msdosdjgpp-gcc \
AR=$HOME/djgpp/bin/i586-pc-msdosdjgpp-ar \
RANLIB=$HOME/djgpp/bin/i586-pc-msdosdjgpp-ranlib \
WATT_ROOT=$HOME/djgpp/net/watt \
--host=i586-pc-msdosdjgpp \
--with-openssl=$HOME/djgpp \
--with-zlib=$HOME/djgpp \
--without-libpsl \
--disable-shared
fi
- name: 'configure log'
if: ${{ !cancelled() }}
run: cat bld/config.log bld/CMakeFiles/CMake*.yaml 2>/dev/null || true

- name: 'curl_config.h'
run: |
echo '::group::raw'; cat bld/lib/curl_config.h || true; echo '::endgroup::'
grep -F '#define' bld/lib/curl_config.h | sort || true
- name: 'build'
run: |
if [ '${{ matrix.build }}' = 'cmake' ]; then
cmake --build bld
else
make -j5 -C bld
fi
- name: 'build tests'
if: ${{ matrix.build == 'cmake' }} # skip for autotools to save time
run: |
if [ '${{ matrix.build }}' = 'cmake' ]; then
cmake --build bld --target testdeps
else
make -j5 -C bld -C tests
fi
- name: 'build examples'
if: ${{ matrix.build == 'cmake' }} # skip for autotools to save time
run: |
if [ '${{ matrix.build }}' = 'cmake' ]; then
cmake --build bld --target curl-examples
else
make -j5 -C bld examples
fi
2 changes: 2 additions & 0 deletions CMake/CurlSymbolHiding.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ if(WIN32 AND (ENABLE_DEBUG OR ENABLE_CURLDEBUG))
# e.g. curl_easy_perform_ev() or curl_dbg_*(),
# so disable symbol hiding for debug builds and for memory tracking.
set(CURL_HIDDEN_SYMBOLS OFF)
elseif(DOS OR AMIGA)
set(CURL_HIDDEN_SYMBOLS OFF)
endif()

set(CURL_HIDES_PRIVATE_SYMBOLS FALSE)
Expand Down
9 changes: 4 additions & 5 deletions CMake/CurlTests.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ int main(void)

#ifdef HAVE_IOCTLSOCKET_CAMEL
/* includes start */
#ifdef _WIN32
# include <winsock2.h>
#endif
#include <proto/bsdsocket.h>
int main(void)
{
/* IoctlSocket source code */
Expand All @@ -196,8 +194,9 @@ int main(void)

#ifdef HAVE_IOCTLSOCKET_CAMEL_FIONBIO
/* includes start */
#ifdef _WIN32
# include <winsock2.h>
#include <proto/bsdsocket.h>
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
int main(void)
{
Expand Down
2 changes: 1 addition & 1 deletion CMake/FindGSS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ if(NOT _GSS_FOUND) # Not found by pkg-config. Let us take more traditional appr

if(_GSS_INCLUDE_DIRS) # jay, we have found something
cmake_push_check_state()
set(CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIRS}")
list(APPEND CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIRS}")
check_include_files("gssapi/gssapi_generic.h;gssapi/gssapi_krb5.h" _gss_have_mit_headers)

if(_gss_have_mit_headers)
Expand Down
2 changes: 1 addition & 1 deletion CMake/OtherTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if(NOT DEFINED HAVE_STRUCT_SOCKADDR_STORAGE)
set(CMAKE_EXTRA_INCLUDE_FILES "")
if(WIN32)
set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h")
set(CMAKE_REQUIRED_LIBRARIES "ws2_32")
list(APPEND CMAKE_REQUIRED_LIBRARIES "ws2_32")
elseif(HAVE_SYS_SOCKET_H)
set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h")
endif()
Expand Down
1 change: 1 addition & 0 deletions CMake/PickyWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set(_picky "")

if(CURL_WERROR AND
((CMAKE_COMPILER_IS_GNUCC AND
NOT DOS AND # Watt-32 headers use the '#include_next' GCC extension
NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0 AND
NOT CMAKE_VERSION VERSION_LESS 3.23.0) OR # to avoid check_symbol_exists() conflicting with GCC -pedantic-errors
CMAKE_C_COMPILER_ID MATCHES "Clang"))
Expand Down
Loading

0 comments on commit a3585c9

Please sign in to comment.