add examples

This commit is contained in:
stubbfel
2018-03-08 01:42:20 +01:00
parent 4f57d552fe
commit c25f8c3dff
3 changed files with 40 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "examples/LKMPG"]
path = examples/LKMPG
url = gitea@gitea.stubbe.rocks:3rd-party/LKMPG.git

36
examples/CMakeLists.txt Normal file
View File

@@ -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()

1
examples/LKMPG Submodule

Submodule examples/LKMPG added at 6e8a27232c