summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt154
-rw-r--r--COPYING339
-rw-r--r--README.md8
-rw-r--r--cmake/Build.cmake27
-rw-r--r--cmake/GenerateBuild.cmake10
-rw-r--r--cmake/GenerateVersion.cmake20
-rw-r--r--cmake/InstallVersionFile.cmake.in8
-rw-r--r--cmake/Kernel.cmake (renamed from src/kernel/cmake/kernel.cmake)3
-rw-r--r--cmake/Version.cmake80
-rw-r--r--cmake/version.cmake21
-rw-r--r--inc/xloop/build.h.in10
-rw-r--r--inc/xloop/version.h.in10
-rw-r--r--src/kernel/CMakeLists.txt32
-rw-r--r--src/kernel/xloop_file_fmt_qcow_main.c4
-rw-r--r--src/kernel/xloop_file_fmt_raw.c4
-rw-r--r--src/kernel/xloop_main.c6
-rw-r--r--src/utils/CMakeLists.txt8
-rw-r--r--src/utils/config.h (renamed from src/utils/config.h.in)19
-rw-r--r--src/utils/lib/CMakeLists.txt1
-rw-r--r--src/utils/libsmartcols/CMakeLists.txt4
-rw-r--r--src/utils/sys-utils/CMakeLists.txt3
21 files changed, 672 insertions, 99 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cc62a4b..a14e369 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,21 +1,41 @@
cmake_minimum_required(VERSION 3.10)
# include CMake macros
-set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
-include(version)
+set(PROJECT_MODULES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
+ ${PROJECT_MODULES_DIR})
# define root CMake project
project(xloop
DESCRIPTION "xloop Linux kernel modules and utility"
LANGUAGES C)
-# define project specific settings
-set(BLK_DEV_XLOOP_MIN_COUNT 8
- CACHE STRING "Number of xloop devices to pre-create at init time")
-set(XLOOP_MAJOR 120
- CACHE STRING "Major number for xloop devices")
-set(XLOOP_CTRL_MINOR 15
- CACHE STRING "Minor number for the xloop-control device")
+# check for system before all other stuff is configured
+if(NOT UNIX OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
+ # abort build of the xloop Linux kernel modules on a system other than Linux, eg. FreeBSD
+ message(FATAL_ERROR "Detected non-Linux system: Abort build of the xloop Linux kernel modules and utility")
+endif(NOT UNIX OR NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
+
+# 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)
+ message(STATUS "Build type is not set. Defaulting to ${CMAKE_BUILD_TYPE} build!")
+endif(NOT CMAKE_BUILD_TYPE)
+
+# include project version and build type related macros
+include(Version)
+include(Build)
+
+# search for required packages
+find_package(Git)
+
+# abort if a required package is not available
+if(NOT GIT_FOUND)
+ message(FATAL_ERROR "No Git found, can't determine xloop project version number!")
+endif(NOT GIT_FOUND)
# set Linux kernel directories
set(KERNEL_BUILD_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build"
@@ -23,6 +43,14 @@ set(KERNEL_BUILD_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build"
set(KERNEL_INSTALL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/extra"
CACHE PATH "Path to install Linux kernel modules")
+# set linux kernel modules specific default settings
+set(BLK_DEV_XLOOP_MIN_COUNT 8
+ CACHE STRING "Number of xloop devices to pre-create at init time")
+set(XLOOP_MAJOR 120
+ CACHE STRING "Major number for xloop devices")
+set(XLOOP_CTRL_MINOR 15
+ CACHE STRING "Minor number for the xloop-control device")
+
# print configured settings
message(STATUS "Path to Linux kernel modules to compile against is " ${KERNEL_BUILD_DIR})
message(STATUS "Path to install Linux kernel modules is " ${KERNEL_INSTALL_DIR})
@@ -30,48 +58,77 @@ message(STATUS "Number of xloop devices to pre-create at init time is " ${BLK_DE
message(STATUS "Major number for xloop devices is " ${XLOOP_MAJOR})
message(STATUS "Minor number for the xloop-control device is " ${XLOOP_CTRL_MINOR})
-# set supported build configurations
-set(CMAKE_CONFIGURATION_TYPES Debug Release)
+# get the Linux kernel version
+get_kernel_version(LINUX_KERNEL_VERSION ${KERNEL_BUILD_DIR})
-# set compilation in debug mode as default configuration
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE Debug)
- message(STATUS "Build type is not set. Defaulting to ${CMAKE_BUILD_TYPE} build!")
-endif()
+# set include directories
+set(PROJECT_GEN_DIR ${CMAKE_BINARY_DIR}/generated)
+set(PROJECT_INCLUDE_DIR_PREFIX inc)
+set(PROJECT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/${PROJECT_INCLUDE_DIR_PREFIX})
+set(PROJECT_INCLUDE_GEN_DIR ${PROJECT_GEN_DIR}/${PROJECT_INCLUDE_DIR_PREFIX})
+include_directories(${PROJECT_INCLUDE_DIR})
-# get versions to define project version
-get_kernel_version(LINUX_KERNEL_VERSION ${KERNEL_BUILD_DIR})
-get_repository_version(REPOSITORY_VERSION)
-set(VERSION ${LINUX_KERNEL_VERSION}-${REPOSITORY_VERSION}
- CACHE STRING "Version of xloop package")
+# generate project version C header file from template
+# exposes xloop-generate-version and xloop-version target
+set(INCLUDE_VERSION_HEADER ${PROJECT_INCLUDE_DIR}/xloop/version.h)
+set(INCLUDE_VERSION_HEADER_TEMPLATE ${PROJECT_INCLUDE_DIR}/xloop/version.h.in)
+set(INCLUDE_VERSION_HEADER_GENERATE ${PROJECT_INCLUDE_GEN_DIR}/xloop/version.h)
+set(INCLUDE_VERSION_HEADER_GENERATE_PREFIX ${PROJECT_INCLUDE_DIR_PREFIX}/xloop)
+gen_project_version(${INCLUDE_VERSION_HEADER} ${INCLUDE_VERSION_HEADER_TEMPLATE} ${INCLUDE_VERSION_HEADER_GENERATE})
+
+# generate project build type C header file from template
+# exposes xloop-generate-build and xloop-build target
+set(INCLUDE_BUILD_HEADER_TEMPLATE ${PROJECT_INCLUDE_DIR}/xloop/build.h.in)
+set(INCLUDE_BUILD_HEADER_GENERATE ${PROJECT_INCLUDE_GEN_DIR}/xloop/build.h)
+gen_build_type(${INCLUDE_BUILD_HEADER_TEMPLATE} ${INCLUDE_BUILD_HEADER_GENERATE})
+
+# enable all error warnings in Debug build configuration
+set(CMAKE_C_FLAGS_DEBUG "-Wall -Wextra -Wpedantic -Wconversion -Wformat -Wformat-security -Werror=format-security")
+set(CMAKE_C_FLAGS_RELEASE "-Wno-error")
+
+# set compilation optimization
+set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -Og -DDEBUG")
+set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG")
# define packaging if Release build is enabled
-if(${CMAKE_BUILD_TYPE} MATCHES Release)
+if(CMAKE_BUILD_TYPE MATCHES "Release")
+ # get version source package or Git repository
+ get_repository_version(REPOSITORY_VERSION ${INCLUDE_VERSION_HEADER} ${CMAKE_BUILD_TYPE})
+
+ # define project version
+ set(REPOSITORY_VERSION_FULL ${REPOSITORY_VERSION}-${LINUX_KERNEL_VERSION})
+
set(CPACK_GENERATOR "DEB;RPM;TGZ")
- set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(CPACK_MONOLITHIC_INSTALL True)
- set(CPACK_SOURCE_IGNORE_FILES "/build/;/.git/;.gitignore$;.*~")
- set(CPACK_PACKAGE_VERSION ${VERSION})
+ set(CPACK_PACKAGE_VERSION ${REPOSITORY_VERSION})
+ set(CPACK_PACKAGE_VERSION_FULL ${REPOSITORY_VERSION_FULL})
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_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CMAKE_SYSTEM_PROCESSOR})
+ set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_${REPOSITORY_VERSION_FULL}_${CMAKE_SYSTEM_PROCESSOR})
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_source)
set(CPACK_STRIP_FILES True)
set(CPACK_PACKAGE_RELOCATABLE False)
set(CPACK_SET_DESTDIR True)
set(CMAKE_INSTALL_PREFIX "/usr")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
+ set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
+ set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
+
# set DEB generator specific packaging options
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc-bin")
- file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst "depmod -a\nudevadm control --reload-rules\n")
- file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm "depmod -a\nudevadm control --reload-rules\n")
- set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst
- ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm)
+ set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6")
+ if(XLOOP_KERNEL_MODULES)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst "depmod -a\nudevadm control --reload-rules\n")
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm "depmod -a\nudevadm control --reload-rules\n")
+ set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postinst
+ ${CMAKE_CURRENT_BINARY_DIR}/package/deb/postrm)
+ endif(XLOOP_KERNEL_MODULES)
+
# set RPM generator specific packaging options
+ set(CPACK_RPM_PACKAGE_REQUIRES "glibc")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/lib"
"/lib/modules"
"/lib/modules/${CMAKE_SYSTEM_VERSION}"
@@ -82,16 +139,35 @@ if(${CMAKE_BUILD_TYPE} MATCHES Release)
"${CPACK_PACKAGING_INSTALL_PREFIX}/share/bash-completion/completions"
"${CPACK_PACKAGING_INSTALL_PREFIX}/share/man"
"${CPACK_PACKAGING_INSTALL_PREFIX}/share/man/man8")
- file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/rpm/post "depmod -a\nudevadm control --reload-rules\n")
- file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/rpm/postun "depmod -a\nudevadm control --reload-rules\n")
- set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_BINARY_DIR}/package/rpm/post)
- set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_BINARY_DIR}/package/rpm/postun)
+ if(XLOOP_KERNEL_MODULES)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/rpm/post "depmod -a\nudevadm control --reload-rules\n")
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/rpm/postun "depmod -a\nudevadm control --reload-rules\n")
+ set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_BINARY_DIR}/package/rpm/post)
+ set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_BINARY_DIR}/package/rpm/postun)
+ endif(XLOOP_KERNEL_MODULES)
+
+ # configure source packaging
+ set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
+ set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${CMAKE_SOURCE_DIR}" "/"
+ "${PROJECT_GEN_DIR}" "/")
+ set(CPACK_SOURCE_IGNORE_FILES "/build/;/.git/;.gitignore$;.*~;version.h.in$")
+
+ # generate install script for CPack to install generated files
+ configure_file(${PROJECT_MODULES_DIR}/InstallVersionFile.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/package/InstallVersionFile.cmake)
+
+ # set CPack install script
+ set(CPACK_INSTALL_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/package/InstallVersionFile.cmake)
+
# include CPack functionality
include(CPack)
-endif()
+
+ # create custom target to build package source
+ add_custom_target(source
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target package_source
+ DEPENDS xloop-generate-version
+ VERBATIM
+ USES_TERMINAL)
+endif(CMAKE_BUILD_TYPE MATCHES "Release")
# add all xloop related projects from the source code directory
add_subdirectory(src)
-
-# print version information
-message(STATUS "Configured ${CMAKE_PROJECT_NAME} in version ${VERSION}")
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..d159169
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/README.md b/README.md
index d1229c9..efa50de 100644
--- a/README.md
+++ b/README.md
@@ -111,17 +111,17 @@ In the `Release` build configuration, installation packages can be built by call
make package
```
-This target creates a Debian installation package (\*.deb) and a compressed archive (\*.tar.gz) containing the built xloop Linux kernel modules and the xlosetup utility executable as well as its man page and bash-completion support.
+This target creates a Debian installation package (\*.deb), a RPM installation package (\*.rpm) and a compressed archive (\*.tar.gz) containing the built xloop Linux kernel modules and the xlosetup utility executable as well as its man page and bash-completion support.
### Sources
-In the `Release` build configuration, sources can be built by calling the make target `package_source`:
+In the `Release` build configuration, sources can be built by calling the make target `source`:
```shell
-make package_source
+make source
```
-This target creates compressed archives (\*_sources.tar.gz and \*_sources.zip) containing the source code of this repository for code distribution purposes.
+This target creates compressed archives (\*_source.tar.gz and \*_source.zip) containing the source code of this repository for code distribution purposes.
## Debugging
diff --git a/cmake/Build.cmake b/cmake/Build.cmake
new file mode 100644
index 0000000..bad9755
--- /dev/null
+++ b/cmake/Build.cmake
@@ -0,0 +1,27 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2020 Manuel Bentele <development@manuel-bentele.de>
+#
+
+macro(gen_build_type BUILD_INPUT_FILE_TEMPLATE BUILD_OUTPUT_FILE)
+ get_filename_component(BUILD_OUTPUT_FILENAME ${BUILD_OUTPUT_FILE} NAME)
+ # command that will trigger a rebuild of build.h every time
+ add_custom_command(OUTPUT regenerate-build-file
+ COMMAND ${CMAKE_COMMAND} -E sleep 0
+ COMMENT "Trigger generating ${BUILD_OUTPUT_FILENAME}")
+
+ # call the GenerateBuild.cmake file to generate the build.h file
+ add_custom_command(OUTPUT ${BUILD_OUTPUT_FILE}
+ COMMAND ${CMAKE_COMMAND} -D BUILD_INPUT_FILE_TEMPLATE=${BUILD_INPUT_FILE_TEMPLATE}
+ -D BUILD_OUTPUT_FILE=${BUILD_OUTPUT_FILE}
+ -D BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -P ${PROJECT_MODULES_DIR}/GenerateBuild.cmake
+ COMMENT "Generating ${BUILD_OUTPUT_FILENAME}"
+ DEPENDS regenerate-build-file)
+ add_custom_target(xloop-generate-build DEPENDS ${BUILD_OUTPUT_FILE})
+
+ # create target to expose project build type
+ add_library(xloop-build INTERFACE)
+ target_include_directories(xloop-build INTERFACE ${PROJECT_INCLUDE_GEN_DIR})
+ add_dependencies(xloop-build xloop-generate-build)
+endmacro(gen_build_type BUILD_INPUT_FILE_TEMPLATE BUILD_OUTPUT_FILE)
diff --git a/cmake/GenerateBuild.cmake b/cmake/GenerateBuild.cmake
new file mode 100644
index 0000000..5af35d2
--- /dev/null
+++ b/cmake/GenerateBuild.cmake
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2020 Manuel Bentele <development@manuel-bentele.de>
+#
+
+# set current build type of the project
+set(XLOOP_BUILD ${BUILD_TYPE})
+
+# write dnbd3 build type into a new C source file based on the specified build file template
+configure_file(${BUILD_INPUT_FILE_TEMPLATE} ${BUILD_OUTPUT_FILE})
diff --git a/cmake/GenerateVersion.cmake b/cmake/GenerateVersion.cmake
new file mode 100644
index 0000000..73b0771
--- /dev/null
+++ b/cmake/GenerateVersion.cmake
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2020 Manuel Bentele <development@manuel-bentele.de>
+#
+
+# set CMake module path to include version macros
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
+ ${VERSION_MODULE_PATH})
+
+# include version macros
+include(Version)
+
+# get Git version of Git repository
+get_repository_version(XLOOP_VERSION ${VERSION_INPUT_FILE} ${VERSION_BUILD_TYPE})
+
+# generate version header if header does not exists
+if(NOT EXISTS ${VERSION_INPUT_FILE})
+ # write dnbd3 version into a new C source file based on the specified version template
+ configure_file(${VERSION_INPUT_FILE_TEMPLATE} ${VERSION_OUTPUT_FILE})
+endif(NOT EXISTS ${VERSION_INPUT_FILE})
diff --git a/cmake/InstallVersionFile.cmake.in b/cmake/InstallVersionFile.cmake.in
new file mode 100644
index 0000000..8121c25
--- /dev/null
+++ b/cmake/InstallVersionFile.cmake.in
@@ -0,0 +1,8 @@
+#
+# AUTOGENERATED: DO NOT EDIT THIS FILE
+#
+
+if(CPACK_SOURCE_INSTALLED_DIRECTORIES AND EXISTS "@INCLUDE_VERSION_HEADER_GENERATE@")
+ file(INSTALL "@INCLUDE_VERSION_HEADER_GENERATE@"
+ DESTINATION "@INCLUDE_VERSION_HEADER_GENERATE_PREFIX@")
+endif(CPACK_SOURCE_INSTALLED_DIRECTORIES AND EXISTS "@INCLUDE_VERSION_HEADER_GENERATE@")
diff --git a/src/kernel/cmake/kernel.cmake b/cmake/Kernel.cmake
index 811ce86..232c298 100644
--- a/src/kernel/cmake/kernel.cmake
+++ b/cmake/Kernel.cmake
@@ -49,8 +49,9 @@ macro(add_kernel_module MODULE_NAME KERNEL_BUILD_DIR KERNEL_INSTALL_DIR MODULE_M
DEPENDS ${BUILD_SOURCE_FILE_PREPARED} ${MODULE_HEADER_FILES_PREPARED} ${MODULE_SOURCE_FILES_PREPARED}
VERBATIM)
add_custom_target(${MODULE_NAME} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${MODULE_NAME}.ko ${ARGV7})
+ # install kernel module
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${MODULE_NAME}/${MODULE_NAME}.ko
DESTINATION ${KERNEL_INSTALL_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- COMPONENT main)
+ COMPONENT kernel)
endmacro(add_kernel_module)
diff --git a/cmake/Version.cmake b/cmake/Version.cmake
new file mode 100644
index 0000000..a061e48
--- /dev/null
+++ b/cmake/Version.cmake
@@ -0,0 +1,80 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2020 Manuel Bentele <development@manuel-bentele.de>
+#
+
+macro(gen_project_version VERSION_INPUT_FILE VERSION_INPUT_FILE_TEMPLATE VERSION_OUTPUT_FILE)
+ get_filename_component(VERSION_OUTPUT_FILENAME ${VERSION_OUTPUT_FILE} NAME)
+ # command that will trigger a rebuild of version.h every time
+ add_custom_command(OUTPUT regenerate-version-file
+ COMMAND ${CMAKE_COMMAND} -E sleep 0
+ COMMENT "Trigger generating ${VERSION_OUTPUT_FILENAME}")
+
+ # call the GenerateVersion.cmake file to generate the version.c file
+ add_custom_command(OUTPUT ${VERSION_OUTPUT_FILE}
+ COMMAND ${CMAKE_COMMAND} -D VERSION_MODULE_PATH=${PROJECT_MODULES_DIR}
+ -D VERSION_INPUT_FILE=${VERSION_INPUT_FILE}
+ -D VERSION_INPUT_FILE_TEMPLATE=${VERSION_INPUT_FILE_TEMPLATE}
+ -D VERSION_OUTPUT_FILE=${VERSION_OUTPUT_FILE}
+ -D VERSION_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -P ${PROJECT_MODULES_DIR}/GenerateVersion.cmake
+ COMMENT "Generating ${VERSION_OUTPUT_FILENAME}"
+ DEPENDS regenerate-version-file)
+ add_custom_target(xloop-generate-version DEPENDS ${VERSION_OUTPUT_FILE})
+
+ # create target to expose project version
+ add_library(xloop-version INTERFACE)
+ target_include_directories(xloop-version INTERFACE ${PROJECT_INCLUDE_GEN_DIR})
+ add_dependencies(xloop-version xloop-generate-version)
+endmacro(gen_project_version VERSION_INPUT_FILE VERSION_INPUT_FILE_TEMPLATE VERSION_OUTPUT_FILE)
+
+# macro to get Linux kernel version from KERNEL_BUILD_DIR string
+macro(get_kernel_version LINUX_KERNEL_VERSION KERNEL_BUILD_DIR)
+ string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" LINUX_KERNEL_VERSION ${KERNEL_BUILD_DIR})
+ if(LINUX_KERNEL_VERSION STREQUAL "")
+ set(LINUX_KERNEL_VERSION "unknown")
+ endif(LINUX_KERNEL_VERSION STREQUAL "")
+endmacro(get_kernel_version LINUX_KERNEL_VERSION KERNEL_BUILD_DIR)
+
+# macro to get Git version information
+macro(get_repository_version REPOSITORY_VERSION VERSION_HEADER_FILE VERSION_BUILD_TYPE)
+ # check if generated version header from source package is available
+ if(EXISTS ${VERSION_HEADER_FILE})
+ # get version information from the generated version header of the source package
+ file(READ ${VERSION_HEADER_FILE} GIT_VERSION)
+ string(REGEX MATCH "\"(([0-9]+:)?[0-9][A-Za-z0-9.+~-]*)\"" GIT_VERSION ${GIT_VERSION})
+ set(GIT_VERSION "${CMAKE_MATCH_1}")
+ else(EXISTS ${VERSION_HEADER_FILE})
+ # get detailed Git version information from Git repository
+ execute_process(COMMAND git describe HEAD
+ OUTPUT_VARIABLE GIT_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ # remove the first letter of the version to satisfy packaging rules
+ string(REGEX MATCH "([0-9]+:)?[0-9][A-Za-z0-9.+~-]*" GIT_VERSION ${GIT_VERSION})
+
+ # overwrite version from Git if version is unknown
+ if(GIT_VERSION STREQUAL "")
+ set(GIT_VERSION "unknown")
+ endif(GIT_VERSION STREQUAL "")
+
+ # get status of Git repository
+ execute_process(COMMAND git status --porcelain
+ OUTPUT_VARIABLE GIT_STATUS
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ # check if Git repository is dirty
+ if(NOT GIT_STATUS STREQUAL "")
+ # the Git repository is dirty, thus extend the version information
+ set(GIT_VERSION "${GIT_VERSION}-modified")
+
+ # print a message in Release build configuration to warn about the dirty repository
+ if(${VERSION_BUILD_TYPE} MATCHES "Release")
+ message(WARNING "This xloop Git repository is dirty! Please commit or revert all changes for a ${VERSION_BUILD_TYPE} build!")
+ endif(${VERSION_BUILD_TYPE} MATCHES "Release")
+ endif(NOT GIT_STATUS STREQUAL "")
+ endif(EXISTS ${VERSION_HEADER_FILE})
+
+ # return version to caller
+ set(${REPOSITORY_VERSION} ${GIT_VERSION})
+endmacro(get_repository_version)
diff --git a/cmake/version.cmake b/cmake/version.cmake
deleted file mode 100644
index 07483af..0000000
--- a/cmake/version.cmake
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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 from KERNEL_BUILD_DIR
-macro(get_kernel_version LINUX_KERNEL_VERSION KERNEL_BUILD_DIR)
- string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" LINUX_KERNEL_VERSION ${KERNEL_BUILD_DIR})
- if(LINUX_KERNEL_VERSION STREQUAL "")
- set(LINUX_KERNEL_VERSION "unknown")
- endif()
-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/inc/xloop/build.h.in b/inc/xloop/build.h.in
new file mode 100644
index 0000000..4a8fbd3
--- /dev/null
+++ b/inc/xloop/build.h.in
@@ -0,0 +1,10 @@
+/*
+ * AUTOGENERATED: DO NOT EDIT THIS FILE
+ */
+
+#ifndef BUILD_H_
+#define BUILD_H_
+
+#define XLOOP_BUILD "@XLOOP_BUILD@"
+
+#endif /* BUILD_H_ */
diff --git a/inc/xloop/version.h.in b/inc/xloop/version.h.in
new file mode 100644
index 0000000..99d730d
--- /dev/null
+++ b/inc/xloop/version.h.in
@@ -0,0 +1,10 @@
+/*
+ * AUTOGENERATED: DO NOT EDIT THIS FILE
+ */
+
+#ifndef VERSION_H_
+#define VERSION_H_
+
+#define XLOOP_VERSION "@XLOOP_VERSION@"
+
+#endif /* VERSION_H_ */
diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt
index dd12c80..2f1446a 100644
--- a/src/kernel/CMakeLists.txt
+++ b/src/kernel/CMakeLists.txt
@@ -3,20 +3,26 @@ cmake_minimum_required(VERSION 3.10)
# set the project name
project(xloop-kernel)
-set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
-include(kernel)
+# include macros to define Linux kernel build targets
+include(Kernel)
# set C flags for a Linux kernel module
-set(KERNEL_C_FLAGS "-DCONFIG_BLK_DEV_XLOOP_MIN_COUNT=${BLK_DEV_XLOOP_MIN_COUNT} -DXLOOP_MAJOR=${XLOOP_MAJOR} -DXLOOP_CTRL_MINOR=${XLOOP_CTRL_MINOR} -DVERSION=${VERSION}"
- CACHE STRING "C flags to be used for building the kernel module")
+set(KERNEL_C_FLAGS "-DCONFIG_BLK_DEV_XLOOP_MIN_COUNT=${BLK_DEV_XLOOP_MIN_COUNT} -DXLOOP_MAJOR=${XLOOP_MAJOR} -DXLOOP_CTRL_MINOR=${XLOOP_CTRL_MINOR} -I ${PROJECT_INCLUDE_GEN_DIR}"
+ CACHE STRING "C flags to be used for building the kernel module")
# set C flags for the debug mode of a Linux kernel module
set(KERNEL_C_FLAGS_DEBUG "-g -DDEBUG"
- CACHE STRING "Additional C flags to be used for building the kernel module in debug mode")
+ CACHE STRING "Additional C flags to be used for building the kernel module in debug mode")
+
+# append include directories to the C flags
+get_property(KERNEL_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
+foreach(KERNEL_INCLUDE_DIR ${KERNEL_INCLUDE_DIRS})
+ set(KERNEL_C_FLAGS "${KERNEL_C_FLAGS} -I ${KERNEL_INCLUDE_DIR}")
+endforeach(KERNEL_INCLUDE_DIR ${KERNEL_INCLUDE_DIRS})
# append debug C flags if debug mode is enabled
-if(CMAKE_BUILD_TYPE MATCHES Debug)
+if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(KERNEL_C_FLAGS "${KERNEL_C_FLAGS} ${KERNEL_C_FLAGS_DEBUG}")
-endif(CMAKE_BUILD_TYPE MATCHES Debug)
+endif(CMAKE_BUILD_TYPE MATCHES "Debug")
# xloop main Linux kernel module
set(KERNEL_MODULE_XLOOP_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt.c
@@ -30,6 +36,8 @@ add_kernel_module(xloop "${KERNEL_BUILD_DIR}"
"${KERNEL_MODULE_XLOOP_SOURCE_FILES}"
"${KERNEL_MODULE_XLOOP_HEADER_FILES}"
${CMAKE_CURRENT_SOURCE_DIR}/Kbuild)
+# add dependency to generate project version header before xloop.ko is built
+add_dependencies(xloop xloop-generate-version)
# xloop_file_fmt_raw Linux kernel module
set(KERNEL_MODULE_XLOOP_RAW_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_raw.c)
@@ -43,6 +51,8 @@ add_kernel_module(xloop_file_fmt_raw "${KERNEL_BUILD_DIR}"
"${KERNEL_MODULE_XLOOP_RAW_HEADER_FILES}"
${CMAKE_CURRENT_SOURCE_DIR}/Kbuild
xloop)
+# add dependency to generate project version header before xloop_file_fmt_raw.ko is built
+add_dependencies(xloop_file_fmt_raw xloop-generate-version)
# xloop_file_fmt_qcow Linux kernel module
set(KERNEL_MODULE_XLOOP_QCOW_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt_qcow_cache.c
@@ -61,13 +71,15 @@ add_kernel_module(xloop_file_fmt_qcow "${KERNEL_BUILD_DIR}"
"${KERNEL_MODULE_XLOOP_QCOW_HEADER_FILES}"
${CMAKE_CURRENT_SOURCE_DIR}/Kbuild
xloop)
+# add dependency to generate project version header before xloop_file_fmt_qcow.ko is built
+add_dependencies(xloop_file_fmt_qcow xloop-generate-version)
-if(${CMAKE_BUILD_TYPE} MATCHES Debug)
+if(CMAKE_BUILD_TYPE MATCHES "Debug")
add_subdirectory(tests)
-endif()
+endif(CMAKE_BUILD_TYPE MATCHES "Debug")
# install udev rules for xloop devices exposed by the xloop kernel module
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/udev/50-xloop.rules
DESTINATION /lib/udev/rules.d
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- COMPONENT main)
+ COMPONENT kernel)
diff --git a/src/kernel/xloop_file_fmt_qcow_main.c b/src/kernel/xloop_file_fmt_qcow_main.c
index 38fe1af..dfde76d 100644
--- a/src/kernel/xloop_file_fmt_qcow_main.c
+++ b/src/kernel/xloop_file_fmt_qcow_main.c
@@ -27,6 +27,8 @@
#include <linux/zstd.h>
#endif
+#include <xloop/version.h>
+
#include "xloop_file_fmt.h"
#include "xloop_file_fmt_qcow_main.h"
#include "xloop_file_fmt_qcow_cache.h"
@@ -1280,4 +1282,4 @@ MODULE_LICENSE("GPL");
MODULE_AUTHOR("Manuel Bentele <development@manuel-bentele.de>");
MODULE_DESCRIPTION("xloop device QCOW file format driver");
MODULE_SOFTDEP("pre: xloop");
-MODULE_VERSION(__stringify(VERSION));
+MODULE_VERSION(XLOOP_VERSION);
diff --git a/src/kernel/xloop_file_fmt_raw.c b/src/kernel/xloop_file_fmt_raw.c
index 76ab39e..12914e8 100644
--- a/src/kernel/xloop_file_fmt_raw.c
+++ b/src/kernel/xloop_file_fmt_raw.c
@@ -23,6 +23,8 @@
#include <linux/uio.h>
#include <linux/version.h>
+#include <xloop/version.h>
+
#include "xloop_file_fmt.h"
static inline loff_t __raw_file_fmt_rq_get_pos(struct xloop_file_fmt *xlo_fmt,
@@ -473,4 +475,4 @@ MODULE_LICENSE("GPL");
MODULE_AUTHOR("Manuel Bentele <development@manuel-bentele.de>");
MODULE_DESCRIPTION("xloop device RAW file format driver");
MODULE_SOFTDEP("pre: xloop");
-MODULE_VERSION(__stringify(VERSION));
+MODULE_VERSION(XLOOP_VERSION);
diff --git a/src/kernel/xloop_main.c b/src/kernel/xloop_main.c
index a3e20a6..300554f 100644
--- a/src/kernel/xloop_main.c
+++ b/src/kernel/xloop_main.c
@@ -88,6 +88,8 @@
#include <linux/debugfs.h>
#endif
+#include <xloop/version.h>
+
#include "xloop_file_fmt.h"
#include "xloop_main.h"
@@ -1719,7 +1721,7 @@ module_param(max_part, int, 0444);
MODULE_PARM_DESC(max_part, "Maximum number of partitions per xloop device");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Manuel Bentele <development@manuel-bentele.de>");
-MODULE_VERSION(__stringify(VERSION));
+MODULE_VERSION(XLOOP_VERSION);
MODULE_ALIAS_BLOCKDEV_MAJOR(XLOOP_MAJOR);
int xloop_register_transfer(struct xloop_func_table *funcs)
@@ -2189,7 +2191,7 @@ static int __init xloop_init(void)
xloop_add(&xlo, i);
mutex_unlock(&xloop_ctl_mutex);
- pr_info("module in version %s loaded\n", __stringify(VERSION));
+ pr_info("module in version %s loaded\n", XLOOP_VERSION);
return 0;
misc_out:
diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt
index cfc5548..f3ea912 100644
--- a/src/utils/CMakeLists.txt
+++ b/src/utils/CMakeLists.txt
@@ -4,15 +4,11 @@ cmake_minimum_required(VERSION 3.10)
project(xloop-utils)
# include global headers
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-# prepare date for configuring config.h
-string(TIMESTAMP DATE "%d-%b-%Y")
+include_directories(${PROJECT_INCLUDE_GEN_DIR})
# 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_compile_options(-include ${CMAKE_CURRENT_SOURCE_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/src/utils/config.h.in b/src/utils/config.h
index 40b8d34..781ddc7 100644
--- a/src/utils/config.h.in
+++ b/src/utils/config.h
@@ -1,6 +1,8 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
+#include <xloop/version.h>
+
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
@@ -693,20 +695,17 @@
/* Define to 1 if you have the `__secure_getenv' function. */
/* #undef HAVE___SECURE_GETENV */
-/* libblkid date string */
-#define LIBBLKID_DATE "@DATE@"
-
/* libblkid version string */
-#define LIBBLKID_VERSION "@VERSION@"
+#define LIBBLKID_VERSION XLOOP_VERSION
/* libfdisk version string */
-#define LIBFDISK_VERSION "@VERSION@"
+#define LIBFDISK_VERSION XLOOP_VERSION
/* libmount version string */
-#define LIBMOUNT_VERSION "@VERSION@"
+#define LIBMOUNT_VERSION XLOOP_VERSION
/* libsmartcols version string */
-#define LIBSMARTCOLS_VERSION "@VERSION@"
+#define LIBSMARTCOLS_VERSION XLOOP_VERSION
/* Should login chown /dev/vcsN? */
/* #undef LOGIN_CHOWN_VCS */
@@ -736,7 +735,7 @@
#define PACKAGE_NAME "util-linux"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "util-linux @VERSION@"
+#define PACKAGE_STRING ("util-linux " XLOOP_VERSION)
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "util-linux"
@@ -745,7 +744,7 @@
#define PACKAGE_URL "http://www.kernel.org/pub/linux/utils/util-linux/"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "@VERSION@"
+#define PACKAGE_VERSION XLOOP_VERSION
/* Should pg ring the bell on invalid keys? */
#define PG_BELL 1
@@ -848,7 +847,7 @@
/* #undef USE_VENDORDIR */
/* Version number of package */
-#define VERSION "@VERSION@"
+#define VERSION XLOOP_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/src/utils/lib/CMakeLists.txt b/src/utils/lib/CMakeLists.txt
index e5fa459..22eafb3 100644
--- a/src/utils/lib/CMakeLists.txt
+++ b/src/utils/lib/CMakeLists.txt
@@ -42,3 +42,4 @@ add_library(libcommon STATIC ${CMAKE_CURRENT_SOURCE_DIR}/blkdev.c
${CMAKE_CURRENT_SOURCE_DIR}/timer.c
${CMAKE_CURRENT_SOURCE_DIR}/timeutils.c
${CMAKE_CURRENT_SOURCE_DIR}/ttyutils.c)
+target_link_libraries(libcommon xloop-version)
diff --git a/src/utils/libsmartcols/CMakeLists.txt b/src/utils/libsmartcols/CMakeLists.txt
index c8deb72..dccb5e2 100644
--- a/src/utils/libsmartcols/CMakeLists.txt
+++ b/src/utils/libsmartcols/CMakeLists.txt
@@ -18,5 +18,5 @@ add_library(libsmartcols STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src/buffer.c
${CMAKE_CURRENT_SOURCE_DIR}/src/table.c
${CMAKE_CURRENT_SOURCE_DIR}/src/version.c
${CMAKE_CURRENT_SOURCE_DIR}/src/walk.c)
-target_include_directories(libsmartcols PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/../lib)
-target_link_libraries(libsmartcols LINK_PUBLIC libcommon)
+target_include_directories(libsmartcols PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
+target_link_libraries(libsmartcols LINK_PUBLIC libcommon xloop-version)
diff --git a/src/utils/sys-utils/CMakeLists.txt b/src/utils/sys-utils/CMakeLists.txt
index 01295d9..e05b5cf 100644
--- a/src/utils/sys-utils/CMakeLists.txt
+++ b/src/utils/sys-utils/CMakeLists.txt
@@ -5,8 +5,7 @@ project(xloop-utils-sys-utils)
# add xlosetup executable
add_executable(xlosetup ${CMAKE_CURRENT_SOURCE_DIR}/xlosetup.c)
-target_link_libraries(xlosetup LINK_PUBLIC libcommon libsmartcols)
-target_include_directories(xlosetup PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../lib ${CMAKE_CURRENT_SOURCE_DIR}/../libsmartcols)
+target_link_libraries(xlosetup libcommon libsmartcols xloop-version)
install(TARGETS xlosetup DESTINATION bin
COMPONENT main)