diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000000..b06690ace61d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,148 @@ +cmake_minimum_required(VERSION 3.10) + +if(NOT (${CMAKE_VERSION} VERSION_LESS "3.13.0")) + # CMake 3.13+ has less restrictive rules for target_link_libraries() + # Until we make 3.13 as required minimum version we want to + # use old behaviour for compatibility + cmake_policy(SET CMP0079 OLD) +endif() + +# TODO: take `host` out of fw build +option(BUILD_HOST "Build host program" OFF) +option(BUILD_UNIT_TESTS "Build unit tests" OFF) + +if(BUILD_HOST) + set(ARCH host) +else() + # firmware build supports only xtensa arch for now + set(ARCH xtensa) +endif() + +# let user override built-in toolchains +if(DEFINED CMAKE_TOOLCHAIN_FILE) + set(TOOLCHAIN "${CMAKE_TOOLCHAIN_FILE}") +else() + include(scripts/cmake/${ARCH}-toolchain.cmake OPTIONAL) +endif() + +include(scripts/cmake/misc.cmake) + +project(SOF C ASM) + +# most of other options are set on per-arch and per-target basis +set(CMAKE_ASM_FLAGS -DASSEMBLY) + +# interface library that is used only as container for sof binary options +# other targets can use it to build with the same options +add_library(sof_options INTERFACE) + +target_include_directories(sof_options INTERFACE ${PROJECT_SOURCE_DIR}/src/include) + +if(BUILD_HOST) + add_subdirectory(src) + # rest of this file is not needed for host build + return() +endif() + +set(PYTHON3 python3) + +# get compiler name and version +execute_process( + COMMAND ${CMAKE_C_COMPILER} --version + COMMAND head -n 1 + OUTPUT_VARIABLE CC_VERSION_TEXT + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + +set(GENERATED_DIRECTORY ${PROJECT_BINARY_DIR}/generated) +file(MAKE_DIRECTORY ${GENERATED_DIRECTORY}/include) + +set(DOT_CONFIG_PATH ${GENERATED_DIRECTORY}/.config) +set(CONFIG_H_PATH ${GENERATED_DIRECTORY}/include/config.h) +set(VERSION_H_PATH ${GENERATED_DIRECTORY}/include/version.h) + +include(scripts/cmake/version.cmake) +sof_add_version_h_rule(${PROJECT_SOURCE_DIR}/scripts/cmake/version.cmake) + +include(scripts/cmake/defconfigs.cmake) + +# cmake itself cannot depend on files that don't exist +# so to make it regenerate when .config file is created, +# we make it depend on containing directory +# NOTE: some filesystems may be unable to watch directory change, +# in that case cmake may need to be regenerated from CLI +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS + ${GENERATED_DIRECTORY} ${DOT_CONFIG_PATH}) + +if(EXISTS ${DOT_CONFIG_PATH}) + read_kconfig_config(${DOT_CONFIG_PATH}) +endif() + +add_custom_target( + menuconfig + COMMAND ${CMAKE_COMMAND} -E env + srctree=${PROJECT_SOURCE_DIR} + CC_VERSION_TEXT=${CC_VERSION_TEXT} + ARCH=${ARCH} + ${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/menuconfig.py + ${PROJECT_SOURCE_DIR}/Kconfig + WORKING_DIRECTORY ${GENERATED_DIRECTORY} + VERBATIM + USES_TERMINAL +) + +add_custom_target( + overrideconfig + COMMAND ${CMAKE_COMMAND} -E env + srctree=${PROJECT_SOURCE_DIR} + CC_VERSION_TEXT=${CC_VERSION_TEXT} + ARCH=${ARCH} + ${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/overrideconfig.py + ${PROJECT_SOURCE_DIR}/Kconfig + ${PROJECT_BINARY_DIR}/override.config + WORKING_DIRECTORY ${GENERATED_DIRECTORY} + VERBATIM + USES_TERMINAL +) + +add_custom_command(OUTPUT ${CONFIG_H_PATH} + COMMAND ${CMAKE_COMMAND} -E env + srctree=${PROJECT_SOURCE_DIR} + CC_VERSION_TEXT=${CC_VERSION_TEXT} + ARCH=${ARCH} + ${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/genconfig.py + --header-path ${CONFIG_H_PATH} + ${PROJECT_SOURCE_DIR}/Kconfig + DEPENDS ${DOT_CONFIG_PATH} + WORKING_DIRECTORY ${GENERATED_DIRECTORY} + COMMENT "Generating ${CONFIG_H_PATH}" + VERBATIM + USES_TERMINAL +) + +add_custom_target(genconfig DEPENDS ${CONFIG_H_PATH}) + +add_dependencies(sof_options genconfig) +target_include_directories(sof_options INTERFACE ${GENERATED_DIRECTORY}/include) + +if(BUILD_UNIT_TESTS) + enable_testing() + add_subdirectory(src/arch/${ARCH}) + add_subdirectory(test) + # rest of this file is not needed for unit tests + return() +endif() + +add_library(sof_ld_flags INTERFACE) +add_library(sof_ld_scripts INTERFACE) + +# declare target with no sources to let cmake know about it +add_executable(sof "") +target_link_libraries(sof sof_options) +target_link_libraries(sof sof_ld_scripts) +target_link_libraries(sof sof_ld_flags) + +add_subdirectory(src) + +target_link_libraries(sof sof_lib) diff --git a/Kconfig b/Kconfig new file mode 100644 index 000000000000..51f7cd92ec86 --- /dev/null +++ b/Kconfig @@ -0,0 +1,57 @@ +mainmenu "SOF $(PROJECTVERSION) Configuration" + +comment "Compiler: $(CC_VERSION_TEXT)" + +config HOST_PTABLE + bool + default n + +config TASK_HAVE_PRIORITY_MEDIUM + bool + default n + +config BOOT_LOADER + bool + default n + +config IRQ_MAP + bool + default n + +config DMA_GW + bool + default n + +config MEM_WND + bool + default n + +source "src/Kconfig" + +menu "Debug" + +config GDB_DEBUG + bool "GDB Stub" + default n + help + Select for GDB debugging + +config DEBUG_HEAP + bool "Heap debug" + default n + help + Select for enable heap alloc debugging + +config DEBUG + bool "Debug build" + default n + help + Select for debug build + +config BUILD_VM_ROM + bool "Build VM ROM" + default n + help + Select if you want to build VM ROM + +endmenu diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 892cc2c08d98..000000000000 --- a/Makefile.am +++ /dev/null @@ -1,71 +0,0 @@ -if BUILD_RIMAGE -SUBDIRS = rimage -else -SUBDIRS = doc src test -endif - -ACLOCAL_AMFLAGS = -I m4 - -EXTRA_DIST = version.sh - -SRC_DIR = $(abs_top_builddir)/src - -if BUILD_HOST -export ARCH_INCDIR = \ - -I $(SRC_DIR)/arch/$(ARCH)/include - -export SOF_INCDIR = \ - -I $(SRC_DIR)/include - -if BUILD_LIB -export PLATFORM_INCDIR = \ - -I $(SRC_DIR)/library/include -endif - -else -export SOF_INCDIR = \ - -I $(SRC_DIR)/include \ - -I $(ROOT_DIR)/include - -ARCH_INCDIR = -I $(SRC_DIR)/arch/$(ARCH)/include - -if BUILD_XTENSA_SMP -ARCH_INCDIR += \ - -I $(SRC_DIR)/arch/$(ARCH)/smp/include \ - -I $(SRC_DIR)/arch/$(ARCH)/smp/xtos -else -ARCH_INCDIR += \ - -I $(SRC_DIR)/arch/$(ARCH)/up/include \ - -I $(SRC_DIR)/arch/$(ARCH)/up/xtos -endif - -export ARCH_INCDIR - -PLATFORM_INCDIR = -I $(SRC_DIR)/platform/$(PLATFORM)/include - -if XCC -PLATFORM_INCDIR += \ - -I $(ROOT_DIR)/arch/include -else -PLATFORM_INCDIR += \ - -I $(SRC_DIR)/platform/$(PLATFORM)/include/arch -endif - -export PLATFORM_INCDIR - -endif - -dist-hook: - ./version.sh $(top_srcdir) - cat .version > $(distdir)/.tarball-version - cat .version > $(distdir)/.version - -doc-dummy: - -doc: doc-dummy - $(MAKE) -C doc doc - -if !BUILD_RIMAGE -all-local: - rm -f $(top_srcdir)/src/include/version.h -endif diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 62683b0b3db0..000000000000 --- a/autogen.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -rm -f .build -if [ ! -f .git/hooks/pre-commit ]; then - ln -s -f ../../scripts/sof-pre-commit-hook.sh .git/hooks/pre-commit -fi -if [ ! -f .git/hooks/post-commit ]; then - ln -s -f ../../scripts/sof-post-commit-hook.sh .git/hooks/post-commit -fi -libtoolize -c --force -aclocal -I m4 --install -autoconf -Wall -autoheader -automake -a --copy --foreign --add-missing diff --git a/configure.ac b/configure.ac deleted file mode 100644 index c656f778ccb6..000000000000 --- a/configure.ac +++ /dev/null @@ -1,686 +0,0 @@ -AC_PREREQ([2.69]) -AC_INIT([sof],[m4_esyscmd(./version.sh)],[sound-open-firmware@alsa-project.org]) -AC_CONFIG_SRCDIR([src/init/init.c]) -AC_CONFIG_HEADERS([src/include/config.h]) -AC_CONFIG_MACRO_DIRS([m4]) -AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability subdir-objects silent-rules color-tests dist-xz tar-ustar]) - -# Initialize maintainer mode -AM_MAINTAINER_MODE([enable]) - -# get version info from git -m4_define(sof_major, `cat .version | cut -dv -f2 | cut -d. -f1`) -m4_define(sof_minor, `cat .version | cut -d. -f2 | cut -d- -f1`) -m4_define(sof_micro, `cat .version | cut -d. -f3 | cut -d- -f1`) -AC_DEFINE_UNQUOTED([SOF_MAJOR], sof_major, [Sof major version]) -AC_DEFINE_UNQUOTED([SOF_MINOR], sof_minor, [Sof minor version]) - -# micr version can sometimes be NULL, so make it 0 -if test sof_micro != ""; then - AC_DEFINE_UNQUOTED([SOF_MICRO], sof_micro, [Sof micro version]) -else - AC_DEFINE_UNQUOTED([SOF_MICRO], 0, [Sof micro version]) -fi - -AC_CANONICAL_HOST - -# Macro to set flag if supported -AC_DEFUN([ADD_OPTIONAL_AM_CFLAGS], - [SAVED_CFLAGS="$CFLAGS" - CFLAGS="-Werror $1" - AC_MSG_CHECKING([whether $CC supports $1]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], - [AC_MSG_RESULT([yes])] - [AM_CFLAGS="$AM_CFLAGS $1"], - [AC_MSG_RESULT([no])]) - CFLAGS="$SAVED_CFLAGS"]) - -# General assembler flags -ASFLAGS="-DASSEMBLY" -AC_SUBST(ASFLAGS) - -# Cross compiler tool libgcc and headers -AC_ARG_WITH([root-dir], - AS_HELP_STRING([--with-root-dir], [Specify location of cross gcc libraries and headers]), - [], [with_root_dir=no]) - -# MEU location -AC_ARG_WITH([meu], - AS_HELP_STRING([--with-meu], [Specify location of MEU tool]), - [], [with_meu=no]) -if test "x$with_meu" != "xno"; then - MEU_PATH="$with_meu" - AC_SUBST(MEU_PATH) - - MEU_VERSION=$($with_meu/meu -ver | grep "Version:" | cut -d" " -f6) - AX_COMPARE_VERSION([$MEU_VERSION], [ge], [12.0.0.1035], [MEU_OFFSET=1088], [MEU_OFFSET=1152]) - AC_SUBST(MEU_OFFSET) -fi -AM_CONDITIONAL(USE_MEU, test "x$with_meu" != "xno") - -# Private key location -AC_ARG_WITH([key], - AS_HELP_STRING([--with-key], [Specify location of private key]), - [], [with_key=no]) -if test "x$with_meu" != "xno"; then - if test "x$with_key" != "xno"; then - PRIVATE_KEY="$with_key" - AC_SUBST(PRIVATE_KEY) - else - AC_MSG_ERROR([Private key location not specified]) - fi -fi - -#check if we should enable debug build -AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug],[enable debug, default: no])], enable_debug=$enableval, enable_debug=no) -if test "$enable_debug" = "yes"; then - AC_DEFINE([DEBUG_BUILD], [1], [Configure to build debug version]) -fi - -# check if we are building ROMs -AC_ARG_ENABLE(roms, [AS_HELP_STRING([--enable-roms],[build roms])], have_roms=$enableval, have_roms=no) -if test "$have_roms" = "yes"; then - AC_DEFINE([CONFIG_ENABLE_ROMS], [1], [Enable building ROMs for QEMU]) -fi - -# check if we should enable GDB debugging -AC_ARG_ENABLE(gdb_debug, [AS_HELP_STRING([--enable-gdb-debug],[gdb debug supported])], enable_gdb_debug=$enableval, enable_gdb_debug=no) -if test "$enable_gdb_debug" = "yes"; then - AC_DEFINE([CONFIG_GDB_DEBUG], [1], [Enable debugging with GDB]) -fi - -# check if we should enable heap alloc debugging -AC_ARG_ENABLE(heap_debug, [AS_HELP_STRING([--enable-heap-debug],[heap debug supported])], enable_heap_debug=$enableval, enable_heap_debug=no) -if test "$enable_heap_debug" = "yes"; then - AC_DEFINE([CONFIG_DEBUG_HEAP], [1], [Enable debugging of heap allocations]) -fi - -# check if we are building FW image or library -AC_ARG_ENABLE(library, [AS_HELP_STRING([--enable-library],[build library])], have_library=$enableval, have_library=no) -if test "$have_library" = "yes"; then - AC_DEFINE([CONFIG_LIB], [1], [Configure for Shared Library]) -fi -AM_CONDITIONAL(BUILD_LIB, test "$have_library" = "yes") - -# check if we are building tools -AC_ARG_ENABLE(rimage, [AS_HELP_STRING([--enable-rimage],[build rimage tool])], have_rimage=$enableval, have_rimage=no) -IMPLICIT_FALLTHROUGH_FLAG="" -if test "$have_rimage" = "yes"; then - AC_DEFINE([CONFIG_RIMAGE], [1], [Configure to build rimage]) - AM_CFLAGS="-O2 -g -Wall -Werror -Wl,-EL -Wmissing-prototypes" - IMPLICIT_FALLTHROUGH_FLAG="-Wimplicit-fallthrough=3" -fi -AM_CONDITIONAL(BUILD_RIMAGE, test "$have_rimage" = "yes") - -# check if we are building docs -AC_ARG_ENABLE(doc, [AS_HELP_STRING([--enable-doc],[build doc])], have_doc=$enableval, have_doc=no) -if test "$have_doc" = "yes"; then - AC_DEFINE([CONFIG_DOC], [1], [Configure to build doc]) -fi -AM_CONDITIONAL(BUILD_DOC, test "$have_doc" = "yes") - -# Disable DMIC driver if requested, by default build for supported platforms -AC_ARG_ENABLE([dmic], AS_HELP_STRING([--disable-dmic], [Disable DMIC driver])) -AS_IF([test "x$enable_dmic" != "xno"], [ - AC_DEFINE([CONFIG_DMIC], [1], [Configure to build DMIC driver]) -]) - -# Architecture support -AC_ARG_WITH([arch], - AS_HELP_STRING([--with-arch], [Specify DSP architecture]), - [], [with_arch=no]) - -case "$with_arch" in - xtensa*) - - ARCH_CFLAGS="-mtext-section-literals" - - ARCH_LDFLAGS="-nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static" - - # automake FLAGS defined here - AM_CFLAGS="-fno-inline-functions -nostdlib -mlongcalls" - AM_LDFLAGS="" - AM_CCASFLAGS="" - - # GCC needs these additional flags on top of any user flags. - CFLAGS="${CFLAGS:+$CFLAGS } -O2 -g -Wall -Werror -Wl,-EL -Wmissing-prototypes" - LDFLAGS="${LDFLAGS:+$LDFLAGS } -nostdlib" - CCASFLAGS="${CCASFLAGS:+$CCASFLAGS } -fno-inline-functions -nostdlib -mlongcalls" - - ARCH="xtensa" - AC_SUBST(ARCH) - - AS_IF([test "x$with_root_dir" = xno], - AC_MSG_ERROR([Please specify cross compiler root header directory]), - [ROOT_DIR=$with_root_dir]) - AC_SUBST(ROOT_DIR) - ;; - host*) - - ARCH_CFLAGS="-g" - - # automake FLAGS defined here - AM_CFLAGS="-O3 -Wall -Werror -Wl,-EL -Wmissing-prototypes" - IMPLICIT_FALLTHROUGH_FLAG="-Wimplicit-fallthrough=3" - AM_LDFLAGS="-lpthread" - AM_CCASFLAGS="-O3 -Wall -Werror -Wl,-EL -Wmissing-prototypes" - - ARCH="host" - AC_SUBST(ARCH) - AC_DEFINE([CONFIG_HOST], [1], [Configure for Host]) - ;; - *) - if test "$have_rimage" = "no" && test "$have_doc" = "no" ; then - AC_MSG_ERROR([DSP architecture not specified]) - fi - ;; -esac - -ADD_OPTIONAL_AM_CFLAGS([-Wimplicit-fallthrough=3]) - -AC_SUBST(ARCH_CFLAGS) -AC_SUBST(ARCH_LDFLAGS) - -AC_SUBST(AM_CFLAGS) -AC_SUBST(AM_LDFLAGS) -AC_SUBST(AM_CCASFLAGS) - -AM_CONDITIONAL(BUILD_XTENSA, test "$ARCH" = "xtensa") -AM_CONDITIONAL(BUILD_HOST, test "$ARCH" = "host") - -# check for xtensa extension -AM_CONDITIONAL(BUILD_XTENSA_SMP, test "$with_arch" = "xtensa-smp") - -# Cmocka tests -AC_ARG_WITH([cmocka-prefix], - AS_HELP_STRING([--with-cmocka-prefix], [Path to cmocka]), - [], [with_cmocka_prefix="no"]) - -# in case of native build, cmocka may be installed -HAVE_CMOCKA_PKG=no -AC_CHECK_LIB(cmocka, _cmocka_run_group_tests, [HAVE_CMOCKA_PKG=yes]) - -if test "x$with_arch" != "xno"; then - if test "x$with_cmocka_prefix" = "xno"; then - if test "$ARCH" = "xtensa"; then - AC_MSG_WARN([Need cmocka to run unit tests. Path to cmocka not specified. Please use --with-cmocka-prefix option.]) - elif test "x$HAVE_CMOCKA_PKG" = "xno"; then - AC_MSG_WARN([Need cmocka to run unit tests. No cmocka library found. Please install cmocka or use --with-cmocka-prefix option.]) - fi - else - CMOCKA_PREFIX="$with_cmocka_prefix" - AC_SUBST(CMOCKA_PREFIX) - fi -fi - -AM_CONDITIONAL(HAVE_CMOCKA_PREFIX, test "x$with_cmocka_prefix" != "xno") - -# Platform support -AC_ARG_WITH([platform], - AS_HELP_STRING([--with-platform], [Specify Host Platform]), - [], [with_platform=no]) - -case "$with_platform" in - baytrail*) - - PLATFORM_LDSCRIPT="baytrail.x" - AC_SUBST(PLATFORM_LDSCRIPT) - - PLATFORM="baytrail" - AC_SUBST(PLATFORM) - - FW_NAME="byt" - AC_SUBST(FW_NAME) - - XTENSA_CORE="hifiep_bd5" - AC_SUBST(XTENSA_CORE) - - AC_DEFINE([CONFIG_BAYTRAIL], [1], [Configure for Baytrail]) - AC_DEFINE([CONFIG_HOST_PTABLE], [1], [Configure handling host page table]) - AC_DEFINE([CONFIG_TASK_HAVE_PRIORITY_MEDIUM], [1], [Configure handling medium priority task]) - ;; - cherrytrail*) - - PLATFORM_LDSCRIPT="baytrail.x" - AC_SUBST(PLATFORM_LDSCRIPT) - - PLATFORM="baytrail" - AC_SUBST(PLATFORM) - - FW_NAME="cht" - AC_SUBST(FW_NAME) - - XTENSA_CORE="hifiep_bd5" - AC_SUBST(XTENSA_CORE) - - AC_DEFINE([CONFIG_CHERRYTRAIL], [1], [Configure for Cherrytrail]) - AC_DEFINE([CONFIG_HOST_PTABLE], [1], [Configure handling host page table]) - AC_DEFINE([CONFIG_TASK_HAVE_PRIORITY_MEDIUM], [1], [Configure handling medium priority task]) - ;; - apollolake*) - - PLATFORM_LDSCRIPT="apollolake.x" - AC_SUBST(PLATFORM_LDSCRIPT) - - PLATFORM="apollolake" - AC_SUBST(PLATFORM) - - FW_NAME="apl" - AC_SUBST(FW_NAME) - - XTENSA_CORE="hifi3_std" - AC_SUBST(XTENSA_CORE) - - AC_DEFINE([CONFIG_APOLLOLAKE], [1], [Configure for Apollolake]) - AC_DEFINE([CONFIG_BOOT_LOADER], [1], [Configure Boot Loader]) - AC_DEFINE([CONFIG_IRQ_MAP], [1], [Configure IRQ maps]) - AC_DEFINE([CONFIG_DMA_GW], [1], [Configure DMA Gateway]) - AC_DEFINE([CONFIG_MEM_WND], [1], [Configure Memory Windows]) - AC_DEFINE([CONFIG_TASK_HAVE_PRIORITY_MEDIUM], [1], [Configure handling medium priority task]) - ;; - kabylake*) - - PLATFORM_LDSCRIPT="apollolake.x" - AC_SUBST(PLATFORM_LDSCRIPT) - - PLATFORM="apollolake" - AC_SUBST(PLATFORM) - - FW_NAME="kbl" - AC_SUBST(FW_NAME) - - XTENSA_CORE="hifi3_std" - AC_SUBST(XTENSA_CORE) - - AC_DEFINE([CONFIG_APOLLOLAKE], [1], [Configure for Apollolake]) - AC_DEFINE([CONFIG_BOOT_LOADER], [1], [Configure Boot Loader]) - AC_DEFINE([CONFIG_IRQ_MAP], [1], [Configure IRQ maps]) - AC_DEFINE([CONFIG_DMA_GW], [1], [Configure DMA Gateway]) - AC_DEFINE([CONFIG_MEM_WND], [1], [Configure Memory Windows]) - AC_DEFINE([CONFIG_TASK_HAVE_PRIORITY_MEDIUM], [1], [Configure handling medium priority task]) - ;; - skylake*) - - PLATFORM_LDSCRIPT="apollolake.x" - AC_SUBST(PLATFORM_LDSCRIPT) - - PLATFORM="apollolake" - AC_SUBST(PLATFORM) - - FW_NAME="skl" - AC_SUBST(FW_NAME) - - XTENSA_CORE="hifi3_std" - AC_SUBST(XTENSA_CORE) - - AC_DEFINE([CONFIG_APOLLOLAKE], [1], [Configure for Apollolake]) - AC_DEFINE([CONFIG_BOOT_LOADER], [1], [Configure Boot Loader]) - AC_DEFINE([CONFIG_IRQ_MAP], [1], [Configure IRQ maps]) - AC_DEFINE([CONFIG_DMA_GW], [1], [Configure DMA Gateway]) - AC_DEFINE([CONFIG_MEM_WND], [1], [Configure Memory Windows]) - AC_DEFINE([CONFIG_TASK_HAVE_PRIORITY_MEDIUM], [1], [Configure handling medium priority task]) - ;; - haswell*) - - PLATFORM_LDSCRIPT="haswell.x" - AC_SUBST(PLATFORM_LDSCRIPT) - - PLATFORM="haswell" - AC_SUBST(PLATFORM) - - FW_NAME="hsw" - AC_SUBST(FW_NAME) - - XTENSA_CORE="hifiep_bd5" - AC_SUBST(XTENSA_CORE) - - AC_DEFINE([CONFIG_HASWELL], [1], [Configure for Haswell]) - AC_DEFINE([CONFIG_HOST_PTABLE], [1], [Configure handling host page table]) - ;; - broadwell*) - - PLATFORM_LDSCRIPT="haswell.x" - AC_SUBST(PLATFORM_LDSCRIPT) - - PLATFORM="haswell" - AC_SUBST(PLATFORM) - - FW_NAME="bdw" - AC_SUBST(FW_NAME) - - XTENSA_CORE="hifiep_bd5" - AC_SUBST(XTENSA_CORE) - - AC_DEFINE([CONFIG_BROADWELL], [1], [Configure for Broadwell]) - AC_DEFINE([CONFIG_HOST_PTABLE], [1], [Configure handling host page table]) - ;; - cannonlake*) - - PLATFORM_LDSCRIPT="cannonlake.x" - AC_SUBST(PLATFORM_LDSCRIPT) - - PLATFORM="cannonlake" - AC_SUBST(PLATFORM) - - FW_NAME="cnl" - AC_SUBST(FW_NAME) - - XTENSA_CORE="hifi4_std" - AC_SUBST(XTENSA_CORE) - - AC_DEFINE([CONFIG_CANNONLAKE], [1], [Configure for Cannonlake]) - AC_DEFINE([CONFIG_BOOT_LOADER], [1], [Configure Boot Loader]) - AC_DEFINE([CONFIG_IRQ_MAP], [1], [Configure IRQ maps]) - AC_DEFINE([CONFIG_DMA_GW], [1], [Configure DMA Gateway]) - AC_DEFINE([CONFIG_MEM_WND], [1], [Configure Memory Windows]) - AC_DEFINE([CONFIG_TASK_HAVE_PRIORITY_MEDIUM], [1], [Configure handling medium priority task]) - ;; - suecreek*) - - PLATFORM_LDSCRIPT="suecreek.x" - AC_SUBST(PLATFORM_LDSCRIPT) - - PLATFORM="suecreek" - AC_SUBST(PLATFORM) - - FW_NAME="sue" - AC_SUBST(FW_NAME) - - XTENSA_CORE="hifi4_std" - AC_SUBST(XTENSA_CORE) - - AC_DEFINE([CONFIG_SUECREEK], [1], [Configure for Suecreek]) - AC_DEFINE([CONFIG_BOOT_LOADER], [1], [Configure Boot Loader]) - AC_DEFINE([CONFIG_IRQ_MAP], [1], [Configure IRQ maps]) - AC_DEFINE([CONFIG_TASK_HAVE_PRIORITY_MEDIUM], [1], [Configure handling medium priority task]) - ;; - icelake*) - - PLATFORM_LDSCRIPT="icelake.x" - AC_SUBST(PLATFORM_LDSCRIPT) - - PLATFORM="icelake" - AC_SUBST(PLATFORM) - - FW_NAME="icl" - AC_SUBST(FW_NAME) - - XTENSA_CORE="hifi4_std" - AC_SUBST(XTENSA_CORE) - - AC_DEFINE([CONFIG_ICELAKE], [1], [Configure for Icelake]) - AC_DEFINE([CONFIG_BOOT_LOADER], [1], [Configure Boot Loader]) - AC_DEFINE([CONFIG_IRQ_MAP], [1], [Configure IRQ maps]) - AC_DEFINE([CONFIG_DMA_GW], [1], [Configure DMA Gateway]) - AC_DEFINE([CONFIG_MEM_WND], [1], [Configure Memory Windows]) - AC_DEFINE([CONFIG_TASK_HAVE_PRIORITY_MEDIUM], [1], [Configure handling medium priority task]) - ;; - *) - if test "$have_rimage" = "no" && test "$have_doc" = "no"; then - if test "$ARCH" = "host"; then - PLATFORM="host" - AC_SUBST(PLATFORM) - else - AC_MSG_ERROR([Host platform not specified]) - fi - fi - ;; -esac - -AM_CONDITIONAL(BUILD_BAYTRAIL, test "$FW_NAME" = "byt") -AM_CONDITIONAL(BUILD_CHERRYTRAIL, test "$FW_NAME" = "cht") -AM_CONDITIONAL(BUILD_HASWELL, test "$FW_NAME" = "hsw") -AM_CONDITIONAL(BUILD_BROADWELL, test "$FW_NAME" = "bdw") -AM_CONDITIONAL(BUILD_APOLLOLAKE, test "$FW_NAME" = "apl" -o "$FW_NAME" = "skl" -o "$FW_NAME" = "kbl") -AM_CONDITIONAL(BUILD_CANNONLAKE, test "$FW_NAME" = "cnl") -AM_CONDITIONAL(BUILD_SUECREEK, test "$FW_NAME" = "sue") -AM_CONDITIONAL(BUILD_ICELAKE, test "$FW_NAME" = "icl") -AM_CONDITIONAL(BUILD_BOOTLOADER, test "$FW_NAME" = "apl" -o "$FW_NAME" = "cnl" -o "$FW_NAME" = "icl" -o "$FW_NAME" = "sue" -o "$FW_NAME" = "skl" -o "$FW_NAME" = "kbl") -AM_CONDITIONAL(BUILD_CAVS, test "$FW_NAME" = "apl" -o "$FW_NAME" = "cnl" -o "$FW_NAME" = "icl" -o "$FW_NAME" = "sue" -o "$FW_NAME" = "skl" -o "$FW_NAME" = "kbl") -AM_CONDITIONAL(BUILD_MODULE, test "$FW_NAME" = "apl" -o "$FW_NAME" = "cnl" -o "$FW_NAME" = "icl" -o "$FW_NAME" = "sue" -o "$FW_NAME" = "skl" -o "$FW_NAME" = "kbl") -AM_CONDITIONAL(BUILD_APL_SSP, test "$FW_NAME" = "apl" -o "$FW_NAME" = "cnl" -o "$FW_NAME" = "icl" -o "$FW_NAME" = "sue" -o "$FW_NAME" = "skl" -o "$FW_NAME" = "kbl") -AM_CONDITIONAL(BUILD_VM_ROM, (test "$have_roms" = "yes") && (test "$FW_NAME" = "apl" -o "$FW_NAME" = "cnl" -o "$FW_NAME" = "icl" -o "$FW_NAME" = "sue" -o "$FW_NAME" = "skl" -o "$FW_NAME" = "kbl")) - - -# DSP core support (Optional) -AC_ARG_WITH([dsp-core], - AS_HELP_STRING([--with-dsp-core], [Specify DSP Core]), - [], [with_dsp_core=no]) - -case "$with_dsp_core" in - *) - XTENSA_CORE="$with_dsp_core" - AC_SUBST(XTENSA_CORE) - ;; - -esac - -PLATFORM_ROM_LDSCRIPT="rom.x" -AC_SUBST(PLATFORM_ROM_LDSCRIPT) - -PLATFORM_BOOT_LDR_LDSCRIPT="boot_ldr.x" -AC_SUBST(PLATFORM_BOOT_LDR_LDSCRIPT) - -# Optimisation settings and checks - -# SSE4_2 support -AC_ARG_ENABLE(sse42, [AS_HELP_STRING([--enable-sse42],[enable SSE42 optimizations])], have_sse42=$enableval, have_sse42=yes) -AX_CHECK_COMPILE_FLAG(-msse4.2, [SSE42_CFLAGS="-DOPS_SSE42 -msse4.2 -ffast-math -ftree-vectorizer-verbose=0"], - [have_sse42=no]) -if test "$have_sse42" = "yes"; then - AC_DEFINE(HAVE_SSE42,1,[Define to enable SSE42 optimizations.]) -fi -AM_CONDITIONAL(HAVE_SSE42, test "$have_sse42" = "yes") -AC_SUBST(SSE42_CFLAGS) - -# AVX support -AC_ARG_ENABLE(avx, [AS_HELP_STRING([--enable-avx],[enable AVX optimizations])], have_avx=$enableval, have_avx=yes) -AX_CHECK_COMPILE_FLAG(-mavx, [AVX_CFLAGS="-DOPS_AVX -mavx -ffast-math -ftree-vectorizer-verbose=0"], - [have_avx=no]) -if test "$have_avx" = "yes"; then - AC_DEFINE(HAVE_AVX,1,[Define to enable AVX optimizations.]) -fi -AM_CONDITIONAL(HAVE_AVX, test "$have_avx" = "yes") -AC_SUBST(AVX_CFLAGS) - - -# AVX2 support -AC_ARG_ENABLE(avx2, [AS_HELP_STRING([--enable-avx2],[enable AVX2 optimizations])], have_avx2=$enableval, have_avx2=yes) -AX_CHECK_COMPILE_FLAG(-mavx2, [AVX2_CFLAGS="-DOPS_AVX2 -mavx2 -ffast-math -ftree-vectorizer-verbose=0"], - [have_avx2=no]) -if test "$have_avx2" = "yes"; then - AC_DEFINE(HAVE_AVX2,1,[Define to enable AVX2 optimizations.]) -fi -AM_CONDITIONAL(HAVE_AVX2, test "$have_avx2" = "yes") -AC_SUBST(AVX2_CFLAGS) - - -# FMA support -AC_ARG_ENABLE(fma, [AS_HELP_STRING([--enable-fma],[enable FMA optimizations])], have_fma=$enableval, have_fma=yes) -AX_CHECK_COMPILE_FLAG(-mfma, [FMA_CFLAGS="-DOPS_FMA -mfma -ffast-math -ftree-vectorizer-verbose=0"], - [have_fma=no]) -if test "$have_fma" = "yes"; then - AC_DEFINE(HAVE_FMA,1,[Define to enable FMA optimizations.]) -fi -AM_CONDITIONAL(HAVE_FMA, test "$have_fma" = "yes") -AC_SUBST(FMA_CFLAGS) - -# Hifi2EP -AC_ARG_ENABLE(hifi2ep, [AS_HELP_STRING([--enable-hifi2ep],[enable HiFi2EP optimizations])], have_hifi2ep=$enableval, have_hifi2ep=yes) -AX_CHECK_COMPILE_FLAG(-mhifi2ep, [FMA_CFLAGS="-DOPS_HIFI2EP -mhifi2ep -ffast-math -ftree-vectorizer-verbose=0"], - [have_hifi2ep=no]) -if test "$have_hifi2ep" = "yes"; then - AC_DEFINE(HAVE_HIFI2EP,1,[Define to enable Hifi2 EP optimizations.]) -fi -AM_CONDITIONAL(HAVE_HIFI2EP, test "$have_hifi2ep" = "yes") -AC_SUBST(HIFI2EP_CFLAGS) - -# Hifi3 -AC_ARG_ENABLE(hifi3, [AS_HELP_STRING([--enable-hifi3],[enable HiFi3 optimizations])], have_hifi3=$enableval, have_hifi3=yes) -AX_CHECK_COMPILE_FLAG(-mhihi3, [FMA_CFLAGS="-DOPS_HIFI3 -mhifi3 -ffast-math -ftree-vectorizer-verbose=0"], - [have_hifi3=no]) -if test "$have_hifi3" = "yes"; then - AC_DEFINE(HAVE_HIFI3,1,[Define to enable Hifi3 optimizations.]) -fi -AM_CONDITIONAL(HAVE_HIFI3, test "$have_hifi3" = "yes") -AC_SUBST(HIFI3_CFLAGS) - -# Test after CFLAGS set othewise test of cross compiler fails. -AM_PROG_AS -AM_PROG_AR -AC_PROG_CC -LT_INIT -AC_CHECK_TOOL([OBJCOPY], [objcopy], []) -AC_CHECK_TOOL([OBJDUMP], [objdump], []) - -# Check for openssl - used by rimage -AC_CHECK_LIB([crypto], [OPENSSL_config], , [have_openssl="no"]) -if test "$have_rimage" = "yes"; then - if test "$have_openssl" = "no"; then - AC_MSG_ERROR([Need OpenSSL libcrypto for rimage code signing]) - fi -fi - -if test "x$prefix" == "xNONE"; then -PEM_KEY_PREFIX="/usr/local/share/rimage" -else -PEM_KEY_PREFIX=$prefix"/share/rimage" -fi -AC_DEFINE_UNQUOTED([PEM_KEY_PREFIX], ["$PEM_KEY_PREFIX"], ["Path for PEM keys"]) -AC_SUBST(PEM_KEY_PREFIX) - -# Check for doxygen and graphviz - used by make doc -AC_CHECK_PROG(have_doxygen, doxygen, true, false) -if test "$have_doxygen" = "false"; then - AC_MSG_WARN([Need doxygen to build documentation]) -fi -AC_CHECK_PROG(have_graphviz, dot, true, false) -if test "$have_graphviz" = "false"; then - AC_MSG_WARN([Need graphviz to build documentation]) -fi - -# Check for compiler type -AM_CONDITIONAL(XCC, test "$CC" = "xt-xcc") - -AM_EXTRA_RECURSIVE_TARGETS([bin]) - -AM_EXTRA_RECURSIVE_TARGETS([vminstall]) - -AC_CONFIG_FILES([ - Makefile - rimage/Makefile - rimage/keys/Makefile - doc/Makefile - src/Makefile - src/tasks/Makefile - src/init/Makefile - src/arch/Makefile - src/arch/xtensa/Makefile - src/arch/xtensa/include/Makefile - src/arch/xtensa/include/arch/Makefile - src/arch/xtensa/include/xtensa/Makefile - src/arch/xtensa/include/xtensa/config/Makefile - src/arch/xtensa/smp/Makefile - src/arch/xtensa/smp/hal/Makefile - src/arch/xtensa/smp/include/Makefile - src/arch/xtensa/smp/include/arch/Makefile - src/arch/xtensa/smp/xtos/Makefile - src/arch/xtensa/up/Makefile - src/arch/xtensa/up/hal/Makefile - src/arch/xtensa/up/include/Makefile - src/arch/xtensa/up/include/arch/Makefile - src/arch/xtensa/up/xtos/Makefile - src/arch/host/Makefile - src/arch/host/include/Makefile - src/arch/host/include/arch/Makefile - src/audio/Makefile - src/math/Makefile - src/drivers/Makefile - src/drivers/intel/Makefile - src/drivers/intel/baytrail/Makefile - src/drivers/intel/haswell/Makefile - src/drivers/intel/cavs/Makefile - src/include/Makefile - src/include/sof/Makefile - src/include/sof/audio/Makefile - src/include/sof/audio/coefficients/Makefile - src/include/sof/audio/coefficients/src/Makefile - src/include/sof/drivers/Makefile - src/include/sof/math/Makefile - src/include/uapi/Makefile - src/include/uapi/ipc/Makefile - src/include/uapi/user/Makefile - src/ipc/Makefile - src/library/Makefile - src/library/include/Makefile - src/library/include/platform/Makefile - src/lib/Makefile - src/host/Makefile - src/platform/Makefile - src/platform/baytrail/Makefile - src/platform/baytrail/include/Makefile - src/platform/baytrail/include/arch/Makefile - src/platform/baytrail/include/arch/xtensa/Makefile - src/platform/baytrail/include/arch/xtensa/config/Makefile - src/platform/baytrail/include/platform/Makefile - src/platform/apollolake/Makefile - src/platform/apollolake/include/Makefile - src/platform/apollolake/include/arch/Makefile - src/platform/apollolake/include/arch/xtensa/Makefile - src/platform/apollolake/include/arch/xtensa/config/Makefile - src/platform/apollolake/include/platform/Makefile - src/platform/haswell/Makefile - src/platform/haswell/include/Makefile - src/platform/haswell/include/arch/Makefile - src/platform/haswell/include/arch/xtensa/Makefile - src/platform/haswell/include/arch/xtensa/config/Makefile - src/platform/haswell/include/platform/Makefile - src/platform/cannonlake/Makefile - src/platform/cannonlake/include/Makefile - src/platform/cannonlake/include/arch/Makefile - src/platform/cannonlake/include/arch/xtensa/Makefile - src/platform/cannonlake/include/arch/xtensa/config/Makefile - src/platform/cannonlake/include/platform/Makefile - src/platform/suecreek/Makefile - src/platform/suecreek/include/Makefile - src/platform/suecreek/include/arch/Makefile - src/platform/suecreek/include/arch/xtensa/Makefile - src/platform/suecreek/include/arch/xtensa/config/Makefile - src/platform/suecreek/include/platform/Makefile - src/platform/icelake/Makefile - src/platform/icelake/include/Makefile - src/platform/icelake/include/arch/Makefile - src/platform/icelake/include/arch/xtensa/Makefile - src/platform/icelake/include/arch/xtensa/config/Makefile - src/platform/icelake/include/platform/Makefile - src/platform/intel/Makefile - src/platform/intel/cavs/Makefile - test/Makefile - test/cmocka/Makefile - src/arch/xtensa/include/arch/gdb/Makefile - src/arch/xtensa/gdb/Makefile -]) -AC_REQUIRE_AUX_FILE([tap-driver.sh]) -AC_OUTPUT - -echo " ----{ $PACKAGE_NAME $VERSION }--- - -Target Architecture: ${ARCH} -Target Platform: ${PLATFORM} -Target Core: ${XTENSA_CORE} -Install Prefix: ${prefix} -PEM: ${PEM_KEY_PREFIX} - -Compiler: ${CC} -OBJCOPY: ${OBJCOPY} -OBJDUMP: ${OBJDUMP} -CFLAGS: ${CFLAGS} -LDFLAGS: ${LDFLAGS} -ARCH_CFLAGS: ${ARCH_CFLAGS} -ARCH_LDFLAGS: ${ARCH_LDFLAGS} -A@&t@M_CFLAGS: ${AM_CFLAGS} -A@&t@M_LDFLAGS: ${AM_LDFLAGS} -A@&t@M_CCASFLAGS: ${AM_CCASFLAGS} -" - diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 000000000000..bf6f8c75178f --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.10) + +project(SOF_DOC) + +set(SOF_ROOT_SOURCE_DIRECTORY "${PROJECT_SOURCE_DIR}/..") + +set(top_srcdir "${SOF_ROOT_SOURCE_DIRECTORY}") + +configure_file( + "${PROJECT_SOURCE_DIR}/sof.doxygen.in" + "${PROJECT_BINARY_DIR}/sof.doxygen" +) + +add_custom_target("doc" + COMMAND doxygen sof.doxygen + VERBATIM + USES_TERMINAL +) + +add_custom_target("doc-clean" + COMMAND rm -rf ${PROJECT_BINARY_DIR}/doxygen + VERBATIM + USES_TERMINAL +) diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100644 index f3db6588db4a..000000000000 --- a/doc/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -EXTRA_DIST=sof.doxygen.in - -AM_CPPFLAGS=-I$(top_srcdir)/include - -doc: - test -e sof.doxygen || sed s:[@]top_srcdir[@]:..:g sof.doxygen.in > sof.doxygen - doxygen sof.doxygen - -doc-clean: - rm -rf $(top_srcdir)/doc/doxygen/* diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 deleted file mode 100644 index dcabb92a1413..000000000000 --- a/m4/ax_check_compile_flag.m4 +++ /dev/null @@ -1,74 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the current language's compiler -# or gives an error. (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the current language's default -# flags (e.g. CFLAGS) when the check is done. The check is thus made with -# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to -# force the compiler to issue an error when a bad flag is given. -# -# INPUT gives an alternative input source to AC_COMPILE_IFELSE. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# 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 3 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, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 5 - -AC_DEFUN([AX_CHECK_COMPILE_FLAG], -[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ - ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" - AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) -AS_VAR_IF(CACHEVAR,yes, - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_COMPILE_FLAGS diff --git a/m4/ax_compare_version.m4 b/m4/ax_compare_version.m4 deleted file mode 100644 index 6df1c5301aab..000000000000 --- a/m4/ax_compare_version.m4 +++ /dev/null @@ -1,178 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_compare_version.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) -# -# DESCRIPTION -# -# This macro compares two version strings. Due to the various number of -# minor-version numbers that can exist, and the fact that string -# comparisons are not compatible with numeric comparisons, this is not -# necessarily trivial to do in a autoconf script. This macro makes doing -# these comparisons easy. -# -# The six basic comparisons are available, as well as checking equality -# limited to a certain number of minor-version levels. -# -# The operator OP determines what type of comparison to do, and can be one -# of: -# -# eq - equal (test A == B) -# ne - not equal (test A != B) -# le - less than or equal (test A <= B) -# ge - greater than or equal (test A >= B) -# lt - less than (test A < B) -# gt - greater than (test A > B) -# -# Additionally, the eq and ne operator can have a number after it to limit -# the test to that number of minor versions. -# -# eq0 - equal up to the length of the shorter version -# ne0 - not equal up to the length of the shorter version -# eqN - equal up to N sub-version levels -# neN - not equal up to N sub-version levels -# -# When the condition is true, shell commands ACTION-IF-TRUE are run, -# otherwise shell commands ACTION-IF-FALSE are run. The environment -# variable 'ax_compare_version' is always set to either 'true' or 'false' -# as well. -# -# Examples: -# -# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) -# AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) -# -# would both be true. -# -# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) -# AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) -# -# would both be false. -# -# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) -# -# would be true because it is only comparing two minor versions. -# -# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) -# -# would be true because it is only comparing the lesser number of minor -# versions of the two values. -# -# Note: The characters that separate the version numbers do not matter. An -# empty string is the same as version 0. OP is evaluated by autoconf, not -# configure, so must be a string, not a variable. -# -# The author would like to acknowledge Guido Draheim whose advice about -# the m4_case and m4_ifvaln functions make this macro only include the -# portions necessary to perform the specific comparison specified by the -# OP argument in the final configure script. -# -# LICENSE -# -# Copyright (c) 2008 Tim Toolan -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 13 - -dnl ######################################################################### -AC_DEFUN([AX_COMPARE_VERSION], [ - AC_REQUIRE([AC_PROG_AWK]) - - # Used to indicate true or false condition - ax_compare_version=false - - # Convert the two version strings to be compared into a format that - # allows a simple string comparison. The end result is that a version - # string of the form 1.12.5-r617 will be converted to the form - # 0001001200050617. In other words, each number is zero padded to four - # digits, and non digits are removed. - AS_VAR_PUSHDEF([A],[ax_compare_version_A]) - A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ - -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ - -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ - -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ - -e 's/[[^0-9]]//g'` - - AS_VAR_PUSHDEF([B],[ax_compare_version_B]) - B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ - -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ - -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ - -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ - -e 's/[[^0-9]]//g'` - - dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary - dnl # then the first line is used to determine if the condition is true. - dnl # The sed right after the echo is to remove any indented white space. - m4_case(m4_tolower($2), - [lt],[ - ax_compare_version=`echo "x$A -x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` - ], - [gt],[ - ax_compare_version=`echo "x$A -x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` - ], - [le],[ - ax_compare_version=`echo "x$A -x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` - ], - [ge],[ - ax_compare_version=`echo "x$A -x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` - ],[ - dnl Split the operator from the subversion count if present. - m4_bmatch(m4_substr($2,2), - [0],[ - # A count of zero means use the length of the shorter version. - # Determine the number of characters in A and B. - ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` - ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` - - # Set A to no more than B's length and B to no more than A's length. - A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` - B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` - ], - [[0-9]+],[ - # A count greater than zero means use only that many subversions - A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` - B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` - ], - [.+],[ - AC_WARNING( - [invalid OP numeric parameter: $2]) - ],[]) - - # Pad zeros at end of numbers to make same length. - ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" - B="$B`echo $A | sed 's/./0/g'`" - A="$ax_compare_version_tmp_A" - - # Check for equality or inequality as necessary. - m4_case(m4_tolower(m4_substr($2,0,2)), - [eq],[ - test "x$A" = "x$B" && ax_compare_version=true - ], - [ne],[ - test "x$A" != "x$B" && ax_compare_version=true - ],[ - AC_WARNING([invalid OP parameter: $2]) - ]) - ]) - - AS_VAR_POPDEF([A])dnl - AS_VAR_POPDEF([B])dnl - - dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. - if test "$ax_compare_version" = "true" ; then - m4_ifvaln([$4],[$4],[:])dnl - m4_ifvaln([$5],[else $5])dnl - fi -]) dnl AX_COMPARE_VERSION - diff --git a/rimage/CMakeLists.txt b/rimage/CMakeLists.txt new file mode 100644 index 000000000000..940c9f513bfc --- /dev/null +++ b/rimage/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 3.10) + +project(SOF_RIMAGE C) + +set(SOF_ROOT_SOURCE_DIRECTORY "${PROJECT_SOURCE_DIR}/..") + +if(NOT DEFINED VERSION_H_PATH) + message(FATAL_ERROR + " Please specify version.h path.\n" + " Example: cmake -DVERSION_H_PATH=${VERSION_H_PATH} ...\n" +) +endif() + +if(NOT DEFINED PEM_KEY_PREFIX) + set(PEM_KEY_PREFIX "/usr/local/share/rimage") +endif() + +get_filename_component(VERSION_H_DIRECTORY ${VERSION_H_PATH} DIRECTORY) + +add_executable(rimage + file_simple.c + man_apl.c + man_cnl.c + man_kbl.c + man_sue.c + cse.c + css.c + plat_auth.c + hash.c + pkcs1_5.c + manifest.c + elf.c + rimage.c +) + +target_compile_options(rimage PRIVATE + -O2 -g -Wall -Werror -Wl,-EL -Wmissing-prototypes -Wimplicit-fallthrough=3 +) + +target_compile_definitions(rimage PRIVATE + PEM_KEY_PREFIX="${PEM_KEY_PREFIX}" +) + +target_link_libraries(rimage PRIVATE "-lcrypto") + +target_include_directories(rimage PRIVATE + "${SOF_ROOT_SOURCE_DIRECTORY}/src/include" + "${VERSION_H_DIRECTORY}" +) diff --git a/rimage/Makefile.am b/rimage/Makefile.am deleted file mode 100644 index 5af59059b7f3..000000000000 --- a/rimage/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -SUBDIRS=keys - -bin_PROGRAMS = rimage - -noinst_HEADERS = \ - rimage.h \ - css.h \ - cse.h \ - plat_auth.h \ - manifest.h \ - file_format.h - -rimage_SOURCES = \ - file_simple.c \ - man_apl.c \ - man_cnl.c \ - man_kbl.c \ - man_sue.c \ - cse.c \ - css.c \ - plat_auth.c \ - hash.c \ - pkcs1_5.c \ - manifest.c \ - elf.c \ - rimage.c - diff --git a/rimage/keys/Makefile.am b/rimage/keys/Makefile.am deleted file mode 100644 index 06fe3071317a..000000000000 --- a/rimage/keys/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -install-data-local: - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(PEM_KEY_PREFIX); - $(INSTALL_DATA) otc_private_key.pem $(PEM_KEY_PREFIX) - $(INSTALL_DATA) otc_public_key.pem $(PEM_KEY_PREFIX) - -EXTRA_DIST = \ - otc_private_key.pem \ - otc_public_key.pem \ No newline at end of file diff --git a/rimage/man_apl.c b/rimage/man_apl.c index 76082dd9111f..f7f1d25f3a13 100644 --- a/rimage/man_apl.c +++ b/rimage/man_apl.c @@ -15,7 +15,6 @@ #include "cse.h" #include "plat_auth.h" #include "manifest.h" -#include #include /* manifest template */ diff --git a/rimage/man_cnl.c b/rimage/man_cnl.c index 5e3480d1ef3d..7142fd26386a 100644 --- a/rimage/man_cnl.c +++ b/rimage/man_cnl.c @@ -15,7 +15,6 @@ #include "cse.h" #include "plat_auth.h" #include "manifest.h" -#include #include /* manifest template */ diff --git a/rimage/man_kbl.c b/rimage/man_kbl.c index 4d5f5464dfe4..5fd16f8c3d24 100644 --- a/rimage/man_kbl.c +++ b/rimage/man_kbl.c @@ -15,7 +15,6 @@ #include "cse.h" #include "plat_auth.h" #include "manifest.h" -#include #include /* diff --git a/rimage/man_sue.c b/rimage/man_sue.c index 2f3ce4abfbc1..741fd0b26a04 100644 --- a/rimage/man_sue.c +++ b/rimage/man_sue.c @@ -15,7 +15,6 @@ #include "cse.h" #include "plat_auth.h" #include "manifest.h" -#include #include /* manifest template */ diff --git a/rimage/pkcs1_5.c b/rimage/pkcs1_5.c index a6f8fbf545e3..adee7a9b3221 100644 --- a/rimage/pkcs1_5.c +++ b/rimage/pkcs1_5.c @@ -26,7 +26,6 @@ #include #include -#include "config.h" #include "rimage.h" #include "css.h" #include "manifest.h" diff --git a/scripts/cmake/defconfigs.cmake b/scripts/cmake/defconfigs.cmake new file mode 100644 index 000000000000..165be6cba1e9 --- /dev/null +++ b/scripts/cmake/defconfigs.cmake @@ -0,0 +1,27 @@ +# Looks for defconfig files in arch directory +set(DEFCONFIGS_DIRECTORY "${PROJECT_SOURCE_DIR}/src/arch/${ARCH}/configs/*_defconfig") +file(GLOB DEFCONFIG_PATHS ${DEFCONFIGS_DIRECTORY}) + +# Adds dependency on defconfigs directory +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${DEFCONFIGS_DIRECTORY}) + +# Adds target for every defconfig, so you we can use it like make *_defconfig +foreach(defconfig_path ${DEFCONFIG_PATHS}) + get_filename_component(defconfig_name ${defconfig_path} NAME) + add_custom_target( + ${defconfig_name} + COMMAND ${CMAKE_COMMAND} -E copy + ${defconfig_path} + ${DOT_CONFIG_PATH} + COMMAND ${CMAKE_COMMAND} -E env + srctree=${PROJECT_SOURCE_DIR} + CC_VERSION_TEXT=${CC_VERSION_TEXT} + ARCH=${ARCH} + ${PYTHON3} ${PROJECT_SOURCE_DIR}/scripts/kconfig/olddefconfig.py + ${PROJECT_SOURCE_DIR}/Kconfig + WORKING_DIRECTORY ${GENERATED_DIRECTORY} + COMMENT "Applying olddefconfig with ${defconfig_name}" + VERBATIM + USES_TERMINAL + ) +endforeach() diff --git a/scripts/cmake/misc.cmake b/scripts/cmake/misc.cmake new file mode 100644 index 000000000000..9f1f96d0da7d --- /dev/null +++ b/scripts/cmake/misc.cmake @@ -0,0 +1,43 @@ +# Reads configs from kconfig file and set them as cmake variables. +# Each config is in format CONFIG_=. +# Configs are added to parent scope with CONFIG_ prefix (as written in file). +function(read_kconfig_config config_file) + file( + STRINGS + ${config_file} + configs_list + REGEX "^CONFIG_" + ENCODING "UTF-8" + ) + + foreach(config ${configs_list}) + string(REGEX MATCH "^([^=]+)=(.*)$" ignored ${config}) + set(config_name ${CMAKE_MATCH_1}) + set(config_value ${CMAKE_MATCH_2}) + + if("${config_value}" MATCHES "^\"(.*)\"$") + set(config_value ${CMAKE_MATCH_1}) + endif() + + set("${config_name}" "${config_value}" PARENT_SCOPE) + endforeach() +endfunction() + +# Adds sources to target like target_sources, but assumes that +# paths are relative to subdirectory. +# Works like: +# Cmake >= 3.13: +# target_sources( PRIVATE ) +# Cmake < 3.13: +# target_sources( PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/) +function(add_local_sources target) + foreach(arg ${ARGN}) + if(IS_ABSOLUTE ${arg}) + set(path ${arg}) + else() + set(path ${CMAKE_CURRENT_SOURCE_DIR}/${arg}) + endif() + + target_sources(${target} PRIVATE ${path}) + endforeach() +endfunction() diff --git a/scripts/cmake/version.cmake b/scripts/cmake/version.cmake new file mode 100644 index 000000000000..7ed9c48f22a8 --- /dev/null +++ b/scripts/cmake/version.cmake @@ -0,0 +1,66 @@ +cmake_minimum_required(VERSION 3.10) + +execute_process(COMMAND git describe --abbrev=4 + OUTPUT_VARIABLE GIT_TAG + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + +execute_process(COMMAND git log --pretty=format:%h -1 + OUTPUT_VARIABLE GIT_LOG_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + +if(NOT GIT_TAG MATCHES "^v") + set(GIT_TAG "v0.0-0-g0000") +endif() + +string(REGEX MATCH "^v([0-9]+)[.]([0-9]+)([.]([0-9]+))?" ignored "${GIT_TAG}") +set(SOF_MAJOR ${CMAKE_MATCH_1}) +set(SOF_MINOR ${CMAKE_MATCH_2}) +set(SOF_MICRO ${CMAKE_MATCH_4}) + +if(NOT SOF_MICRO MATCHES "^[0-9]+$") + set(SOF_MICRO 0) +endif() + +string(SUBSTRING "${GIT_LOG_HASH}" 0 5 SOF_TAG) +if(NOT SOF_TAG) + set(SOF_TAG 0) +endif() + +# TODO +set(SOF_BUILD 0) + +function(sof_check_version_h version_h_path) + string(CONCAT header_content + "#define SOF_MAJOR ${SOF_MAJOR}\n" + "#define SOF_MINOR ${SOF_MINOR}\n" + "#define SOF_MICRO ${SOF_MICRO}\n" + "#define SOF_TAG \"${SOF_TAG}\"\n" + "#define SOF_BUILD ${SOF_BUILD}\n" + ) + + if(EXISTS "${version_h_path}") + file(READ "${version_h_path}" old_version_content) + if(header_content STREQUAL old_version_content) + return() + endif() + endif() + + message(STATUS "Generating ${version_h_path}") + file(WRITE "${version_h_path}" "${header_content}") +endfunction() + +function(sof_add_version_h_rule + version_cmake_path) + + add_custom_command(OUTPUT ${VERSION_H_PATH} + COMMAND ${CMAKE_COMMAND} -DVERSION_H_PATH=${VERSION_H_PATH} -P ${version_cmake_path} + VERBATIM + USES_TERMINAL + ) +endfunction() + +sof_check_version_h("${VERSION_H_PATH}") diff --git a/scripts/cmake/xtensa-toolchain.cmake b/scripts/cmake/xtensa-toolchain.cmake new file mode 100644 index 000000000000..4e14dc5ea907 --- /dev/null +++ b/scripts/cmake/xtensa-toolchain.cmake @@ -0,0 +1,43 @@ +message(STATUS "Preparing Xtensa toolchain") + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_VERSION 1) + +set(CMAKE_ASM_COMPILER_FORCED 1) +set(CMAKE_C_COMPILER_FORCED 1) + +set(CMAKE_ASM_COMPILER_ID GNU) +set(CMAKE_C_COMPILER_ID GNU) + +# in case if *_FORCED variables are ignored, +# try to just compile lib instead of executable +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +if(TOOLCHAIN) + set(CROSS_COMPILE "${TOOLCHAIN}-") +else() + message(FATAL_ERROR + " Please specify toolchain to use.\n" + " Examples:\n" + " 1) cmake -DTOOLCHAIN=xt ...\n" + " 2) cmake -DTOOLCHAIN=xtensa-apl-elf ...\n" + ) +endif() + +# xt toolchain only partially follows gcc convention +if(TOOLCHAIN STREQUAL "xt") + set(XCC 1) + set(CMAKE_C_COMPILER ${CROSS_COMPILE}xcc) +else() + set(CMAKE_C_COMPILER ${CROSS_COMPILE}gcc) +endif() + +set(CMAKE_LD ${CROSS_COMPILE}ld CACHE STRING "") +set(CMAKE_AR ${CROSS_COMPILE}ar CACHE STRING "") +set(CMAKE_OBJCOPY ${CROSS_COMPILE}objcopy) +set(CMAKE_OBJDUMP ${CROSS_COMPILE}objdump) + +set(CMAKE_FIND_ROOT_PATH ".") +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/scripts/host-build-all.sh b/scripts/host-build-all.sh index 9544802f8ded..392c681f7a31 100755 --- a/scripts/host-build-all.sh +++ b/scripts/host-build-all.sh @@ -3,30 +3,8 @@ # fail on any errors set -e -# parse the args -for args in $@ -do - if [[ "$args" == "-l" ]] - then - BUILD_LOCAL=1 - fi -done - -# run autogen.sh -./autogen.sh - -pwd=`pwd` - -# Build library for host platform architecture -if [[ "x$BUILD_LOCAL" == "x" ]] -then - ./configure --with-arch=host --enable-library=yes --host=x86_64-unknown-linux-gnu -else - # make sure host lib is build in local folder - echo "BUILD in local folder!" - rm -rf $pwd/local/ - ./configure --with-arch=host --enable-library=yes --host=x86_64-unknown-linux-gnu --prefix=$pwd/host-lib -fi - -make +mkdir build_host +cd build_host +cmake -DBUILD_HOST=ON -DCMAKE_INSTALL_PREFIX=install .. +make -j4 make install diff --git a/scripts/kconfig/alldefconfig.py b/scripts/kconfig/alldefconfig.py new file mode 100644 index 000000000000..66759e06e21c --- /dev/null +++ b/scripts/kconfig/alldefconfig.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +# Copyright (c) 2018, Ulf Magnusson +# SPDX-License-Identifier: ISC + +# Works like 'make alldefconfig'. Verified by the test suite to generate +# identical output to 'make alldefconfig' for all ARCHes. +# +# The default output filename is '.config'. A different filename can be passed +# in the KCONFIG_CONFIG environment variable. +# +# Usage for the Linux kernel: +# +# $ make [ARCH=] scriptconfig SCRIPT=Kconfiglib/alldefconfig.py + +import kconfiglib + +def main(): + kconf = kconfiglib.standard_kconfig() + kconfiglib.load_allconfig(kconf, "alldef.config") + kconf.write_config() + +if __name__ == "__main__": + main() diff --git a/scripts/kconfig/genconfig.py b/scripts/kconfig/genconfig.py new file mode 100644 index 000000000000..a7c9e07c0235 --- /dev/null +++ b/scripts/kconfig/genconfig.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python + +# Copyright (c) 2018, Ulf Magnusson +# SPDX-License-Identifier: ISC + +# Generates a C header from the configuration, matching the format of +# include/generated/autoconf.h in the kernel. +# +# Optionally generates a directory structure with one file per symbol that can +# be used to implement incremental builds. See the docstring for +# Kconfig.sync_deps() in Kconfiglib. +# +# Usage (see argument help texts for more information): +# +# genconfig.py [-h] [--header-path HEADER_FILE] +# [--sync-deps [OUTPUT_DIR]] [--config-out CONFIG_FILE] +# [KCONFIG_FILENAME] + +import argparse + +import kconfiglib + +DESCRIPTION = """ +Generates a header file with defines from the configuration. Optionally +creates/updates a directory with incremental build information as well (see the +docstring for the Kconfig.sync_deps() function in Kconfiglib). The .config file +to generate the configuration from can be specified by setting the +KCONFIG_CONFIG environment variable. +""" + +DEFAULT_HEADER_PATH = "config.h" +DEFAULT_SYNC_DEPS_PATH = "deps/" + +def main(): + parser = argparse.ArgumentParser(description=DESCRIPTION) + + parser.add_argument( + "--header-path", + metavar="HEADER_FILE", + default=DEFAULT_HEADER_PATH, + help="Path for the generated header file (default: {})" + .format(DEFAULT_HEADER_PATH)) + + parser.add_argument( + "--sync-deps", + dest="sync_deps_path", + metavar="OUTPUT_DIR", + nargs="?", + const=DEFAULT_SYNC_DEPS_PATH, + help="Enable generation of build dependency information for " + "incremental builds, optionally specifying the output path " + "(default: {})".format(DEFAULT_SYNC_DEPS_PATH)) + + parser.add_argument( + "--config-out", + dest="config_path", + metavar="CONFIG_FILE", + help="Write the configuration to the specified filename. " + "This is useful if you include .config files in Makefiles, as " + "the generated configuration file will be a full .config file " + "even if .config is outdated. The generated configuration " + "matches what olddefconfig would produce. If you use " + "--sync-deps, you can include deps/auto.conf instead. " + "--config-out is meant for cases where incremental build " + "information isn't needed.") + + parser.add_argument( + "kconfig_filename", + metavar="KCONFIG_FILENAME", + nargs="?", + default="Kconfig", + help="Top-level Kconfig file (default: Kconfig)") + + args = parser.parse_args() + + + kconf = kconfiglib.Kconfig(args.kconfig_filename) + kconf.load_config(verbose=False) + + kconf.write_autoconf(args.header_path) + + if args.sync_deps_path is not None: + kconf.sync_deps(args.sync_deps_path) + + if args.config_path is not None: + kconf.write_config(args.config_path, save_old=False) + +if __name__ == "__main__": + main() diff --git a/scripts/kconfig/kconfiglib.py b/scripts/kconfig/kconfiglib.py new file mode 100644 index 000000000000..30b750731764 --- /dev/null +++ b/scripts/kconfig/kconfiglib.py @@ -0,0 +1,6640 @@ +# Copyright (c) 2011-2018, Ulf Magnusson +# SPDX-License-Identifier: ISC + +""" +Overview +======== + +Kconfiglib is a Python 2/3 library for scripting and extracting information +from Kconfig (https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt) +configuration systems. + +See the homepage at https://github.com/ulfalizer/Kconfiglib for a longer +overview. + +Using Kconfiglib on the Linux kernel with the Makefile targets +============================================================== + +For the Linux kernel, a handy interface is provided by the +scripts/kconfig/Makefile patch, which can be applied with either 'git am' or +the 'patch' utility: + + $ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | git am + $ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | patch -p1 + +Warning: Not passing -p1 to patch will cause the wrong file to be patched. + +Please tell me if the patch does not apply. It should be trivial to apply +manually, as it's just a block of text that needs to be inserted near the other +*conf: targets in scripts/kconfig/Makefile. + +Look further down for a motivation for the Makefile patch and for instructions +on how you can use Kconfiglib without it. + +If you do not wish to install Kconfiglib via pip, the Makefile patch is set up +so that you can also just clone Kconfiglib into the kernel root: + + $ git clone git://github.com/ulfalizer/Kconfiglib.git + $ git am Kconfiglib/makefile.patch (or 'patch -p1 < Kconfiglib/makefile.patch') + +Warning: The directory name Kconfiglib/ is significant in this case, because +it's added to PYTHONPATH by the new targets in makefile.patch. + +The targets added by the Makefile patch are described in the following +sections. + + +make kmenuconfig +---------------- + +This target runs the curses menuconfig interface with Python 3 (Python 2 is +currently not supported for the menuconfig). + + +make [ARCH=] iscriptconfig +-------------------------------- + +This target gives an interactive Python prompt where a Kconfig instance has +been preloaded and is available in 'kconf'. To change the Python interpreter +used, pass PYTHONCMD= to make. The default is "python". + +To get a feel for the API, try evaluating and printing the symbols in +kconf.defined_syms, and explore the MenuNode menu tree starting at +kconf.top_node by following 'next' and 'list' pointers. + +The item contained in a menu node is found in MenuNode.item (note that this can +be one of the constants kconfiglib.MENU and kconfiglib.COMMENT), and all +symbols and choices have a 'nodes' attribute containing their menu nodes +(usually only one). Printing a menu node will print its item, in Kconfig +format. + +If you want to look up a symbol by name, use the kconf.syms dictionary. + + +make scriptconfig SCRIPT=