`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
358 lines
12 KiB
CMake
358 lines
12 KiB
CMake
#***************************************************************************
|
|
# _ _ ____ _
|
|
# 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
|
|
#
|
|
###########################################################################
|
|
# Find the GSS Kerberos library
|
|
#
|
|
# Input variables:
|
|
#
|
|
# - `GSS_ROOT_DIR`: Set this variable to the root installation of GSS. (also supported as environment)
|
|
#
|
|
# Result variables:
|
|
#
|
|
# - `GSS_FOUND`: System has the Heimdal library.
|
|
# - `GSS_FLAVOUR`: "GNU", "MIT" or "Heimdal" if anything found.
|
|
# - `GSS_INCLUDE_DIRS`: The GSS include directories.
|
|
# - `GSS_LIBRARIES`: The GSS library names.
|
|
# - `GSS_LIBRARY_DIRS`: The GSS library directories.
|
|
# - `GSS_PC_REQUIRES`: The GSS pkg-config packages.
|
|
# - `GSS_CFLAGS`: Required compiler flags.
|
|
# - `GSS_VERSION`: This is set to version advertised by pkg-config or read from manifest.
|
|
# In case the library is found but no version info available it is set to "unknown"
|
|
|
|
set(_gnu_modname "gss")
|
|
set(_mit_modname "mit-krb5-gssapi")
|
|
set(_heimdal_modname "heimdal-gssapi")
|
|
|
|
include(CheckIncludeFile)
|
|
include(CheckIncludeFiles)
|
|
include(CheckTypeSize)
|
|
|
|
set(_gss_root_hints
|
|
"${GSS_ROOT_DIR}"
|
|
"$ENV{GSS_ROOT_DIR}"
|
|
)
|
|
|
|
# Try to find library using system pkg-config if user did not specify root dir
|
|
if(NOT GSS_ROOT_DIR AND NOT "$ENV{GSS_ROOT_DIR}")
|
|
if(CURL_USE_PKGCONFIG)
|
|
find_package(PkgConfig QUIET)
|
|
pkg_search_module(_GSS ${_gnu_modname} ${_mit_modname} ${_heimdal_modname})
|
|
list(APPEND _gss_root_hints "${_GSS_PREFIX}")
|
|
endif()
|
|
if(WIN32)
|
|
list(APPEND _gss_root_hints "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos;InstallDir]")
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT _GSS_FOUND) # Not found by pkg-config. Let us take more traditional approach.
|
|
find_file(_gss_configure_script
|
|
NAMES
|
|
"krb5-config"
|
|
HINTS
|
|
${_gss_root_hints}
|
|
PATH_SUFFIXES
|
|
"bin"
|
|
NO_CMAKE_PATH
|
|
NO_CMAKE_ENVIRONMENT_PATH
|
|
)
|
|
|
|
# If not found in user-supplied directories, maybe system knows better
|
|
find_file(_gss_configure_script
|
|
NAMES
|
|
"krb5-config"
|
|
PATH_SUFFIXES
|
|
"bin"
|
|
)
|
|
|
|
if(_gss_configure_script)
|
|
execute_process(
|
|
COMMAND ${_gss_configure_script} "--cflags" "gssapi"
|
|
OUTPUT_VARIABLE _GSS_CFLAGS
|
|
RESULT_VARIABLE _gss_configure_failed
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
message(STATUS "FindGSS krb5-config --cflags: ${_GSS_CFLAGS}")
|
|
if(NOT _gss_configure_failed) # 0 means success
|
|
# Should also work in an odd case when multiple directories are given
|
|
string(STRIP "${_GSS_CFLAGS}" _GSS_CFLAGS)
|
|
string(REGEX REPLACE " +-I" ";" _GSS_CFLAGS "${_GSS_CFLAGS}")
|
|
string(REGEX REPLACE " +-([^I][^ \\t;]*)" ";-\\1" _GSS_CFLAGS "${_GSS_CFLAGS}")
|
|
|
|
foreach(_flag IN LISTS _GSS_CFLAGS)
|
|
if(_flag MATCHES "^-I.*")
|
|
string(REGEX REPLACE "^-I" "" _val "${_flag}")
|
|
list(APPEND _GSS_INCLUDE_DIRS "${_val}")
|
|
else()
|
|
list(APPEND _GSS_CFLAGS "${_flag}")
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
|
|
execute_process(
|
|
COMMAND ${_gss_configure_script} "--libs" "gssapi"
|
|
OUTPUT_VARIABLE _gss_lib_flags
|
|
RESULT_VARIABLE _gss_configure_failed
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
message(STATUS "FindGSS krb5-config --libs: ${_gss_lib_flags}")
|
|
|
|
if(NOT _gss_configure_failed) # 0 means success
|
|
# This script gives us libraries and link directories. Blah. We have to deal with it.
|
|
string(STRIP "${_gss_lib_flags}" _gss_lib_flags)
|
|
string(REGEX REPLACE " +-(L|l)" ";-\\1" _gss_lib_flags "${_gss_lib_flags}")
|
|
string(REGEX REPLACE " +-([^Ll][^ \\t;]*)" ";-\\1" _gss_lib_flags "${_gss_lib_flags}")
|
|
|
|
foreach(_flag IN LISTS _gss_lib_flags)
|
|
if(_flag MATCHES "^-l.*")
|
|
string(REGEX REPLACE "^-l" "" _val "${_flag}")
|
|
list(APPEND _GSS_LIBRARIES "${_val}")
|
|
elseif(_flag MATCHES "^-L.*")
|
|
string(REGEX REPLACE "^-L" "" _val "${_flag}")
|
|
list(APPEND _GSS_LIBRARY_DIRS "${_val}")
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
|
|
execute_process(
|
|
COMMAND ${_gss_configure_script} "--version"
|
|
OUTPUT_VARIABLE _GSS_VERSION
|
|
RESULT_VARIABLE _gss_configure_failed
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
# Older versions may not have the "--version" parameter. In this case we just do not care.
|
|
if(_gss_configure_failed)
|
|
set(_GSS_VERSION 0)
|
|
endif()
|
|
|
|
execute_process(
|
|
COMMAND ${_gss_configure_script} "--vendor"
|
|
OUTPUT_VARIABLE _gss_vendor
|
|
RESULT_VARIABLE _gss_configure_failed
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
# Older versions may not have the "--vendor" parameter. In this case we just do not care.
|
|
if(_gss_configure_failed)
|
|
set(GSS_FLAVOUR "Heimdal") # most probably, should not really matter
|
|
else()
|
|
if(_gss_vendor MATCHES ".*H|heimdal.*")
|
|
set(GSS_FLAVOUR "Heimdal")
|
|
else()
|
|
set(GSS_FLAVOUR "MIT")
|
|
endif()
|
|
endif()
|
|
|
|
else() # Either there is no config script or we are on a platform that does not provide one (Windows?)
|
|
|
|
find_path(_GSS_INCLUDE_DIRS NAMES "gssapi/gssapi.h"
|
|
HINTS
|
|
${_gss_root_hints}
|
|
PATH_SUFFIXES
|
|
"include"
|
|
"inc"
|
|
)
|
|
|
|
if(_GSS_INCLUDE_DIRS) # jay, we have found something
|
|
cmake_push_check_state()
|
|
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)
|
|
set(GSS_FLAVOUR "MIT")
|
|
else()
|
|
# Prevent compiling the header - just check if we can include it
|
|
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D__ROKEN_H__")
|
|
check_include_file("roken.h" _gss_have_roken_h)
|
|
|
|
check_include_file("heimdal/roken.h" _gss_have_heimdal_roken_h)
|
|
if(_gss_have_roken_h OR _gss_have_heimdal_roken_h)
|
|
set(GSS_FLAVOUR "Heimdal")
|
|
endif()
|
|
endif()
|
|
cmake_pop_check_state()
|
|
else()
|
|
# I am not convinced if this is the right way but this is what autotools do at the moment
|
|
find_path(_GSS_INCLUDE_DIRS NAMES "gssapi.h"
|
|
HINTS
|
|
${_gss_root_hints}
|
|
PATH_SUFFIXES
|
|
"include"
|
|
"inc"
|
|
)
|
|
|
|
if(_GSS_INCLUDE_DIRS)
|
|
set(GSS_FLAVOUR "Heimdal")
|
|
else()
|
|
find_path(_GSS_INCLUDE_DIRS NAMES "gss.h"
|
|
HINTS
|
|
${_gss_root_hints}
|
|
PATH_SUFFIXES
|
|
"include"
|
|
)
|
|
|
|
if(_GSS_INCLUDE_DIRS)
|
|
set(GSS_FLAVOUR "GNU")
|
|
set(GSS_PC_REQUIRES "gss")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
# If we have headers, check if we can link libraries
|
|
if(GSS_FLAVOUR)
|
|
set(_gss_libdir_suffixes "")
|
|
set(_gss_libdir_hints ${_gss_root_hints})
|
|
get_filename_component(_gss_calculated_potential_root "${_GSS_INCLUDE_DIRS}" DIRECTORY)
|
|
list(APPEND _gss_libdir_hints ${_gss_calculated_potential_root})
|
|
|
|
if(WIN32)
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
list(APPEND _gss_libdir_suffixes "lib/AMD64")
|
|
if(GSS_FLAVOUR STREQUAL "GNU")
|
|
set(_gss_libname "gss")
|
|
elseif(GSS_FLAVOUR STREQUAL "MIT")
|
|
set(_gss_libname "gssapi64")
|
|
else()
|
|
set(_gss_libname "libgssapi")
|
|
endif()
|
|
else()
|
|
list(APPEND _gss_libdir_suffixes "lib/i386")
|
|
if(GSS_FLAVOUR STREQUAL "GNU")
|
|
set(_gss_libname "gss")
|
|
elseif(GSS_FLAVOUR STREQUAL "MIT")
|
|
set(_gss_libname "gssapi32")
|
|
else()
|
|
set(_gss_libname "libgssapi")
|
|
endif()
|
|
endif()
|
|
else()
|
|
list(APPEND _gss_libdir_suffixes "lib;lib64") # those suffixes are not checked for HINTS
|
|
if(GSS_FLAVOUR STREQUAL "GNU")
|
|
set(_gss_libname "gss")
|
|
elseif(GSS_FLAVOUR STREQUAL "MIT")
|
|
set(_gss_libname "gssapi_krb5")
|
|
else()
|
|
set(_gss_libname "gssapi")
|
|
endif()
|
|
endif()
|
|
|
|
find_library(_GSS_LIBRARIES NAMES ${_gss_libname}
|
|
HINTS
|
|
${_gss_libdir_hints}
|
|
PATH_SUFFIXES
|
|
${_gss_libdir_suffixes}
|
|
)
|
|
endif()
|
|
endif()
|
|
else()
|
|
# _GSS_MODULE_NAME set since CMake 3.16
|
|
if(_GSS_MODULE_NAME STREQUAL _gnu_modname OR _GSS_${_gnu_modname}_VERSION)
|
|
set(GSS_FLAVOUR "GNU")
|
|
set(GSS_PC_REQUIRES "gss")
|
|
if(NOT _GSS_VERSION) # for old CMake versions?
|
|
set(_GSS_VERSION ${_GSS_${_gnu_modname}_VERSION})
|
|
endif()
|
|
elseif(_GSS_MODULE_NAME STREQUAL _mit_modname OR _GSS_${_mit_modname}_VERSION)
|
|
set(GSS_FLAVOUR "MIT")
|
|
set(GSS_PC_REQUIRES "mit-krb5-gssapi")
|
|
if(NOT _GSS_VERSION) # for old CMake versions?
|
|
set(_GSS_VERSION ${_GSS_${_mit_modname}_VERSION})
|
|
endif()
|
|
else()
|
|
set(GSS_FLAVOUR "Heimdal")
|
|
set(GSS_PC_REQUIRES "heimdal-gssapi")
|
|
if(NOT _GSS_VERSION) # for old CMake versions?
|
|
set(_GSS_VERSION ${_GSS_${_heimdal_modname}_VERSION})
|
|
endif()
|
|
endif()
|
|
message(STATUS "Found GSS/${GSS_FLAVOUR} (via pkg-config): ${_GSS_INCLUDE_DIRS} (found version \"${_GSS_VERSION}\")")
|
|
endif()
|
|
|
|
string(REPLACE ";" " " _GSS_CFLAGS "${_GSS_CFLAGS}")
|
|
|
|
set(GSS_INCLUDE_DIRS ${_GSS_INCLUDE_DIRS})
|
|
set(GSS_LIBRARIES ${_GSS_LIBRARIES})
|
|
set(GSS_LIBRARY_DIRS ${_GSS_LIBRARY_DIRS})
|
|
set(GSS_CFLAGS ${_GSS_CFLAGS})
|
|
set(GSS_VERSION ${_GSS_VERSION})
|
|
|
|
if(GSS_FLAVOUR)
|
|
if(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "Heimdal")
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
set(_heimdal_manifest_file "Heimdal.Application.amd64.manifest")
|
|
else()
|
|
set(_heimdal_manifest_file "Heimdal.Application.x86.manifest")
|
|
endif()
|
|
|
|
if(EXISTS "${GSS_INCLUDE_DIRS}/${_heimdal_manifest_file}")
|
|
file(STRINGS "${GSS_INCLUDE_DIRS}/${_heimdal_manifest_file}" _heimdal_version_str
|
|
REGEX "^.*version=\"[0-9]\\.[^\"]+\".*$")
|
|
|
|
string(REGEX MATCH "[0-9]\\.[^\"]+" GSS_VERSION "${_heimdal_version_str}")
|
|
endif()
|
|
|
|
if(NOT GSS_VERSION)
|
|
set(GSS_VERSION "Heimdal Unknown")
|
|
endif()
|
|
elseif(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "MIT")
|
|
get_filename_component(_mit_version "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos\\SDK\\CurrentVersion;VersionString]" NAME
|
|
CACHE)
|
|
if(WIN32 AND _mit_version)
|
|
set(GSS_VERSION "${_mit_version}")
|
|
else()
|
|
set(GSS_VERSION "MIT Unknown")
|
|
endif()
|
|
elseif(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "GNU")
|
|
if(GSS_INCLUDE_DIRS AND EXISTS "${GSS_INCLUDE_DIRS}/gss.h")
|
|
set(_version_regex "#[\t ]*define[\t ]+GSS_VERSION[\t ]+\"([^\"]*)\"")
|
|
file(STRINGS "${GSS_INCLUDE_DIRS}/gss.h" _version_str REGEX "${_version_regex}")
|
|
string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
|
|
set(GSS_VERSION "${_version_str}")
|
|
unset(_version_regex)
|
|
unset(_version_str)
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(GSS
|
|
REQUIRED_VARS
|
|
GSS_FLAVOUR
|
|
GSS_LIBRARIES
|
|
VERSION_VAR
|
|
GSS_VERSION
|
|
FAIL_MESSAGE
|
|
"Could NOT find GSS, try to set the path to GSS root folder in the system variable GSS_ROOT_DIR"
|
|
)
|
|
|
|
mark_as_advanced(
|
|
_GSS_CFLAGS
|
|
_GSS_FOUND
|
|
_GSS_INCLUDE_DIRS
|
|
_GSS_LIBRARIES
|
|
_GSS_LIBRARY_DIRS
|
|
_GSS_MODULE_NAME
|
|
_GSS_PREFIX
|
|
_GSS_VERSION
|
|
)
|