Skip to content

Commit 06ceeb1

Browse files
committed
build: add cmake
fix: CMake definition for cmake specific files feat: add cmake lists to drivers and kmi fix: revert unnecesary changes fix: missing .c file fix: typos and names chore: add build specific version number and add comments feat: add last cmakelists fix: fix compilation issues feat: fix names feat: add manpages feat: cmake working feat: add flags feat: working everything
1 parent adb3722 commit 06ceeb1

File tree

25 files changed

+489
-9
lines changed

25 files changed

+489
-9
lines changed

.cmake/FindFUSE.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
####
2+
# Find libfuse and set the offset to 64bits
3+
###
4+
find_package(PkgConfig REQUIRED)
5+
6+
pkg_check_modules(FUSE REQUIRED "fuse>=2.6.0" IMPORTED_TARGET)
7+
target_compile_definitions(PkgConfig::FUSE INTERFACE
8+
_FILE_OFFSET_BITS=64
9+
)

.cmake/FindNetSNMP.cmake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#####
2+
# Find the Net SNMP library (net-snmp)
3+
#
4+
option(ENABLE_SNMP "Enable SNMP support" YES)
5+
set(NetSNMP_FOUND OFF CACHE BOOL "net-snmp is found")
6+
7+
if(ENABLE_SNMP OR NetSNMP_FIND_REQUIRED)
8+
find_program(NetSNMP_CONFIG_BIN net-snmp-config REQUIRED)
9+
else()
10+
find_program(NetSNMP_CONFIG_BIN net-snmp-config)
11+
endif()
12+
13+
14+
if(NetSNMP_CONFIG_BIN)
15+
execute_process(COMMAND ${NetSNMP_CONFIG_BIN} --cflags
16+
OUTPUT_VARIABLE NetSNMP_CFLAGS
17+
OUTPUT_STRIP_TRAILING_WHITESPACE
18+
)
19+
execute_process(COMMAND ${NetSNMP_CONFIG_BIN} --libs
20+
OUTPUT_VARIABLE NetSNMP_LIBS
21+
OUTPUT_STRIP_TRAILING_WHITESPACE
22+
)
23+
execute_process(COMMAND ${NetSNMP_CONFIG_BIN} --agent-libs
24+
OUTPUT_VARIABLE NetSNMP_AGENT_LIBS
25+
OUTPUT_STRIP_TRAILING_WHITESPACE
26+
)
27+
# NetSNMP import library
28+
add_library(NetSNMP INTERFACE IMPORTED)
29+
separate_arguments(NetSNMP_CFLAGS)
30+
separate_arguments(NetSNMP_AGENT_LIBS)
31+
separate_arguments(NetSNMP_LIBS)
32+
33+
set_target_properties(NetSNMP PROPERTIES
34+
INTERFACE_COMPILE_OPTIONS "${NetSNMP_CFLAGS};${NetSNMP_LIBS};${NetSNMP_AGENT_LIBS}"
35+
)
36+
set(NetSNMP_FOUND ON CACHE BOOL "net-snmp is found")
37+
endif()

.cmake/FindUUID.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
###
2+
# Find UUID package
3+
#
4+
find_package(PkgConfig REQUIRED)
5+
6+
if(APPLE)
7+
pkg_check_modules(UUID REQUIRED "uuid>=1.6" IMPORTED_TARGET)
8+
else()
9+
pkg_check_modules(UUID REQUIRED "uuid>=1.36" IMPORTED_TARGET)
10+
endif()

.cmake/LTFSUtils.cmake

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Set the tape backend and set default in case is not defined
3+
#
4+
macro(option_tape_backend)
5+
if (NOT DEFAULT_TAPE)
6+
if(LINUX)
7+
set(DEFAULT_TAPE sg)
8+
elseif(APPLE)
9+
set(DEFAULT_TAPE iokit)
10+
elseif(BSD)
11+
if(FREEBSD)
12+
set(DEFAULT_TAPE cam)
13+
elseif(NETBSD)
14+
set(DEFAULT_TAPE scsipi-ibmtape)
15+
endif()
16+
endif()
17+
elseif (NOT ENABLE_LINTAPE AND DEFAULT_TAPE STREQUAL "lin_tape")
18+
message(FATAL_ERROR "lin_tape is not enabled -DENABLE_LINTAPE is required.")
19+
endif()
20+
endmacro()
21+
22+
macro(option_unorm2)
23+
string(REPLACE "." ";" ICU_VERSION_ARRAY ${ICU_VERSION})
24+
list(GET ICU_VERSION_ARRAY 0 ICU_VERSION_MAJOR)
25+
if(ICU_6X OR ICU_VERSION_MAJOR GREATER_EQUAL "56")
26+
add_compile_definitions(USE_UNORM2)
27+
message(STATUS "Using ICU6x funtions")
28+
endif()
29+
endmacro()

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Files generated by cmake
2+
__cmake_systeminformation
3+
.cache
4+
build
5+
CMakeFiles
6+
17
# Files generated by ./autogen.sh
28
Makefile.in
39
aclocal.m4

CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
cmake_minimum_required(VERSION 3.26)
2+
project(ltfs LANGUAGES C)
3+
set(VERSION "2.5.0.0 (Prelim cmake)")
4+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5+
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/.cmake")
6+
7+
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug|Release")
8+
set(CMAKE_BUILD_TYPE Debug)
9+
endif()
10+
11+
# Add dependencies
12+
include(GNUInstallDirs REQUIRED)
13+
include(LTFSUtils REQUIRED)
14+
find_package(Threads REQUIRED)
15+
find_package(ICU COMPONENTS uc)
16+
find_package(LibXml2 REQUIRED)
17+
find_package(FUSE REQUIRED)
18+
find_package(UUID REQUIRED)
19+
find_package(NetSNMP)
20+
# Configure project
21+
set(DEFAULT_TAPE "" CACHE STRING "default tape backend plugin, e.g. sg, iokit, cam, scsipi-ibmtape")
22+
set(DEFAULT_IOSCHED "unified" CACHE STRING "default I/O scheduler plugin, e.g. unified")
23+
set(DEFAULT_KMI "none" CACHE STRING "default key manager interface plugin, e.g. none")
24+
option(MSG_CHECK "compile in message checking mode (may be binary is defunct)" OFF)
25+
option(POSIXLINK_ONLY "compile with livelink mode support" ON)
26+
option(USE_NEW_LOCKING "use new locking system or not" ON)
27+
option(ENABLE_LIN_TAPE "support IBM's lin_tape driver or not" OFF)
28+
option(SUPPORT_BUGGY_IFS "support buggy I/Fs for tape drivers" OFF)
29+
option(INDENT_INDEXES "enable xml indentation for index" OFF)
30+
option(FORMAT_SPEC25 "support format spec 2.5 or not" OFF)
31+
option(ICU_6X "force to use ICU6x (unorm2) functions" OFF)
32+
option(HAVE_XML_PARSE_HUGE "enable xml parsing with huge file support" OFF)
33+
option_tape_backend()
34+
option_unorm2()
35+
add_compile_definitions(_GNU_SOURCE __CMAKE_BUILD)
36+
37+
# Generate targets and configrations
38+
add_subdirectory(messages)
39+
add_subdirectory(src)
40+
add_subdirectory(conf)
41+
add_subdirectory(man)
42+
configure_file(ltfs.pc.in ltfs.pc)

conf/CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# NOTE: This can be done using an .in file with @VARS@ but somehow this is done using sed
2+
set(PLAT_OPTS)
3+
if(ENABLE_LINTAPE)
4+
# list(APPEND PLAT_OPTS "plugin tape lin_tape ${CMAKE_INSTALL_LIBDIR}/ltfs/libtape_lin_tape.so")
5+
list(APPEND PLAT_OPTS "plugin tape lin_tape libtape_lin_tape.so")
6+
endif()
7+
8+
if(LINUX)
9+
list(APPEND PLAT_OPTS "plugin tape sg libtape_sg.so")
10+
elseif(APPLE)
11+
list(APPEND PLAT_OPTS "plugin tape iokit libtape_iokit.so")
12+
elseif(BSD)
13+
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
14+
list(APPEND PLAT_OPTS "plugin tape cam libtape-cam.so")
15+
elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
16+
list(APPEND PLAT_OPTS "plugin tape scsipi-ibmtape libtape_scsipi_ibmtape.so")
17+
endif()
18+
endif()
19+
20+
file(REAL_PATH "ltfs.conf.in" CONFIG_FILE)
21+
file(COPY_FILE "ltfs.conf.local" "${CMAKE_CURRENT_BINARY_DIR}/ltfs.conf.local")
22+
add_custom_command(OUTPUT "ltfs.conf"
23+
COMMAND sed -e "s!__PLATFORM_DRIVERS__!${PLAT_OPTS}!" ${CONFIG_FILE} > .tmp1
24+
COMMAND sed -e "s!__LIBDIR__!${CMAKE_INSTALL_LIBDIR}!" .tmp1 > .tmp2
25+
COMMAND sed -e "s!__DEFAULT_TAPE__!${DEFAULT_TAPE}!" .tmp2 > .tmp1
26+
COMMAND sed -e "s!__DEFAULT_IOSCHED__!${DEFAULT_IOSCHED}!" .tmp1 > .tmp2
27+
COMMAND sed -e "s!__DEFAULT_KMI__!${DEFAULT_KMI}!" .tmp2 > .tmp1
28+
COMMAND sed -e "s!__CONFDIR__!${CMAKE_CURRENT_BINARY_DIR}!" .tmp1 > ltfs.conf
29+
DEPENDS ${CONFIG_FILE}
30+
BYPRODUCTS .tmp1 .tmp2
31+
)
32+
add_custom_target("conf" ALL DEPENDS "ltfs.conf")

conf/ltfs.conf.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
# The PLUGIN-PATH may contain spaces.
1111

1212
__PLATFORM_DRIVERS__
13-
plugin tape file __LIBDIR__/ltfs/libtape-file.so
14-
plugin tape itdtimg __LIBDIR__/ltfs/libtape-itdtimg.so
13+
plugin tape file libtape-file.so
14+
plugin tape itdtimg libtape-itdtimg.so
1515

1616
# I/O scheduler plugins
1717
# Syntax: plugin iosched PLUGIN-NAME PLUGIN-PATH
1818
# The PLUGIN-PATH may contain spaces.
19-
plugin iosched unified __LIBDIR__/ltfs/libiosched-unified.so
20-
plugin iosched fcfs __LIBDIR__/ltfs/libiosched-fcfs.so
19+
plugin iosched unified libiosched-unified.so
20+
plugin iosched fcfs libiosched-fcfs.so
2121

2222
# Key Manager Interface plugins
2323
# Syntax: plugin kmi PLUGIN-NAME PLUGIN-PATH
2424
# The PLUGIN-PATH may contain spaces.
25-
plugin kmi flatfile __LIBDIR__/ltfs/libkmi-flatfile.so
26-
plugin kmi simple __LIBDIR__/ltfs/libkmi-simple.so
25+
plugin kmi flatfile libkmi-flatfile.so
26+
plugin kmi simple libkmi-simple.so
2727

2828
# Default plugins
2929
# Syntax: default PLUGIN-TYPE PLUGIN-NAME

man/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
set(MANPAGES
2+
mkltfs
3+
ltfsck
4+
ltfs
5+
ltfs_ordered_copy
6+
ltfsindextool
7+
)
8+
9+
add_custom_target(man)
10+
foreach(NAME IN LISTS MANPAGES)
11+
file(REAL_PATH "sgml/${NAME}.sgml" SOURCE)
12+
add_custom_target("man_${NAME}"
13+
docbook2man ${SOURCE} # 2> /dev/null
14+
DEPENDS ${SOURCE}
15+
)
16+
add_dependencies(man "man_${NAME}")
17+
endforeach()

messages/CMakeLists.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
set(MESSAGES_LIBS
2+
bin_ltfs
3+
bin_ltfsck
4+
bin_ltfsindextool
5+
bin_mkltfs
6+
internal_error
7+
iosched_fcfs
8+
iosched_unified
9+
kmi_flatfile
10+
kmi_simple
11+
libltfs
12+
tape_common
13+
tape_freebsd_cam
14+
tape_generic_file
15+
tape_generic_itdtimg
16+
tape_iokit
17+
tape_linux_lin_tape
18+
tape_linux_sg
19+
)
20+
set(LIBS)
21+
foreach(NAME IN LISTS MESSAGES_LIBS)
22+
file(GLOB SRCS "${NAME}/*.txt")
23+
set(OUT "lib${NAME}.a")
24+
list(APPEND LIBS ${OUT})
25+
26+
make_directory("${CMAKE_CURRENT_BINARY_DIR}/res_${NAME}")
27+
add_custom_command(OUTPUT ${OUT}
28+
COMMAND ${ICU_GENRB_EXECUTABLE} -q ${SRCS} 1> /dev/null
29+
COMMAND ls *.res > paths.txt
30+
COMMAND ${ICU_PKGDATA_EXECUTABLE} -m static -p ${NAME} -q paths.txt 1> /dev/null
31+
COMMAND cp ${OUT} ..
32+
DEPENDS ${SRCS}
33+
BYPRODUCTS res_${NAME}
34+
WORKING_DIRECTORY res_${NAME}
35+
)
36+
37+
# Define the library as an imported CMake lib
38+
add_library("lib${NAME}" STATIC IMPORTED GLOBAL)
39+
set_target_properties("lib${NAME}" PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/lib${NAME}.a")
40+
add_dependencies("lib${NAME}" "messages")
41+
endforeach()
42+
# Do this to not rebuild the entire message libraries every run
43+
add_custom_target(messages ALL DEPENDS ${LIBS})

0 commit comments

Comments
 (0)