summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bentele2020-09-10 13:30:47 +0200
committerManuel Bentele2020-09-16 07:37:56 +0200
commit1dd2c3999236595a5f6cebdf35dfe7536ff5c34d (patch)
tree75b42c0631cb78ae9b0ce2a817399f8095bc6b07
parentFixed major number of xloop device and device names in xlosetup (diff)
downloadxloop-1dd2c3999236595a5f6cebdf35dfe7536ff5c34d.tar.gz
xloop-1dd2c3999236595a5f6cebdf35dfe7536ff5c34d.tar.xz
xloop-1dd2c3999236595a5f6cebdf35dfe7536ff5c34d.zip
Generate util-linux configuration to build xlosetup
-rw-r--r--CMakeLists.txt51
-rw-r--r--cmake/version.cmake21
-rw-r--r--utils/CMakeLists.txt8
-rw-r--r--utils/config.h.in (renamed from utils/config.h)16
-rw-r--r--utils/libsmartcols/src/libsmartcols.h7
5 files changed, 71 insertions, 32 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 76439db..08b0138 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,14 @@
cmake_minimum_required(VERSION 3.10)
-# set the project name
-project(xloop)
+# include CMake macros
+set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+include(version)
+
+# define root CMake project
+project(xloop
+ DESCRIPTION "xloop Kernel modules and utility"
+ HOMEPAGE_URL "https://git.openslx.org/openslx-ng/xloop.git/"
+ LANGUAGES C)
# define project specific settings
set(BLK_DEV_XLOOP_MIN_COUNT 8
@@ -13,35 +20,49 @@ set(XLOOP_MAJOR 120
message(STATUS "Number of xloop devices to pre-create at init time is " ${BLK_DEV_XLOOP_MIN_COUNT})
message(STATUS "Major number for xloop devices is " ${XLOOP_MAJOR})
+# set supported build configurations
+set(CMAKE_CONFIGURATION_TYPES Debug Release)
+
# set compilation in debug mode as default configuration
if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE "Debug")
+ set(CMAKE_BUILD_TYPE Debug)
+ message(STATUS "Build type is not set. Defaulting to ${CMAKE_BUILD_TYPE} build!")
endif()
-# define packaging
-if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
- set(CPACK_GENERATOR "DEB")
- set(CPACK_SOURCE_GENERATOR "TGZ")
- set(CPACK_IGNORE_FILES "*.gitignore")
- set(CPACK_PACKAGE_NAME "xloop")
- set(CPACK_PACKAGE_DESCRIPTION "xloop Kernel modules and utility")
- set(CPACK_PACKAGE_VERSION_MAJOR 0)
- set(CPACK_PACKAGE_VERSION_MINOR 1)
+# get versions to define project version
+get_kernel_version(LINUX_KERNEL_VERSION)
+get_repository_version(REPOSITORY_VERSION)
+set(VERSION ${LINUX_KERNEL_VERSION}-${REPOSITORY_VERSION})
+
+# define packaging if Release build is enabled
+if(${CMAKE_BUILD_TYPE} MATCHES Release)
+ set(CPACK_GENERATOR "DEB;TGZ")
+ set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
+ set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
+ set(CPACK_MONOLITHIC_INSTALL True)
+ set(CPACK_IGNORE_FILES ".git*")
+ set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_PACKAGE_SECTION admin)
set(CPACK_PACKAGE_VENDOR "University of Freiburg")
set(CPACK_PACKAGE_CONTACT "Christian Rößler <christian.roessler@rz.uni-freiburg.de>")
- set(CPACK_PACKAGE_HOMEPAGE_URL "https://git.openslx.org/openslx-ng/xloop.git/")
set(CPACK_PACKAGE_CHECKSUM SHA256)
- set(CPACK_STRIP_FILES TRUE)
- set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
+ set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CMAKE_SYSTEM_PROCESSOR})
+ set(CPACK_STRIP_FILES True)
+ set(CPACK_SET_DESTDIR True)
+ set(CMAKE_INSTALL_PREFIX /usr)
+ # set DEB generator specific packaging options
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst "depmod -a\n")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm "depmod -a\n")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst
${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm)
+ # include CPack functionality
include(CPack)
endif()
# add subprojects
add_subdirectory(kernel)
add_subdirectory(utils)
+
+# print version information
+message(STATUS "Configured ${CMAKE_PROJECT_NAME} in version ${VERSION}")
diff --git a/cmake/version.cmake b/cmake/version.cmake
new file mode 100644
index 0000000..da3951d
--- /dev/null
+++ b/cmake/version.cmake
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# CMake macros to get version numbers
+# Copyright (C) 2020 Manuel Bentele <development@manuel-bentele.de>
+#
+
+# macro to get Linux kernel version
+macro(get_kernel_version LINUX_KERNEL_VERSION)
+ execute_process(COMMAND uname -r
+ OUTPUT_VARIABLE UNAME_RESULT
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" LINUX_KERNEL_VERSION ${UNAME_RESULT})
+endmacro(get_kernel_version)
+
+# macro to get short hash of latest commit
+macro(get_repository_version REPOSITORY_VERSION)
+ execute_process(COMMAND git rev-parse --short HEAD
+ OUTPUT_VARIABLE SHORT_HASH_RESULT
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "[0-9a-fA-F]+" REPOSITORY_VERSION ${SHORT_HASH_RESULT})
+endmacro(get_repository_version)
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index df83a7a..1388f2b 100644
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -7,8 +7,12 @@ project(xloop-utils)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
-# add include of config.h to each source file
-add_compile_options(-include ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
+# prepare date for configuring config.h
+string(TIMESTAMP DATE "%d-%b-%Y")
+
+# configure configuration config.h and add it to each source file
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+add_compile_options(-include ${CMAKE_CURRENT_BINARY_DIR}/config.h)
# add xloop specific compile options
add_definitions(-DCONFIG_BLK_DEV_XLOOP_MIN_COUNT=${BLK_DEV_XLOOP_MIN_COUNT} -DXLOOP_MAJOR=${XLOOP_MAJOR})
diff --git a/utils/config.h b/utils/config.h.in
index f74c162..40b8d34 100644
--- a/utils/config.h
+++ b/utils/config.h.in
@@ -694,19 +694,19 @@
/* #undef HAVE___SECURE_GETENV */
/* libblkid date string */
-#define LIBBLKID_DATE "23-Jul-2020"
+#define LIBBLKID_DATE "@DATE@"
/* libblkid version string */
-#define LIBBLKID_VERSION "2.36.97"
+#define LIBBLKID_VERSION "@VERSION@"
/* libfdisk version string */
-#define LIBFDISK_VERSION "2.36.97"
+#define LIBFDISK_VERSION "@VERSION@"
/* libmount version string */
-#define LIBMOUNT_VERSION "2.36.97"
+#define LIBMOUNT_VERSION "@VERSION@"
/* libsmartcols version string */
-#define LIBSMARTCOLS_VERSION "2.36.97"
+#define LIBSMARTCOLS_VERSION "@VERSION@"
/* Should login chown /dev/vcsN? */
/* #undef LOGIN_CHOWN_VCS */
@@ -736,7 +736,7 @@
#define PACKAGE_NAME "util-linux"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "util-linux 2.36.97-87ac5-dirty"
+#define PACKAGE_STRING "util-linux @VERSION@"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "util-linux"
@@ -745,7 +745,7 @@
#define PACKAGE_URL "http://www.kernel.org/pub/linux/utils/util-linux/"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "2.36.97-87ac5"
+#define PACKAGE_VERSION "@VERSION@"
/* Should pg ring the bell on invalid keys? */
#define PG_BELL 1
@@ -848,7 +848,7 @@
/* #undef USE_VENDORDIR */
/* Version number of package */
-#define VERSION "2.36.97-87ac5"
+#define VERSION "@VERSION@"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
diff --git a/utils/libsmartcols/src/libsmartcols.h b/utils/libsmartcols/src/libsmartcols.h
index 2b2c08f..5714bfa 100644
--- a/utils/libsmartcols/src/libsmartcols.h
+++ b/utils/libsmartcols/src/libsmartcols.h
@@ -19,13 +19,6 @@ extern "C" {
#include <sys/types.h>
/**
- * LIBSMARTCOLS_VERSION:
- *
- * Library version string
- */
-#define LIBSMARTCOLS_VERSION "2.36.97"
-
-/**
* libscols_iter:
*
* Generic iterator