Merge remote-tracking branch 'origin/cleanup-cmake-modules' into integration_2026_w02 (!3842)
Remove unused cmake_targets files See individual commits
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
export UHD_IMAGES_DIR=$SNAP/uhd_images
|
||||
exec $@
|
||||
@@ -1,4 +0,0 @@
|
||||
src=${dir}
|
||||
obj-m += ${name}.o
|
||||
${name}-y += ${objs}
|
||||
ccflags-y += ${module_cc_opt}
|
||||
@@ -1,66 +0,0 @@
|
||||
# Analogue for standard CMake module with same name, appeared in CMake 2.8.3.
|
||||
#
|
||||
# Used for compatibility with older versions of cmake.
|
||||
|
||||
function(cmake_parse_arguments prefix options one_value_keywords multi_value_keywords)
|
||||
set(all_keywords ${options} ${one_value_keywords} ${multi_value_keywords})
|
||||
# Clear variables before parsing.
|
||||
foreach(arg ${one_value_keywords} ${multie_value_keywords})
|
||||
set(cpa_${arg})
|
||||
endforeach()
|
||||
|
||||
foreach(arg ${options})
|
||||
set(cpa_${arg} FALSE)
|
||||
endforeach()
|
||||
|
||||
set(cpa_UNPARSED_ARGUMENTS)
|
||||
|
||||
set(current_keyword)
|
||||
# Classification for current_keyword:
|
||||
# 'ONE' or 'MULTY'.
|
||||
set(current_keyword_type)
|
||||
|
||||
# now iterate over all arguments and fill the result variables
|
||||
foreach(arg ${ARGN})
|
||||
list(FIND all_keywords ${arg} keyword_index)
|
||||
|
||||
if(keyword_index EQUAL -1)
|
||||
if(current_keyword)
|
||||
if(current_keyword_type STREQUAL "ONE")
|
||||
set(cpa_${current_keyword} ${arg})
|
||||
set(current_keyword)
|
||||
else(current_keyword_type STREQUAL "ONE")
|
||||
list(APPEND cpa_${current_keyword} ${arg})
|
||||
endif(current_keyword_type STREQUAL "ONE")
|
||||
else(current_keyword)
|
||||
list(APPEND cpa_UNPARSED_ARGUMENTS ${arg})
|
||||
endif(current_keyword)
|
||||
else(keyword_index EQUAL -1)
|
||||
if(current_keyword AND current_keyword_type STREQUAL "ONE")
|
||||
message(SEND_ERROR "Value is expected for one-value-keyword ${current_keyword}")
|
||||
endif(current_keyword AND current_keyword_type STREQUAL "ONE")
|
||||
list(FIND options ${arg} option_index)
|
||||
if(option_index EQUAL -1)
|
||||
set(current_keyword ${arg})
|
||||
list(FIND one_value_keywords ${arg} one_value_index)
|
||||
if(one_value_index EQUAL -1)
|
||||
set(current_keyword_type "MULTI")
|
||||
else(one_value_index EQUAL -1)
|
||||
set(current_keyword_type "ONE")
|
||||
endif(one_value_index EQUAL -1)
|
||||
else(option_index EQUAL -1)
|
||||
set(current_keyword)
|
||||
set(cpa_${arg} TRUE)
|
||||
endif(option_index EQUAL -1)
|
||||
endif(keyword_index EQUAL -1)
|
||||
endforeach(arg ${ARGN})
|
||||
|
||||
if(current_keyword AND current_keyword_type STREQUAL "ONE")
|
||||
message(SEND_ERROR "Value is expected for one-value-keyword ${current_keyword}")
|
||||
endif(current_keyword AND current_keyword_type STREQUAL "ONE")
|
||||
|
||||
# propagate the result variables to the caller:
|
||||
foreach(keyword ${all_keywords} UNPARSED_ARGUMENTS)
|
||||
set(${prefix}_${keyword} ${cpa_${keyword}} PARENT_SCOPE)
|
||||
endforeach(keyword ${all_keywords})
|
||||
endfunction(cmake_parse_arguments prefix options one_value_keywords multi_value_keywords)
|
||||
@@ -1,48 +0,0 @@
|
||||
# - Find mysqlclient
|
||||
# Find the native MySQL includes and library
|
||||
#
|
||||
# MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
|
||||
# MYSQL_LIBRARIES - List of libraries when using MySQL.
|
||||
# MYSQL_FOUND - True if MySQL found.
|
||||
|
||||
IF (MYSQL_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
SET(MYSQL_FIND_QUIETLY TRUE)
|
||||
ENDIF (MYSQL_INCLUDE_DIR)
|
||||
|
||||
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
|
||||
/usr/local/include/mysql
|
||||
/usr/include/mysql
|
||||
)
|
||||
|
||||
SET(MYSQL_NAMES mysqlclient mysqlclient_r)
|
||||
FIND_LIBRARY(MYSQL_LIBRARY
|
||||
NAMES ${MYSQL_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
|
||||
IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
|
||||
SET(MYSQL_FOUND TRUE)
|
||||
SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )
|
||||
ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
|
||||
SET(MYSQL_FOUND FALSE)
|
||||
SET( MYSQL_LIBRARIES )
|
||||
ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
|
||||
|
||||
IF (MYSQL_FOUND)
|
||||
IF (NOT MYSQL_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
|
||||
ENDIF (NOT MYSQL_FIND_QUIETLY)
|
||||
ELSE (MYSQL_FOUND)
|
||||
IF (MYSQL_FIND_REQUIRED)
|
||||
MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
|
||||
MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
|
||||
ENDIF (MYSQL_FIND_REQUIRED)
|
||||
ENDIF (MYSQL_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MYSQL_LIBRARY
|
||||
MYSQL_INCLUDE_DIR
|
||||
)
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
# - Look for GNU Bison, the parser generator
|
||||
# Based off a news post from Andy Cedilnik at Kitware
|
||||
# Defines the following:
|
||||
# BISON_EXECUTABLE - path to the bison executable
|
||||
# BISON_FILE - parse a file with bison
|
||||
# BISON_PREFIX_OUTPUTS - Set to true to make BISON_FILE produce prefixed
|
||||
# symbols in the generated output based on filename.
|
||||
# So for ${filename}.y, you'll get ${filename}parse(), etc.
|
||||
# instead of yyparse().
|
||||
# BISON_GENERATE_DEFINES - Set to true to make BISON_FILE output the matching
|
||||
# .h file for a .c file. You want this if you're using
|
||||
# flex.
|
||||
|
||||
IF(NOT DEFINED BISON_PREFIX_OUTPUTS)
|
||||
SET(BISON_PREFIX_OUTPUTS FALSE)
|
||||
ENDIF(NOT DEFINED BISON_PREFIX_OUTPUTS)
|
||||
|
||||
IF(NOT DEFINED BISON_GENERATE_DEFINES)
|
||||
SET(BISON_GENERATE_DEFINES FALSE)
|
||||
ENDIF(NOT DEFINED BISON_GENERATE_DEFINES)
|
||||
|
||||
IF(NOT BISON_EXECUTABLE)
|
||||
MESSAGE(STATUS "Looking for bison")
|
||||
FIND_PROGRAM(BISON_EXECUTABLE bison)
|
||||
IF(BISON_EXECUTABLE)
|
||||
MESSAGE(STATUS "Looking for bison -- ${BISON_EXECUTABLE}")
|
||||
ENDIF(BISON_EXECUTABLE)
|
||||
ENDIF(NOT BISON_EXECUTABLE)
|
||||
|
||||
IF(BISON_EXECUTABLE)
|
||||
MACRO(BISON_FILE FILENAME)
|
||||
GET_FILENAME_COMPONENT(PATH "${FILENAME}" PATH)
|
||||
IF("${PATH}" STREQUAL "")
|
||||
SET(PATH_OPT "")
|
||||
ELSE("${PATH}" STREQUAL "")
|
||||
SET(PATH_OPT "/${PATH}")
|
||||
ENDIF("${PATH}" STREQUAL "")
|
||||
GET_FILENAME_COMPONENT(HEAD "${FILENAME}" NAME_WE)
|
||||
IF(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
|
||||
FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
|
||||
ENDIF(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
|
||||
IF(BISON_PREFIX_OUTPUTS)
|
||||
SET(PREFIX "${HEAD}")
|
||||
ELSE(BISON_PREFIX_OUTPUTS)
|
||||
SET(PREFIX "yy")
|
||||
ENDIF(BISON_PREFIX_OUTPUTS)
|
||||
SET(OUTFILE "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}/${HEAD}.tab.c")
|
||||
IF(BISON_GENERATE_DEFINES)
|
||||
SET(HEADER "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}/${HEAD}.tab.h")
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT "${OUTFILE}" "${HEADER}"
|
||||
COMMAND "${BISON_EXECUTABLE}"
|
||||
ARGS "--name-prefix=${PREFIX}"
|
||||
"--defines"
|
||||
"--output-file=${OUTFILE}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}")
|
||||
SET_SOURCE_FILES_PROPERTIES("${OUTFILE}" "${HEADER}" PROPERTIES GENERATED TRUE)
|
||||
SET_SOURCE_FILES_PROPERTIES("${HEADER}" PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
ELSE(BISON_GENERATE_DEFINES)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT "${OUTFILE}"
|
||||
COMMAND "${BISON_EXECUTABLE}"
|
||||
ARGS "--name-prefix=${PREFIX}"
|
||||
"--output-file=${OUTFILE}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}")
|
||||
SET_SOURCE_FILES_PROPERTIES("${OUTFILE}" PROPERTIES GENERATED TRUE)
|
||||
ENDIF(BISON_GENERATE_DEFINES)
|
||||
ENDMACRO(BISON_FILE)
|
||||
ENDIF(BISON_EXECUTABLE)
|
||||
@@ -1,46 +0,0 @@
|
||||
# - Look for GNU flex, the lexer generator.
|
||||
# Defines the following:
|
||||
# FLEX_EXECUTABLE - path to the flex executable
|
||||
# FLEX_FILE - parse a file with flex
|
||||
# FLEX_PREFIX_OUTPUTS - Set to true to make FLEX_FILE produce outputs of
|
||||
# lex.${filename}.c, not lex.yy.c . Passes -P to flex.
|
||||
|
||||
IF(NOT DEFINED FLEX_PREFIX_OUTPUTS)
|
||||
SET(FLEX_PREFIX_OUTPUTS FALSE)
|
||||
ENDIF(NOT DEFINED FLEX_PREFIX_OUTPUTS)
|
||||
|
||||
IF(NOT FLEX_EXECUTABLE)
|
||||
MESSAGE(STATUS "Looking for flex")
|
||||
FIND_PROGRAM(FLEX_EXECUTABLE flex)
|
||||
IF(FLEX_EXECUTABLE)
|
||||
MESSAGE(STATUS "Looking for flex -- ${FLEX_EXECUTABLE}")
|
||||
ENDIF(FLEX_EXECUTABLE)
|
||||
ENDIF(NOT FLEX_EXECUTABLE)
|
||||
|
||||
IF(FLEX_EXECUTABLE)
|
||||
MACRO(FLEX_FILE FILENAME)
|
||||
GET_FILENAME_COMPONENT(PATH "${FILENAME}" PATH)
|
||||
IF("${PATH}" STREQUAL "")
|
||||
SET(PATH_OPT "")
|
||||
ELSE("${PATH}" STREQUAL "")
|
||||
SET(PATH_OPT "/${PATH}")
|
||||
ENDIF("${PATH}" STREQUAL "")
|
||||
IF(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
|
||||
FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
|
||||
ENDIF(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}")
|
||||
IF(FLEX_PREFIX_OUTPUTS)
|
||||
GET_FILENAME_COMPONENT(PREFIX "${FILENAME}" NAME_WE)
|
||||
ELSE(FLEX_PREFIX_OUTPUTS)
|
||||
SET(PREFIX "yy")
|
||||
ENDIF(FLEX_PREFIX_OUTPUTS)
|
||||
SET(OUTFILE "${CMAKE_CURRENT_BINARY_DIR}${PATH_OPT}/lex.${PREFIX}.c")
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT "${OUTFILE}"
|
||||
COMMAND "${FLEX_EXECUTABLE}"
|
||||
ARGS "--prefix=${PREFIX}"
|
||||
"--outfile=${OUTFILE}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}")
|
||||
SET_SOURCE_FILES_PROPERTIES("${OUTFILE}" PROPERTIES GENERATED TRUE)
|
||||
ENDMACRO(FLEX_FILE)
|
||||
ENDIF(FLEX_EXECUTABLE)
|
||||
@@ -1,8 +0,0 @@
|
||||
# FindGCCXML
|
||||
# ----------
|
||||
find_program(GCCXML
|
||||
NAMES gccxml
|
||||
PATHS "/usr/bin"
|
||||
"usr/local/bin"
|
||||
)
|
||||
mark_as_advanced(GCCXML)
|
||||
@@ -1,105 +0,0 @@
|
||||
# - Support for building kernel modules
|
||||
|
||||
# This module defines several variables which may be used when build
|
||||
# kernel modules.
|
||||
#
|
||||
# The following variables are set here:
|
||||
# Kbuild_VERSION_STRING - kernel version.
|
||||
# Kbuild_ARCH - architecture.
|
||||
# Kbuild_BUILD_DIR - directory for build kernel and/or its components.
|
||||
# Kbuild_VERSION_{MAJOR|MINOR|TWEAK} - kernel version components
|
||||
# Kbuild_VERSION_STRING_CLASSIC - classic representation of version,
|
||||
# where parts are delimited by dots.
|
||||
#
|
||||
# Cache variables which affect on this package:
|
||||
# CMAKE_SYSTEM_VERSION - change Kbuild_VERSION_STRING
|
||||
# Also, setting CMAKE_SYSTEM_VERSION will be interpreted by cmake as crosscompile.
|
||||
#
|
||||
# Cache variables(ADVANCED) which affect on this package:
|
||||
# ARCH - if not empty, change Kbuild_ARCH
|
||||
# KBUILD_DIR - change Kbuild_BUILD_DIR
|
||||
|
||||
set(Kbuild_VERSION_STRING ${CMAKE_SYSTEM_VERSION})
|
||||
|
||||
# Form classic version view.
|
||||
string(REGEX MATCH "([0-9]+)\\.([0-9]+)[.-]([0-9]+)"
|
||||
_kernel_version_match
|
||||
"${Kbuild_VERSION_STRING}"
|
||||
)
|
||||
|
||||
if(NOT _kernel_version_match)
|
||||
message(FATAL_ERROR "Kernel version has unexpected format: ${Kbuild_VERSION_STRING}")
|
||||
endif(NOT _kernel_version_match)
|
||||
|
||||
set(Kbuild_VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(Kbuild_VERSION_MINOR ${CMAKE_MATCH_2})
|
||||
set(Kbuild_VERSION_TWEAK ${CMAKE_MATCH_3})
|
||||
# Version string for compare
|
||||
set(Kbuild_VERSION_STRING_CLASSIC "${Kbuild_VERSION_MAJOR}.${Kbuild_VERSION_MINOR}.${Kbuild_VERSION_TWEAK}")
|
||||
|
||||
set(KBUILD_DIR "/lib/modules/${Kbuild_VERSION_STRING}/build" CACHE PATH
|
||||
"Directory for build linux kernel and/or its components."
|
||||
)
|
||||
mark_as_advanced(KBUILD_DIR)
|
||||
|
||||
set(Kbuild_BUILD_DIR "${KBUILD_DIR}")
|
||||
|
||||
set(ARCH "" CACHE STRING
|
||||
"Architecture for build linux kernel components for, empty string means autodetect."
|
||||
)
|
||||
mark_as_advanced(ARCH)
|
||||
|
||||
if(NOT ARCH)
|
||||
# Autodetect arch.
|
||||
execute_process(COMMAND uname -m
|
||||
RESULT_VARIABLE uname_m_result
|
||||
OUTPUT_VARIABLE ARCH_DEFAULT
|
||||
)
|
||||
if(NOT uname_m_result EQUAL 0)
|
||||
message("'uname -m' failed:")
|
||||
message("${ARCH_DEFAULT}")
|
||||
message(FATAL_ERROR "Failed to determine system architecture.")
|
||||
endif(NOT uname_m_result EQUAL 0)
|
||||
|
||||
string(REGEX REPLACE "\n$" "" ARCH_DEFAULT "${ARCH_DEFAULT}")
|
||||
|
||||
# Pairs of pattern-replace for postprocess architecture string from
|
||||
# 'uname -m'.
|
||||
# Taken from ./Makefile of the kernel build.
|
||||
set(_kbuild_arch_replacers
|
||||
"i.86" "x86"
|
||||
"x86_64" "x86"
|
||||
"sun4u" "sparc64"
|
||||
"arm.*" "arm"
|
||||
"sa110" "arm"
|
||||
"s390x" "s390"
|
||||
"parisc64" "parisc"
|
||||
"ppc.*" "powerpc"
|
||||
"mips.*" "mips"
|
||||
"sh[234].*" "sh"
|
||||
"aarch64.*" "arm64"
|
||||
)
|
||||
|
||||
set(_current_pattern)
|
||||
foreach(p ${_kbuild_arch_replacers})
|
||||
if(_current_pattern)
|
||||
string(REGEX REPLACE "${_current_pattern}" "${p}" ARCH_DEFAULT "${ARCH_DEFAULT}")
|
||||
set(_current_pattern)
|
||||
else(_current_pattern)
|
||||
set(_current_pattern "${p}")
|
||||
endif(_current_pattern)
|
||||
endforeach(p ${_kbuild_arch_replacers})
|
||||
|
||||
set(Kbuild_ARCH "${ARCH_DEFAULT}")
|
||||
else(NOT ARCH)
|
||||
# User-provided value is used.
|
||||
set(Kbuild_ARCH "${ARCH}")
|
||||
endif(NOT ARCH)
|
||||
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Kbuild
|
||||
REQUIRED_VARS Kbuild_BUILD_DIR
|
||||
VERSION_VAR KBuild_VERSION_STRING_CLASSIC
|
||||
)
|
||||
@@ -1,4 +0,0 @@
|
||||
src=${dir}
|
||||
obj-m += ${name}.o
|
||||
${name}-y += ${objs}
|
||||
ccflags-y += ${module_cc_opt}
|
||||
@@ -1,229 +0,0 @@
|
||||
# Create rule for obtain one file by copying another one
|
||||
function(rule_copy_file target_file source_file)
|
||||
add_custom_command(OUTPUT ${target_file}
|
||||
COMMAND cp -p ${source_file} ${target_file}
|
||||
DEPENDS ${source_file}
|
||||
)
|
||||
endfunction(rule_copy_file target_file source_file)
|
||||
|
||||
# rule_copy_source([source_dir] file ...)
|
||||
#
|
||||
# Create rule for obtain file(s) in binary tree by copiing it from source tree.
|
||||
#
|
||||
# Files are given relative to ${source_dir}, if it is set, or
|
||||
# relative to ${CMAKE_CURRENT_SOURCE_DIR}.
|
||||
#
|
||||
# Files will be copied into ${CMAKE_CURRENT_BINARY_DIR} with same
|
||||
# relative paths.
|
||||
#
|
||||
# ${source_dir} should be absolute path(that is, starts from '/').
|
||||
# Otherwise first argument is treated as first file to copy.
|
||||
function(rule_copy_source file)
|
||||
string(REGEX MATCH "^/" is_abs_path ${file})
|
||||
if(is_abs_path)
|
||||
set(source_dir ${file})
|
||||
set(files ${ARGN})
|
||||
else(is_abs_path)
|
||||
set(source_dir ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(files ${file} ${ARGN})
|
||||
endif(is_abs_path)
|
||||
|
||||
foreach(file_real ${files})
|
||||
rule_copy_file("${CMAKE_CURRENT_BINARY_DIR}/${file_real}"
|
||||
${source_dir}/${file_real})
|
||||
endforeach(file_real ${files})
|
||||
endfunction(rule_copy_source file)
|
||||
|
||||
# to_abs_path(output_var path [...])
|
||||
#
|
||||
# Convert relative path of file to absolute path:
|
||||
# use path in source tree, if file already exist there.
|
||||
# otherwise use path in binary tree.
|
||||
# If initial path already absolute, return it.
|
||||
function(to_abs_path output_var)
|
||||
set(result)
|
||||
foreach(path ${ARGN})
|
||||
string(REGEX MATCH "^/" _is_abs_path ${path})
|
||||
if(_is_abs_path)
|
||||
list(APPEND result ${path})
|
||||
else(_is_abs_path)
|
||||
file(GLOB to_abs_path_file
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${path}"
|
||||
)
|
||||
if(NOT to_abs_path_file)
|
||||
set (to_abs_path_file "${CMAKE_CURRENT_BINARY_DIR}/${path}")
|
||||
endif(NOT to_abs_path_file)
|
||||
list(APPEND result ${to_abs_path_file})
|
||||
endif(_is_abs_path)
|
||||
endforeach(path ${ARGN})
|
||||
set("${output_var}" ${result} PARENT_SCOPE)
|
||||
endfunction(to_abs_path output_var path)
|
||||
|
||||
# is_path_inside_dir(output_var dir path)
|
||||
#
|
||||
# Set output_var to true if path is absolute path inside given directory.
|
||||
# NOTE: Path should be absolute.
|
||||
macro(is_path_inside_dir output_var dir path)
|
||||
file(RELATIVE_PATH _rel_path ${dir} ${path})
|
||||
string(REGEX MATCH "^\\.\\." _is_not_inside_dir ${_rel_path})
|
||||
if(_is_not_inside_dir)
|
||||
set(${output_var} "FALSE")
|
||||
else(_is_not_inside_dir)
|
||||
set(${output_var} "TRUE")
|
||||
endif(_is_not_inside_dir)
|
||||
endmacro(is_path_inside_dir output_var dir path)
|
||||
|
||||
|
||||
# Write given content to the file.
|
||||
#
|
||||
# If file is already exists and its content is same as written one, file
|
||||
# is not rewritten, so its write timestamp remains unchanged.
|
||||
function(file_update filename content)
|
||||
if(EXISTS "${filename}")
|
||||
file(READ "${filename}" old_content)
|
||||
if(old_content STREQUAL "${content}")
|
||||
return()
|
||||
endif(old_content STREQUAL "${content}")
|
||||
endif(EXISTS "${filename}")
|
||||
# File doesn't exists or its content differ.
|
||||
file(WRITE "${filename}" "${content}")
|
||||
endfunction(file_update filename content)
|
||||
|
||||
|
||||
# Write given content to the file in APPEND mode.
|
||||
#
|
||||
# For append we use position variable <pos> which should be initialized
|
||||
# to 0 for every new build process and which is updated every time when
|
||||
# this function is called.
|
||||
# If file is already exists and its content at given <pos> is same as
|
||||
# written one, file is not rewritten, so its write timestamp remains unchanged.
|
||||
#
|
||||
# Note, that file will not be rewritten if new build process issues less
|
||||
# APPEND actions than one which create file.
|
||||
# But similar problem exists for file_update() and even for built-in
|
||||
# configure_file() command: file will not be removed if new build process
|
||||
# do not call configure_file() for it.
|
||||
function(file_update_append filename content POS)
|
||||
set(pos "${${POS}}")
|
||||
string(LENGTH "${content}" len)
|
||||
# Update output variable first.
|
||||
# This allows to use return() when need not to do anything
|
||||
math(EXPR pos_new "${pos}+${len}")
|
||||
set(${POS} "${pos_new}" PARENT_SCOPE)
|
||||
if(EXISTS "${filename}")
|
||||
file(READ "${filename}" old_content LIMIT "${len}" OFFSET "${pos}")
|
||||
if(old_content STREQUAL "${content}")
|
||||
return()
|
||||
elseif(old_content STREQUAL "")
|
||||
file(APPEND "${filename}" "${content}")
|
||||
return()
|
||||
endif(old_content STREQUAL "${content}")
|
||||
else(EXISTS "${filename}")
|
||||
if(NOT pos EQUAL 0)
|
||||
message(FATAL_ERROR "Appending to non-zero position to non-existent file.")
|
||||
endif(NOT pos EQUAL 0)
|
||||
endif(EXISTS "${filename}")
|
||||
# File doesn't exists or its content differ.
|
||||
if(NOT pos EQUAL 0)
|
||||
file(READ "${filename}" prefix LIMIT "${pos}")
|
||||
else(NOT pos EQUAL 0)
|
||||
set(prefix)
|
||||
endif(NOT pos EQUAL 0)
|
||||
file(WRITE "${filename}" "${prefix}${content}")
|
||||
endfunction(file_update_append filename content POS)
|
||||
|
||||
|
||||
# Common mechanism for output status message
|
||||
# when checking different aspects.
|
||||
#
|
||||
# Normal using:
|
||||
#
|
||||
# check_begin("Checking <...>")
|
||||
# if(NOT <check-already-has-been-done>)
|
||||
# check_try() # Here message is printed
|
||||
# # Perform check(try_compile(), etc.)
|
||||
# endif(NOT <check-already-has-been-done>)
|
||||
# check_end("<check-result>") # Here message is printed with result.
|
||||
|
||||
# Should be called (unconditionally) when new cheking is issued.
|
||||
# Note, that given @status_msg is not printed at that step.
|
||||
function(check_begin status_msg)
|
||||
set(_check_status_msg ${status_msg} PARENT_SCOPE)
|
||||
set(_check_has_tries PARENT_SCOPE)
|
||||
endfunction(check_begin status_msg)
|
||||
|
||||
# Should be called before every real checking, that is which is not come
|
||||
# from cache variables comparision.
|
||||
#
|
||||
# First call of that function is trigger printing of @status_msg,
|
||||
# passed to check_begin().
|
||||
function(check_try)
|
||||
if(NOT _check_has_tries)
|
||||
message(STATUS "${_check_status_msg}")
|
||||
set(_check_has_tries "1" PARENT_SCOPE)
|
||||
endif(NOT _check_has_tries)
|
||||
endfunction(check_try)
|
||||
|
||||
# Should be called when cheking is end, and @result_msg should be short
|
||||
# description of check result.
|
||||
# If any check_try() has been issued before,
|
||||
# "@status_msg - @result_msg"
|
||||
# will be printed.
|
||||
# Otherwise,
|
||||
# "@status_msg - [cached] @result_msg"
|
||||
# will be printed, at it will be the only message for that check.
|
||||
function(check_end result_msg)
|
||||
if(NOT _check_has_tries)
|
||||
message(STATUS "${_check_status_msg} [cached] - ${result_msg}")
|
||||
else(NOT _check_has_tries)
|
||||
message(STATUS "${_check_status_msg} - ${result_msg}")
|
||||
endif(NOT _check_has_tries)
|
||||
set(_check_status_msg PARENT_SCOPE)
|
||||
set(_check_has_tries PARENT_SCOPE)
|
||||
endfunction(check_end result_msg)
|
||||
|
||||
# set_bool_string(var true_string false_string value [CACHE ... | PARENT_SCOPE])
|
||||
#
|
||||
# Set variable to one of two string according to true property of some value.
|
||||
#
|
||||
# If 'value' is true-evaluated, 'var' will be set to 'true_string',
|
||||
# otherwise to 'var' will be set to 'false_string'.
|
||||
# Like standard set(), macro accept CACHE and PARENT_SCOPE modifiers.
|
||||
#
|
||||
# Useful for form meaningful value for cache variables, contained result
|
||||
# of some operation.
|
||||
# Also may be used for form message for check_end().
|
||||
macro(set_bool_string var true_string false_string value)
|
||||
# Macro parameters are not a variables, so them cannot be tested
|
||||
# using 'if(value)'.
|
||||
# Usage 'if(${value})' leads to warnings since 2.6.4 when ${val}
|
||||
# is boolean constant
|
||||
# (because until 2.6.4 'if(value)' always dereference val).
|
||||
# So copy 'value' to local variable for test it.
|
||||
set(_set_bool_string_value ${value})
|
||||
if(_set_bool_string_value)
|
||||
set(${var} "${true_string}" ${ARGN})
|
||||
else()
|
||||
set(${var} "${false_string}" ${ARGN})
|
||||
endif()
|
||||
endmacro(set_bool_string)
|
||||
|
||||
# set_zero_string(var true_string false_string value [CACHE ... | PARENT_SCOPE])
|
||||
#
|
||||
# Set variable to one of two string according to zero property of some value.
|
||||
#
|
||||
# If 'value' is '0' (presizely), 'var' will be set to 'zero_string',
|
||||
# otherwise to 'var' will be set to 'nonzero_string'.
|
||||
# Like standard set(), macro accept CACHE and PARENT_SCOPE modifiers.
|
||||
#
|
||||
# Useful for form meaningful value for cache variables, contained result
|
||||
# of execute_process().
|
||||
# Also may be used for form message for check_end().
|
||||
macro(set_zero_string var zero_string nonzero_string value)
|
||||
set(_set_zero_string_value ${value})
|
||||
if(_set_zero_string_value EQUAL "0")
|
||||
set(${var} ${zero_string} ${ARGN})
|
||||
else()
|
||||
set(${var} ${nonzero_string} ${ARGN})
|
||||
endif()
|
||||
endmacro(set_zero_string)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,539 +0,0 @@
|
||||
set(kmodule_this_module_dir "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
||||
set(kmodule_test_sources_dir "${CMAKE_SOURCE_DIR}/cmake/kmodule_sources")
|
||||
|
||||
set(kmodule_function_map_file "")
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
if (KEDR_SYSTEM_MAP_FILE)
|
||||
set (kmodule_function_map_file "${KEDR_SYSTEM_MAP_FILE}")
|
||||
else (KEDR_SYSTEM_MAP_FILE)
|
||||
# KEDR_SYSTEM_MAP_FILE is not specified, construct the default path
|
||||
# to the symbol map file.
|
||||
set (kmodule_function_map_file
|
||||
"${KEDR_ROOT_DIR}/boot/System.map-${KBUILD_VERSION_STRING}"
|
||||
)
|
||||
endif (KEDR_SYSTEM_MAP_FILE)
|
||||
endif (CMAKE_CROSSCOMPILING)
|
||||
|
||||
# List of unreliable functions, that is, the functions that may be
|
||||
# be exported and mentioned in System.map but still cannot be used
|
||||
# because no header provides their declarations.
|
||||
set(unreliable_functions_list
|
||||
"__kmalloc_node"
|
||||
"kmem_cache_alloc_node"
|
||||
"kmem_cache_alloc_node_notrace"
|
||||
"kmem_cache_alloc_node_trace"
|
||||
)
|
||||
|
||||
# kmodule_is_function_exist(function_name RESULT_VAR)
|
||||
# Verify, whether given function exist in the kernel space on the current system.
|
||||
# RESULT_VAR is TRUE, if function_name exist in the kernel space, FALSE otherwise.
|
||||
# RESULT_VAR is cached.
|
||||
|
||||
function(kmodule_is_function_exist function_name RESULT_VAR)
|
||||
check_begin("Looking for ${function_name} in the kernel")
|
||||
if(NOT DEFINED ${RESULT_VAR})
|
||||
check_try()
|
||||
execute_process(
|
||||
COMMAND sh "${kmodule_this_module_dir}/kmodule_files/scripts/lookup_kernel_function.sh"
|
||||
${function_name} ${kmodule_function_map_file}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
RESULT_VARIABLE kmodule_is_function_exist_result
|
||||
OUTPUT_QUIET)
|
||||
|
||||
if (kmodule_is_function_exist_result EQUAL 0)
|
||||
list(FIND unreliable_functions_list ${function_name} unreliable_function_index)
|
||||
if(unreliable_function_index GREATER -1)
|
||||
# Additional verification for unreliable function
|
||||
kbuild_try_compile(kmodule_function_is_exist_reliable
|
||||
"${CMAKE_BINARY_DIR}/check_unreliable_functions/${function_name}"
|
||||
"${kmodule_test_sources_dir}/check_unreliable_functions/${function_name}.c"
|
||||
)
|
||||
if(NOT kmodule_function_is_exist_reliable)
|
||||
set(kmodule_is_function_exist_result 1)
|
||||
endif(NOT kmodule_function_is_exist_reliable)
|
||||
endif(unreliable_function_index GREATER -1)
|
||||
endif(kmodule_is_function_exist_result EQUAL 0)
|
||||
|
||||
if (kmodule_is_function_exist_result EQUAL 0)
|
||||
set(${RESULT_VAR} "TRUE" CACHE INTERNAL "Does ${function_name} exist in the kernel?")
|
||||
elseif(kmodule_is_function_exist_result EQUAL 1)
|
||||
set(${RESULT_VAR} "FALSE" CACHE INTERNAL "Does ${function_name} exist in the kernel?")
|
||||
else(kmodule_is_function_exist_result EQUAL 0)
|
||||
message(FATAL_ERROR
|
||||
"Cannot determine whether function '${function_name}' exists in the kernel"
|
||||
)
|
||||
endif(kmodule_is_function_exist_result EQUAL 0)
|
||||
endif(NOT DEFINED ${RESULT_VAR})
|
||||
set_bool_string(check_result "found" "not found" ${${RESULT_VAR}})
|
||||
check_end(${check_result})
|
||||
endfunction(kmodule_is_function_exist function_name RESULT_VAR)
|
||||
|
||||
# Creates the list of functions that actually exist on the
|
||||
# current system.
|
||||
#
|
||||
# kmodule_configure_kernel_functions(output_list
|
||||
# {[REQUIRED | OPTIONAL] {func | ONE_OF_LIST}} ...)
|
||||
#
|
||||
# ONE_OF_LIST := ONE_OF_BEGIN {func ...} ONE_OF_END
|
||||
#
|
||||
# There are 2 modes of function lookup:
|
||||
# OPTIONAL - if the function doesn't exist, it is silently ignored.
|
||||
# REQUIRED - if the function doesn't exist, FATAL_ERROR message is printed.
|
||||
#
|
||||
# Initial mode is REQUIRED, and it can be changed at any time by REQUIRED
|
||||
# and OPTIONAL keywords.
|
||||
#
|
||||
# ONE_OF_BEGIN/ONE_OF_END determine a section for which no more than one
|
||||
# function among all listed there should exist. FATAL_ERROR message is
|
||||
# printed otherwise. When mode is REQUIRED, precisely one function must
|
||||
# exist.
|
||||
# Inside this section other keywords must not be used (even another
|
||||
# ONE_OF_BEGIN).
|
||||
|
||||
function(kmodule_configure_kernel_functions output_list)
|
||||
set(kmodule_configure_kernel_functions_mode "REQUIRED")
|
||||
set(kmodule_configure_kernel_functions_one_of_section "FALSE")
|
||||
set(output_list_tmp)
|
||||
set(${output_list})
|
||||
foreach(arg ${ARGN})
|
||||
if(arg STREQUAL "REQUIRED" OR arg STREQUAL "OPTIONAL")
|
||||
if(kmodule_configure_kernel_functions_one_of_section)
|
||||
message(FATAL_ERROR
|
||||
"Inside ONE_OF_BEGIN/ONE_OF_END section, other keywords are not allowed."
|
||||
)
|
||||
endif(kmodule_configure_kernel_functions_one_of_section)
|
||||
set(kmodule_configure_kernel_functions_mode ${arg})
|
||||
elseif(arg STREQUAL "ONE_OF_BEGIN")
|
||||
if(kmodule_configure_kernel_functions_one_of_section)
|
||||
message(FATAL_ERROR "Nested ONE_OF_BEGIN/ONE_OF_END sections are not allowed.")
|
||||
endif(kmodule_configure_kernel_functions_one_of_section)
|
||||
set(kmodule_configure_kernel_functions_one_of_section "TRUE")
|
||||
set(kmodule_configure_kernel_functions_one_of_section_function)
|
||||
elseif(arg STREQUAL "ONE_OF_END")
|
||||
if(NOT kmodule_configure_kernel_functions_one_of_section)
|
||||
message(FATAL_ERROR "ONE_OF_END without ONE_OF_BEGIN is not allowed.")
|
||||
endif(NOT kmodule_configure_kernel_functions_one_of_section)
|
||||
if(kmodule_configure_kernel_functions_one_of_section_function)
|
||||
list(APPEND output_list_tmp ${kmodule_configure_kernel_functions_one_of_section_function})
|
||||
else(kmodule_configure_kernel_functions_one_of_section_function)
|
||||
if(kmodule_configure_kernel_functions_mode STREQUAL "REQUIRED")
|
||||
message(FATAL_ERROR
|
||||
"None of the functions listed in ONE_OF section exist in the kernel but it is required."
|
||||
)
|
||||
endif(kmodule_configure_kernel_functions_mode STREQUAL "REQUIRED")
|
||||
endif(kmodule_configure_kernel_functions_one_of_section_function)
|
||||
set(kmodule_configure_kernel_functions_one_of_section "FALSE")
|
||||
else(arg STREQUAL "REQUIRED" OR arg STREQUAL "OPTIONAL")
|
||||
set(kmodule_func_varname _KMODULE_IS_${arg}_EXIST)
|
||||
kedr_find_function(${arg} ${kmodule_func_varname})
|
||||
if(kmodule_configure_kernel_functions_one_of_section)
|
||||
if(${kmodule_func_varname})
|
||||
if(kmodule_configure_kernel_functions_one_of_section_function)
|
||||
message(FATAL_ERROR "Two functions from ONE_OF sections exist in the kernel.")
|
||||
else(kmodule_configure_kernel_functions_one_of_section_function)
|
||||
set(kmodule_configure_kernel_functions_one_of_section_function ${arg})
|
||||
endif(kmodule_configure_kernel_functions_one_of_section_function)
|
||||
endif(${kmodule_func_varname})
|
||||
else(kmodule_configure_kernel_functions_one_of_section)
|
||||
if(${kmodule_func_varname})
|
||||
list(APPEND output_list_tmp ${arg})
|
||||
else(${kmodule_func_varname})
|
||||
if(kmodule_configure_kernel_functions_mode STREQUAL "REQUIRED")
|
||||
message(FATAL_ERROR "Function ${arg} is not found in the kernel but it is required.")
|
||||
endif(kmodule_configure_kernel_functions_mode STREQUAL "REQUIRED")
|
||||
endif(${kmodule_func_varname})
|
||||
endif(kmodule_configure_kernel_functions_one_of_section)
|
||||
endif(arg STREQUAL "REQUIRED" OR arg STREQUAL "OPTIONAL")
|
||||
endforeach(arg ${ARGN})
|
||||
if(kmodule_configure_kernel_functions_one_of_section)
|
||||
message(FATAL_ERROR "Found ONE_OF_BEGIN without ONE_OF_END")
|
||||
endif(kmodule_configure_kernel_functions_one_of_section)
|
||||
set(${output_list} ${output_list_tmp} PARENT_SCOPE)
|
||||
endfunction(kmodule_configure_kernel_functions output_list)
|
||||
|
||||
############################################################################
|
||||
# Utility macros to check for particular features. If the particular feature
|
||||
# is supported, the macros will set the corresponding variable to TRUE,
|
||||
# otherwise - to FALSE (the name of variable is mentioned in the comments
|
||||
# for the macro).
|
||||
############################################################################
|
||||
|
||||
# Check if the system has everything necessary to build at least simple
|
||||
# kernel modules.
|
||||
# The macro sets variable 'MODULE_BUILD_SUPPORTED'.
|
||||
macro(check_module_build)
|
||||
check_begin("Checking if kernel modules can be built on this system")
|
||||
if (NOT MODULE_BUILD_SUPPORTED)
|
||||
check_try()
|
||||
kbuild_try_compile(module_build_supported_impl
|
||||
"${CMAKE_BINARY_DIR}/check_module_build"
|
||||
"${kmodule_test_sources_dir}/check_module_build/module.c"
|
||||
)
|
||||
set_bool_string(MODULE_BUILD_SUPPORTED "yes" "no" ${module_build_supported_impl}
|
||||
CACHE INTERNAL "Can kernel modules be built on this system?"
|
||||
)
|
||||
endif (NOT MODULE_BUILD_SUPPORTED)
|
||||
|
||||
check_end("${MODULE_BUILD_SUPPORTED}")
|
||||
|
||||
if (NOT MODULE_BUILD_SUPPORTED)
|
||||
message(FATAL_ERROR
|
||||
"There are problems with building kernel modules on this system. "
|
||||
"Please check that the appropriate kernel headers and build tools "
|
||||
"are installed."
|
||||
)
|
||||
endif (NOT MODULE_BUILD_SUPPORTED)
|
||||
endmacro(check_module_build)
|
||||
|
||||
# Check if reliable stack trace information can be obtained.
|
||||
# This is the case, for example, if the kernel is compiled with support
|
||||
# for frame pointers and/or stack unwind on.
|
||||
# The macro sets variable 'STACK_TRACE_RELIABLE'.
|
||||
macro(check_stack_trace)
|
||||
check_begin("Checking if stack trace information is reliable")
|
||||
if (NOT DEFINED STACK_TRACE_RELIABLE)
|
||||
check_try()
|
||||
kbuild_try_compile(stack_trace_reliable_impl
|
||||
"${CMAKE_BINARY_DIR}/check_stack_trace"
|
||||
"${kmodule_test_sources_dir}/check_stack_trace/module.c"
|
||||
)
|
||||
set_bool_string(STACK_TRACE_RELIABLE "yes" "no" ${stack_trace_reliable_impl}
|
||||
CACHE INTERNAL "Are stack traces reliable on this system?")
|
||||
endif (NOT DEFINED STACK_TRACE_RELIABLE)
|
||||
check_end("${STACK_TRACE_RELIABLE}")
|
||||
|
||||
if (NOT STACK_TRACE_RELIABLE)
|
||||
message ("\n[WARNING]\n"
|
||||
"It looks like reliable stack traces cannot be obtained on this system.\n"
|
||||
"The output of KEDR-based tools like LeakCheck will be less detailed\n"
|
||||
"(each stack trace shown will contain only one frame).\n"
|
||||
"If this is not acceptable, you could rebuild the kernel with\n"
|
||||
"CONFIG_FRAME_POINTER or CONFIG_STACK_UNWIND (if available) set to \"y\"\n"
|
||||
"and then reconfigure and rebuild KEDR.\n")
|
||||
endif (NOT STACK_TRACE_RELIABLE)
|
||||
endmacro(check_stack_trace)
|
||||
|
||||
# Check whether ring buffer is implemented by the kernel.
|
||||
# Set cache variable RING_BUFFER_IMPLEMENTED according to this checking.
|
||||
function(check_ring_buffer)
|
||||
check_begin("Checking if ring buffer is implemented in the kernel")
|
||||
|
||||
if (NOT DEFINED RING_BUFFER_IMPLEMENTED)
|
||||
check_try()
|
||||
kbuild_try_compile(ring_buffer_implemented_impl
|
||||
"${CMAKE_BINARY_DIR}/check_ring_buffer"
|
||||
"${kmodule_test_sources_dir}/check_ring_buffer/module.c"
|
||||
)
|
||||
|
||||
set_bool_string(RING_BUFFER_IMPLEMENTED "yes" "no" "${ring_buffer_implemented_impl}"
|
||||
CACHE INTERNAL "Whether ring buffer is implemented in the kernel"
|
||||
)
|
||||
endif (NOT DEFINED RING_BUFFER_IMPLEMENTED)
|
||||
check_end(${RING_BUFFER_IMPLEMENTED})
|
||||
|
||||
if (NOT RING_BUFFER_IMPLEMENTED)
|
||||
message("\n[WARNING]\nRing buffer is not supported by the system.\n"
|
||||
"The tracing facilities as well as call monitoring plugins will not be built.\n"
|
||||
"If this is not acceptable, you could rebuild the kernel with\n"
|
||||
"CONFIG_RING_BUFFER set to \"y\" and then reconfigure and rebuild KEDR.\n")
|
||||
endif (NOT RING_BUFFER_IMPLEMENTED)
|
||||
endfunction(check_ring_buffer)
|
||||
|
||||
# Check which memory allocator is used by the kernel.
|
||||
# Set KERNEL_MEMORY_ALLOCATOR to 'slab', 'slub', 'slob' or 'other'.
|
||||
#
|
||||
# Some functions in that allocators may have same names, but different signatures.
|
||||
function(check_allocator)
|
||||
check_begin("Checking which memory allocator is used by the kernel")
|
||||
if(NOT DEFINED KERNEL_MEMORY_ALLOCATOR)
|
||||
check_try()
|
||||
# Use local variable for detect allocator,
|
||||
# Cache one will be set at the end
|
||||
set(allocator "")
|
||||
if(allocator STREQUAL "")
|
||||
kbuild_try_compile(is_allocator_slab
|
||||
"${CMAKE_BINARY_DIR}/check_allocator_slab"
|
||||
"${kmodule_test_sources_dir}/check_allocator/module.c"
|
||||
KBUILD_COMPILE_DEFINITIONS "-DIS_ALLOCATOR_SLAB"
|
||||
)
|
||||
if (is_allocator_slab)
|
||||
set(allocator "slab")
|
||||
endif (is_allocator_slab)
|
||||
endif(allocator STREQUAL "")
|
||||
|
||||
if(allocator STREQUAL "")
|
||||
kbuild_try_compile(is_allocator_slub
|
||||
"${CMAKE_BINARY_DIR}/check_allocator_slub"
|
||||
"${kmodule_test_sources_dir}/check_allocator/module.c"
|
||||
KBUILD_COMPILE_DEFINITIONS "-DIS_ALLOCATOR_SLUB"
|
||||
)
|
||||
if (is_allocator_slub)
|
||||
set(allocator "slub")
|
||||
endif (is_allocator_slub)
|
||||
endif(allocator STREQUAL "")
|
||||
|
||||
if(allocator STREQUAL "")
|
||||
kbuild_try_compile(is_allocator_slob
|
||||
"${CMAKE_BINARY_DIR}/check_allocator_slob"
|
||||
"${kmodule_test_sources_dir}/check_allocator/module.c"
|
||||
KBUILD_COMPILE_DEFINITIONS "-DIS_ALLOCATOR_SLOB"
|
||||
)
|
||||
if (is_allocator_slob)
|
||||
set(allocator "slob")
|
||||
endif (is_allocator_slub)
|
||||
endif(allocator STREQUAL "")
|
||||
|
||||
if(allocator STREQUAL "")
|
||||
set(allocator "other")
|
||||
endif(allocator STREQUAL "")
|
||||
|
||||
set(KERNEL_MEMORY_ALLOCATOR "${allocator}" CACHE INTERNAL
|
||||
"Memory allocator which is used by the kernel"
|
||||
)
|
||||
endif (NOT DEFINED KERNEL_MEMORY_ALLOCATOR)
|
||||
check_end("${KERNEL_MEMORY_ALLOCATOR}")
|
||||
endfunction(check_allocator)
|
||||
|
||||
# Check if 'kfree_rcu' is available in the kernel (it is likely to be
|
||||
# a macro or an inline). If it is available, we should handle it as
|
||||
# 'free' in LeakCheck. As KEDR cannot normally intercept kfree_rcu()
|
||||
# itself, it needs to intercept call_rcu/call_rcu_sched and check their
|
||||
# arguments.
|
||||
# The macro sets variable 'HAVE_KFREE_RCU'.
|
||||
macro(check_kfree_rcu)
|
||||
check_begin("Checking if kfree_rcu() is available")
|
||||
|
||||
if (NOT DEFINED HAVE_KFREE_RCU)
|
||||
check_try()
|
||||
kbuild_try_compile(have_kfree_rcu_impl
|
||||
"${CMAKE_BINARY_DIR}/check_kfree_rcu"
|
||||
"${kmodule_test_sources_dir}/check_kfree_rcu/module.c"
|
||||
)
|
||||
|
||||
set_bool_string(HAVE_KFREE_RCU "yes" "no" ${have_kfree_rcu_impl}
|
||||
CACHE INTERNAL "Is kfree_rcu() available?"
|
||||
)
|
||||
endif ()
|
||||
check_end("${HAVE_KFREE_RCU}")
|
||||
endmacro(check_kfree_rcu)
|
||||
############################################################################
|
||||
|
||||
# Check if posix_acl_from_xattr() accepts struct user_namespace as the
|
||||
# first argument.
|
||||
# The macro sets variable 'POSIX_ACL_XATTR_HAS_USER_NS'.
|
||||
macro(check_xattr_user_ns)
|
||||
check_begin("Checking if posix_acl_from_xattr() has struct user_namespace * argument")
|
||||
if (NOT DEFINED POSIX_ACL_XATTR_HAS_USER_NS)
|
||||
check_try()
|
||||
kbuild_try_compile(have_xattr_user_ns_impl
|
||||
"${CMAKE_BINARY_DIR}/check_xattr_user_ns"
|
||||
"${kmodule_test_sources_dir}/check_xattr_user_ns/module.c"
|
||||
)
|
||||
|
||||
set_bool_string(POSIX_ACL_XATTR_HAS_USER_NS "yes" "no" ${have_xattr_user_ns_impl}
|
||||
CACHE INTERNAL "Does posix_acl_from_xattr() have struct user_namespace argument?"
|
||||
)
|
||||
endif ()
|
||||
check_end("${POSIX_ACL_XATTR_HAS_USER_NS}")
|
||||
endmacro(check_xattr_user_ns)
|
||||
############################################################################
|
||||
|
||||
# Check if hlist_for_each_entry*() macros accept only 'type *pos' argument
|
||||
# rather than both 'type *tpos' and 'hlist_node *pos' as the loop cursors.
|
||||
# The macro sets variable 'HLIST_FOR_EACH_ENTRY_POS_ONLY'.
|
||||
macro(check_hlist_for_each_entry)
|
||||
check_begin("Checking the signatures of hlist_for_each_entry*() macros")
|
||||
if (NOT DEFINED HLIST_FOR_EACH_ENTRY_POS_ONLY)
|
||||
check_try()
|
||||
kbuild_try_compile(pos_only_impl
|
||||
"${CMAKE_BINARY_DIR}/check_hlist_for_each_entry"
|
||||
"${kmodule_test_sources_dir}/check_hlist_for_each_entry/module.c"
|
||||
)
|
||||
set_bool_string(HLIST_FOR_EACH_ENTRY_POS_ONLY "yes" "no" ${pos_only_impl}
|
||||
CACHE INTERNAL
|
||||
"Do hlist_for_each_entry*() macros have only 'type *pos' to use as a loop cursor?"
|
||||
)
|
||||
endif ()
|
||||
set_bool_string(check_result "do not use additional loop cursor" "use additional loop cursor"
|
||||
${HLIST_FOR_EACH_ENTRY_POS_ONLY})
|
||||
check_end(${check_result})
|
||||
endmacro(check_hlist_for_each_entry)
|
||||
############################################################################
|
||||
|
||||
# Check if 'random32' is available in the kernel.
|
||||
# The macro sets variable 'KEDR_HAVE_RANDOM32'.
|
||||
macro(check_random32)
|
||||
check_begin("Checking if random32() is available")
|
||||
if (NOT DEFINED KEDR_HAVE_RANDOM32)
|
||||
check_try()
|
||||
kbuild_try_compile(have_random32_impl
|
||||
"${CMAKE_BINARY_DIR}/check_random32"
|
||||
"${kmodule_test_sources_dir}/check_random32/module.c"
|
||||
)
|
||||
set_bool_string(KEDR_HAVE_RANDOM32 "yes" "no" "${have_random32_impl}"
|
||||
CACHE INTERNAL "Is random32() available?"
|
||||
)
|
||||
endif ()
|
||||
check_end("${KEDR_HAVE_RANDOM32}")
|
||||
endmacro(check_random32)
|
||||
############################################################################
|
||||
|
||||
# The payload modules should call kedr_find_function() for each kernel
|
||||
# function they would like to process. If the function is not known
|
||||
# to KEDR (absent from the "function database", see "functions/" directory),
|
||||
# kedr_find_function() issues a fatal error.
|
||||
#
|
||||
# 'func_name' is the name of the function,
|
||||
# 'found_var' is the name of the output variable (the variable will evaluate
|
||||
# as "true" if found, as "false" otherwise).
|
||||
function (kedr_find_function func_name found_var)
|
||||
if (NOT DEFINED KEDR_DATA_FILE_${func_name})
|
||||
message(FATAL_ERROR "Unsupported function: ${func_name}")
|
||||
endif (NOT DEFINED KEDR_DATA_FILE_${func_name})
|
||||
|
||||
# OK, known function.
|
||||
kmodule_is_function_exist(${func_name} ${found_var})
|
||||
if (${found_var})
|
||||
# Mark the function as used by at least one payload module.
|
||||
# This can be used when preparing the tests for call interception.
|
||||
# The actual value does not matter, it only matters that this
|
||||
# variable is defined.
|
||||
set(KEDR_FUNC_USED_${func_name} "yes" CACHE INTERNAL
|
||||
"Is kernel function ${func_name} used by any payload module?")
|
||||
set(${found_var} "${${found_var}}" PARENT_SCOPE)
|
||||
else ()
|
||||
set(${found_var} "NO" PARENT_SCOPE)
|
||||
endif (${found_var})
|
||||
endfunction (kedr_find_function func_name found_var)
|
||||
|
||||
# Returns (in ${path_var}) the path to the .data file for the function
|
||||
# ${func_name}. The function must be present in the system and
|
||||
# kedr_find_function() must be called for it before kedr_get_data_for_func().
|
||||
function (kedr_get_data_for_func func_name path_var)
|
||||
if (NOT DEFINED KEDR_FUNC_USED_${func_name})
|
||||
message(FATAL_ERROR
|
||||
"Attempt to lookup data for a function that is not marked as used: "
|
||||
"${func_name}")
|
||||
endif (NOT DEFINED KEDR_FUNC_USED_${func_name})
|
||||
|
||||
set(${path_var} "${KEDR_DATA_FILE_${func_name}}" PARENT_SCOPE)
|
||||
endfunction (kedr_get_data_for_func func_name path_var)
|
||||
|
||||
# kedr_get_header_data_list(list_var func1 [func2 func3 ...])
|
||||
# Get the list of paths to the 'header.data' files for the given functions.
|
||||
# The functions must be present in the system and # kedr_find_function()
|
||||
# must be called for each of them before kedr_get_header_data_list() is
|
||||
# called.
|
||||
# The resulting list is returned in ${list_var}. It will contain at least
|
||||
# one item. It will not contain duplicates.
|
||||
function (kedr_get_header_data_list list_var)
|
||||
set(hdata_list)
|
||||
foreach (func ${ARGN})
|
||||
if (NOT DEFINED KEDR_FUNC_USED_${func})
|
||||
message(FATAL_ERROR
|
||||
"Attempt to lookup header data for a function that is not marked as used: "
|
||||
"${func}")
|
||||
endif (NOT DEFINED KEDR_FUNC_USED_${func})
|
||||
list(APPEND hdata_list "${KEDR_HEADER_DATA_FILE_${func}}")
|
||||
endforeach ()
|
||||
list(REMOVE_DUPLICATES hdata_list)
|
||||
|
||||
list(LENGTH hdata_list hdata_list_len)
|
||||
if (NOT hdata_list_len)
|
||||
message(FATAL_ERROR
|
||||
"kedr_get_header_data_list(): BUG: the output list is empty.")
|
||||
endif (NOT hdata_list_len)
|
||||
|
||||
set(${list_var} ${hdata_list} PARENT_SCOPE)
|
||||
endfunction (kedr_get_header_data_list list_var)
|
||||
|
||||
# kedr_create_header_rules(
|
||||
# header_impl_file header_data_file func1 [func2 ...])
|
||||
# Create the rules to generate ${header_impl_file} from
|
||||
# ${header_data_file} and the specific header files for the given
|
||||
# functions.
|
||||
function(kedr_create_header_rules header_impl_file header_data_file
|
||||
functions)
|
||||
set(hlist_data)
|
||||
kedr_get_header_data_list(hlist_data ${functions} ${ARGN})
|
||||
to_abs_path(hdata_files_abs ${header_data_file} ${hlist_data})
|
||||
add_custom_command(OUTPUT ${header_impl_file}
|
||||
COMMAND cat ${hdata_files_abs} > ${header_impl_file}
|
||||
DEPENDS ${hdata_files_abs}
|
||||
)
|
||||
endfunction(kedr_create_header_rules header_impl_file header_data_file
|
||||
functions)
|
||||
|
||||
# kedr_create_data_rules(func)
|
||||
# Create the rules to generate ${func}_impl.data from
|
||||
# ${func}.data (contains processing instructions specific to the current
|
||||
# payload) and the .data file from "func_db" (contains function signature).
|
||||
function(kedr_create_data_rules func)
|
||||
set(func_db_data_file)
|
||||
kedr_get_data_for_func(${func} func_db_data_file)
|
||||
|
||||
set(func_proc_data_file)
|
||||
to_abs_path(func_proc_data_file ${func}.data)
|
||||
|
||||
add_custom_command(OUTPUT "${func}_impl.data"
|
||||
COMMAND printf "\"[group]\\n\"" > "${func}_impl.data"
|
||||
COMMAND grep -E -v '\\[group\\]'
|
||||
"${func_db_data_file}" >> "${func}_impl.data"
|
||||
COMMAND printf "\"\\n\"" >> "${func}_impl.data"
|
||||
COMMAND grep -E -v '\\[group\\]'
|
||||
"${func_proc_data_file}" >> "${func}_impl.data"
|
||||
DEPENDS
|
||||
"${func_proc_data_file}"
|
||||
"${func_db_data_file}"
|
||||
)
|
||||
endfunction(kedr_create_data_rules func)
|
||||
|
||||
# kedr_create_payload_module(module_name payload_data_file template_dir)
|
||||
# Create the rules to build a payload module with the given name.
|
||||
# 'payload_data_file' defines how the kernel functions are to be processed
|
||||
# by this payload module.
|
||||
# 'template_dir' - path to the direcotry containing the templates to be used
|
||||
# to prepare the source code of the module from 'payload_data_file'.
|
||||
function(kedr_create_payload_module module_name payload_data_file
|
||||
template_dir)
|
||||
|
||||
# Rules to build the module
|
||||
kbuild_add_module(${module_name}
|
||||
"payload.c"
|
||||
"functions_support.c"
|
||||
)
|
||||
kbuild_link_module(${module_name} kedr)
|
||||
|
||||
# Rules to obtain the source files of the module
|
||||
kedr_generate("payload.c" ${payload_data_file} "${template_dir}")
|
||||
kedr_generate("functions_support.c" ${payload_data_file} "${KEDR_GEN_TEMPLATES_DIR}/functions_support.c")
|
||||
endfunction(kedr_create_payload_module module_name payload_data_file
|
||||
template_dir)
|
||||
|
||||
# kedr_create_payload_data(payload_data_file func1 [func2 ...])
|
||||
# Create .data files and the header data files for the functions and prepare
|
||||
# the main .data file (${payload_data_file}) for the payload module.
|
||||
function(kedr_create_payload_data header_data_file payload_data_file
|
||||
functions)
|
||||
set(header_impl_file "header_impl.data")
|
||||
set(functions_data)
|
||||
|
||||
foreach(func ${functions} ${ARGN})
|
||||
list(APPEND functions_data "${func}_impl.data")
|
||||
kedr_create_data_rules(${func})
|
||||
endforeach(func ${functions} ${ARGN})
|
||||
|
||||
kedr_create_header_rules(${header_impl_file} ${header_data_file}
|
||||
${functions} ${ARGN})
|
||||
|
||||
to_abs_path(payload_data_file_abs ${payload_data_file})
|
||||
to_abs_path(source_files_abs ${header_impl_file} ${functions_data})
|
||||
|
||||
set(payload_data_file_abs "${CMAKE_CURRENT_BINARY_DIR}/${payload_data_file}")
|
||||
add_custom_command(OUTPUT ${payload_data_file_abs}
|
||||
COMMAND cat ${source_files_abs} > ${payload_data_file_abs}
|
||||
DEPENDS ${source_files_abs}
|
||||
)
|
||||
endfunction(kedr_create_payload_data header_data_file payload_data_file
|
||||
functions)
|
||||
############################################################################
|
||||
@@ -1,98 +0,0 @@
|
||||
#/*
|
||||
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
# * contributor license agreements. See the NOTICE file distributed with
|
||||
# * this work for additional information regarding copyright ownership.
|
||||
# * The OpenAirInterface Software Alliance licenses this file to You under
|
||||
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
# * except in compliance with the License.
|
||||
# * You may obtain a copy of the License at
|
||||
# *
|
||||
# * http://www.openairinterface.org/?page_id=698
|
||||
# *
|
||||
# * Unless required by applicable law or agreed to in writing, software
|
||||
# * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# * See the License for the specific language governing permissions and
|
||||
# * limitations under the License.
|
||||
# *-------------------------------------------------------------------------------
|
||||
# * For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
# * contact@openairinterface.org
|
||||
# */
|
||||
|
||||
# file example_oaisim_enb_ue_mme_virtual.txt
|
||||
# brief
|
||||
# author Lionel Gauthier
|
||||
|
||||
TODO: a document file, PDF for example, with nice pictures, etc
|
||||
This example shows how to generate and launch enb, 1 ue (NAS still not virtualized in UE) in virtualised mode, mme_gw, hss executables on the same host:
|
||||
|
||||
################
|
||||
Configuration
|
||||
################
|
||||
freediameter 1.2.0 (not 1.1.5, 1.1.6,...) has to be installed and patched (done by check_install_oai_software() calling install_freediameter_from_source() in script build_helper)
|
||||
|
||||
Config File:
|
||||
/etc/hosts must contain the fqdn of the MME and HSS (same since both run on the same host):
|
||||
(assuming the realm is openair4G.eur)
|
||||
127.0.0.1 localhost
|
||||
127.0.1.1 yang.openair4G.eur yang
|
||||
...
|
||||
|
||||
################
|
||||
BUILDING, RUNNING
|
||||
################
|
||||
|
||||
Building HSS:
|
||||
yang@yang:~/openair4G/trunk/cmake_targets$ tools/build_hss -c --connect-to-mme yang.openair4G.eur -t -T --realm openair4G.eur
|
||||
|
||||
Configuring the HSS:
|
||||
In oai_db (easier for newbies to access HSS database through http://127.0.0.1/phpmyadmin)
|
||||
In table mmeidentity, enter the record corresponding to your MME:
|
||||
(idmmeidentity, mmehost, mmerealm)
|
||||
In table pdn, enter the record allowing an IMSI to connect to an APN
|
||||
In table users, enter the record corresponding to your USIM card.
|
||||
|
||||
Running the HSS:
|
||||
yang@yang:~/openair4G/trunk/cmake_targets$ sudo tools/run_hss -g
|
||||
|
||||
|
||||
|
||||
Building the MME-GW:
|
||||
yang@yang:~/openair4G/trunk/cmake_targets/tools$ ./build_epc -c -d -t -T --s6a-server
|
||||
|
||||
Configuring the MME-GW:
|
||||
You can configure in file openair4G/trunk/cmake_targets/tools/epc.local.enb.conf.in the following parameters:
|
||||
MCC/MNC of your network
|
||||
SGI interface (outgoing interface of the S/P-GW)
|
||||
Integrity algorithms, Ciphering algorithms
|
||||
Please note that DNS addresses are hardcoded in source code (TODO in list).
|
||||
|
||||
Running the MME-GW:
|
||||
yang@yang:~/openair4G/trunk/cmake_targets/tools$ sudo ./run_epc -l -g -K
|
||||
|
||||
|
||||
|
||||
Building eNB:
|
||||
yang@yang:~/openair4G/trunk/cmake_targets$ ./build_oai --oaisim
|
||||
|
||||
Configuring the eNB:
|
||||
The default configuration file for the eNB is trunk/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.generic.oaisim.local_mme.conf
|
||||
|
||||
Running eNB:
|
||||
yang@yang:~/openair4G/trunk/cmake_targets$ tools/run_enb_ue_virt_s1 -m /tmp -K /tmp/enb_ue_virt_s1_itti.log
|
||||
|
||||
|
||||
Putting some IP UL/DL traffic in the bearer:
|
||||
ping -s 1000 -m 1 192.168.12.100 -I oip1
|
||||
|
||||
|
||||
################
|
||||
Tools available:
|
||||
###############
|
||||
|
||||
1) itti_analyser (list messages exchanged between protocol layers)
|
||||
2) xforms (Layer 1)
|
||||
3) vcd (timing mesurements)
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CACHE_DIR=/mnt/oai_agent_cache
|
||||
|
||||
if [ ! -d $CACHE_DIR ]; then
|
||||
echo "Creating cache dir in $CACHE_DIR"
|
||||
sudo mkdir $CACHE_DIR
|
||||
fi
|
||||
|
||||
if grep -qs "$CACHE_DIR" /proc/mounts; then
|
||||
echo "Agent cache is already mounted"
|
||||
else
|
||||
echo "Agent cache was not mounted"
|
||||
echo "Mounting..."
|
||||
sudo mount -o size=100m -t tmpfs none "$CACHE_DIR"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Mount success"
|
||||
else
|
||||
echo "Something went wrong with the mount"
|
||||
fi
|
||||
fi
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
for i in $(seq 1 $1);
|
||||
do
|
||||
let table=1000+$i
|
||||
echo "sudo ip route add 10.0.1.0/24 dev oaitun_ue$i table $table"
|
||||
sudo ip route add 10.0.1.0/24 dev oaitun_ue$i table $table
|
||||
echo "sudo ip route add default via 10.0.1.1 dev oaitun_ue$i table $table"
|
||||
sudo ip route add default via 10.0.1.1 dev oaitun_ue$i table $table
|
||||
let octet=$i+1
|
||||
echo "sudo ip rule add from 10.0.1.$octet table $table"
|
||||
sudo ip rule add from 10.0.1.$octet table $table
|
||||
done
|
||||
Reference in New Issue
Block a user