Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 128 commits into from

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Nov 10, 2024

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 Cross Compiling for Amiga OS - Error implicit declaration of function 'ioctl' #15537
    Closes Crosscompile for AmigaOS3 - Changes to Configure.ac and Nonblock.c #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: Makefile.mk: drop in favour of autotools and cmake (MS-DOS, AmigaOS3) #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 #9764


  • split into multiple PRs or commits? [MERGE AS-IS]

w/o whitespace: https://github.com/curl/curl/pull/15543/files?w=1

@vszakats vszakats added the build label Nov 10, 2024
@github-actions github-actions bot added cmdline tool CI Continuous Integration labels Nov 10, 2024
@vszakats
Copy link
Member Author

vszakats commented Nov 10, 2024

Successfully cross-built for MS-DOS with:

DJGPP=/path/to/djgpp
./configure \
  CC="$DJGPP/bin/i586-pc-msdosdjgpp-gcc" \
  AR="$DJGPP/bin/i586-pc-msdosdjgpp-ar" \
  RANLIB="$DJGPP/bin/i586-pc-msdosdjgpp-ranlib" \
  WATT_ROOT="$DJGPP/net/watt" \
  --host=i586-pc-msdosdjgpp \
  --with-openssl="$DJGPP" \
  --with-zlib="$DJGPP" \
  --without-libpsl \
  --disable-shared

cmake . \
  -DCMAKE_SYSTEM_NAME=DOS \
  -DCMAKE_SYSTEM_PROCESSOR=x86 \
  -DCMAKE_C_COMPILER_TARGET=i586-pc-msdosdjgpp \
  -DCMAKE_C_COMPILER="$DJGPP/bin/i586-pc-msdosdjgpp-gcc" \
  -DWATT_ROOT="$DJGPP/net/watt" \
  -DOPENSSL_INCLUDE_DIR="$DJGPP/include" \
  -DOPENSSL_SSL_LIBRARY="$DJGPP/lib/libssl.a" \
  -DOPENSSL_CRYPTO_LIBRARY="$DJGPP/lib/libcrypto.a" \
  -DZLIB_INCLUDE_DIR="$DJGPP/include" \
  -DZLIB_LIBRARY="$DJGPP/lib/libz.a" \
  -DCURL_USE_LIBPSL=OFF
curl 8.11.1-DEV (i586-pc-msdosdjgpp) libcurl/8.11.1-DEV OpenSSL/1.0.2u zlib/1.2.12
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc HSTS HTTPS-proxy libz NTLM SSL threadsafe UnixSockets

build templates for Amiga:

# https://github.com/bebbo/amiga-gcc/releases/download/Mechen/amiga-gcc.tgz
# https://github.com/jens-maus/amissl/releases/download/5.18/AmiSSL-5.18-SDK.lha
AMISSL='/path/to/AmiSSL/Developer'
./configure \
  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 \
  --with-amissl \
  CFLAGS='-O0 -msoft-float -mcrt=clib2' \
  CPPFLAGS="-I$AMISSL/include" \
  LDFLAGS="-L$AMISSL/lib/AmigaOS3" \
  LIBS='-lnet -lm -latomic' \
  --without-libpsl \
  --disable-shared

cmake . \
  -DAMIGA=1 \
  -DCMAKE_SYSTEM_NAME=Generic \
  -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' \
  -DAMISSL_INCLUDE_DIR="$AMISSL/include" \
  -DAMISSL_STUBS_LIBRARY="$AMISSL/lib/AmigaOS3/libamisslstubs.a" \
  -DAMISSL_AUTO_LIBRARY="$AMISSL/lib/AmigaOS3/libamisslauto.a" \
  -DCURL_USE_LIBPSL=OFF

based on #15603

Officially there is no CMake support for DJGPP, but it works with some tweaks.
No support for Amiga OS at all, but could be made work.
Probably could be made to work with AmigaOS as well, but without cross-tool
binaries for my platforms, it's something for another time.

@vszakats
Copy link
Member Author

vszakats commented Nov 15, 2024

I'm wondering if it'd make sense to delete lib/config-dos.h and lib/config-amigaos.h with this? They are no longer used within the repo. Or maybe convert them to configure caches?

edit: converting them to a cmake or autotools cache is certainly possible, but the maintenance cost is high.

@vszakats vszakats changed the title Makefile.mk: delete in favour of autotools Makefile.mk: delete in favour of autotools and cmake Nov 15, 2024
@vszakats vszakats force-pushed the mk-delete branch 2 times, most recently from 0a532ec to 85694c5 Compare November 15, 2024 23:15
@vszakats vszakats added cmake tidy-up and removed cmdline tool CI Continuous Integration labels Nov 15, 2024
@github-actions github-actions bot added cmdline tool CI Continuous Integration labels Nov 16, 2024
@github-actions github-actions bot added the tests label Nov 16, 2024
@vszakats vszakats force-pushed the mk-delete branch 2 times, most recently from 6fe0d32 to 732e98f Compare November 16, 2024 20:20
@bagder
Copy link
Member

bagder commented Nov 16, 2024

I'm wondering if it'd make sense to delete lib/config-dos.h and lib/config-amigaos.h with this? They are no longer used within the repo. Or maybe convert them to configure caches?

edit: converting them to a cmake or autotools cache is certainly possible, but the maintenance cost is high.

I think trying to do them as caches is just overkill and not something we do for any other platforms either. configure/cmake should be able to generate the correct setup on their own. IMHO, those two "hard coded" config files should be removed if we think configure/cmake can do the job.

@vszakats
Copy link
Member Author

Arrived to the same conclusion, it's overkill.

With MS-DOS + CMake the toolchain env is detected fine now (also matching previous manual values). Dependency detection is probably broken due to CMake insisting on the .lib suffix, but feeding the libs manually via -DNAME_LIBRARY=/path/to/libname.a should work it around.

@vszakats vszakats force-pushed the mk-delete branch 8 times, most recently from fc2a411 to 09796ce Compare November 18, 2024 13:02
Fixes detection for AmigaOS, where `gethostname` is a macro.
It is mapped to OpenSSL and some CA fallback enabled to
do what autotools does.
propagate `USE_AMISSL` via `curl_config.h` like autotools
```
In file included from /home/runner/work/curl/curl/bld/tests/libtest/libtest_bundle.c:27663:0,
                 from /home/runner/work/curl/curl/bld/tests/libtest/CMakeFiles/libtests.dir/Unity/unity_0_c.c:4:
/home/runner/work/curl/curl/tests/libtest/lib1960.c: In function 'test_lib1960':
/home/runner/work/curl/curl/tests/libtest/lib1960.c:104:6: error: pointer targets in initialization differ in signedness [-Wpointer-sign]
   if(inet_pton(AF_INET, libtest_arg2, &serv_addr.sin_addr) <= 0) {
      ^~~~~~~~~
```
https://github.com/curl/curl/actions/runs/11913123282/job/33198164993#step:8:96
It's a simple cross-build, not "non-native", just like AmigaOS.
This reverts commit c59917ecf441a69ea3496f2cb8f26e2f3cf91476.

I'm not sure if we want this chore.
@vszakats vszakats closed this in a3585c9 Dec 16, 2024
@vszakats vszakats deleted the mk-delete branch December 16, 2024 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build CI Continuous Integration cmake cmdline tool feature-window A merge of this requires an open feature window tests tidy-up
Development

Successfully merging this pull request may close these issues.

Cross Compiling for Amiga OS - Error implicit declaration of function 'ioctl'
4 participants