From a039c02c6b7595bf34c801160032f4fe8bdbcf33 Mon Sep 17 00:00:00 2001 From: Wolfywolfy Date: Sat, 13 Jul 2024 11:19:34 -0300 Subject: [PATCH] Move autotools build to CMake. --- .github/workflows/ccpp.yml | 15 ++- .github/workflows/codeql.yml | 6 +- CMakeLists.txt | 25 ++++- Makefile.am | 12 --- bootstrap | 2 - cmake/config.h.cmake | 88 ++++++++++------- configure.ac | 179 ----------------------------------- examples/Makefile.am | 48 ---------- include/Makefile.am | 15 --- lib/CMakeLists.txt | 2 +- 10 files changed, 91 insertions(+), 301 deletions(-) delete mode 100644 Makefile.am delete mode 100755 bootstrap delete mode 100644 configure.ac delete mode 100644 examples/Makefile.am delete mode 100644 include/Makefile.am diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 3c9f44c0..4c826ddf 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -14,14 +14,13 @@ jobs: run: | sudo apt update sudo apt install -y libkrb5-dev - - name: configure + + - name: CMake configure run: | - ./bootstrap - ./configure - - name: make - run: make - - name: make distcheck - run: make distcheck + cmake -S . -B build + + - name: Build (Linux) + run: cmake --build build build-windows: name: Windows build @@ -30,7 +29,7 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Cmake configure + - name: CMake configure run: | cmake -G "Visual Studio 17 2022" . - name: Build (MSVC) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 60f3c663..84833809 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -32,8 +32,10 @@ jobs: languages: ${{ matrix.language }} queries: +security-and-quality - - name: Autobuild - uses: github/codeql-action/autobuild@v3 + - name: Build CMake + run: | + cmake -S . -B build + cmake --build build - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d1ccc40..e2bdbc13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ if(NOT ESP_PLATFORM) + if(CMAKE_SYSTEM_NAME MATCHES NintendoSwitch OR CMAKE_SYSTEM_NAME MATCHES Nintendo3DS OR CMAKE_SYSTEM_NAME MATCHES Dreamcast OR CMAKE_SYSTEM_NAME MATCHES NintendoGameCube OR CMAKE_SYSTEM_NAME MATCHES NintendoDS OR CMAKE_SYSTEM_NAME MATCHES NintendoWii OR CMAKE_SYSTEM_NAME MATCHES CafeOS) cmake_minimum_required(VERSION 3.13) elseif(VITA) @@ -10,11 +11,20 @@ if(NOT ESP_PLATFORM) cmake_minimum_required(VERSION 3.5) endif() - if(IOP AND BUILD_IRX) + if(NOT IOP AND BUILD_IRX) project(smb2man LANGUAGES C - VERSION 4.0.0 + VERSION 2.2.0 ) + set(VERSION 2.2.0) + set(PACKAGE "smb2man") + set(PACKAGE_BUGREPORT "ronniesahlberg@gmail.com or andregui17@outlook.com") + set(PACKAGE_NAME "smb2man") + set(PACKAGE_VERSION "${VERSION}") + set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") + set(PACKAGE_TARNAME "${PACKAGE}") + set(PACKAGE_URL "https://github.com/sahlberg/libsmb2") + elseif(PICO_BOARD) project(libsmb2 C CXX ASM) else() @@ -22,9 +32,20 @@ if(NOT ESP_PLATFORM) LANGUAGES C VERSION 4.0.0 ) + set(VERSION 4.0.0) + set(PACKAGE "libsmb2") + set(PACKAGE_BUGREPORT "ronniesahlberg@gmail.com") + set(PACKAGE_NAME "libsmb2") + set(PACKAGE_VERSION "${VERSION}") + set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") + set(PACKAGE_TARNAME "${PACKAGE}") + set(PACKAGE_URL "https://github.com/sahlberg/libsmb2") endif() + configure_file(libsmb2.pc.in libsmb2.pc @ONLY) + endif() + if(NOT PICO_BOARD OR NOT ESP_PLATFORM) set(SOVERSION 1 CACHE STRING "" FORCE) if(NOT IOP AND NOT BUILD_IRX) diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 13051ecc..00000000 --- a/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -if ENABLE_EXAMPLES - MAYBE_EXAMPLES = examples -endif - -SUBDIRS = include lib . $(MAYBE_EXAMPLES) -ACLOCAL_AMFLAGS = -I m4 - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libsmb2.pc - -EXTRA_DIST = \ - libsmb2.pc.in diff --git a/bootstrap b/bootstrap deleted file mode 100755 index 5a29d5f3..00000000 --- a/bootstrap +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -autoreconf -vif diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 491a225e..0b1c8203 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -1,99 +1,123 @@ /* config.h.cmake */ /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ARPA_INET_H +#cmakedefine HAVE_ARPA_INET_H "@HAVE_ARPA_INET_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DLFCN_H +#cmakedefine HAVE_DLFCN_H "@HAVE_DLFCN_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_FCNTL_H +#cmakedefine HAVE_FCNTL_H "@HAVE_FCNTL_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_FCNTL_H +#cmakedefine HAVE_SYS_FCNTL_H "@HAVE_SYS_FCNTL_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_GSSAPI_GSSAPI_H +#cmakedefine HAVE_GSSAPI_GSSAPI_H "@HAVE_GSSAPI_GSSAPI_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_INTTYPES_H +#cmakedefine HAVE_INTTYPES_H "@HAVE_INTTYPES_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETDB_H +#cmakedefine HAVE_NETDB_H "@HAVE_NETDB_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETINET_IN_H +#cmakedefine HAVE_NETINET_IN_H "@HAVE_NETINET_IN_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETINET_TCP_H +#cmakedefine HAVE_NETINET_TCP_H "@HAVE_NETINET_TCP_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_POLL_H +#cmakedefine HAVE_POLL_H "@HAVE_POLL_H@" /* Whether sockaddr struct has sa_len */ -#cmakedefine HAVE_SOCKADDR_LEN +#cmakedefine HAVE_SOCKADDR_LEN "@HAVE_SOCKADDR_LEN@" /* Whether we have sockaddr_Storage */ -#cmakedefine HAVE_SOCKADDR_STORAGE +#cmakedefine HAVE_SOCKADDR_STORAGE "@HAVE_SOCKADDR_STORAGE@" /* Whether we have linger */ -#cmakedefine HAVE_LINGER +#cmakedefine HAVE_LINGER "@HAVE_LINGER@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDINT_H +#cmakedefine HAVE_STDINT_H "@HAVE_STDINT_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDIO_H +#cmakedefine HAVE_STDIO_H "@HAVE_STDIO_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDLIB_H +#cmakedefine HAVE_STDLIB_H "@HAVE_STDLIB_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRINGS_H +#cmakedefine HAVE_STRINGS_H "@HAVE_STRINGS_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRING_H +#cmakedefine HAVE_STRING_H "@HAVE_STRING_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_IOCTL_H +#cmakedefine HAVE_SYS_IOCTL_H "@HAVE_SYS_IOCTL_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_POLL_H +#cmakedefine HAVE_SYS_POLL_H "@HAVE_SYS_POLL_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_SOCKET_H +#cmakedefine HAVE_SYS_SOCKET_H "@HAVE_SYS_SOCKET_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_STAT_H +#cmakedefine HAVE_SYS_STAT_H "@HAVE_SYS_STAT_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TYPES_H +#cmakedefine HAVE_SYS_TYPES_H "@HAVE_SYS_TYPES_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_UIO_H +#cmakedefine HAVE_SYS_UIO_H "@HAVE_SYS_UIO_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS__IOVEC_H +#cmakedefine HAVE_SYS__IOVEC_H "@HAVE_SYS__IOVEC_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_TIME_H +#cmakedefine HAVE_TIME_H "@HAVE_TIME_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TIME_H +#cmakedefine HAVE_SYS_TIME_H "@HAVE_SYS_TIME_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H +#cmakedefine HAVE_UNISTD_H "@HAVE_UNISTD_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_UNISTD_H +#cmakedefine HAVE_SYS_UNISTD_H "@HAVE_SYS_UNISTD_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ERRNO_H +#cmakedefine HAVE_ERRNO_H "@HAVE_ERRNO_H@" /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_ERRNO_H +#cmakedefine HAVE_SYS_ERRNO_H "@HAVE_SYS_ERRNO_H@" /* Define to 1 if all of the C90 standard headers exist (not just the ones required in a freestanding environment). This macro is provided for backward compatibility; new code need not use it. */ -#cmakedefine STDC_HEADERS \ No newline at end of file +#cmakedefine STDC_HEADERS "@STDC_HEADERS@" + +/* Name of package */ +#cmakedefine PACKAGE "@PACKAGE@" + +/* Define to the address where bug reports for this package should be sent. */ +#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" + +/* Define to the full name of this package. */ +#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@" + +/* Define to the full name and version of this package. */ +#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" + +/* Define to the one symbol short name of this package. */ +#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@" + +/* Define to the home page for this package. */ +#cmakedefine PACKAGE_URL "@PACKAGE_URL@" + +/* Define to the version of this package. */ +#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" + +/* Version number of package */ +#cmakedefine VERSION "@VERSION@" diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 3d978f9f..00000000 --- a/configure.ac +++ /dev/null @@ -1,179 +0,0 @@ -AC_INIT([libsmb2], [4.0.0], [ronniesahlberg@gmail.com]) - -AC_PREREQ([2.58]) -AC_CONFIG_HEADERS([config.h]) -AM_INIT_AUTOMAKE([-Wall foreign subdir-objects 1.11]) -AC_CANONICAL_HOST -AC_CONFIG_MACRO_DIR([m4]) - -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) - -dnl Do not add default CFLAGS in AC_PROG_CC -: ${CFLAGS=""} -AC_PROG_CC -AC_PROG_LIBTOOL - -AM_PROG_CC_C_O - -dnl We always want 64 bit file offsets -CFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64" - -AC_ARG_ENABLE([examples], - [AS_HELP_STRING([--enable-examples], - [Build example programs])]) - -AM_CONDITIONAL([ENABLE_EXAMPLES], - [test "$enable_examples" = "yes"]) - -AC_ARG_WITH([libkrb5], - [AS_HELP_STRING([--without-libkrb5], - [Do not link with libkrb5 and use builtin - NTLMSSP module for authentication instead.])]) - -AS_IF([test "x$with_libkrb5" != "xno"], [ - MAYBE_LIBKRB5="-lgssapi_krb5" - AC_DEFINE([HAVE_LIBKRB5], [1], [Whether we use gssapi_krb5 or not]) - AC_MSG_NOTICE([Build with gssapi_krb5 support]) - dnl Check for gssapi/gssapi.h - AC_CHECK_HEADERS([gssapi/gssapi.h], [], [ - AC_MSG_ERROR([You need gssapi development files to compile libsmb2.]) - ]) -], [ - MAYBE_LIBKRB5="" - AC_MSG_NOTICE([Build WITHOUT gssapi_krb5 support]) -]) - -AC_ARG_WITH([lingering_TCP_sockets], - [AS_HELP_STRING([--without-lingering-TCP-sockets], - [Do not allow TCP sockets to linger after closure.])]) - -AS_IF([test "x$with_lingering_TCP_sockets" != "xno"], [ - AC_DEFINE([CONFIGURE_OPTION_TCP_LINGER], [1], [Whether or not TCP sockets should be allowed to linger after closure]) - AC_MSG_NOTICE([Build with lingering TCP sockets]) -], [ - AC_DEFINE([CONFIGURE_OPTION_TCP_LINGER], [0], [Whether or not TCP sockets should be allowed to linger after closure]) - AC_MSG_NOTICE([Build without lingering TCP sockets]) -]) - -AC_SUBST([MAYBE_LIBKRB5]) - -AC_ARG_ENABLE([werror], - [AS_HELP_STRING([--disable-werror], - [Disables building with -Werror by default])]) - -AS_IF([test "$GCC" = "yes"], [ - WARN_CFLAGS="-Wall -Wshadow -Wno-write-strings -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wno-strict-aliasing" - AS_IF([test "$enable_werror" != "no"], [ - WARN_CFLAGS="${WARN_CFLAGS} -Werror" - ]) -]) -AC_SUBST([WARN_CFLAGS]) - -LIBSOCKET= -SYS= - -case $host in - *solaris*) - AC_CHECK_LIB([socket], [main], , [AC_MSG_ERROR([Can not find required library])]) - AC_CHECK_LIB([nsl], [main], , [AC_MSG_ERROR([Can not find required library])]) - ;; - *mingw32* | *cygwin* | *wince* | *mingwce*) - LIBSOCKET='-lws2_32' - SYS=mingw32 - ;; - *) - ;; -esac -AM_CONDITIONAL([HAVE_WIN32], [test "${SYS}" = "mingw32"]) -AC_SUBST([LIBSOCKET]) - -dnl Check for poll.h -AC_CHECK_HEADERS([poll.h]) - -dnl Check for sys/poll.h -AC_CHECK_HEADERS([sys/poll.h]) - -dnl Check for unistd.h -AC_CHECK_HEADERS([unistd.h]) - -dnl Check for sys/unistd.h -AC_CHECK_HEADERS([sys/unistd.h]) - -dnl Check for netdb.h -AC_CHECK_HEADERS([netdb.h]) - -dnl Check for sys/ioctl.h -AC_CHECK_HEADERS([sys/ioctl.h]) - -dnl Check for sys/socket.h -AC_CHECK_HEADERS([sys/socket.h]) - -dnl Check for sys/uio.h -AC_CHECK_HEADERS([sys/uio.h]) - -dnl Check for sys/_iovec.h -AC_CHECK_HEADERS([sys/_iovec.h]) - -dnl Check for netinet/tcp.h -AC_CHECK_HEADERS([netinet/tcp.h]) - -dnl Check for netinet/in.h -AC_CHECK_HEADERS([netinet/in.h]) - -dnl Check for arpa/inet.h -AC_CHECK_HEADERS([arpa/inet.h]) - -dnl Check for time.h -AC_CHECK_HEADERS([time.h]) - -dnl Check for sys/time.h -AC_CHECK_HEADERS([sys/time.h]) - -dnl Check for strings.h -AC_CHECK_HEADERS([strings.h]) - -dnl Check for fcntl.h -AC_CHECK_HEADERS([fcntl.h]) - -dnl Check for sys/fcntl.h -AC_CHECK_HEADERS([sys/fcntl.h]) - -dnl Check for errno.h -AC_CHECK_HEADERS([errno.h]) - -dnl Check for sys/errno.h -AC_CHECK_HEADERS([sys/errno.h]) - -dnl Check if sockaddr data struct includes a "sa_len" -AC_CHECK_MEMBER([struct sockaddr.sa_len], [ - AC_DEFINE([HAVE_SOCKADDR_LEN], [1], [Whether sockaddr struct has sa_len]) -], [], [ -#include -#include -]) - -dnl Check if sockaddr_storage struct includes a "ss_family" -AC_CHECK_MEMBER([struct sockaddr_storage.ss_family], [ - AC_DEFINE([HAVE_SOCKADDR_STORAGE], [1], [Whether we have sockaddr_Storage]) -], [], [ -#include -#include -]) - -dnl Check if sockaddr_storage struct includes a "l_linger" -AC_CHECK_MEMBER([struct linger.l_linger], [ - AC_DEFINE([HAVE_LINGER], [1], [Whether we have linger]) -], [], [ -#include -#include -]) - -dnl Output -AC_CONFIG_FILES([ - Makefile - examples/Makefile - include/Makefile - lib/Makefile -]) - -AC_OUTPUT([libsmb2.pc]) diff --git a/examples/Makefile.am b/examples/Makefile.am deleted file mode 100644 index 313aabb5..00000000 --- a/examples/Makefile.am +++ /dev/null @@ -1,48 +0,0 @@ -noinst_PROGRAMS = smb2-cat-async smb2-cat-sync \ - smb2-dcerpc-coder-test \ - smb2-ftruncate-sync \ - smb2-ls-async smb2-ls-sync \ - smb2-put-async \ - smb2-put-sync \ - smb2-raw-fsstat-async \ - smb2-raw-getsd-async \ - smb2-raw-stat-async \ - smb2-readlink \ - smb2-lsa-lookupsids \ - smb2-lseek-sync \ - smb2-share-enum \ - smb2-share-info \ - smb2-stat-sync \ - smb2-statvfs-sync \ - smb2-truncate-sync \ - smb2-rename-sync \ - smb2-CMD-FIND - -AM_CPPFLAGS = \ - -I$(abs_top_srcdir)/include \ - -I$(abs_top_srcdir)/include/smb2 \ - "-D_U_=__attribute__((unused))" \ - -Wall -Werror - -COMMON_LIBS = ../lib/libsmb2.la -smb2_cat_async_LDADD = $(COMMON_LIBS) -smb2_cat_sync_LDADD = $(COMMON_LIBS) -smb2_ftruncate_sync_LDADD = $(COMMON_LIBS) -smb2_dcerpc_coder_test_LDADD = $(COMMON_LIBS) -smb2_ls_async_LDADD = $(COMMON_LIBS) -smb2_ls_sync_LDADD = $(COMMON_LIBS) -smb2_put_async_LDADD = $(COMMON_LIBS) -smb2_put_sync_LDADD = $(COMMON_LIBS) -smb2_raw_fsstat_async_LDADD = $(COMMON_LIBS) -smb2_raw_getsd_async_LDADD = $(COMMON_LIBS) -smb2_raw_stat_async_LDADD = $(COMMON_LIBS) -smb2_readlink_LDADD = $(COMMON_LIBS) -smb2_lsa_lookupsids_LDADD = $(COMMON_LIBS) -smb2_lseek_sync_LDADD = $(COMMON_LIBS) -smb2_share_enum_LDADD = $(COMMON_LIBS) -smb2_share_info_LDADD = $(COMMON_LIBS) -smb2_stat_sync_LDADD = $(COMMON_LIBS) -smb2_statvfs_sync_LDADD = $(COMMON_LIBS) -smb2_truncate_sync_LDADD = $(COMMON_LIBS) -smb2_rename_sync_LDADD = $(COMMON_LIBS) -smb2_CMD_FIND_LDADD = $(COMMON_LIBS) diff --git a/include/Makefile.am b/include/Makefile.am deleted file mode 100644 index 21e74dcf..00000000 --- a/include/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -smb2dir = $(includedir)/smb2 -dist_smb2_HEADERS = \ - smb2/libsmb2.h \ - smb2/libsmb2-dcerpc.h \ - smb2/libsmb2-dcerpc-lsa.h \ - smb2/libsmb2-dcerpc-srvsvc.h \ - smb2/libsmb2-raw.h \ - smb2/smb2.h \ - smb2/smb2-errors.h - -dist_noinst_HEADERS = \ - asprintf.h \ - libsmb2-private.h \ - portable-endian.h \ - slist.h diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 00c0780b..3b7b51ac 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -105,7 +105,7 @@ elseif(ESP_PLATFORM) register_component() -elseif(BUILD_IRX AND IOP) +elseif(IOP AND BUILD_IRX) set(SOURCES ps2/smb2_fio.c ps2/smb2man.c