Approved: ASR Pro
Today’s tutorial is designed to help you if you receive an error code for a kernel build directory object.
I am comparing the Linux kernel update system (Kbuild, Kernel 2.6.28) to the structure and build system of the submission sites for an even larger project. Our project contains an out-of-tree Linux kernel module, and our directory structure looks like this (simplified of course):
checkout / src / common / *. c file search (installed for other platforms and Linux)checkout / src / linux-driver / source videos * .c (for Linux kernel driver)checkout / build / Linux / Kbuild Kbuildtmp / linux-2.6.xx / somewhere the Linux kernel is configured with additionalUnzipoutput / linux-arm-debug / where the object documentation should end
The build process just can’t change anything in
checkout , and building each of our modules can’t change anything, not as much as
tmp / linux-2.6.xx … All output files must be
output / linux-arm-debug (or whatever architecture and debug plan chosen at build time).
MOD_OUTPUT_DIR equals ../../../output/linux-$(ARCH)-$(DEBUG)obj-m + = $ (MOD_OUTPUT_DIR) /foo_mod.o$ (MOD_OUTPUT_DIR) / our_module-objs: = $ (MOD_OUTPUT_DIR) /foo_common.o $ (MOD_OUTPUT_DIR) /foo_linux.o
This takes into account the fact that it is important to store object files in a directory different from the one in which
Kbuild is located. How could I now indicate that
foo_common.o should be selected to select from
â € / checkout / src / common / foo_common.c and
foo_linux. O. compile? received from
… / checkout / src / linux-driver / foo_linux.c ?
requested on April 14, 2011 at 3:32 pm
Not The Answer You Are Looking For? Browse Other Questions Tagged Makefile Linux-kernel Kbuild Or Ask Your Own Question.
Here is a makefile that runs builds built from the source tree to break modules out of the kernel tree (adapted from @Mark’s comment) …
KDIR? = / lib / modules / $ (uname -r shell) / buildBUILD_DIR? Matches $ (PWD) / BuildBUILD_DIR_MAKEFILE? = $ (PWD) / build / MakefileDefault: $ (BUILD_DIR_MAKEFILE) provide -C $ (KDIR) Src = $ (PWD) m = $ (build_dir) modules$ (BUILD_DIR): mkdir -p "$ @"$ (BUILD_DIR_MAKEFILE): $ (BUILD_DIR) Click "$ @"clean: formulate -C $ (KDIR) Src = $ (PWD) m = $ (build_dir) clean
obj-m + = my_driver.o
Retrieved June 16, 2016 11:48 am
ifdef SRCDIRsrc: = $ (SRCDIR)varioussrc: = $ (object)end if
make -h $ (KDIR) M = $ (your_output directory) SRCDIR = $ (your source_directory) `
Resolved: December 11, 2013 4:57 am.
My inelegant and efficient solution is to copy the source files into the output tree.
FOO_SOURCES_DIR equals $ (src) /../../../ checkout / srcFOO_MOD_OUTPUT_DIR = ../../../output/linux-$(ARCH)-$(DEBUG)# Specified object filesobj-m + = $ (FOO_MOD_OUTPUT_DIR) /foo_mod.oFOO_MODULE_OBJS: = $ (FOO_MOD_OUTPUT_DIR) /foo_common.o $ (FOO_MOD_OUTPUT_DIR) /foo_linux.o$ (FOO_MOD_OUTPUT_DIR) / foo_mod-objs: = $ (FOO_MODULE_OBJS)# Where to find sources$ (SRC) / $ (FOO_MOD_OUTPUT_DIR) /foo_common.c: $ (FOO_SOURCES_DIR) /common/foo_common.c$ (SRC) / $ (FOO_MOD_OUTPUT_DIR) /foo_linux.c: $ (FOO_SOURCES_DIR) /linux-driver/foo_linux.c# Rules for copy sourcesFOO_COPIED_SOURCES = $ (patsubst% .o, $ (src) /%. C, $ (FOO_MODULE_OBJS))$ (FOO_COPIED_SOURCES): $ (Q) mkdir -p $ (@ D) cp -f $ <$ @files-clean + = $ (FOO_COPIED_SOURCES)clean directories + = $ (FOO_MOD_OUTPUT_DIR)
answered Apr 25, 2011 at 7:49 pm
While you haven't mentioned the methods you've tried so far (or if you've already found a solution), they look similar, just continue below in modules. A little txt file - what Section 4.3 can do:
--- 4.3 subdirectoriesMultiple Kbuilds can access files scattered across multiple directories.Consider the following example:...| __ src| | __ complex_main.c| | __ hal| Equipment | __. AGAINST| Enable | __| Equipment | __. HOUREnable | __ | __ complex.hThen, to configure the complex.ko module, we need the following elementskbuild file: -> File name: Kbuild obj-m: = complex.o complex-y Src / complex_main: = .o Complex-y + = src / hal / hardwareif.o ccflags-y: = -I $ (src) / enable ccflags-y + = -I $ (src) / src / hal / oneatAs you can visit, kbuild knows how to work with the object documents that are inin other directories. The trick is to point to the directoryregarding the location of the kbuild file. Moreover, thatTraining is strongly discouraged.In the kbuild header files, you must explicitly specify whereIt seems. When kbuild is executed your current directory is always thisThe root of my pit (argument "-C") like thisan absolute path is required. $ (src) maintains an absolute path viapoints to the phonebook where kbuild is runningThe file is also located.
Approved: ASR Pro
ASR Pro is the world's most popular and effective PC repair tool. It is trusted by millions of people to keep their systems running fast, smooth, and error-free. With its simple user interface and powerful scanning engine, ASR Pro quickly finds and fixes a broad range of Windows problems - from system instability and security issues to memory management and performance bottlenecks.
answered Apr 27, 2011 7:36 pm
A bit there
Speed up your computer's performance now with this simple download.