diff --git a/.github/workflows/build-centos8.yml b/.github/workflows/build-centos8.yml index 3bb9ebb3..2cd246f3 100644 --- a/.github/workflows/build-centos8.yml +++ b/.github/workflows/build-centos8.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Set up Git repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: recursive - name: Build LTFS diff --git a/.github/workflows/build-debian11.yml b/.github/workflows/build-debian11.yml index 3c0f35e7..bfc663b0 100644 --- a/.github/workflows/build-debian11.yml +++ b/.github/workflows/build-debian11.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Set up Git repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: recursive - name: Build LTFS diff --git a/.github/workflows/build-debian12.yml b/.github/workflows/build-debian12.yml index 395cdf81..db1a76d8 100644 --- a/.github/workflows/build-debian12.yml +++ b/.github/workflows/build-debian12.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Set up Git repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: recursive - name: Build LTFS diff --git a/.github/workflows/build-fedora28.yml b/.github/workflows/build-fedora28.yml index 8a3bf106..7b37bb96 100644 --- a/.github/workflows/build-fedora28.yml +++ b/.github/workflows/build-fedora28.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Set up Git repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: recursive - name: Build LTFS diff --git a/.github/workflows/build-ubuntu-bionic.yml b/.github/workflows/build-ubuntu-bionic.yml index 53d6a063..2909c508 100644 --- a/.github/workflows/build-ubuntu-bionic.yml +++ b/.github/workflows/build-ubuntu-bionic.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Set up Git repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: recursive - name: Build LTFS diff --git a/.github/workflows/build-ubuntu-focal.yml b/.github/workflows/build-ubuntu-focal.yml index 30a3ce8c..7c23a54d 100644 --- a/.github/workflows/build-ubuntu-focal.yml +++ b/.github/workflows/build-ubuntu-focal.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Set up Git repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: recursive - name: Build LTFS diff --git a/.github/workflows/build-ubuntu-xeneal.yml b/.github/workflows/build-ubuntu-xeneal.yml index d68432ee..c3d4f1d9 100644 --- a/.github/workflows/build-ubuntu-xeneal.yml +++ b/.github/workflows/build-ubuntu-xeneal.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Set up Git repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: recursive - name: Build LTFS diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 00000000..0c913128 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,30 @@ +name: CMake Build + +on: [push, pull_request] + +jobs: + build: + name: Build and test with CMake + runs-on: ubuntu-latest + + steps: + - name: Set up Git repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install dependencies + run: | + sudo apt-get -q update + sudo apt-get -q -y install --no-install-recommends \ + build-essential cmake pkg-config \ + icu-devtools libicu-dev libxml2-dev uuid-dev libsnmp-dev \ + libfuse-dev attr + + - name: Build + run: | + cmake -S . -B build + cmake --build build -j"$(nproc)" + + - name: Run tests + run: ctest --test-dir build --output-on-failure diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index affc7019..c549044c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,13 +39,13 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: recursive # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) #- name: Autobuild - # uses: github/codeql-action/autobuild@v2 + # uses: github/codeql-action/autobuild@v4 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -75,4 +75,4 @@ jobs: make - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v4 diff --git a/.github/workflows/update-uthash.yml b/.github/workflows/update-uthash.yml index f4adb134..a095fca7 100644 --- a/.github/workflows/update-uthash.yml +++ b/.github/workflows/update-uthash.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: recursive token: ${{ secrets.GITHUB_TOKEN }} @@ -36,7 +36,7 @@ jobs: - name: Create Pull Request if: steps.check_changes.outputs.changed == 'true' - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v8 with: commit-message: 'chore: update uthash.h from upstream' title: 'chore: update uthash.h from upstream' diff --git a/.gitignore b/.gitignore index 0711b11e..4eec34fb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ aclocal.m4 autom4te.cache/ build-aux/ m4/ -config.h.in +/config.h.in configure # Files generated by ./configure config.h diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..55e820db --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,235 @@ +# +# CMake build for LTFS. Coexists with the autotools build; both are +# maintained. The package version is read from the top-level VERSION file +# (the single source of truth shared with configure.ac). +# +cmake_minimum_required(VERSION 3.18) + +# --- Version (single source of truth: ./VERSION) ----------------------------- +file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" _ltfs_ver_lines) +list(GET _ltfs_ver_lines 0 LTFS_VERSION_NUM) +list(LENGTH _ltfs_ver_lines _ltfs_ver_n) +set(LTFS_VERSION_SUFFIX "") +if(_ltfs_ver_n GREATER 1) + list(GET _ltfs_ver_lines 1 LTFS_VERSION_SUFFIX) +endif() +if(LTFS_VERSION_SUFFIX STREQUAL "") + set(LTFS_VERSION_FULL "${LTFS_VERSION_NUM}") +else() + set(LTFS_VERSION_FULL "${LTFS_VERSION_NUM} ${LTFS_VERSION_SUFFIX}") +endif() + +project(ltfs VERSION ${LTFS_VERSION_NUM} LANGUAGES C) + +set(LTFS_PACKAGE_NAME "LTFS") +set(LTFS_PACKAGE_TARNAME "ltfs") +set(LTFS_BUGREPORT "IBM corporation.") + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE) +endif() + +include(GNUInstallDirs) +include(CheckIncludeFile) +include(CheckSymbolExists) +include(CheckTypeSize) +include(CheckCCompilerFlag) + +# --- Options (mirror the autotools --enable/--with switches) ------------------ +option(LTFS_ENABLE_SNMP "Build with SNMP support" ON) +option(LTFS_ENABLE_LINTAPE "Build the IBM lin_tape backend (Linux only)" OFF) +option(LTFS_SUPPORT_BUGGY_IFS "Work around buggy tape interfaces" OFF) +option(LTFS_LIVELINK "Enable livelink symlink mode" ON) +option(LTFS_MESSAGE_CHECK "Compile in message-checking mode" OFF) +option(LTFS_WERROR "Treat warnings as errors" OFF) +option(LTFS_DEBUG "Compile with extra debugging output" OFF) + +# New locking defaults ON for NetBSD (its old locking is broken), OFF elsewhere. +if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") + option(LTFS_NEW_LOCKING "Use the new locking implementation" ON) +else() + option(LTFS_NEW_LOCKING "Use the new locking implementation" OFF) +endif() + +# Default plugin selection, matching configure.ac. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(_default_tape "sg") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(_default_tape "iokit") +elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + set(_default_tape "cam") +elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") + set(_default_tape "scsipi-ibmtape") +endif() +set(DEFAULT_TAPE "${_default_tape}" CACHE STRING "Default tape backend plugin") +set(DEFAULT_IOSCHED "unified" CACHE STRING "Default I/O scheduler plugin") +set(DEFAULT_KMI "none" CACHE STRING "Default key manager plugin") + +# --- Dependencies ------------------------------------------------------------ +# find_package is used wherever a CMake package exists (LibXml2, ICU, Threads). +# libfuse, libuuid, and net-snmp ship no CMake config; pkg-config is their +# canonical interface, wrapped as IMPORTED_TARGETs (PkgConfig::*). +find_package(PkgConfig REQUIRED) + +pkg_check_modules(FUSE REQUIRED IMPORTED_TARGET fuse>=2.6.0) + +find_package(LibXml2 2.6.16 REQUIRED) + +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + pkg_check_modules(UUID REQUIRED IMPORTED_TARGET uuid>=1.6) +else() + pkg_check_modules(UUID REQUIRED IMPORTED_TARGET uuid>=1.36) +endif() + +# ICU via the CMake module (replaces the removed icu-config). +find_package(ICU REQUIRED COMPONENTS uc i18n io data) +set(LTFS_ICU6X OFF) +if(ICU_VERSION VERSION_GREATER_EQUAL "60") + set(LTFS_ICU6X ON) +endif() + +find_package(Threads REQUIRED) +if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") + find_library(RT_LIBRARY rt) +endif() + +# SNMP (optional). +if(LTFS_ENABLE_SNMP) + pkg_check_modules(NETSNMP IMPORTED_TARGET net-snmp>=5.3) + if(NOT NETSNMP_FOUND) + message(WARNING "net-snmp not found via pkg-config; disabling SNMP") + set(LTFS_ENABLE_SNMP OFF) + endif() +endif() + +# Platform-specific libraries (declared for all platforms; used where built). +# backtrace() has a CMake module (libc on glibc, libexecinfo on the BSDs); +# cam/bsdxml/mt and the Apple frameworks ship neither CMake configs nor +# pkg-config files, so find_library is the canonical way to locate them. +if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + find_library(CAM_LIBRARY cam REQUIRED) + find_library(BSDXML_LIBRARY bsdxml REQUIRED) + find_library(MT_LIBRARY mt REQUIRED) + find_package(Backtrace REQUIRED) +elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") + find_package(Backtrace REQUIRED) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + find_library(IOKIT_FRAMEWORK IOKit REQUIRED) + find_library(COREFOUNDATION_FRAMEWORK CoreFoundation REQUIRED) +endif() + +# ICU host tools for the message bundles. +find_program(GENRB genrb REQUIRED) +find_program(PKGDATA pkgdata REQUIRED) + +# --- Feature checks for config.h --------------------------------------------- +check_include_file("sys/sysctl.h" HAVE_SYS_SYSCTL_H) +check_include_file("fcntl.h" HAVE_FCNTL_H) +check_include_file("limits.h" HAVE_LIMITS_H) +check_include_file("stddef.h" HAVE_STDDEF_H) +check_include_file("stdint.h" HAVE_STDINT_H) +check_include_file("stdlib.h" HAVE_STDLIB_H) +check_include_file("string.h" HAVE_STRING_H) +check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H) +check_include_file("sys/mount.h" HAVE_SYS_MOUNT_H) +check_include_file("sys/time.h" HAVE_SYS_TIME_H) +check_include_file("termios.h" HAVE_TERMIOS_H) +check_include_file("unistd.h" HAVE_UNISTD_H) +check_type_size("time_t" SIZEOF_TIME_T) + +# xmlTextReaderSetup and XML_PARSE_HUGE (need libxml2 flags in scope). +# XML_PARSE_HUGE is an enumerator, not a macro, so it needs a compile test. +include(CheckCSourceCompiles) +set(CMAKE_REQUIRED_INCLUDES ${LIBXML2_INCLUDE_DIRS}) +set(CMAKE_REQUIRED_LIBRARIES ${LIBXML2_LIBRARIES}) +check_symbol_exists(xmlTextReaderSetup "libxml/xmlreader.h" HAVE_XML_READER_SETUP) +check_c_source_compiles(" +#include +int main(void) { int foo = XML_PARSE_HUGE; (void)foo; return 0; }" + HAVE_XML_PARSE_HUGE) +unset(CMAKE_REQUIRED_INCLUDES) +unset(CMAKE_REQUIRED_LIBRARIES) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY) + +# --- Common compile settings ------------------------------------------------- +# Definitions every translation unit gets, mirroring AM_CPPFLAGS/AM_CFLAGS. +add_compile_definitions( + _GNU_SOURCE + LTFS_CONFIG_FILE="${CMAKE_INSTALL_FULL_SYSCONFDIR}/ltfs.conf" + LTFS_BASE_DIR="${CMAKE_INSTALL_PREFIX}" +) +if(LTFS_ENABLE_SNMP) + add_compile_definitions(ENABLE_SNMP) +endif() +if(LTFS_NEW_LOCKING) + add_compile_definitions(USE_NEW_LOCKING) +endif() +if(NOT LTFS_LIVELINK) + add_compile_definitions(POSIXLINK_ONLY) +endif() +if(LTFS_MESSAGE_CHECK) + add_compile_definitions(MSG_CHECK) +endif() +if(LTFS_DEBUG) + add_compile_definitions(DEBUG TRACE) +endif() +if(LTFS_ICU6X) + add_compile_definitions(ICU6x) +endif() +if(LTFS_SUPPORT_BUGGY_IFS AND (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")) + add_compile_definitions(SUPPORT_BUGGY_IFS) +endif() + +# -Wno-unused-parameter: callback signatures (FUSE operations, plugin ops) +# must keep parameters they do not use. +# -Wno-missing-field-initializers: designated initializers of operation and +# option tables intentionally leave the remaining members zeroed. +add_compile_options(-Wall -Wextra -Wno-unused-parameter + -Wno-missing-field-initializers -Wsign-compare -fsigned-char) +if(LTFS_WERROR) + add_compile_options(-Werror -Wno-deprecated-declarations) +endif() + +# config.h (binary dir) and the src tree on the include path for every target. +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src) + +# CRC files need SSE4.2 on capable x86; detected once, applied to the ltfs_crc +# object library (see src/tape_drivers). +set(LTFS_CRC_OPTIONS "") +if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|i[3-6]86") + check_c_compiler_flag("-msse4.2" LTFS_HAVE_MSSE42) + if(LTFS_HAVE_MSSE42) + set(LTFS_CRC_OPTIONS -msse4.2 -D__SSE42__) + endif() +endif() + +# Helper modules. +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +include(LtfsMessages) +include(LtfsPlugin) + +enable_testing() + +# --- Subprojects ------------------------------------------------------------- +add_subdirectory(messages) +add_subdirectory(src) +add_subdirectory(conf) +add_subdirectory(man) +add_subdirectory(init.d) +add_subdirectory(tests) + +# pkg-config file (reuse the autotools template). +set(prefix "${CMAKE_INSTALL_PREFIX}") +set(exec_prefix "\${prefix}") +set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") +set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") +set(PACKAGE "ltfs") +set(VERSION "${LTFS_VERSION_FULL}") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ltfs.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/ltfs.pc @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ltfs.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..c2841714 --- /dev/null +++ b/VERSION @@ -0,0 +1,2 @@ +2.4.5.1 +(Prelim) diff --git a/cmake/LtfsMessages.cmake b/cmake/LtfsMessages.cmake new file mode 100644 index 00000000..eb832a3b --- /dev/null +++ b/cmake/LtfsMessages.cmake @@ -0,0 +1,39 @@ +# ICU message-bundle compilation for the CMake build. Reuses the shared +# messages/make_message_src.sh so the genrb/pkgdata logic lives in one place. + +# ltfs_add_message_bundle() +# Compiles messages//*.txt into /messages/lib_dat.a and +# registers a build target msg_. Link it into a consumer with +# ltfs_link_message(). +function(ltfs_add_message_bundle name) + set(_src_dir "${CMAKE_SOURCE_DIR}/messages/${name}") + set(_out_dir "${CMAKE_BINARY_DIR}/messages") + set(_archive "${_out_dir}/lib${name}_dat.a") + file(GLOB _txt "${_src_dir}/*.txt") + + add_custom_command( + OUTPUT "${_archive}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${_out_dir}" + COMMAND ${CMAKE_COMMAND} -E env "GENRB=${GENRB}" "PKGDATA=${PKGDATA}" + sh "${CMAKE_SOURCE_DIR}/messages/make_message_src.sh" + "lib${name}_dat.a" "${_src_dir}" "${_out_dir}" + DEPENDS ${_txt} "${CMAKE_SOURCE_DIR}/messages/make_message_src.sh" + COMMENT "Compiling message bundle ${name}" + VERBATIM) + + add_custom_target(msg_${name} DEPENDS "${_archive}") + # Record the archive path for ltfs_link_message(). + set_property(GLOBAL PROPERTY ltfs_msg_archive_${name} "${_archive}") +endfunction() + +# ltfs_link_message( ) +# Links message bundle into (as a plain archive input, the +# way the autotools build put it on LDFLAGS) and orders the build after it. +function(ltfs_link_message target name) + get_property(_archive GLOBAL PROPERTY ltfs_msg_archive_${name}) + if(NOT _archive) + message(FATAL_ERROR "Unknown message bundle '${name}'") + endif() + target_link_libraries(${target} PRIVATE "${_archive}") + add_dependencies(${target} msg_${name}) +endfunction() diff --git a/cmake/LtfsPlugin.cmake b/cmake/LtfsPlugin.cmake new file mode 100644 index 00000000..d41f3063 --- /dev/null +++ b/cmake/LtfsPlugin.cmake @@ -0,0 +1,36 @@ +# Helper for LTFS runtime plugins (tape backends, I/O schedulers, key managers). +# Reproduces the autotools "-module -avoid-version" behavior: an unversioned +# shared module named lib.so, installed under /ltfs. + +# ltfs_add_plugin( +# SOURCES +# [MSG ] +# [CRC] # link the SSE-optimized CRC objects +# [INCLUDES ] +# [DEFINES ] +# [LIBS ]) +function(ltfs_add_plugin target) + cmake_parse_arguments(P "CRC" "MSG" "SOURCES;INCLUDES;DEFINES;LIBS" ${ARGN}) + + add_library(${target} MODULE ${P_SOURCES}) + set_target_properties(${target} PROPERTIES + PREFIX "" # name is exactly .so, no extra lib prefix + SUFFIX ".so" # plugins are .so even on macOS (loader expects it) + OUTPUT_NAME "${target}") + + target_link_libraries(${target} PRIVATE ltfs ${P_LIBS}) + if(P_CRC) + target_link_libraries(${target} PRIVATE ltfs_crc) + endif() + if(P_INCLUDES) + target_include_directories(${target} PRIVATE ${P_INCLUDES}) + endif() + if(P_DEFINES) + target_compile_definitions(${target} PRIVATE ${P_DEFINES}) + endif() + if(P_MSG) + ltfs_link_message(${target} ${P_MSG}) + endif() + + install(TARGETS ${target} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/ltfs) +endfunction() diff --git a/cmake/config.h.in b/cmake/config.h.in new file mode 100644 index 00000000..4529fbab --- /dev/null +++ b/cmake/config.h.in @@ -0,0 +1,36 @@ +/* config.h generated by CMake. Parity with the autotools config.h for the + * subset of macros the LTFS sources actually use. Feature toggles such as + * HAVE_FUSE3, ICU6x, USE_NEW_LOCKING are passed on the command line (see the + * top-level CMakeLists.txt), exactly as the autotools build does. */ +#ifndef LTFS_CMAKE_CONFIG_H +#define LTFS_CMAKE_CONFIG_H + +#define PACKAGE "@LTFS_PACKAGE_TARNAME@" +#define PACKAGE_NAME "@LTFS_PACKAGE_NAME@" +#define PACKAGE_TARNAME "@LTFS_PACKAGE_TARNAME@" +#define PACKAGE_VERSION "@LTFS_VERSION_FULL@" +#define PACKAGE_STRING "@LTFS_PACKAGE_NAME@ @LTFS_VERSION_FULL@" +#define PACKAGE_BUGREPORT "@LTFS_BUGREPORT@" +#define PACKAGE_URL "" +#define VERSION "@LTFS_VERSION_FULL@" + +/* Referenced by the sources */ +#cmakedefine HAVE_SYS_SYSCTL_H 1 +#cmakedefine HAVE_XML_PARSE_HUGE 1 +#cmakedefine HAVE_XML_READER_SETUP 1 +#define SIZEOF_TIME_T @SIZEOF_TIME_T@ + +/* Header availability (parity with autotools; mostly unreferenced) */ +#cmakedefine HAVE_FCNTL_H 1 +#cmakedefine HAVE_LIMITS_H 1 +#cmakedefine HAVE_STDDEF_H 1 +#cmakedefine HAVE_STDINT_H 1 +#cmakedefine HAVE_STDLIB_H 1 +#cmakedefine HAVE_STRING_H 1 +#cmakedefine HAVE_SYS_IOCTL_H 1 +#cmakedefine HAVE_SYS_MOUNT_H 1 +#cmakedefine HAVE_SYS_TIME_H 1 +#cmakedefine HAVE_TERMIOS_H 1 +#cmakedefine HAVE_UNISTD_H 1 + +#endif /* LTFS_CMAKE_CONFIG_H */ diff --git a/conf/CMakeLists.txt b/conf/CMakeLists.txt new file mode 100644 index 00000000..bcc4f46a --- /dev/null +++ b/conf/CMakeLists.txt @@ -0,0 +1,36 @@ +# Generate ltfs.conf from ltfs.conf.in, reproducing the autotools multi-pass +# sed substitution (__PLATFORM_DRIVERS__, __LIBDIR__, __DEFAULT_*__, +# __CONFDIR__). +set(_plat_drivers "") +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(_plat_drivers "plugin tape sg __LIBDIR__/ltfs/libtape-sg.so") + if(LTFS_ENABLE_LINTAPE) + string(APPEND _plat_drivers "\nplugin tape lin_tape __LIBDIR__/ltfs/libtape-lin_tape.so") + endif() +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(_plat_drivers "plugin tape iokit __LIBDIR__/ltfs/libtape-iokit.so") +elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + set(_plat_drivers "plugin tape cam __LIBDIR__/ltfs/libtape-cam.so") +elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") + set(_plat_drivers "plugin tape scsipi-ibmtape __LIBDIR__/ltfs/libtape-scsipi-ibmtape.so") +endif() + +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/ltfs.conf.in" _conf) +string(REPLACE "__PLATFORM_DRIVERS__" "${_plat_drivers}" _conf "${_conf}") +string(REPLACE "__LIBDIR__" "${CMAKE_INSTALL_FULL_LIBDIR}" _conf "${_conf}") +string(REPLACE "__DEFAULT_TAPE__" "${DEFAULT_TAPE}" _conf "${_conf}") +string(REPLACE "__DEFAULT_IOSCHED__" "${DEFAULT_IOSCHED}" _conf "${_conf}") +string(REPLACE "__DEFAULT_KMI__" "${DEFAULT_KMI}" _conf "${_conf}") +string(REPLACE "__CONFDIR__" "${CMAKE_INSTALL_FULL_SYSCONFDIR}" _conf "${_conf}") +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ltfs.conf" CONTENT "${_conf}") + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ltfs.conf" + DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}) +# ltfs.conf.local holds user edits: install only when absent. The prefix is +# resolved at install time (escaped) so --prefix overrides are honored. +install(CODE " + set(_confdir \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}\") + if(NOT EXISTS \"\${_confdir}/ltfs.conf.local\") + file(INSTALL \"${CMAKE_CURRENT_SOURCE_DIR}/ltfs.conf.local\" + DESTINATION \"\${_confdir}\") + endif()") diff --git a/configure.ac b/configure.ac index f28d2b28..baa656f4 100644 --- a/configure.ac +++ b/configure.ac @@ -36,7 +36,12 @@ dnl dnl LTFS configure.ac. dnl -AC_INIT([LTFS], [2.4.5.1 (Prelim)], IBM corporation.) +dnl Package version is kept in the top-level VERSION file (line 1: numeric +dnl X.Y.Z.W, line 2: optional suffix) so the autotools and CMake builds share +dnl a single source of truth. The awk joins them into "X.Y.Z.W suffix". +AC_INIT([LTFS], + m4_esyscmd_s([awk 'NR==1{n=$0} NR==2{s=$0} END{if(s=="")printf "%s",n; else printf "%s %s",n,s}' VERSION]), + IBM corporation.) AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIRS([m4]) diff --git a/init.d/CMakeLists.txt b/init.d/CMakeLists.txt new file mode 100644 index 00000000..7b57bf4a --- /dev/null +++ b/init.d/CMakeLists.txt @@ -0,0 +1,10 @@ +# Service script, installed only when absent (it may carry local edits). +install(CODE " + set(_dir \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/ltfs\") + if(NOT EXISTS \"\${_dir}/ltfs\") + file(INSTALL \"${CMAKE_CURRENT_SOURCE_DIR}/ltfs\" + DESTINATION \"\${_dir}\" + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) + endif()") diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt new file mode 100644 index 00000000..e3c338c9 --- /dev/null +++ b/man/CMakeLists.txt @@ -0,0 +1,4 @@ +install(FILES mkltfs.8 ltfsck.8 ltfs-sde.8 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man8) +install(FILES ltfs_ordered_copy.1 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) diff --git a/messages/CMakeLists.txt b/messages/CMakeLists.txt new file mode 100644 index 00000000..8d84d142 --- /dev/null +++ b/messages/CMakeLists.txt @@ -0,0 +1,36 @@ +# Compile the ICU message bundles needed by the Linux build. Platform bundles +# (lin_tape, iokit, cam, scsipi-ibmtape) are added when those backends build. +set(LTFS_MESSAGE_BUNDLES + libltfs + internal_error + tape_common + bin_ltfs + bin_mkltfs + bin_ltfsck + iosched_fcfs + iosched_unified + kmi_simple + kmi_flatfile + tape_generic_file + tape_generic_itdtimg) + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + list(APPEND LTFS_MESSAGE_BUNDLES tape_linux_sg) + if(LTFS_ENABLE_LINTAPE) + list(APPEND LTFS_MESSAGE_BUNDLES tape_linux_lin_tape) + endif() +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + list(APPEND LTFS_MESSAGE_BUNDLES tape_iokit) +endif() + +foreach(_b ${LTFS_MESSAGE_BUNDLES}) + ltfs_add_message_bundle(${_b}) +endforeach() + +# Optional: regenerate src/ltfsmsg.h in message-check mode. +if(LTFS_MESSAGE_CHECK) + add_custom_target(ltfsmsg_header ALL + COMMAND ${CMAKE_COMMAND} -E echo "message check enabled" + COMMENT "(message checking) generate src/ltfsmsg.h via print_error_messages.py" + VERBATIM) +endif() diff --git a/messages/make_message_src.sh b/messages/make_message_src.sh index 82488e81..b2e7e7b5 100755 --- a/messages/make_message_src.sh +++ b/messages/make_message_src.sh @@ -1,38 +1,44 @@ #!/bin/sh +# Compile an ICU message bundle (a directory of *.txt resource files) into a +# static archive lib_dat.a using genrb + pkgdata. +# +# Usage: make_message_src.sh [src_bundle_dir] [out_dir] +# e.g. libbin_ltfs_dat.a; the bundle name is derived from it +# [src_bundle_dir] directory holding the *.txt files (default: ./) +# [out_dir] directory to write the archive into (default: .) +# +# genrb/pkgdata are taken from $GENRB/$PKGDATA when set (the build system +# passes the paths it discovered); otherwise they are guessed per-OS. This +# script is shared by the autotools and CMake builds: the one-argument form +# preserves the historical in-source layout used by messages/Makefile.am. + set -e KERNEL_NAME=`uname -s` + +# Resolve the ICU tools, honoring the environment first. if [ "$KERNEL_NAME" = "Darwin" ]; then ICU_FRAMEWORK=/Library/Frameworks/ICU.framework - - if [ -d ${ICU_FRAMEWORK} ]; then - export PATH=${PATH}:${ICU_FRAMEWORK}/Versions/Current/usr/bin - export DYLD_LIBRARY_PATH=${ICU_FRAMEWORK}/Versions/Current/usr/lib - GENRB=${ICU_FRAMEWORK}/Versions/Current/usr/bin/genrb - PKGDATA=${ICU_FRAMEWORK}/Versions/Current/usr/bin/pkgdata + if [ -d "${ICU_FRAMEWORK}" ]; then + export PATH="${PATH}:${ICU_FRAMEWORK}/Versions/Current/usr/bin" + export DYLD_LIBRARY_PATH="${ICU_FRAMEWORK}/Versions/Current/usr/lib" + : "${GENRB:=${ICU_FRAMEWORK}/Versions/Current/usr/bin/genrb}" + : "${PKGDATA:=${ICU_FRAMEWORK}/Versions/Current/usr/bin/pkgdata}" else - GENRB=genrb - PKGDATA=pkgdata + : "${GENRB:=genrb}" + : "${PKGDATA:=pkgdata}" fi elif [ "$KERNEL_NAME" = "FreeBSD" ]; then - GENRB=genrb - PKGDATA=/usr/local/bin/pkgdata + : "${GENRB:=genrb}" + : "${PKGDATA:=/usr/local/bin/pkgdata}" else - if [ -x /usr/bin/genrb ]; then - GENRB=/usr/bin/genrb - else - GENRB=genrb - fi - if [ -x /usr/bin/pkgdata ]; then - PKGDATA=/usr/bin/pkgdata - else - PKGDATA=pkgdata - fi + if [ -x /usr/bin/genrb ]; then : "${GENRB:=/usr/bin/genrb}"; else : "${GENRB:=genrb}"; fi + if [ -x /usr/bin/pkgdata ]; then : "${PKGDATA:=/usr/bin/pkgdata}"; else : "${PKGDATA:=pkgdata}"; fi fi -if [ "$#" -ne "1" ]; then - echo "Usage: $0 object_file" +if [ "$#" -lt "1" ]; then + echo "Usage: $0 archive_name [src_bundle_dir] [out_dir]" exit 1 fi @@ -46,65 +52,64 @@ case $KERNEL_NAME in ;; esac -cd ${BASENAME} +# Source bundle dir and output dir default to the historical in-source layout. +SRC_DIR=${2:-./${BASENAME}} +OUT_DIR=${3:-.} +mkdir -p "$OUT_DIR" +OUT_DIR=`cd "$OUT_DIR" && pwd` # absolute, survives the work-dir cd +SRC_DIR=`cd "$SRC_DIR" && pwd` make_obj() { echo "Processing ${BASENAME}" - # Create a fresh work directory - if [ -d work ]; then - rm -rf work - fi - mkdir work + WORK="${OUT_DIR}/.work-${BASENAME}" + rm -rf "$WORK" + mkdir -p "$WORK" - # Generate files - ${GENRB} -d work -q *.txt - cd work - ls *.res >packagelist.txt - ${PKGDATA} -p ${BASENAME} -m static -q packagelist.txt >/dev/null + # Generate the resource files, then package them statically. + ${GENRB} -d "$WORK" -q "${SRC_DIR}"/*.txt + ( cd "$WORK" && ls *.res > packagelist.txt && \ + ${PKGDATA} -p ${BASENAME} -m static -q packagelist.txt >/dev/null ) case $KERNEL_NAME in MINGW32_NT*) - mv ${BASENAME}.dat ../../ + mv "$WORK/${BASENAME}.dat" "$OUT_DIR/" ;; FreeBSD) - # pkgdata with -m static generates an ar(1) archive - # with several object files on FreeBSD. To avoid - # reworking the makefiles for all OSes, just rename - # the archive to match the regular convention. The - # linker handles it without a problem. - mv lib${BASENAME}.a ../../lib${BASENAME}_dat.a + # pkgdata -m static produces an ar(1) archive with several + # object files on FreeBSD; rename it to the regular convention. + mv "$WORK/lib${BASENAME}.a" "$OUT_DIR/lib${BASENAME}_dat.a" ;; NetBSD) - # generate libtool archive for later linking - mv lib${BASENAME}.a ../../lib${BASENAME}_dat.a + # Generate a libtool archive for later linking. + mv "$WORK/lib${BASENAME}.a" "$OUT_DIR/lib${BASENAME}_dat.a" OBJFILE=${BASENAME}_dat.o LTFILE=${BASENAME}_dat.lo - mkdir -p .libs ../../.libs - mv ${OBJFILE} .libs + mkdir -p "$WORK/.libs" "$OUT_DIR/.libs" + mv "$WORK/${OBJFILE}" "$WORK/.libs" LTVERS=`libtool --version | sed -e 's/^\([^ ]*\) (GNU \(.*\)) \(.*\)$$/\1 - GNU \2 \3/' -e q` - echo "# ${OBJFILE} - a libtool object file" > ${LTFILE} - echo "# Generated by ${LTVERS}" >> ${LTFILE} - echo "pic_object='.libs/${OBJFILE}'" >> ${LTFILE} - echo "non_pic_object=none" >> ${LTFILE} - libtool --mode=link --tag=CC cc -o ../../lib${BASENAME}_dat.la ${LTFILE} - cp ../../lib${BASENAME}_dat.a ../../.libs + echo "# ${OBJFILE} - a libtool object file" > "$OUT_DIR/${LTFILE}" + echo "# Generated by ${LTVERS}" >> "$OUT_DIR/${LTFILE}" + echo "pic_object='.libs/${OBJFILE}'" >> "$OUT_DIR/${LTFILE}" + echo "non_pic_object=none" >> "$OUT_DIR/${LTFILE}" + cp "$WORK/.libs/${OBJFILE}" "$OUT_DIR/.libs/" + ( cd "$OUT_DIR" && libtool --mode=link --tag=CC cc -o "lib${BASENAME}_dat.la" "${LTFILE}" ) + cp "$OUT_DIR/lib${BASENAME}_dat.a" "$OUT_DIR/.libs" ;; *) - mv ${BASENAME}_dat.o ../../lib${BASENAME}_dat.a + mv "$WORK/${BASENAME}_dat.o" "$OUT_DIR/lib${BASENAME}_dat.a" ;; esac - # Clean up - cd .. - rm -rf work + rm -rf "$WORK" } -# Check whether we need to do anything -if [ -f "../$1" ]; then - for file in *.txt; do - if [ "$file" -nt "../$1" ]; then +# Rebuild only when a source file is newer than the existing archive. +OUT_FILE="$OUT_DIR/$1" +if [ -f "$OUT_FILE" ]; then + for file in "$SRC_DIR"/*.txt; do + if [ "$file" -nt "$OUT_FILE" ]; then make_obj exit 0 fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..c59ec8c9 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,47 @@ +add_subdirectory(libltfs) + +# CRC routines compiled with SSE4.2 where available (replaces the autotools +# per-backend symlink + CRC_OPTIMIZE compile rule). One object library, linked +# into every tape backend. +add_library(ltfs_crc OBJECT + tape_drivers/reed_solomon_crc.c + tape_drivers/crc32c_crc.c) +target_include_directories(ltfs_crc PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/tape_drivers) +if(LTFS_CRC_OPTIONS) + target_compile_options(ltfs_crc PRIVATE ${LTFS_CRC_OPTIONS}) +endif() +set_target_properties(ltfs_crc PROPERTIES POSITION_INDEPENDENT_CODE ON) + +# I/O scheduler and key-manager plugins (always built). +add_subdirectory(iosched) +add_subdirectory(kmi) + +# Tape backends: the file simulator and the image driver are portable; the +# real device backends are platform-specific. +add_subdirectory(tape_drivers/generic/file) +add_subdirectory(tape_drivers/generic/itdtimg) +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + add_subdirectory(tape_drivers/linux/sg) + if(LTFS_ENABLE_LINTAPE) + add_subdirectory(tape_drivers/linux/lin_tape) + endif() +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + add_subdirectory(tape_drivers/osx/iokit) +elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + # Not ported to CMake yet; use the autotools build for this backend. + message(STATUS "LTFS: the cam tape backend has no CMake target yet, skipping") +elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") + message(STATUS "LTFS: the scsipi-ibmtape tape backend has no CMake target yet, skipping") +endif() + +add_subdirectory(utils) + +# The ltfs mount executable. +add_executable(ltfs_bin main.c ltfs_fuse.c) +set_target_properties(ltfs_bin PROPERTIES OUTPUT_NAME ltfs) +set_target_properties(ltfs_bin PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_link_libraries(ltfs_bin PRIVATE ltfs) +ltfs_link_message(ltfs_bin bin_ltfs) +install(TARGETS ltfs_bin RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/iosched/CMakeLists.txt b/src/iosched/CMakeLists.txt new file mode 100644 index 00000000..15ee4e49 --- /dev/null +++ b/src/iosched/CMakeLists.txt @@ -0,0 +1,7 @@ +ltfs_add_plugin(libiosched-fcfs + SOURCES fcfs.c + MSG iosched_fcfs) + +ltfs_add_plugin(libiosched-unified + SOURCES unified.c cache_manager.c + MSG iosched_unified) diff --git a/src/kmi/CMakeLists.txt b/src/kmi/CMakeLists.txt new file mode 100644 index 00000000..d9927e33 --- /dev/null +++ b/src/kmi/CMakeLists.txt @@ -0,0 +1,8 @@ +ltfs_add_plugin(libkmi-simple + SOURCES simple.c key_format_ltfs.c + DEFINES KMI_SIMPLE + MSG kmi_simple) + +ltfs_add_plugin(libkmi-flatfile + SOURCES flatfile.c key_format_ltfs.c + MSG kmi_flatfile) diff --git a/src/libltfs/CMakeLists.txt b/src/libltfs/CMakeLists.txt new file mode 100644 index 00000000..8cd49c10 --- /dev/null +++ b/src/libltfs/CMakeLists.txt @@ -0,0 +1,90 @@ +# The core LTFS library: a versioned shared object that the executables and +# all runtime plugins link against. +add_library(ltfs SHARED + ltfs.c + ltfs_internal.c + ltfs_fsops.c + ltfs_fsops_raw.c + ltfssnmp.c + fs.c + xml_common.c + xml_writer.c + xml_reader.c + xml_writer_libltfs.c + xml_reader_libltfs.c + label.c + base64.c + tape.c + iosched.c + dcache.c + kmi.c + pathname.c + index_criteria.c + xattr.c + ltfslogging.c + ltfstrace.c + ltfs_thread.c + config_file.c + plugin.c + periodic_sync.c + arch/uuid_internal.c + arch/filename_handling.c + arch/time_internal.c + arch/arch_info.c + arch/errormap.c) + +set_target_properties(ltfs PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR}) + +# Dependencies are PUBLIC so executables and plugins that link ltfs inherit +# the include paths and link flags, mirroring the autotools "flags are +# global" arrangement. All are imported targets. +target_link_libraries(ltfs PUBLIC + PkgConfig::FUSE + LibXml2::LibXml2 + PkgConfig::UUID + ICU::uc ICU::i18n ICU::io ICU::data + Threads::Threads + ${CMAKE_DL_LIBS}) +if(RT_LIBRARY) + target_link_libraries(ltfs PUBLIC ${RT_LIBRARY}) +endif() +if(LTFS_ENABLE_SNMP) + target_link_libraries(ltfs PUBLIC PkgConfig::NETSNMP) +endif() + +ltfs_link_message(ltfs libltfs) +ltfs_link_message(ltfs internal_error) +ltfs_link_message(ltfs tape_common) + +install(TARGETS ltfs LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +# Public headers (the autotools nobase_pkginclude_HEADERS set), preserving the +# libltfs/ and tape_drivers/ subpaths under /ltfs. +set(_pub_hdrs + libltfs/config_file.h libltfs/dcache_ops.h libltfs/iosched_ops.h + libltfs/kmi_ops.h libltfs/ltfs_fsops.h libltfs/tape_ops.h + libltfs/ltfs_error.h libltfs/ltfs.h libltfs/ltfslogging.h + libltfs/ltfstrace.h libltfs/ltfs_types.h libltfs/ltfs_thread.h + libltfs/ltfs_locking.h libltfs/ltfs_locking_old.h libltfs/ltfs_locking_new.h + libltfs/queue.h libltfs/uthash.h libltfs/uthash_ext.h libltfs/plugin.h + libltfs/tape.h libltfs/xml.h + libltfs/arch/signal_internal.h libltfs/arch/arch_info.h + libltfs/arch/time_internal.h libltfs/arch/errormap.h + libltfs/arch/ltfs_arch_ops.h + tape_drivers/ibm_tape.h tape_drivers/spc_op_codes.h + tape_drivers/ssc_op_codes.h tape_drivers/tape_drivers.h) +foreach(_h ${_pub_hdrs}) + get_filename_component(_subdir "${_h}" DIRECTORY) + install(FILES "${CMAKE_SOURCE_DIR}/src/${_h}" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ltfs/${_subdir}") +endforeach() + +# SNMP MIB definitions. +if(LTFS_ENABLE_SNMP) + install(FILES + "${CMAKE_CURRENT_SOURCE_DIR}/LtfsSnmpTrapDef.txt" + "${CMAKE_CURRENT_SOURCE_DIR}/LTFS-MIB.txt" + DESTINATION "${CMAKE_INSTALL_PREFIX}/share/snmp") +endif() diff --git a/src/tape_drivers/generic/file/CMakeLists.txt b/src/tape_drivers/generic/file/CMakeLists.txt new file mode 100644 index 00000000..290252a9 --- /dev/null +++ b/src/tape_drivers/generic/file/CMakeLists.txt @@ -0,0 +1,9 @@ +set(_td "${CMAKE_SOURCE_DIR}/src/tape_drivers") + +ltfs_add_plugin(libtape-file + SOURCES + filedebug_tc.c + filedebug_conf_tc.c + ${_td}/ibm_tape.c + INCLUDES ${_td} + MSG tape_generic_file) diff --git a/src/tape_drivers/generic/itdtimg/CMakeLists.txt b/src/tape_drivers/generic/itdtimg/CMakeLists.txt new file mode 100644 index 00000000..187d0d26 --- /dev/null +++ b/src/tape_drivers/generic/itdtimg/CMakeLists.txt @@ -0,0 +1,4 @@ +ltfs_add_plugin(libtape-itdtimg + SOURCES itdtimg_tc.c + INCLUDES ${CMAKE_SOURCE_DIR}/src/tape_drivers + MSG tape_generic_itdtimg) diff --git a/src/tape_drivers/linux/sg/CMakeLists.txt b/src/tape_drivers/linux/sg/CMakeLists.txt new file mode 100644 index 00000000..37cfd2a2 --- /dev/null +++ b/src/tape_drivers/linux/sg/CMakeLists.txt @@ -0,0 +1,14 @@ +set(_td "${CMAKE_SOURCE_DIR}/src/tape_drivers") + +ltfs_add_plugin(libtape-sg + SOURCES + sg_scsi_tape.c + sg_tape.c + ${_td}/vendor_compat.c + ${_td}/ibm_tape.c + ${_td}/hp_tape.c + ${_td}/quantum_tape.c + ${_td}/open_factor.c + INCLUDES ${_td} + CRC + MSG tape_linux_sg) diff --git a/src/tape_drivers/osx/iokit/CMakeLists.txt b/src/tape_drivers/osx/iokit/CMakeLists.txt new file mode 100644 index 00000000..d1a7b395 --- /dev/null +++ b/src/tape_drivers/osx/iokit/CMakeLists.txt @@ -0,0 +1,15 @@ +set(_td "${CMAKE_SOURCE_DIR}/src/tape_drivers") + +ltfs_add_plugin(libtape-iokit + SOURCES + iokit_tape.c + iokit_scsi.c + iokit_service.c + ${_td}/vendor_compat.c + ${_td}/ibm_tape.c + ${_td}/hp_tape.c + ${_td}/quantum_tape.c + INCLUDES ${_td} + LIBS ${IOKIT_FRAMEWORK} ${COREFOUNDATION_FRAMEWORK} + CRC + MSG tape_iokit) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt new file mode 100644 index 00000000..1e29cf1d --- /dev/null +++ b/src/utils/CMakeLists.txt @@ -0,0 +1,13 @@ +add_executable(mkltfs mkltfs.c) +set_target_properties(mkltfs PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_link_libraries(mkltfs PRIVATE ltfs) +ltfs_link_message(mkltfs bin_mkltfs) +install(TARGETS mkltfs RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +add_executable(ltfsck ltfsck.c) +set_target_properties(ltfsck PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_link_libraries(ltfsck PRIVATE ltfs) +ltfs_link_message(ltfsck bin_ltfsck) +install(TARGETS ltfsck RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +install(PROGRAMS ltfs_ordered_copy DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..b81d71c8 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,18 @@ +# Integration tests: the shell scripts under t/ (introduced by the test-suite +# change) run through ctest. Register whatever is present so this build works +# with or without the suite; SKIP_RETURN_CODE 77 covers hosts without +# /dev/fuse. +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/helpers/fsops_helper.c") + add_executable(fsops_helper helpers/fsops_helper.c) + set_target_properties(fsops_helper PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests/helpers") +endif() + +file(GLOB _test_scripts "${CMAKE_CURRENT_SOURCE_DIR}/t/*.sh") +foreach(_path ${_test_scripts}) + get_filename_component(_t "${_path}" NAME_WE) + add_test(NAME ${_t} COMMAND sh "${_path}") + set_tests_properties(${_t} PROPERTIES + SKIP_RETURN_CODE 77 + ENVIRONMENT "top_srcdir=${CMAKE_SOURCE_DIR};top_builddir=${CMAKE_BINARY_DIR}") +endforeach()