linux kernel make tag variable - linux

Linux kernel source can use make tags to get the tag for editor.
In scripts/tags.sh, line7 and line8 say that "Uses the following environment variables: ARCH, SUBARCH, SRCARCH, srctree, src, obj"
I want to ask What are these variable meaning?
I already read this article,but it just mention the two vairables, SRCARCH and SUBARCH.

Variables you should use
Next variables can be passed to tags.sh (actually you should pass them to make tags cscope command, and Makefile will pass them to tags.sh for you).
ARCH: which architecture to index. You can see all architectures list just by doing ls -l arch/ in your kernel source tree.
SUBARCH: the meaning of this variable depends on your architecture:
if ARCH=arm, SUBARCH will be used to determine arch/arm/mach-* and arch/arm/plat-* directories, and these directories will be indexed
if ARCH=um, use SUBARCH to specify which architecture you actually want to use in your User-Mode Linux (like SUBARCH=arm or SUBARCH=x86)
for the rest of architectures, you can omit this variable
ALLSOURCE_ARCHS: use this to index more than one architecture. Like ALLSOURCE_ARCHS="x86 mips arm" or ALLSOURCE_ARCHS="all". If you only want to index one architecture, omit this variable and use ARCH instead.
COMPILED_SOURCE: set this variable to 1 if you want to index only actually compiled source files. If you want to index all source files, omit setting this variable.
O= (this is actually Makefile parameter): use absolute paths (useful if you want to load created cscope/ctags index files outside of kernel directory, e.g. for development of out-of-tree kernel modules). If you want to use relative paths (i.e. you're gonna do development only in kernel dir), just omit that parameter.
Variables you don't need to touch
SRCARCH: being set from ARCH variable in Makefile and then passed to script. You probably don't need to mess with it, just set ARCH variable correctly
srctree: kernel source tree path. This variable will be passed from Makefile automatically if you're using this script via make cscope tags.
src and obj variables: those are not used by scripts/tags.sh anymore. It was replaced by utilizing KBUILD_SRC variable, which is provided from Makefile automatically, when you provide O=... parameter to it.
Usage
Basically, I'd recommend to only use scripts/tags.sh via make invocation. Example:
$ make O=. ARCH=arm SUBARCH=omap2 COMPILED_SOURCE=1 cscope tags
or
$ make ARCH=x86 cscope tags

Related

Which library does `Cmake` prefer to link to when invoking `target_link_libraries(target_name, library_name_without_postfix)`?

Both static and shared versions of a specific library are in the same folder, then which library does Cmake prefer to link to when invoking target_link_libraries(target_name, library_name_without_postfix)?
Why?
If target_link_libraries takes the library name in the 2nd parameter, it entirely depends on the linker. In your case, the link line will be translated to
-llibrary_name_without_postfix.
In this case, it will be searched in the standard path like, LD_LIBRARY_PATH, /etc/ld.so.conf or in the system path.
Since you didn't say anything about the location, I assume the library lives in the current build directory. And you have a command somewhere including the current build directory in the linker path using link_directories. In this case, the default link is dynamic.

How to make a kernel interface to user-level?

I'm building a syscall to kernel Linux, so I need to export a structure to use in user level. I've read some documentation and they said I need to use a *.h below kernel/include/uapi or use make headers_install. But nothing seems to work. gcc doesn't identify the data type I tried to export.
So, what are the prerequisites to use this command and what exactly it makes (what headers it export and under what conditions) ?

mapping kernel config variables to modules

In general, how do I know what set of kernel config options are necessary to have some .ko file built?
For example, I need 'xt_conntrack.ko'. What resources are there that let me know whether or not enabling CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m in my kernel config is necessary or even sufficient to result in my built .ko file? How do I find the full set of kconfig options required to yield a kernel module?
http://cateee.net/lkddb/web-lkddb/NETFILTER_XT_MATCH_CONNTRACK.html indicates it will build "xt_conntrack", but I am not seeing it when I =m it and all of its dependencies.
On the other side, there is no set of kconfig flags visible here (http://modules.libres.ch/browse/linux/v3.0/x86_64/xt_conntrack/)
How do I find the full set of kconfig options required to yield a kernel module?
In general, determining set of options for building a kernel module is complex process. Steps described below may guide in that process.
1. Find a Makefile
Find a Makefile which builds a kernel module. This file is located in the same directory, where .ko file is produced; this directory usually coincides with a directory of module's source files. This Makefile contains a line which builds a module:
obj-${CONFIG_...} := <module_name>.o
Example:
A module xt_conntrack.ko is built by the line
obj-$(CONFIG_NETFILTER_XT_MATCH_CONNTRACK) += xt_conntrack.o
in file net/netfilter/Makefile.
2. Determine final option
There are several ways how configuration options may affect on building a module.
The option is used directly in the line, produced the module:
obj-${CONFIG_X} := <module_name>.o
means that option CONFIG_X should be set for the module to be built.
Given Makefile is conditionally included into the upper one:
obj-${CONFIG_Y} := <dir>/
The line produced the module is guarded by "if" clause:
ifeq ($(CONFIG_F),y)
obj-m := <module_name>.o
endif
Alternatively, guard may protect inclusion of the Makefile from the upper one:
ifeq ($(CONFIG_F),y)
obj-m := <dir>/
endif
Example:
A module xt_conntrack depends by rule 1 from CONFIG_NETFILTER_XT_MATCH_CONNTRACK option.
Also it depends by rule 2 from CONFIG_NETFILTER option, because outer net/Makefile includes net/netfilter/Makefile via
obj-$(CONFIG_NETFILTER) += netfilter/
3. Find definition of the option and determine its availability
Note: This is the most complicated step, mainly because availability of the option is expressed in terms of other options. It is recommended to use ready-made tools for that. E.g., make menuconfig tool may search options and show their definition.
Every configuration option is defined in one of Kconfig files.
Definition determines:
availability of the option (when the option can be used),
possible values of the option (y/n - boolean, y/m/n - tristate, etc.),
whether the option can be set by a user.
Example:
Option NETFILTER_XT_MATCH_CONNTRACK is defined in net/netfilter/Kconfig as
config NETFILTER_XT_MATCH_CONNTRACK
tristate '"conntrack" connection tracking match support'
depends on NF_CONNTRACK
default m if NETFILTER_ADVANCED=n
help
This is a general conntrack match module, a superset of the state match.
It allows matching on additional conntrack information, which is
useful in complex configurations, such as NAT gateways with multiple
internet links or tunnels.
To compile it as a module, choose M here. If unsure, say N.
That is, the option is available (can be set) only when NF_CONNTRACK option is set.
Documentation for format of Kconfig files is located at Documentation/kbuild/kconfig-language.txt.

Rename the 'makefile' build.exe expects to something that won't clash?

In the DDK/WDK the build.exe expects certain files in a folder. As soon as you give a sources file, you are also expected to have a makefile in the same folder. Obviously this name clashes with all kinds of make variants in a mixed source tree that is built on various platforms and tool chains.
Is there a way to name it something else, such as makefile.ddk and have nmake.exe (the backend to build.exe for this step) pick up on that other name?
I'm not afraid to script things, but I would prefer if I could pass an option to build.exe, e.g. via the /nmake args switch. I am using a range of DDKs/WDKs from the 2003 Server IFS Kit to the latest Windows 7 and 8 WDKs.
The /nmake option will do the job. I just tested this and it works:
build /nmake "/f makefile.ddk"
The quotes are necessary.

How do I ignore a system file picked up by `configure' generated from AC_CHECK_HEADERS

We using an automated build system which downloads and compiles source. The only interface I have to control the behaviour of the compilation is by setting ENV VARs and the arguments given to `./configure'.
The issue is that the 'configure' script (of the particular source I'm compiling) checks for a system header file, which if found, adversely affects the compilation process. (the compilation process will avoid compiling libraries which it believes are already installed on the local system when the above mentioned system header file is found.)
Since this is an automated process, I cannot modify the 'configure' script in anyway, and as mentioned can only specify the environment variables and arguments passed to `configure'. The configure script uses the AC_CHECK_HEADERS macro to generate the code to do the check for the system file. Is there anyway to avoid a check of a specific system file from the configure arguments?
The troublesome header file is in the path /usr/include/pcap/.
Thanks
Well there's a few things you could try:
remove foo.h from AC_CHECK_HEADERS and always build the library
use AC_CHECK_HEADER for foo.h and check for /usr/include/pcap/foo.h and don't AC_DEFINE(HAVE_FOO_H) if /usr/include/pcap/foo.h is there.
you could use AC_ARG_ENABLE or AC_ARG_WITH to turn off the offending test on a host-by-host basis via arguments to configure. So the answer to that question is yes.
All of these assume you can modify configure.ac and regenerate configure. If you can't do that you might have to modify configure (in an automated fashion, of course).

Resources