From c25f8c3dff1d3be807063cc35d755766ffcf67c6 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Thu, 8 Mar 2018 01:42:20 +0100 Subject: [PATCH] add examples --- .gitmodules | 3 +++ examples/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++++ examples/LKMPG | 1 + 3 files changed, 40 insertions(+) create mode 100644 .gitmodules create mode 100644 examples/CMakeLists.txt create mode 160000 examples/LKMPG diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3f0e14d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "examples/LKMPG"] + path = examples/LKMPG + url = gitea@gitea.stubbe.rocks:3rd-party/LKMPG.git diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..68cf8f7 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 2.6) +include("../BuildKernelModule.cmake") + +project ("example_modules") + +set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -pedantic -Weverything") +if(NOT KERNEL_DIR) + Set(KERNEL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build" ) +endif() + +# create LKMPG examples + +## find example folder +file(GLOB LKMPG_Folders + "${PROJECT_SOURCE_DIR}/LKMPG/[0-9][0-9][0-9].*" + "${PROJECT_SOURCE_DIR}/LKMPG/[0-9][0-9].*" + "${PROJECT_SOURCE_DIR}/LKMPG/[0-9].*") +list(GET LKMPG_Folders 0 LKMPG_Folder) +set(LKMPG_Example_Folder "${LKMPG_Folder}/examples/") + +include_directories("${LKMPG_Example_Folder}") + +## enable debug mode +add_definitions(-DDEBUG) + +## create each c file as own module +file(GLOB LKMPG_files "${LKMPG_Example_Folder}/*.c") +foreach(module_file ${LKMPG_files}) + string(REGEX MATCH "^.+\\.c$" match_file ${module_file}) + if(NOT ${match_file}) + file(RELATIVE_PATH rel_file "${LKMPG_Example_Folder}" ${module_file} ) + string(REPLACE ".c" "" module_name ${rel_file}) + add_module("${module_name}" "${module_file}" "${KERNEL_DIR}") + endif() +endforeach() + diff --git a/examples/LKMPG b/examples/LKMPG new file mode 160000 index 0000000..6e8a272 --- /dev/null +++ b/examples/LKMPG @@ -0,0 +1 @@ +Subproject commit 6e8a27232cf2ee2ac2915989bc29d4b5fea81820