Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6
* 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6: kbuild: make KBUILD_NOCMDDEP=1 handle empty built-in.o scripts/kallsyms.c: fix potential segfault scripts/gen_initramfs_list.sh: Convert to a /bin/sh script kbuild: Fix GNU make v3.80 compatibility kbuild: Fix passing -Wno-* options to gcc 4.4+ kbuild: move scripts/basic/docproc.c to scripts/docproc.c kbuild: Fix Makefile.asm-generic for um kbuild: Allow to combine multiple W= levels kbuild: Disable -Wunused-but-set-variable for gcc 4.6.0 Fix handling of backlash character in LINUX_COMPILE_BY name kbuild: asm-generic support kbuild: implement several W= levels kbuild: Fix build with binutils <= 2.19 initramfs: Use KBUILD_BUILD_TIMESTAMP for generated entries kbuild: Allow to override LINUX_COMPILE_BY and LINUX_COMPILE_HOST macros kbuild: Drop unused LINUX_COMPILE_TIME and LINUX_COMPILE_DOMAIN macros kbuild: Use the deterministic mode of ar kbuild: Call gzip with -n kbuild: move KALLSYMS_EXTRA_PASS from Kconfig to Makefile Kconfig: improve KALLSYMS_ALL documentation Fix up trivial conflict in Makefile
This commit is contained in:
commit
2bb732cdb4
20 changed files with 287 additions and 108 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -57,6 +57,7 @@ modules.builtin
|
|||
include/config
|
||||
include/linux/version.h
|
||||
include/generated
|
||||
arch/*/include/generated
|
||||
|
||||
# stgit generated dirs
|
||||
patches-*
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ installmandocs: mandocs
|
|||
###
|
||||
#External programs used
|
||||
KERNELDOC = $(srctree)/scripts/kernel-doc
|
||||
DOCPROC = $(objtree)/scripts/basic/docproc
|
||||
DOCPROC = $(objtree)/scripts/docproc
|
||||
|
||||
XMLTOFLAGS = -m $(srctree)/Documentation/DocBook/stylesheet.xsl
|
||||
XMLTOFLAGS += --skip-validation
|
||||
|
|
|
|||
|
|
@ -201,3 +201,16 @@ KBUILD_ENABLE_EXTRA_GCC_CHECKS
|
|||
--------------------------------------------------
|
||||
If enabled over the make command line with "W=1", it turns on additional
|
||||
gcc -W... options for more extensive build-time checking.
|
||||
|
||||
KBUILD_BUILD_TIMESTAMP
|
||||
--------------------------------------------------
|
||||
Setting this to a date string overrides the timestamp used in the
|
||||
UTS_VERSION definition (uname -v in the running kernel). The value has to
|
||||
be a string that can be passed to date -d. The default value
|
||||
is the output of the date command at one point during build.
|
||||
|
||||
KBUILD_BUILD_USER, KBUILD_BUILD_HOST
|
||||
--------------------------------------------------
|
||||
These two variables allow to override the user@host string displayed during
|
||||
boot and in /proc/version. The default value is the output of the commands
|
||||
whoami and host, respectively.
|
||||
|
|
|
|||
|
|
@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
|
|||
--- 6.6 Commands useful for building a boot image
|
||||
--- 6.7 Custom kbuild commands
|
||||
--- 6.8 Preprocessing linker scripts
|
||||
--- 6.9 Generic header files
|
||||
|
||||
=== 7 Kbuild syntax for exported headers
|
||||
--- 7.1 header-y
|
||||
--- 7.2 objhdr-y
|
||||
--- 7.3 destination-y
|
||||
--- 7.4 generic-y
|
||||
|
||||
=== 8 Kbuild Variables
|
||||
=== 9 Makefile language
|
||||
|
|
@ -499,6 +501,18 @@ more details, with real examples.
|
|||
gcc >= 3.00. For gcc < 3.00, -malign-functions=4 is used.
|
||||
Note: cc-option-align uses KBUILD_CFLAGS for $(CC) options
|
||||
|
||||
cc-disable-warning
|
||||
cc-disable-warning checks if gcc supports a given warning and returns
|
||||
the commandline switch to disable it. This special function is needed,
|
||||
because gcc 4.4 and later accept any unknown -Wno-* option and only
|
||||
warn about it if there is another warning in the source file.
|
||||
|
||||
Example:
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
|
||||
|
||||
In the above example, -Wno-unused-but-set-variable will be added to
|
||||
KBUILD_CFLAGS only if gcc really accepts it.
|
||||
|
||||
cc-version
|
||||
cc-version returns a numerical version of the $(CC) compiler version.
|
||||
The format is <major><minor> where both are two digits. So for example
|
||||
|
|
@ -955,6 +969,11 @@ When kbuild executes, the following steps are followed (roughly):
|
|||
used when linking modules. This is often a linker script.
|
||||
From commandline LDFLAGS_MODULE shall be used (see kbuild.txt).
|
||||
|
||||
KBUILD_ARFLAGS Options for $(AR) when creating archives
|
||||
|
||||
$(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic
|
||||
mode) if this option is supported by $(AR).
|
||||
|
||||
--- 6.2 Add prerequisites to archprepare:
|
||||
|
||||
The archprepare: rule is used to list prerequisites that need to be
|
||||
|
|
@ -1209,6 +1228,14 @@ When kbuild executes, the following steps are followed (roughly):
|
|||
The kbuild infrastructure for *lds file are used in several
|
||||
architecture-specific files.
|
||||
|
||||
--- 6.9 Generic header files
|
||||
|
||||
The directory include/asm-generic contains the header files
|
||||
that may be shared between individual architectures.
|
||||
The recommended approach how to use a generic header file is
|
||||
to list the file in the Kbuild file.
|
||||
See "7.4 generic-y" for further info on syntax etc.
|
||||
|
||||
=== 7 Kbuild syntax for exported headers
|
||||
|
||||
The kernel include a set of headers that is exported to userspace.
|
||||
|
|
@ -1265,6 +1292,32 @@ See subsequent chapter for the syntax of the Kbuild file.
|
|||
In the example above all exported headers in the Kbuild file
|
||||
will be located in the directory "include/linux" when exported.
|
||||
|
||||
--- 7.4 generic-y
|
||||
|
||||
If an architecture uses a verbatim copy of a header from
|
||||
include/asm-generic then this is listed in the file
|
||||
arch/$(ARCH)/include/asm/Kbuild like this:
|
||||
|
||||
Example:
|
||||
#arch/x86/include/asm/Kbuild
|
||||
generic-y += termios.h
|
||||
generic-y += rtc.h
|
||||
|
||||
During the prepare phase of the build a wrapper include
|
||||
file is generated in the directory:
|
||||
|
||||
arch/$(ARCH)/include/generated/asm
|
||||
|
||||
When a header is exported where the architecture uses
|
||||
the generic header a similar wrapper is generated as part
|
||||
of the set of exported headers in the directory:
|
||||
|
||||
usr/include/asm
|
||||
|
||||
The generated wrapper will in both cases look like the following:
|
||||
|
||||
Example: termios.h
|
||||
#include <asm-generic/termios.h>
|
||||
|
||||
=== 8 Kbuild Variables
|
||||
|
||||
|
|
|
|||
50
Makefile
50
Makefile
|
|
@ -103,7 +103,7 @@ ifeq ("$(origin O)", "command line")
|
|||
endif
|
||||
|
||||
ifeq ("$(origin W)", "command line")
|
||||
export KBUILD_ENABLE_EXTRA_GCC_CHECKS := 1
|
||||
export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
|
||||
endif
|
||||
|
||||
# That's our default target when none is given on the command line
|
||||
|
|
@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
|
|||
|
||||
# Use LINUXINCLUDE when you must reference the include/ directory.
|
||||
# Needed to be compatible with the O= option
|
||||
LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
|
||||
LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
|
||||
-Iarch/$(hdr-arch)/include/generated -Iinclude \
|
||||
$(if $(KBUILD_SRC), -I$(srctree)/include) \
|
||||
-include include/generated/autoconf.h
|
||||
|
||||
|
|
@ -382,6 +383,7 @@ export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV
|
|||
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
|
||||
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
|
||||
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
|
||||
export KBUILD_ARFLAGS
|
||||
|
||||
# When compiling out-of-tree modules, put MODVERDIR in the module
|
||||
# tree rather than in the kernel tree. The kernel tree might
|
||||
|
|
@ -416,6 +418,12 @@ ifneq ($(KBUILD_SRC),)
|
|||
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
|
||||
endif
|
||||
|
||||
# Support for using generic headers in asm-generic
|
||||
PHONY += asm-generic
|
||||
asm-generic:
|
||||
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
|
||||
obj=arch/$(SRCARCH)/include/generated/asm
|
||||
|
||||
# To make sure we do not include .config for any of the *config targets
|
||||
# catch them early, and hand them over to scripts/kconfig/Makefile
|
||||
# It is allowed to specify more targets when calling make, including
|
||||
|
|
@ -559,6 +567,10 @@ ifndef CONFIG_CC_STACKPROTECTOR
|
|||
KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
|
||||
endif
|
||||
|
||||
# This warning generated too much noise in a regular build.
|
||||
# Use make W=1 to enable this warning (see scripts/Makefile.build)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
|
||||
|
||||
ifdef CONFIG_FRAME_POINTER
|
||||
KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
||||
else
|
||||
|
|
@ -604,7 +616,7 @@ CHECKFLAGS += $(NOSTDINC_FLAGS)
|
|||
KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
|
||||
|
||||
# disable pointer signed / unsigned warnings in gcc 4.0
|
||||
KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign)
|
||||
|
||||
# disable invalid "can't wrap" optimizations for signed / pointers
|
||||
KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
|
||||
|
|
@ -612,6 +624,9 @@ KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
|
|||
# conserve stack if available
|
||||
KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
|
||||
|
||||
# use the deterministic mode of AR if available
|
||||
KBUILD_ARFLAGS := $(call ar-option,D)
|
||||
|
||||
# check for 'asm goto'
|
||||
ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y)
|
||||
KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
|
||||
|
|
@ -797,15 +812,17 @@ ifdef CONFIG_KALLSYMS
|
|||
# o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
|
||||
# o Verify that the System.map from vmlinux matches the map from
|
||||
# .tmp_vmlinux2, just in case we did not generate kallsyms correctly.
|
||||
# o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using
|
||||
# o If 'make KALLSYMS_EXTRA_PASS=1" was used, do an extra pass using
|
||||
# .tmp_vmlinux3 and .tmp_kallsyms3.o. This is only meant as a
|
||||
# temporary bypass to allow the kernel to be built while the
|
||||
# maintainers work out what went wrong with kallsyms.
|
||||
|
||||
ifdef CONFIG_KALLSYMS_EXTRA_PASS
|
||||
last_kallsyms := 3
|
||||
else
|
||||
last_kallsyms := 2
|
||||
|
||||
ifdef KALLSYMS_EXTRA_PASS
|
||||
ifneq ($(KALLSYMS_EXTRA_PASS),0)
|
||||
last_kallsyms := 3
|
||||
endif
|
||||
endif
|
||||
|
||||
kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
|
||||
|
|
@ -816,7 +833,8 @@ define verify_kallsyms
|
|||
$(cmd_sysmap) .tmp_vmlinux$(last_kallsyms) .tmp_System.map
|
||||
$(Q)cmp -s System.map .tmp_System.map || \
|
||||
(echo Inconsistent kallsyms data; \
|
||||
echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \
|
||||
echo This is a bug - please report about it; \
|
||||
echo Try "make KALLSYMS_EXTRA_PASS=1" as a workaround; \
|
||||
rm .tmp_kallsyms* ; /bin/false )
|
||||
endef
|
||||
|
||||
|
|
@ -947,7 +965,7 @@ ifneq ($(KBUILD_SRC),)
|
|||
endif
|
||||
|
||||
# prepare2 creates a makefile if using a separate output directory
|
||||
prepare2: prepare3 outputmakefile
|
||||
prepare2: prepare3 outputmakefile asm-generic
|
||||
|
||||
prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
|
||||
include/config/auto.conf
|
||||
|
|
@ -1021,7 +1039,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
|
|||
hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
|
||||
|
||||
PHONY += __headers
|
||||
__headers: include/linux/version.h scripts_basic FORCE
|
||||
__headers: include/linux/version.h scripts_basic asm-generic FORCE
|
||||
$(Q)$(MAKE) $(build)=scripts build_unifdef
|
||||
|
||||
PHONY += headers_install_all
|
||||
|
|
@ -1136,7 +1154,8 @@ CLEAN_FILES += vmlinux System.map \
|
|||
.tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
|
||||
|
||||
# Directories & files removed with 'make mrproper'
|
||||
MRPROPER_DIRS += include/config usr/include include/generated
|
||||
MRPROPER_DIRS += include/config usr/include include/generated \
|
||||
arch/*/include/generated
|
||||
MRPROPER_FILES += .config .config.old .version .old_version \
|
||||
include/linux/version.h \
|
||||
Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
|
||||
|
|
@ -1267,7 +1286,11 @@ help:
|
|||
@echo ' make O=dir [targets] Locate all output files in "dir", including .config'
|
||||
@echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
|
||||
@echo ' make C=2 [targets] Force check of all c source with $$CHECK'
|
||||
@echo ' make W=1 [targets] Enable extra gcc checks'
|
||||
@echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
|
||||
@echo ' 1: warnings which may be relevant and do not occur too often'
|
||||
@echo ' 2: warnings which occur quite often but may still be relevant'
|
||||
@echo ' 3: more obscure warnings, can most likely be ignored'
|
||||
@echo ' Multiple levels can be combined with W=12 or W=123'
|
||||
@echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
|
||||
@echo ''
|
||||
@echo 'Execute "make" or "make all" to build all targets marked with [*] '
|
||||
|
|
@ -1291,6 +1314,7 @@ $(help-board-dirs): help-%:
|
|||
# Documentation targets
|
||||
# ---------------------------------------------------------------------------
|
||||
%docs: scripts_basic FORCE
|
||||
$(Q)$(MAKE) $(build)=scripts build_docproc
|
||||
$(Q)$(MAKE) $(build)=Documentation/DocBook $@
|
||||
|
||||
else # KBUILD_EXTMOD
|
||||
|
|
@ -1375,7 +1399,7 @@ endif # KBUILD_EXTMOD
|
|||
clean: $(clean-dirs)
|
||||
$(call cmd,rmdirs)
|
||||
$(call cmd,rmfiles)
|
||||
@find $(or $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
|
||||
@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
|
||||
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
|
||||
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
|
||||
-o -name '*.symtypes' -o -name 'modules.order' \
|
||||
|
|
|
|||
26
init/Kconfig
26
init/Kconfig
|
|
@ -959,24 +959,18 @@ config KALLSYMS_ALL
|
|||
bool "Include all symbols in kallsyms"
|
||||
depends on DEBUG_KERNEL && KALLSYMS
|
||||
help
|
||||
Normally kallsyms only contains the symbols of functions, for nicer
|
||||
OOPS messages. Some debuggers can use kallsyms for other
|
||||
symbols too: say Y here to include all symbols, if you need them
|
||||
and you don't care about adding 300k to the size of your kernel.
|
||||
Normally kallsyms only contains the symbols of functions for nicer
|
||||
OOPS messages and backtraces (i.e., symbols from the text and inittext
|
||||
sections). This is sufficient for most cases. And only in very rare
|
||||
cases (e.g., when a debugger is used) all symbols are required (e.g.,
|
||||
names of variables from the data sections, etc).
|
||||
|
||||
Say N.
|
||||
|
||||
config KALLSYMS_EXTRA_PASS
|
||||
bool "Do an extra kallsyms pass"
|
||||
depends on KALLSYMS
|
||||
help
|
||||
If kallsyms is not working correctly, the build will fail with
|
||||
inconsistent kallsyms data. If that occurs, log a bug report and
|
||||
turn on KALLSYMS_EXTRA_PASS which should result in a stable build.
|
||||
Always say N here unless you find a bug in kallsyms, which must be
|
||||
reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while
|
||||
you wait for kallsyms to be fixed.
|
||||
This option makes sure that all symbols are loaded into the kernel
|
||||
image (i.e., symbols from all sections) in cost of increased kernel
|
||||
size (depending on the kernel configuration, it may be 300KiB or
|
||||
something like this).
|
||||
|
||||
Say N unless you really need all symbols.
|
||||
|
||||
config HOTPLUG
|
||||
bool "Support for hot-pluggable devices" if EXPERT
|
||||
|
|
|
|||
1
scripts/.gitignore
vendored
1
scripts/.gitignore
vendored
|
|
@ -8,3 +8,4 @@ bin2c
|
|||
unifdef
|
||||
ihex2fw
|
||||
recordmcount
|
||||
docproc
|
||||
|
|
|
|||
|
|
@ -118,6 +118,11 @@ cc-option-yn = $(call try-run,\
|
|||
cc-option-align = $(subst -functions=0,,\
|
||||
$(call cc-option,-falign-functions=0,-malign-functions=0))
|
||||
|
||||
# cc-disable-warning
|
||||
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
|
||||
cc-disable-warning = $(call try-run,\
|
||||
$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1)))
|
||||
|
||||
# cc-version
|
||||
# Usage gcc-ver := $(call cc-version)
|
||||
cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
|
||||
|
|
@ -141,6 +146,11 @@ cc-ldoption = $(call try-run,\
|
|||
ld-option = $(call try-run,\
|
||||
$(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
|
||||
|
||||
# ar-option
|
||||
# Usage: KBUILD_ARFLAGS := $(call ar-option,D)
|
||||
# Important: no spaces around options
|
||||
ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
|
||||
|
||||
######
|
||||
|
||||
###
|
||||
|
|
@ -187,6 +197,8 @@ ifneq ($(KBUILD_NOCMDDEP),1)
|
|||
# User may override this check using make KBUILD_NOCMDDEP=1
|
||||
arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
|
||||
$(filter-out $(cmd_$@), $(cmd_$(1))) )
|
||||
else
|
||||
arg-check = $(if $(strip $(cmd_$@)),,1)
|
||||
endif
|
||||
|
||||
# >'< substitution is for echo to work,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
# pnmttologo: Convert pnm files to logo files
|
||||
# conmakehash: Create chartable
|
||||
# conmakehash: Create arrays for initializing the kernel console tables
|
||||
# docproc: Used in Documentation/DocBook
|
||||
|
||||
hostprogs-$(CONFIG_KALLSYMS) += kallsyms
|
||||
hostprogs-$(CONFIG_LOGO) += pnmtologo
|
||||
|
|
@ -16,12 +17,14 @@ hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount
|
|||
always := $(hostprogs-y) $(hostprogs-m)
|
||||
|
||||
# The following hostprogs-y programs are only build on demand
|
||||
hostprogs-y += unifdef
|
||||
hostprogs-y += unifdef docproc
|
||||
|
||||
# This target is used internally to avoid "is up to date" messages
|
||||
# These targets are used internally to avoid "is up to date" messages
|
||||
PHONY += build_unifdef
|
||||
build_unifdef: scripts/unifdef FORCE
|
||||
@:
|
||||
build_docproc: scripts/docproc FORCE
|
||||
@:
|
||||
|
||||
subdir-$(CONFIG_MODVERSIONS) += genksyms
|
||||
subdir-y += mod
|
||||
|
|
|
|||
23
scripts/Makefile.asm-generic
Normal file
23
scripts/Makefile.asm-generic
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# include/asm-generic contains a lot of files that are used
|
||||
# verbatim by several architectures.
|
||||
#
|
||||
# This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild
|
||||
# and for each file listed in this file with generic-y creates
|
||||
# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
|
||||
|
||||
kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
|
||||
-include $(kbuild-file)
|
||||
|
||||
include scripts/Kbuild.include
|
||||
|
||||
# Create output directory if not already present
|
||||
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
|
||||
|
||||
quiet_cmd_wrap = WRAP $@
|
||||
cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
|
||||
|
||||
all: $(patsubst %, $(obj)/%, $(generic-y))
|
||||
|
||||
$(obj)/%.h:
|
||||
$(call cmd,wrap)
|
||||
|
||||
|
|
@ -51,36 +51,52 @@ ifeq ($(KBUILD_NOPEDANTIC),)
|
|||
endif
|
||||
|
||||
#
|
||||
# make W=1 settings
|
||||
# make W=... settings
|
||||
#
|
||||
# $(call cc-option... ) handles gcc -W.. options which
|
||||
# W=1 - warnings that may be relevant and does not occur too often
|
||||
# W=2 - warnings that occur quite often but may still be relevant
|
||||
# W=3 - the more obscure warnings, can most likely be ignored
|
||||
#
|
||||
# $(call cc-option, -W...) handles gcc -W.. options which
|
||||
# are not supported by all versions of the compiler
|
||||
ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
|
||||
KBUILD_EXTRA_WARNINGS := -Wextra
|
||||
KBUILD_EXTRA_WARNINGS += -Wunused -Wno-unused-parameter
|
||||
KBUILD_EXTRA_WARNINGS += -Waggregate-return
|
||||
KBUILD_EXTRA_WARNINGS += -Wbad-function-cast
|
||||
KBUILD_EXTRA_WARNINGS += -Wcast-qual
|
||||
KBUILD_EXTRA_WARNINGS += -Wcast-align
|
||||
KBUILD_EXTRA_WARNINGS += -Wconversion
|
||||
KBUILD_EXTRA_WARNINGS += -Wdisabled-optimization
|
||||
KBUILD_EXTRA_WARNINGS += -Wlogical-op
|
||||
KBUILD_EXTRA_WARNINGS += -Wmissing-declarations
|
||||
KBUILD_EXTRA_WARNINGS += -Wmissing-format-attribute
|
||||
KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wmissing-include-dirs,)
|
||||
KBUILD_EXTRA_WARNINGS += -Wmissing-prototypes
|
||||
KBUILD_EXTRA_WARNINGS += -Wnested-externs
|
||||
KBUILD_EXTRA_WARNINGS += -Wold-style-definition
|
||||
KBUILD_EXTRA_WARNINGS += $(call cc-option, -Woverlength-strings,)
|
||||
KBUILD_EXTRA_WARNINGS += -Wpacked
|
||||
KBUILD_EXTRA_WARNINGS += -Wpacked-bitfield-compat
|
||||
KBUILD_EXTRA_WARNINGS += -Wpadded
|
||||
KBUILD_EXTRA_WARNINGS += -Wpointer-arith
|
||||
KBUILD_EXTRA_WARNINGS += -Wredundant-decls
|
||||
KBUILD_EXTRA_WARNINGS += -Wshadow
|
||||
KBUILD_EXTRA_WARNINGS += -Wswitch-default
|
||||
KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wvla,)
|
||||
KBUILD_CFLAGS += $(KBUILD_EXTRA_WARNINGS)
|
||||
warning- := $(empty)
|
||||
|
||||
warning-1 := -Wextra -Wunused -Wno-unused-parameter
|
||||
warning-1 += -Wmissing-declarations
|
||||
warning-1 += -Wmissing-format-attribute
|
||||
warning-1 += -Wmissing-prototypes
|
||||
warning-1 += -Wold-style-definition
|
||||
warning-1 += $(call cc-option, -Wmissing-include-dirs)
|
||||
warning-1 += $(call cc-option, -Wunused-but-set-variable)
|
||||
|
||||
warning-2 := -Waggregate-return
|
||||
warning-2 += -Wcast-align
|
||||
warning-2 += -Wdisabled-optimization
|
||||
warning-2 += -Wnested-externs
|
||||
warning-2 += -Wshadow
|
||||
warning-2 += $(call cc-option, -Wlogical-op)
|
||||
|
||||
warning-3 := -Wbad-function-cast
|
||||
warning-3 += -Wcast-qual
|
||||
warning-3 += -Wconversion
|
||||
warning-3 += -Wpacked
|
||||
warning-3 += -Wpadded
|
||||
warning-3 += -Wpointer-arith
|
||||
warning-3 += -Wredundant-decls
|
||||
warning-3 += -Wswitch-default
|
||||
warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
|
||||
warning-3 += $(call cc-option, -Wvla)
|
||||
|
||||
warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
|
||||
warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
|
||||
warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
|
||||
|
||||
ifeq ("$(strip $(warning))","")
|
||||
$(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
|
||||
endif
|
||||
|
||||
KBUILD_CFLAGS += $(warning)
|
||||
endif
|
||||
|
||||
include scripts/Makefile.lib
|
||||
|
|
@ -351,7 +367,7 @@ quiet_cmd_link_o_target = LD $@
|
|||
cmd_link_o_target = $(if $(strip $(obj-y)),\
|
||||
$(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \
|
||||
$(cmd_secanalysis),\
|
||||
rm -f $@; $(AR) rcs $@)
|
||||
rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@)
|
||||
|
||||
$(builtin-target): $(obj-y) FORCE
|
||||
$(call if_changed,link_o_target)
|
||||
|
|
@ -377,7 +393,7 @@ $(modorder-target): $(subdir-ym) FORCE
|
|||
#
|
||||
ifdef lib-target
|
||||
quiet_cmd_link_l_target = AR $@
|
||||
cmd_link_l_target = rm -f $@; $(AR) rcs $@ $(lib-y)
|
||||
cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y)
|
||||
|
||||
$(lib-target): $(lib-y) FORCE
|
||||
$(call if_changed,link_l_target)
|
||||
|
|
|
|||
|
|
@ -27,8 +27,13 @@ header-y := $(filter-out %/, $(header-y))
|
|||
install-file := $(install)/.install
|
||||
check-file := $(install)/.check
|
||||
|
||||
# generic-y list all files an architecture uses from asm-generic
|
||||
# Use this to build a list of headers which require a wrapper
|
||||
wrapper-files := $(filter $(header-y), $(generic-y))
|
||||
|
||||
# all headers files for this dir
|
||||
all-files := $(header-y) $(objhdr-y)
|
||||
header-y := $(filter-out $(generic-y), $(header-y))
|
||||
all-files := $(header-y) $(objhdr-y) $(wrapper-files)
|
||||
input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
|
||||
$(addprefix $(objtree)/$(obj)/,$(objhdr-y))
|
||||
output-files := $(addprefix $(install)/, $(all-files))
|
||||
|
|
@ -47,6 +52,9 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
|
|||
cmd_install = \
|
||||
$(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
|
||||
$(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
|
||||
for F in $(wrapper-files); do \
|
||||
echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
|
||||
done; \
|
||||
touch $@
|
||||
|
||||
quiet_cmd_remove = REMOVE $(unwanted)
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
|
|||
# ---------------------------------------------------------------------------
|
||||
|
||||
quiet_cmd_gzip = GZIP $@
|
||||
cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \
|
||||
cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
|
||||
(rm -f $@ ; false)
|
||||
|
||||
# DTC
|
||||
|
|
|
|||
2
scripts/basic/.gitignore
vendored
2
scripts/basic/.gitignore
vendored
|
|
@ -1,3 +1 @@
|
|||
hash
|
||||
fixdep
|
||||
docproc
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@
|
|||
# .config is included by main Makefile.
|
||||
# ---------------------------------------------------------------------------
|
||||
# fixdep: Used to generate dependency information during build process
|
||||
# docproc: Used in Documentation/DocBook
|
||||
|
||||
hostprogs-y := fixdep docproc
|
||||
hostprogs-y := fixdep
|
||||
always := $(hostprogs-y)
|
||||
|
||||
# fixdep is needed to compile other host programs
|
||||
|
|
|
|||
583
scripts/docproc.c
Normal file
583
scripts/docproc.c
Normal file
|
|
@ -0,0 +1,583 @@
|
|||
/*
|
||||
* docproc is a simple preprocessor for the template files
|
||||
* used as placeholders for the kernel internal documentation.
|
||||
* docproc is used for documentation-frontend and
|
||||
* dependency-generator.
|
||||
* The two usages have in common that they require
|
||||
* some knowledge of the .tmpl syntax, therefore they
|
||||
* are kept together.
|
||||
*
|
||||
* documentation-frontend
|
||||
* Scans the template file and call kernel-doc for
|
||||
* all occurrences of ![EIF]file
|
||||
* Beforehand each referenced file is scanned for
|
||||
* any symbols that are exported via these macros:
|
||||
* EXPORT_SYMBOL(), EXPORT_SYMBOL_GPL(), &
|
||||
* EXPORT_SYMBOL_GPL_FUTURE()
|
||||
* This is used to create proper -function and
|
||||
* -nofunction arguments in calls to kernel-doc.
|
||||
* Usage: docproc doc file.tmpl
|
||||
*
|
||||
* dependency-generator:
|
||||
* Scans the template file and list all files
|
||||
* referenced in a format recognized by make.
|
||||
* Usage: docproc depend file.tmpl
|
||||
* Writes dependency information to stdout
|
||||
* in the following format:
|
||||
* file.tmpl src.c src2.c
|
||||
* The filenames are obtained from the following constructs:
|
||||
* !Efilename
|
||||
* !Ifilename
|
||||
* !Dfilename
|
||||
* !Ffilename
|
||||
* !Pfilename
|
||||
*
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
/* exitstatus is used to keep track of any failing calls to kernel-doc,
|
||||
* but execution continues. */
|
||||
int exitstatus = 0;
|
||||
|
||||
typedef void DFL(char *);
|
||||
DFL *defaultline;
|
||||
|
||||
typedef void FILEONLY(char * file);
|
||||
FILEONLY *internalfunctions;
|
||||
FILEONLY *externalfunctions;
|
||||
FILEONLY *symbolsonly;
|
||||
FILEONLY *findall;
|
||||
|
||||
typedef void FILELINE(char * file, char * line);
|
||||
FILELINE * singlefunctions;
|
||||
FILELINE * entity_system;
|
||||
FILELINE * docsection;
|
||||
|
||||
#define MAXLINESZ 2048
|
||||
#define MAXFILES 250
|
||||
#define KERNELDOCPATH "scripts/"
|
||||
#define KERNELDOC "kernel-doc"
|
||||
#define DOCBOOK "-docbook"
|
||||
#define LIST "-list"
|
||||
#define FUNCTION "-function"
|
||||
#define NOFUNCTION "-nofunction"
|
||||
#define NODOCSECTIONS "-no-doc-sections"
|
||||
|
||||
static char *srctree, *kernsrctree;
|
||||
|
||||
static char **all_list = NULL;
|
||||
static int all_list_len = 0;
|
||||
|
||||
static void consume_symbol(const char *sym)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < all_list_len; i++) {
|
||||
if (!all_list[i])
|
||||
continue;
|
||||
if (strcmp(sym, all_list[i]))
|
||||
continue;
|
||||
all_list[i] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void usage (void)
|
||||
{
|
||||
fprintf(stderr, "Usage: docproc {doc|depend} file\n");
|
||||
fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n");
|
||||
fprintf(stderr, "doc: frontend when generating kernel documentation\n");
|
||||
fprintf(stderr, "depend: generate list of files referenced within file\n");
|
||||
fprintf(stderr, "Environment variable SRCTREE: absolute path to sources.\n");
|
||||
fprintf(stderr, " KBUILD_SRC: absolute path to kernel source tree.\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute kernel-doc with parameters given in svec
|
||||
*/
|
||||
static void exec_kernel_doc(char **svec)
|
||||
{
|
||||
pid_t pid;
|
||||
int ret;
|
||||
char real_filename[PATH_MAX + 1];
|
||||
/* Make sure output generated so far are flushed */
|
||||
fflush(stdout);
|
||||
switch (pid=fork()) {
|
||||
case -1:
|
||||
perror("fork");
|
||||
exit(1);
|
||||
case 0:
|
||||
memset(real_filename, 0, sizeof(real_filename));
|
||||
strncat(real_filename, kernsrctree, PATH_MAX);
|
||||
strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
|
||||
PATH_MAX - strlen(real_filename));
|
||||
execvp(real_filename, svec);
|
||||
fprintf(stderr, "exec ");
|
||||
perror(real_filename);
|
||||
exit(1);
|
||||
default:
|
||||
waitpid(pid, &ret ,0);
|
||||
}
|
||||
if (WIFEXITED(ret))
|
||||
exitstatus |= WEXITSTATUS(ret);
|
||||
else
|
||||
exitstatus = 0xff;
|
||||
}
|
||||
|
||||
/* Types used to create list of all exported symbols in a number of files */
|
||||
struct symbols
|
||||
{
|
||||
char *name;
|
||||
};
|
||||
|
||||
struct symfile
|
||||
{
|
||||
char *filename;
|
||||
struct symbols *symbollist;
|
||||
int symbolcnt;
|
||||
};
|
||||
|
||||
struct symfile symfilelist[MAXFILES];
|
||||
int symfilecnt = 0;
|
||||
|
||||
static void add_new_symbol(struct symfile *sym, char * symname)
|
||||
{
|
||||
sym->symbollist =
|
||||
realloc(sym->symbollist, (sym->symbolcnt + 1) * sizeof(char *));
|
||||
sym->symbollist[sym->symbolcnt++].name = strdup(symname);
|
||||
}
|
||||
|
||||
/* Add a filename to the list */
|
||||
static struct symfile * add_new_file(char * filename)
|
||||
{
|
||||
symfilelist[symfilecnt++].filename = strdup(filename);
|
||||
return &symfilelist[symfilecnt - 1];
|
||||
}
|
||||
|
||||
/* Check if file already are present in the list */
|
||||
static struct symfile * filename_exist(char * filename)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < symfilecnt; i++)
|
||||
if (strcmp(symfilelist[i].filename, filename) == 0)
|
||||
return &symfilelist[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* List all files referenced within the template file.
|
||||
* Files are separated by tabs.
|
||||
*/
|
||||
static void adddep(char * file) { printf("\t%s", file); }
|
||||
static void adddep2(char * file, char * line) { line = line; adddep(file); }
|
||||
static void noaction(char * line) { line = line; }
|
||||
static void noaction2(char * file, char * line) { file = file; line = line; }
|
||||
|
||||
/* Echo the line without further action */
|
||||
static void printline(char * line) { printf("%s", line); }
|
||||
|
||||
/*
|
||||
* Find all symbols in filename that are exported with EXPORT_SYMBOL &
|
||||
* EXPORT_SYMBOL_GPL (& EXPORT_SYMBOL_GPL_FUTURE implicitly).
|
||||
* All symbols located are stored in symfilelist.
|
||||
*/
|
||||
static void find_export_symbols(char * filename)
|
||||
{
|
||||
FILE * fp;
|
||||
struct symfile *sym;
|
||||
char line[MAXLINESZ];
|
||||
if (filename_exist(filename) == NULL) {
|
||||
char real_filename[PATH_MAX + 1];
|
||||
memset(real_filename, 0, sizeof(real_filename));
|
||||
strncat(real_filename, srctree, PATH_MAX);
|
||||
strncat(real_filename, "/", PATH_MAX - strlen(real_filename));
|
||||
strncat(real_filename, filename,
|
||||
PATH_MAX - strlen(real_filename));
|
||||
sym = add_new_file(filename);
|
||||
fp = fopen(real_filename, "r");
|
||||
if (fp == NULL)
|
||||
{
|
||||
fprintf(stderr, "docproc: ");
|
||||
perror(real_filename);
|
||||
exit(1);
|
||||
}
|
||||
while (fgets(line, MAXLINESZ, fp)) {
|
||||
char *p;
|
||||
char *e;
|
||||
if (((p = strstr(line, "EXPORT_SYMBOL_GPL")) != NULL) ||
|
||||
((p = strstr(line, "EXPORT_SYMBOL")) != NULL)) {
|
||||
/* Skip EXPORT_SYMBOL{_GPL} */
|
||||
while (isalnum(*p) || *p == '_')
|
||||
p++;
|
||||
/* Remove parentheses & additional whitespace */
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
if (*p != '(')
|
||||
continue; /* Syntax error? */
|
||||
else
|
||||
p++;
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
e = p;
|
||||
while (isalnum(*e) || *e == '_')
|
||||
e++;
|
||||
*e = '\0';
|
||||
add_new_symbol(sym, p);
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Document all external or internal functions in a file.
|
||||
* Call kernel-doc with following parameters:
|
||||
* kernel-doc -docbook -nofunction function_name1 filename
|
||||
* Function names are obtained from all the src files
|
||||
* by find_export_symbols.
|
||||
* intfunc uses -nofunction
|
||||
* extfunc uses -function
|
||||
*/
|
||||
static void docfunctions(char * filename, char * type)
|
||||
{
|
||||
int i,j;
|
||||
int symcnt = 0;
|
||||
int idx = 0;
|
||||
char **vec;
|
||||
|
||||
for (i=0; i <= symfilecnt; i++)
|
||||
symcnt += symfilelist[i].symbolcnt;
|
||||
vec = malloc((2 + 2 * symcnt + 3) * sizeof(char *));
|
||||
if (vec == NULL) {
|
||||
perror("docproc: ");
|
||||
exit(1);
|
||||
}
|
||||
vec[idx++] = KERNELDOC;
|
||||
vec[idx++] = DOCBOOK;
|
||||
vec[idx++] = NODOCSECTIONS;
|
||||
for (i=0; i < symfilecnt; i++) {
|
||||
struct symfile * sym = &symfilelist[i];
|
||||
for (j=0; j < sym->symbolcnt; j++) {
|
||||
vec[idx++] = type;
|
||||
consume_symbol(sym->symbollist[j].name);
|
||||
vec[idx++] = sym->symbollist[j].name;
|
||||
}
|
||||
}
|
||||
vec[idx++] = filename;
|
||||
vec[idx] = NULL;
|
||||
printf("<!-- %s -->\n", filename);
|
||||
exec_kernel_doc(vec);
|
||||
fflush(stdout);
|
||||
free(vec);
|
||||
}
|
||||
static void intfunc(char * filename) { docfunctions(filename, NOFUNCTION); }
|
||||
static void extfunc(char * filename) { docfunctions(filename, FUNCTION); }
|
||||
|
||||
/*
|
||||
* Document specific function(s) in a file.
|
||||
* Call kernel-doc with the following parameters:
|
||||
* kernel-doc -docbook -function function1 [-function function2]
|
||||
*/
|
||||
static void singfunc(char * filename, char * line)
|
||||
{
|
||||
char *vec[200]; /* Enough for specific functions */
|
||||
int i, idx = 0;
|
||||
int startofsym = 1;
|
||||
vec[idx++] = KERNELDOC;
|
||||
vec[idx++] = DOCBOOK;
|
||||
|
||||
/* Split line up in individual parameters preceded by FUNCTION */
|
||||
for (i=0; line[i]; i++) {
|
||||
if (isspace(line[i])) {
|
||||
line[i] = '\0';
|
||||
startofsym = 1;
|
||||
continue;
|
||||
}
|
||||
if (startofsym) {
|
||||
startofsym = 0;
|
||||
vec[idx++] = FUNCTION;
|
||||
vec[idx++] = &line[i];
|
||||
}
|
||||
}
|
||||
for (i = 0; i < idx; i++) {
|
||||
if (strcmp(vec[i], FUNCTION))
|
||||
continue;
|
||||
consume_symbol(vec[i + 1]);
|
||||
}
|
||||
vec[idx++] = filename;
|
||||
vec[idx] = NULL;
|
||||
exec_kernel_doc(vec);
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert specific documentation section from a file.
|
||||
* Call kernel-doc with the following parameters:
|
||||
* kernel-doc -docbook -function "doc section" filename
|
||||
*/
|
||||
static void docsect(char *filename, char *line)
|
||||
{
|
||||
char *vec[6]; /* kerneldoc -docbook -function "section" file NULL */
|
||||
char *s;
|
||||
|
||||
for (s = line; *s; s++)
|
||||
if (*s == '\n')
|
||||
*s = '\0';
|
||||
|
||||
if (asprintf(&s, "DOC: %s", line) < 0) {
|
||||
perror("asprintf");
|
||||
exit(1);
|
||||
}
|
||||
consume_symbol(s);
|
||||
free(s);
|
||||
|
||||
vec[0] = KERNELDOC;
|
||||
vec[1] = DOCBOOK;
|
||||
vec[2] = FUNCTION;
|
||||
vec[3] = line;
|
||||
vec[4] = filename;
|
||||
vec[5] = NULL;
|
||||
exec_kernel_doc(vec);
|
||||
}
|
||||
|
||||
static void find_all_symbols(char *filename)
|
||||
{
|
||||
char *vec[4]; /* kerneldoc -list file NULL */
|
||||
pid_t pid;
|
||||
int ret, i, count, start;
|
||||
char real_filename[PATH_MAX + 1];
|
||||
int pipefd[2];
|
||||
char *data, *str;
|
||||
size_t data_len = 0;
|
||||
|
||||
vec[0] = KERNELDOC;
|
||||
vec[1] = LIST;
|
||||
vec[2] = filename;
|
||||
vec[3] = NULL;
|
||||
|
||||
if (pipe(pipefd)) {
|
||||
perror("pipe");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
switch (pid=fork()) {
|
||||
case -1:
|
||||
perror("fork");
|
||||
exit(1);
|
||||
case 0:
|
||||
close(pipefd[0]);
|
||||
dup2(pipefd[1], 1);
|
||||
memset(real_filename, 0, sizeof(real_filename));
|
||||
strncat(real_filename, kernsrctree, PATH_MAX);
|
||||
strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
|
||||
PATH_MAX - strlen(real_filename));
|
||||
execvp(real_filename, vec);
|
||||
fprintf(stderr, "exec ");
|
||||
perror(real_filename);
|
||||
exit(1);
|
||||
default:
|
||||
close(pipefd[1]);
|
||||
data = malloc(4096);
|
||||
do {
|
||||
while ((ret = read(pipefd[0],
|
||||
data + data_len,
|
||||
4096)) > 0) {
|
||||
data_len += ret;
|
||||
data = realloc(data, data_len + 4096);
|
||||
}
|
||||
} while (ret == -EAGAIN);
|
||||
if (ret != 0) {
|
||||
perror("read");
|
||||
exit(1);
|
||||
}
|
||||
waitpid(pid, &ret ,0);
|
||||
}
|
||||
if (WIFEXITED(ret))
|
||||
exitstatus |= WEXITSTATUS(ret);
|
||||
else
|
||||
exitstatus = 0xff;
|
||||
|
||||
count = 0;
|
||||
/* poor man's strtok, but with counting */
|
||||
for (i = 0; i < data_len; i++) {
|
||||
if (data[i] == '\n') {
|
||||
count++;
|
||||
data[i] = '\0';
|
||||
}
|
||||
}
|
||||
start = all_list_len;
|
||||
all_list_len += count;
|
||||
all_list = realloc(all_list, sizeof(char *) * all_list_len);
|
||||
str = data;
|
||||
for (i = 0; i < data_len && start != all_list_len; i++) {
|
||||
if (data[i] == '\0') {
|
||||
all_list[start] = str;
|
||||
str = data + i + 1;
|
||||
start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse file, calling action specific functions for:
|
||||
* 1) Lines containing !E
|
||||
* 2) Lines containing !I
|
||||
* 3) Lines containing !D
|
||||
* 4) Lines containing !F
|
||||
* 5) Lines containing !P
|
||||
* 6) Lines containing !C
|
||||
* 7) Default lines - lines not matching the above
|
||||
*/
|
||||
static void parse_file(FILE *infile)
|
||||
{
|
||||
char line[MAXLINESZ];
|
||||
char * s;
|
||||
while (fgets(line, MAXLINESZ, infile)) {
|
||||
if (line[0] == '!') {
|
||||
s = line + 2;
|
||||
switch (line[1]) {
|
||||
case 'E':
|
||||
while (*s && !isspace(*s)) s++;
|
||||
*s = '\0';
|
||||
externalfunctions(line+2);
|
||||
break;
|
||||
case 'I':
|
||||
while (*s && !isspace(*s)) s++;
|
||||
*s = '\0';
|
||||
internalfunctions(line+2);
|
||||
break;
|
||||
case 'D':
|
||||
while (*s && !isspace(*s)) s++;
|
||||
*s = '\0';
|
||||
symbolsonly(line+2);
|
||||
break;
|
||||
case 'F':
|
||||
/* filename */
|
||||
while (*s && !isspace(*s)) s++;
|
||||
*s++ = '\0';
|
||||
/* function names */
|
||||
while (isspace(*s))
|
||||
s++;
|
||||
singlefunctions(line +2, s);
|
||||
break;
|
||||
case 'P':
|
||||
/* filename */
|
||||
while (*s && !isspace(*s)) s++;
|
||||
*s++ = '\0';
|
||||
/* DOC: section name */
|
||||
while (isspace(*s))
|
||||
s++;
|
||||
docsection(line + 2, s);
|
||||
break;
|
||||
case 'C':
|
||||
while (*s && !isspace(*s)) s++;
|
||||
*s = '\0';
|
||||
if (findall)
|
||||
findall(line+2);
|
||||
break;
|
||||
default:
|
||||
defaultline(line);
|
||||
}
|
||||
}
|
||||
else {
|
||||
defaultline(line);
|
||||
}
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE * infile;
|
||||
int i;
|
||||
|
||||
srctree = getenv("SRCTREE");
|
||||
if (!srctree)
|
||||
srctree = getcwd(NULL, 0);
|
||||
kernsrctree = getenv("KBUILD_SRC");
|
||||
if (!kernsrctree || !*kernsrctree)
|
||||
kernsrctree = srctree;
|
||||
if (argc != 3) {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
/* Open file, exit on error */
|
||||
infile = fopen(argv[2], "r");
|
||||
if (infile == NULL) {
|
||||
fprintf(stderr, "docproc: ");
|
||||
perror(argv[2]);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (strcmp("doc", argv[1]) == 0)
|
||||
{
|
||||
/* Need to do this in two passes.
|
||||
* First pass is used to collect all symbols exported
|
||||
* in the various files;
|
||||
* Second pass generate the documentation.
|
||||
* This is required because some functions are declared
|
||||
* and exported in different files :-((
|
||||
*/
|
||||
/* Collect symbols */
|
||||
defaultline = noaction;
|
||||
internalfunctions = find_export_symbols;
|
||||
externalfunctions = find_export_symbols;
|
||||
symbolsonly = find_export_symbols;
|
||||
singlefunctions = noaction2;
|
||||
docsection = noaction2;
|
||||
findall = find_all_symbols;
|
||||
parse_file(infile);
|
||||
|
||||
/* Rewind to start from beginning of file again */
|
||||
fseek(infile, 0, SEEK_SET);
|
||||
defaultline = printline;
|
||||
internalfunctions = intfunc;
|
||||
externalfunctions = extfunc;
|
||||
symbolsonly = printline;
|
||||
singlefunctions = singfunc;
|
||||
docsection = docsect;
|
||||
findall = NULL;
|
||||
|
||||
parse_file(infile);
|
||||
|
||||
for (i = 0; i < all_list_len; i++) {
|
||||
if (!all_list[i])
|
||||
continue;
|
||||
fprintf(stderr, "Warning: didn't use docs for %s\n",
|
||||
all_list[i]);
|
||||
}
|
||||
}
|
||||
else if (strcmp("depend", argv[1]) == 0)
|
||||
{
|
||||
/* Create first part of dependency chain
|
||||
* file.tmpl */
|
||||
printf("%s\t", argv[2]);
|
||||
defaultline = noaction;
|
||||
internalfunctions = adddep;
|
||||
externalfunctions = adddep;
|
||||
symbolsonly = adddep;
|
||||
singlefunctions = adddep2;
|
||||
docsection = adddep2;
|
||||
findall = adddep;
|
||||
parse_file(infile);
|
||||
printf("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Unknown option: %s\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
fclose(infile);
|
||||
fflush(stdout);
|
||||
return exitstatus;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
|
||||
# Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org>
|
||||
#
|
||||
|
|
@ -105,9 +105,9 @@ list_parse() {
|
|||
# for links, devices etc the format differs. See gen_init_cpio for details
|
||||
parse() {
|
||||
local location="$1"
|
||||
local name="${location/${srcdir}//}"
|
||||
local name="/${location#${srcdir}}"
|
||||
# change '//' into '/'
|
||||
name="${name//\/\///}"
|
||||
name=$(echo "$name" | sed -e 's://*:/:g')
|
||||
local mode="$2"
|
||||
local uid="$3"
|
||||
local gid="$4"
|
||||
|
|
@ -117,8 +117,8 @@ parse() {
|
|||
[ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0
|
||||
local str="${mode} ${uid} ${gid}"
|
||||
|
||||
[ "${ftype}" == "invalid" ] && return 0
|
||||
[ "${location}" == "${srcdir}" ] && return 0
|
||||
[ "${ftype}" = "invalid" ] && return 0
|
||||
[ "${location}" = "${srcdir}" ] && return 0
|
||||
|
||||
case "${ftype}" in
|
||||
"file")
|
||||
|
|
@ -192,7 +192,7 @@ input_file() {
|
|||
if [ -f "$1" ]; then
|
||||
${dep_list}header "$1"
|
||||
is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\?/cpio/')"
|
||||
if [ $2 -eq 0 -a ${is_cpio} == "cpio" ]; then
|
||||
if [ $2 -eq 0 -a ${is_cpio} = "cpio" ]; then
|
||||
cpio_file=$1
|
||||
echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed"
|
||||
[ ! -z ${dep_list} ] && echo "$1"
|
||||
|
|
@ -204,7 +204,7 @@ input_file() {
|
|||
else
|
||||
echo "$1 \\"
|
||||
cat "$1" | while read type dir file perm ; do
|
||||
if [ "$type" == "file" ]; then
|
||||
if [ "$type" = "file" ]; then
|
||||
echo "$file \\";
|
||||
fi
|
||||
done
|
||||
|
|
@ -226,7 +226,7 @@ cpio_list=
|
|||
output="/dev/stdout"
|
||||
output_file=""
|
||||
is_cpio_compressed=
|
||||
compr="gzip -9 -f"
|
||||
compr="gzip -n -9 -f"
|
||||
|
||||
arg="$1"
|
||||
case "$arg" in
|
||||
|
|
@ -240,7 +240,7 @@ case "$arg" in
|
|||
output_file="$1"
|
||||
cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)"
|
||||
output=${cpio_list}
|
||||
echo "$output_file" | grep -q "\.gz$" && compr="gzip -9 -f"
|
||||
echo "$output_file" | grep -q "\.gz$" && compr="gzip -n -9 -f"
|
||||
echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f"
|
||||
echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f"
|
||||
echo "$output_file" | grep -q "\.xz$" && \
|
||||
|
|
@ -287,8 +287,15 @@ done
|
|||
# we are careful to delete tmp files
|
||||
if [ ! -z ${output_file} ]; then
|
||||
if [ -z ${cpio_file} ]; then
|
||||
timestamp=
|
||||
if test -n "$KBUILD_BUILD_TIMESTAMP"; then
|
||||
timestamp="$(date -d"$KBUILD_BUILD_TIMESTAMP" +%s || :)"
|
||||
if test -n "$timestamp"; then
|
||||
timestamp="-t $timestamp"
|
||||
fi
|
||||
fi
|
||||
cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)"
|
||||
usr/gen_init_cpio ${cpio_list} > ${cpio_tfile}
|
||||
usr/gen_init_cpio $timestamp ${cpio_list} > ${cpio_tfile}
|
||||
else
|
||||
cpio_tfile=${cpio_file}
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -500,6 +500,8 @@ static void optimize_result(void)
|
|||
|
||||
/* find the token with the breates profit value */
|
||||
best = find_best_token();
|
||||
if (token_profit[best] == 0)
|
||||
break;
|
||||
|
||||
/* place it in the "best" table */
|
||||
best_table_len[i] = 2;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,16 @@ if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then
|
|||
else
|
||||
TIMESTAMP=$KBUILD_BUILD_TIMESTAMP
|
||||
fi
|
||||
if test -z "$KBUILD_BUILD_USER"; then
|
||||
LINUX_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
|
||||
else
|
||||
LINUX_COMPILE_BY=$KBUILD_BUILD_USER
|
||||
fi
|
||||
if test -z "$KBUILD_BUILD_HOST"; then
|
||||
LINUX_COMPILE_HOST=`hostname`
|
||||
else
|
||||
LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST
|
||||
fi
|
||||
|
||||
UTS_VERSION="#$VERSION"
|
||||
CONFIG_FLAGS=""
|
||||
|
|
@ -63,20 +73,8 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
|
|||
|
||||
echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
|
||||
|
||||
echo \#define LINUX_COMPILE_TIME \"`date +%T`\"
|
||||
echo \#define LINUX_COMPILE_BY \"`whoami`\"
|
||||
echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
|
||||
|
||||
domain=`dnsdomainname 2> /dev/null`
|
||||
if [ -z "$domain" ]; then
|
||||
domain=`domainname 2> /dev/null`
|
||||
fi
|
||||
|
||||
if [ -n "$domain" ]; then
|
||||
echo \#define LINUX_COMPILE_DOMAIN \"`echo $domain | $UTS_TRUNCATE`\"
|
||||
else
|
||||
echo \#define LINUX_COMPILE_DOMAIN
|
||||
fi
|
||||
echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
|
||||
echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
|
||||
|
||||
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\"
|
||||
) > .tmpcompile
|
||||
|
|
@ -91,8 +89,8 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
|
|||
# first line.
|
||||
|
||||
if [ -r $TARGET ] && \
|
||||
grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \
|
||||
grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \
|
||||
grep -v 'UTS_VERSION' $TARGET > .tmpver.1 && \
|
||||
grep -v 'UTS_VERSION' .tmpcompile > .tmpver.2 && \
|
||||
cmp -s .tmpver.1 .tmpver.2; then
|
||||
rm -f .tmpcompile
|
||||
else
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
static unsigned int offset;
|
||||
static unsigned int ino = 721;
|
||||
static time_t default_mtime;
|
||||
|
||||
struct file_handler {
|
||||
const char *type;
|
||||
|
|
@ -102,7 +103,6 @@ static int cpio_mkslink(const char *name, const char *target,
|
|||
unsigned int mode, uid_t uid, gid_t gid)
|
||||
{
|
||||
char s[256];
|
||||
time_t mtime = time(NULL);
|
||||
|
||||
if (name[0] == '/')
|
||||
name++;
|
||||
|
|
@ -114,7 +114,7 @@ static int cpio_mkslink(const char *name, const char *target,
|
|||
(long) uid, /* uid */
|
||||
(long) gid, /* gid */
|
||||
1, /* nlink */
|
||||
(long) mtime, /* mtime */
|
||||
(long) default_mtime, /* mtime */
|
||||
(unsigned)strlen(target)+1, /* filesize */
|
||||
3, /* major */
|
||||
1, /* minor */
|
||||
|
|
@ -152,7 +152,6 @@ static int cpio_mkgeneric(const char *name, unsigned int mode,
|
|||
uid_t uid, gid_t gid)
|
||||
{
|
||||
char s[256];
|
||||
time_t mtime = time(NULL);
|
||||
|
||||
if (name[0] == '/')
|
||||
name++;
|
||||
|
|
@ -164,7 +163,7 @@ static int cpio_mkgeneric(const char *name, unsigned int mode,
|
|||
(long) uid, /* uid */
|
||||
(long) gid, /* gid */
|
||||
2, /* nlink */
|
||||
(long) mtime, /* mtime */
|
||||
(long) default_mtime, /* mtime */
|
||||
0, /* filesize */
|
||||
3, /* major */
|
||||
1, /* minor */
|
||||
|
|
@ -242,7 +241,6 @@ static int cpio_mknod(const char *name, unsigned int mode,
|
|||
unsigned int maj, unsigned int min)
|
||||
{
|
||||
char s[256];
|
||||
time_t mtime = time(NULL);
|
||||
|
||||
if (dev_type == 'b')
|
||||
mode |= S_IFBLK;
|
||||
|
|
@ -259,7 +257,7 @@ static int cpio_mknod(const char *name, unsigned int mode,
|
|||
(long) uid, /* uid */
|
||||
(long) gid, /* gid */
|
||||
1, /* nlink */
|
||||
(long) mtime, /* mtime */
|
||||
(long) default_mtime, /* mtime */
|
||||
0, /* filesize */
|
||||
3, /* major */
|
||||
1, /* minor */
|
||||
|
|
@ -460,7 +458,7 @@ static int cpio_mkfile_line(const char *line)
|
|||
static void usage(const char *prog)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n"
|
||||
"\t%s <cpio_list>\n"
|
||||
"\t%s [-t <timestamp>] <cpio_list>\n"
|
||||
"\n"
|
||||
"<cpio_list> is a file containing newline separated entries that\n"
|
||||
"describe the files to be included in the initramfs archive:\n"
|
||||
|
|
@ -491,7 +489,11 @@ static void usage(const char *prog)
|
|||
"nod /dev/console 0600 0 0 c 5 1\n"
|
||||
"dir /root 0700 0 0\n"
|
||||
"dir /sbin 0755 0 0\n"
|
||||
"file /sbin/kinit /usr/src/klibc/kinit/kinit 0755 0 0\n",
|
||||
"file /sbin/kinit /usr/src/klibc/kinit/kinit 0755 0 0\n"
|
||||
"\n"
|
||||
"<timestamp> is time in seconds since Epoch that will be used\n"
|
||||
"as mtime for symlinks, special files and directories. The default\n"
|
||||
"is to use the current time for these entries.\n",
|
||||
prog);
|
||||
}
|
||||
|
||||
|
|
@ -529,17 +531,42 @@ int main (int argc, char *argv[])
|
|||
char *args, *type;
|
||||
int ec = 0;
|
||||
int line_nr = 0;
|
||||
const char *filename;
|
||||
|
||||
if (2 != argc) {
|
||||
default_mtime = time(NULL);
|
||||
while (1) {
|
||||
int opt = getopt(argc, argv, "t:h");
|
||||
char *invalid;
|
||||
|
||||
if (opt == -1)
|
||||
break;
|
||||
switch (opt) {
|
||||
case 't':
|
||||
default_mtime = strtol(optarg, &invalid, 10);
|
||||
if (!*optarg || *invalid) {
|
||||
fprintf(stderr, "Invalid timestamp: %s\n",
|
||||
optarg);
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage(argv[0]);
|
||||
exit(opt == 'h' ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc - optind != 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "-"))
|
||||
filename = argv[optind];
|
||||
if (!strcmp(filename, "-"))
|
||||
cpio_list = stdin;
|
||||
else if (! (cpio_list = fopen(argv[1], "r"))) {
|
||||
else if (!(cpio_list = fopen(filename, "r"))) {
|
||||
fprintf(stderr, "ERROR: unable to open '%s': %s\n\n",
|
||||
argv[1], strerror(errno));
|
||||
filename, strerror(errno));
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue