diff --git a/Kconfig b/Kconfig index 31479abce2..8ad71d088d 100644 --- a/Kconfig +++ b/Kconfig @@ -9,25 +9,6 @@ source mainboard/Kconfig source arch/Kconfig -config BOOTFLASH - bool - default y - help - Build the BOOTFLASH area. This includes all the reset vector, - Cache-As-Ram (CAR) code, early device setup, and the code that - parses the "file system" in the non-BOOTFLASH area. +source lib/Kconfig -config BIOS - bool - default y - help - Build the rest of the BIOS. This includes memory init, device - init, PCI init, and so on. - -config UNCOMPRESSORS - bool - default y - help - Build the various uncompressors found in the uncompressors - directory. diff --git a/Makefile b/Makefile index 7f32429e07..0680db73a6 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ VERSION = 3 PATCHLEVEL = 0 SUBLEVEL = 0 -EXTRAVERSION = 0 -NAME=I Hate Cute Names +EXTRAVERSION = -wth +NAME=Gonna Kick It # *DOCUMENTATION* # To see a list of typical targets execute "make help" @@ -20,7 +20,7 @@ MAKEFLAGS += --no-print-directory # their own directory. If in some directory we have a dependency on # a file in another dir (which doesn't happen often, but it's often # unavoidable when linking the built-in.o targets which finally -# turn into vmlinux), we will call a sub make in that other dir, and +# turn into linuxbios), we will call a sub make in that other dir, and # after that we are sure that everything which is in that other dir # is now up to date. # @@ -34,11 +34,11 @@ MAKEFLAGS += --no-print-directory ifdef V ifeq ("$(origin V)", "command line") - LBBUILD_VERBOSE = $(V) + KBUILD_VERBOSE = $(V) endif endif -ifndef LBBUILD_VERBOSE - LBBUILD_VERBOSE = 0 +ifndef KBUILD_VERBOSE + KBUILD_VERBOSE = 0 endif # Call sparse as part of compilation of C files @@ -46,22 +46,22 @@ endif ifdef C ifeq ("$(origin C)", "command line") - LBBUILD_CHECKSRC = $(C) + KBUILD_CHECKSRC = $(C) endif endif -ifndef LBBUILD_CHECKSRC - LBBUILD_CHECKSRC = 0 +ifndef KBUILD_CHECKSRC + KBUILD_CHECKSRC = 0 endif # Use make M=dir to specify directory of external module to build # Old syntax make ... SUBDIRS=$PWD is still supported -# Setting the environment variable LBBUILD_EXTMOD take precedence +# Setting the environment variable KBUILD_EXTMOD take precedence ifdef SUBDIRS - LBBUILD_EXTMOD ?= $(SUBDIRS) + KBUILD_EXTMOD ?= $(SUBDIRS) endif ifdef M ifeq ("$(origin M)", "command line") - LBBUILD_EXTMOD := $(M) + KBUILD_EXTMOD := $(M) endif endif @@ -72,63 +72,72 @@ endif # 1) O= # Use "make O=dir/to/store/output/files/" # -# 2) Set LBBUILD_OUTPUT -# Set the environment variable LBBUILD_OUTPUT to point to the directory +# 2) Set KBUILD_OUTPUT +# Set the environment variable KBUILD_OUTPUT to point to the directory # where the output files shall be placed. -# export LBBUILD_OUTPUT=dir/to/store/output/files/ +# export KBUILD_OUTPUT=dir/to/store/output/files/ # make # -# The O= assignment takes precedence over the LBBUILD_OUTPUT environment +# The O= assignment takes precedence over the KBUILD_OUTPUT environment # variable. -# LBBUILD_SRC is set on invocation of make in OBJ directory -# LBBUILD_SRC is not intended to be used by the regular user (for now) -ifeq ($(LBBUILD_SRC),) +# KBUILD_SRC is set on invocation of make in OBJ directory +# KBUILD_SRC is not intended to be used by the regular user (for now) +ifeq ($(KBUILD_SRC),) # OK, Make called in directory where kernel src resides # Do we want to locate output files in a separate directory? ifdef O ifeq ("$(origin O)", "command line") - LBBUILD_OUTPUT := $(O) + KBUILD_OUTPUT := $(O) endif endif # That's our default target when none is given on the command line -PHONY := all -all: +.PHONY: _all +_all: -ifneq ($(LBBUILD_OUTPUT),) +ifneq ($(KBUILD_OUTPUT),) # Invoke a second make in the output directory, passing relevant variables # check that the output directory actually exists -saved-output := $(LBBUILD_OUTPUT) -LBBUILD_OUTPUT := $(shell cd $(LBBUILD_OUTPUT) && /bin/pwd) -$(if $(LBBUILD_OUTPUT),, \ +saved-output := $(KBUILD_OUTPUT) +KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) +$(if $(KBUILD_OUTPUT),, \ $(error output directory "$(saved-output)" does not exist)) -PHONY += $(MAKECMDGOALS) +.PHONY: $(MAKECMDGOALS) $(filter-out _all,$(MAKECMDGOALS)) _all: - $(if $(LBBUILD_VERBOSE:1=),@)$(MAKE) -C $(LBBUILD_OUTPUT) \ - LBBUILD_SRC=$(CURDIR) \ - LBBUILD_EXTMOD="$(LBBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@ + $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ + KBUILD_SRC=$(CURDIR) \ + KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@ # Leave processing to above invocation of make skip-makefile := 1 -endif # ifneq ($(LBBUILD_OUTPUT),) -endif # ifeq ($(LBBUILD_SRC),) +endif # ifneq ($(KBUILD_OUTPUT),) +endif # ifeq ($(KBUILD_SRC),) # We process the rest of the Makefile if this is the final invocation of make ifeq ($(skip-makefile),) -srctree := $(if $(LBBUILD_SRC),$(LBBUILD_SRC),$(CURDIR)) +# If building an external module we do not care about the all: rule +# but instead _all depend on modules +.PHONY: all +ifeq ($(KBUILD_EXTMOD),) +_all: all +else +_all: modules +endif + +srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) TOPDIR := $(srctree) # FIXME - TOPDIR is obsolete, use srctree/objtree objtree := $(CURDIR) src := $(srctree) obj := $(objtree) -VPATH := $(srctree)$(if $(LBBUILD_EXTMOD),:$(LBBUILD_EXTMOD)) +VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) export srctree objtree VPATH TOPDIR @@ -139,7 +148,7 @@ export srctree objtree VPATH TOPDIR # then ARCH is assigned, getting whatever value it gets normally, and # SUBARCH is subsequently ignored. -SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/sun4u/sparc64/ \ -e s/arm.*/arm/ -e s/sa110/arm/ \ -e s/s390x/s390/ -e s/parisc64/parisc/ \ -e s/ppc.*/powerpc/ -e s/mips.*/mips/ ) @@ -179,7 +188,35 @@ HOSTCXX = g++ HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer HOSTCXXFLAGS = -O2 -export LBBUILD_CHECKSRC LBBUILD_SRC +# Decide whether to build built-in, modular, or both. +# Normally, just do built-in. + +KBUILD_MODULES := +KBUILD_BUILTIN := 1 + +# If we have only "make modules", don't compile built-in objects. +# When we're building modules with modversions, we need to consider +# the built-in objects during the descend as well, in order to +# make sure the checksums are uptodate before we record them. + +ifeq ($(MAKECMDGOALS),modules) + KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) +endif + +# If we have "make modules", compile modules +# in addition to whatever we do anyway. +# Just "make" or "make all" shall build modules as well + +ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) + KBUILD_MODULES := 1 +endif + +ifeq ($(MAKECMDGOALS),) + KBUILD_MODULES := 1 +endif + +export KBUILD_MODULES KBUILD_BUILTIN +export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD # Beautify output # --------------------------------------------------------------------------- @@ -201,10 +238,10 @@ export LBBUILD_CHECKSRC LBBUILD_SRC # # $(Q)ln $@ :< # -# If LBBUILD_VERBOSE equals 0 then the above command will be hidden. -# If LBBUILD_VERBOSE equals 1 then the above command is displayed. +# If KBUILD_VERBOSE equals 0 then the above command will be hidden. +# If KBUILD_VERBOSE equals 1 then the above command is displayed. -ifeq ($(LBBUILD_VERBOSE),1) +ifeq ($(KBUILD_VERBOSE),1) quiet = Q = else @@ -219,7 +256,7 @@ ifneq ($(findstring s,$(MAKEFLAGS)),) quiet=silent_ endif -export quiet Q LBBUILD_VERBOSE +export quiet Q KBUILD_VERBOSE # Look for make include files relative to root of kernel src @@ -247,40 +284,60 @@ OBJDUMP = $(CROSS_COMPILE)objdump AWK = awk GENKSYMS = scripts/genksyms/genksyms DEPMOD = /sbin/depmod +KALLSYMS = scripts/kallsyms PERL = perl CHECK = sparse -CHECKFLAGS := -D__linuxbios__ -Dlinuxbios -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF) -CFLAGS = -AFLAGS = +CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF) +MODFLAGS = -DMODULE +CFLAGS_MODULE = $(MODFLAGS) +AFLAGS_MODULE = $(MODFLAGS) +LDFLAGS_MODULE = -r +CFLAGS_KERNEL = +AFLAGS_KERNEL = # Use LINUXBIOSINCLUDE when you must reference the include/ directory. # Needed to be compatible with the O= option -LINUXBIOSINCLUDE := -Iinclude \ - -I$(srctree)/include \ - -I$(srctree)/include/cpu/generic/$(ARCH)/ \ - -I$(srctree)/include/cpu/generic/x86/ \ - -include $(srctree)/include/linuxbios/autoconf.h +LINUXBIOSINCLUDE := -Iinclude \ + -I$(srctree)/include \ + -I$(srctree)/include/cpu/generic/$(ARCH)/ \ + -include $(srctree)/include/linuxbios/autoconf.h -CPPFLAGS := $(LINUXBIOSINCLUDE) +#LINUXINCLUDE := -Iinclude \ +# $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \ +# -include $(objtree)/include/linuxbios/autoconf.h + +CPPFLAGS := -D__KERNEL__ $(LINUXBIOSINCLUDE) CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ - -fno-strict-aliasing -fno-common + -Werror-implicit-function-declaration \ + -fno-strict-aliasing -fno-common \ + -ffreestanding AFLAGS := -D__ASSEMBLY__ -# Read LINUXBIOSRELEASE from .linuxbiosrelease (if it exists) -LINUXBIOSRELEASE = $(shell cat .linuxbiosrelease 2> /dev/null) -LINUXBIOSVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) +# Warn about unsupported modules in kernels built inside Autobuild +ifneq ($(wildcard /.buildenv),) +CFLAGS += -DUNSUPPORTED_MODULES=1 +endif -export VERSION PATCHLEVEL SUBLEVEL LINUXBIOSRELEASE LINUXBIOSVERSION \ +# Read KERNELRELEASE from .kernelrelease (if it exists) +KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null) +KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) + +export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \ ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \ - HOSTCXX HOSTCXXFLAGS CHECK CHECKFLAGS + HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS export CPPFLAGS NOSTDINC_FLAGS LINUXBIOSINCLUDE OBJCOPYFLAGS LDFLAGS -export CFLAGS -export AFLAGS +export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE +export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE + +# When compiling out-of-tree modules, put MODVERDIR in the module +# tree rather than in the kernel tree. The kernel tree might +# even be read-only. +export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions # Files to ignore in find ... statements @@ -291,22 +348,24 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exc # Rules shared between *config targets and build targets # Basic helpers built in scripts/ -PHONY += scripts_basic +.PHONY: scripts_basic scripts_basic: $(Q)$(MAKE) $(build)=scripts/basic # To avoid any implicit rule to kick in, define an empty command. scripts/basic/%: scripts_basic ; -PHONY += outputmakefile -# outputmakefile generates a Makefile in the output directory, if using a -# separate output directory. This allows convenient use of make in the -# output directory. +.PHONY: outputmakefile +# outputmakefile generate a Makefile to be placed in output directory, if +# using a seperate output directory. This allows convinient use +# of make in output directory outputmakefile: -ifneq ($(LBBUILD_SRC),) - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ - $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) -endif + $(Q)if test ! $(srctree) -ef $(objtree); then \ + $(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ + $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) \ + > $(objtree)/Makefile; \ + echo ' GEN $(objtree)/Makefile'; \ + fi # 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 @@ -329,7 +388,7 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) endif endif -ifeq ($(LBBUILD_EXTMOD),) +ifeq ($(KBUILD_EXTMOD),) ifneq ($(filter config %config,$(MAKECMDGOALS)),) config-targets := 1 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) @@ -344,7 +403,7 @@ ifeq ($(mixed-targets),1) # Handle them one by one. %:: FORCE - $(Q)$(MAKE) -C $(srctree) LBBUILD_SRC= $@ + $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@ else ifeq ($(config-targets),1) @@ -352,23 +411,40 @@ ifeq ($(config-targets),1) # *config targets only - make sure prerequisites are updated, and descend # in scripts/kconfig to make the *config target -# Read arch specific Makefile to set LBBUILD_DEFCONFIG as needed. -# LBBUILD_DEFCONFIG may point out an alternative default configuration +# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. +# KBUILD_DEFCONFIG may point out an alternative default configuration # used for 'make defconfig' -# The ? makes the error go away if configuration has been done yet. - -export LBBUILD_DEFCONFIG +include $(srctree)/arch/$(ARCH)/Makefile +export KBUILD_DEFCONFIG config %config: scripts_basic outputmakefile FORCE $(Q)mkdir -p include/linux $(Q)$(MAKE) $(build)=scripts/kconfig $@ - $(Q)$(MAKE) -C $(srctree) LBBUILD_SRC= .linuxbiosrelease + $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease else # =========================================================================== -# Build targets only - this includes vmlinux, arch specific targets, clean +# Build targets only - this includes linuxbios, arch specific targets, clean # targets and others. In general all targets except *config targets. +ifeq ($(KBUILD_EXTMOD),) +# Additional helpers built in scripts/ +# Carefully list dependencies so we do not try to build scripts twice +# in parrallel +.PHONY: scripts +scripts: scripts_basic include/config/MARKER + $(Q)$(MAKE) $(build)=$(@) + +scripts_basic: $(objtree)/include/linuxbios/autoconf.h + +# Objects we will link into linuxbios / subdirs we need to visit +#init-y := inita/ +#drivers-y := drivers/ sound/ +#net-y := net/ +libs-y := lib/ +core-y := mainboard/ +endif # KBUILD_EXTMOD + ifeq ($(dot-config),1) # In this section, we need .config @@ -387,18 +463,19 @@ include .config # with it and forgot to run make oldconfig. # If kconfig.d is missing then we are probarly in a cleaned tree so # we execute the config step to be sure to catch updated Kconfig files -include/linuxbios/autoconf.h: .kconfig.d .config +$(objtree)/include/linuxbios/autoconf.h: .kconfig.d .config + $(Q)mkdir -p include/linuxbios $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig else # Dummy target needed, because used as prerequisite -include/linuxbios/autoconf.h: ; +$(objtree)/include/linuxbios/autoconf.h: ; endif # The all: target is the default when no target is given on the # command line. # This allow a user to issue only 'make' to build a kernel including modules -# Defaults vmlinux but it is usually overriden in the arch makefile -all: linuxbios.rom +# Defaults linuxbios but it is usually overriden in the arch makefile +all: linuxbios ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE CFLAGS += -Os @@ -406,23 +483,27 @@ else CFLAGS += -O2 endif +#Add align options if CONFIG_CC_* is not equal to 0 +add-align = $(if $(filter-out 0,$($(1))),$(cc-option-align)$(2)=$($(1))) +CFLAGS += $(call add-align,CONFIG_CC_ALIGN_FUNCTIONS,-functions) +CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LABELS,-labels) +CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LOOPS,-loops) +CFLAGS += $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps) + ifdef CONFIG_FRAME_POINTER CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,) else CFLAGS += -fomit-frame-pointer endif -ifdef CONFIG_UNWIND_INFO -CFLAGS += -fasynchronous-unwind-tables -endif - ifdef CONFIG_DEBUG_INFO CFLAGS += -g endif -# mainboard Makefile may override CC so keep this after mainboard Makefile is included -#NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) -NOSTDINC_FLAGS += -isystem $(shell $(CC) -print-file-name=include) +include $(srctree)/arch/$(ARCH)/Makefile + +# arch Makefile may override CC so keep this after arch Makefile is included +NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) CHECKFLAGS += $(NOSTDINC_FLAGS) # warn about C99 declaration after statement @@ -432,30 +513,56 @@ CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) CFLAGS += $(call cc-option,-Wno-pointer-sign,) # Default kernel image to build when no specific target is given. -# LBBUILD_IMAGE may be overruled on the commandline or +# KBUILD_IMAGE may be overruled on the commandline or # set in the environment # Also any assignments in arch/$(ARCH)/Makefile take precedence over # this default value -export LBBUILD_IMAGE ?= linuxbios.rom startup_code.rom +export KBUILD_IMAGE ?= linuxbios + +# +# INSTALL_PATH specifies where to place the updated kernel and system map +# images. Default is /boot, but you can set it to other values +export INSTALL_PATH ?= /boot + +# +# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory +# relocations required by build roots. This is not defined in the +# makefile but the arguement can be passed to make if needed. +# + +MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) +export MODLIB -core-y := mainboard/ -core-y += arch/ -ifeq ($(LBBUILD_COMPRESSORS),) -core-y += compressors +ifeq ($(KBUILD_EXTMOD),) +#core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ +#core-$(CONFIG_KDB) += kdb/ -linuxbios-dirs := $(patsubst %/,%,$(filter %/, $(core-y))) +linuxbios-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ + $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ + $(net-y) $(net-m) $(libs-y) $(libs-m))) -linuxbios-alldirs := $(sort $(linuxbios-dirs)) +linuxbios-alldirs := $(sort $(linuxbios-dirs) $(patsubst %/,%,$(filter %/, \ + $(init-n) $(init-) \ + $(core-n) $(core-) $(drivers-n) $(drivers-) \ + $(net-n) $(net-) $(libs-n) $(libs-)))) -# Build vmlinux +init-y := $(patsubst %/, %/built-in.o, $(init-y)) +core-y := $(patsubst %/, %/built-in.o, $(core-y)) +drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) +net-y := $(patsubst %/, %/built-in.o, $(net-y)) +libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) +libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) +libs-y := $(libs-y1) $(libs-y2) + +# Build linuxbios # --------------------------------------------------------------------------- -# vmlinux is build from the objects selected by $(linuxbios-init) and +# linuxbios is build from the objects selected by $(linuxbios-init) and # $(linuxbios-main). Most are built-in.o files from top-level directories # in the kernel tree, others are specified in arch/$(ARCH)Makefile. # Ordering when linking is important, and $(linuxbios-init) must be first. # -# vmlinux +# linuxbios # ^ # | # +-< $(linuxbios-init) @@ -466,10 +573,10 @@ linuxbios-alldirs := $(sort $(linuxbios-dirs)) # | # +-< kallsyms.o (see description in CONFIG_KALLSYMS section) # -# vmlinux version (uname -v) cannot be updated during normal +# linuxbios version (uname -v) cannot be updated during normal # descending-into-subdirs phase since we do not yet know if we need to -# update vmlinux. -# Therefore this step is delayed until just before final link of vmlinux - +# update linuxbios. +# Therefore this step is delayed until just before final link of linuxbios - # except in the kallsyms case where it is done just before adding the # symbols to the kernel. # @@ -478,19 +585,19 @@ linuxbios-alldirs := $(sort $(linuxbios-dirs)) linuxbios-init := $(head-y) $(init-y) linuxbios-main := $(core-y) $(libs-y) $(drivers-y) $(net-y) linuxbios-all := $(linuxbios-init) $(linuxbios-main) -#linuxbios-lds := mainboard/$(MAINBOARD)/linuxbios.lds +#linuxbios-lds := arch/$(ARCH)/kernel/linuxbios.lds -# Rule to link vmlinux - also used during CONFIG_KALLSYMS +# Rule to link linuxbios - also used during CONFIG_KALLSYMS # May be overridden by arch/$(ARCH)/Makefile -quiet_cmd_vmlinux__ ?= LD $@ - cmd_vmlinux__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) -o $@ \ +quiet_cmd_linuxbios__ ?= LD $@ + cmd_linuxbios__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_linuxbios) -o $@ \ -T $(linuxbios-lds) $(linuxbios-init) \ --start-group $(linuxbios-main) --end-group \ $(filter-out $(linuxbios-lds) $(linuxbios-init) $(linuxbios-main) FORCE ,$^) -# Generate new vmlinux version -quiet_cmd_vmlinux_version = GEN .version - cmd_vmlinux_version = set -e; \ +# Generate new linuxbios version +quiet_cmd_linuxbios_version = GEN .version + cmd_linuxbios_version = set -e; \ if [ ! -r .version ]; then \ rm -f .version; \ echo 1 >.version; \ @@ -498,23 +605,22 @@ quiet_cmd_vmlinux_version = GEN .version mv .version .old_version; \ expr 0$$(cat .old_version) + 1 >.version; \ fi; \ - $(MAKE) $(build)=init # Generate System.map quiet_cmd_sysmap = SYSMAP cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap -# Link of vmlinux +# Link of linuxbios # If CONFIG_KALLSYMS is set .version is already updated # Generate System.map and verify that the content is consistent -# Use + in front of the vmlinux_version rule to silent warning with make -j2 +# Use + in front of the linuxbios_version rule to silent warning with make -j2 # First command is ':' to allow us to use + in front of the rule define rule_linuxbios__ : - $(if $(CONFIG_KALLSYMS),,+$(call cmd,vmlinux_version)) + $(if $(CONFIG_KALLSYMS),,+$(call cmd,linuxbios_version)) - $(call cmd,vmlinux__) - $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd + $(call cmd,linuxbios__) + $(Q)echo 'cmd_$@ := $(cmd_linuxbios__)' > $(@D)/.$(@F).cmd $(Q)$(if $($(quiet)cmd_sysmap), \ echo ' $($(quiet)cmd_sysmap) System.map' &&) \ @@ -527,27 +633,94 @@ define rule_linuxbios__ endef -# Generate section listing all symbols and add it into vmlinux $(kallsyms.o) +ifdef CONFIG_KALLSYMS +# Generate section listing all symbols and add it into linuxbios $(kallsyms.o) # It's a three stage process: -# o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is +# o .tmp_linuxbios1 has all symbols and sections, but __kallsyms is # empty # Running kallsyms on that gives us .tmp_kallsyms1.o with -# the right size - vmlinux version (uname -v) is updated during this step -# o .tmp_vmlinux2 now has a __kallsyms section of the right size, +# the right size - linuxbios version (uname -v) is updated during this step +# o .tmp_linuxbios2 now has a __kallsyms section of the right size, # but due to the added section, some addresses have shifted. # From here, we generate a correct .tmp_kallsyms2.o -# 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 The correct .tmp_kallsyms2.o is linked into the final linuxbios. +# o Verify that the System.map from linuxbios matches the map from +# .tmp_linuxbios2, just in case we did not generate kallsyms correctly. # o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using -# .tmp_vmlinux3 and .tmp_kallsyms3.o. This is only meant as a +# .tmp_linuxbios3 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 +endif -# vmlinux image - including updated kernel symbols -linuxbios.rom: $(linuxbios-lds) $(linuxbios-init) $(linuxbios-main) $(kallsyms.o) FORCE - $(call if_changed_rule,linuxbios) +kallsyms.o := .tmp_kallsyms$(last_kallsyms).o + +define verify_kallsyms + $(Q)$(if $($(quiet)cmd_sysmap), \ + echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \ + $(cmd_sysmap) .tmp_linuxbios$(last_kallsyms) .tmp_System.map + $(Q)cmp -s System.map .tmp_System.map || \ + (echo Inconsistent kallsyms data; \ + echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \ + rm .tmp_kallsyms* ; /bin/false ) +endef + +# Update linuxbios version before link +# Use + in front of this rule to silent warning about make -j1 +# First command is ':' to allow us to use + in front of this rule +cmd_ksym_ld = $(cmd_linuxbios__) +define rule_ksym_ld + : + +$(call cmd,linuxbios_version) + $(call cmd,linuxbios__) + $(Q)echo 'cmd_$@ := $(cmd_linuxbios__)' > $(@D)/.$(@F).cmd +endef + +# Generate .S file with all kernel symbols +quiet_cmd_kallsyms = KSYM $@ + cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \ + $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@ + +.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE + $(call if_changed_dep,as_o_S) + +.tmp_kallsyms%.S: .tmp_linuxbios% $(KALLSYMS) + $(call cmd,kallsyms) + +# .tmp_linuxbios1 must be complete except kallsyms, so update linuxbios version +.tmp_linuxbios1: $(linuxbios-lds) $(linuxbios-all) FORCE + $(call if_changed_rule,ksym_ld) + +.tmp_linuxbios2: $(linuxbios-lds) $(linuxbios-all) .tmp_kallsyms1.o FORCE + $(call if_changed,linuxbios__) + +.tmp_linuxbios3: $(linuxbios-lds) $(linuxbios-all) .tmp_kallsyms2.o FORCE + $(call if_changed,linuxbios__) + +# Needs to visit scripts/ before $(KALLSYMS) can be used. +$(KALLSYMS): scripts ; + +# Generate some data for debugging strange kallsyms problems +debug_kallsyms: .tmp_map$(last_kallsyms) + +.tmp_map%: .tmp_linuxbios% FORCE + ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@ + +.tmp_map3: .tmp_map2 + +.tmp_map2: .tmp_map1 + +endif # ifdef CONFIG_KALLSYMS + +# linuxbios image - including updated kernel symbols +#linuxbios: $(linuxbios-lds) $(linuxbios-init) $(linuxbios-main) $(kallsyms.o) FORCE +include $(srctree)/arch/$(ARCH)/Makefile.target +linuxbios: $(linuxbios-init) $(linuxbios-main) linuxbios.rom FORCE + $(Q)echo "linuxbios build process is done." $(Q)rm -f .old_version # The actual objects are generated when descending, @@ -560,16 +733,16 @@ $(sort $(linuxbios-init) $(linuxbios-main)) $(linuxbios-lds): $(linuxbios-dirs) # make menuconfig etc. # Error messages still appears in the original language -PHONY += $(linuxbios-dirs) +.PHONY: $(linuxbios-dirs) $(linuxbios-dirs): prepare scripts $(Q)$(MAKE) $(build)=$@ # Build the kernel release string -# The LINUXBIOSRELEASE is stored in a file named .linuxbiosrelease +# The KERNELRELEASE is stored in a file named .kernelrelease # to be used when executing for example make install or make modules_install # # Take the contents of any files called localversion* and the config -# variable CONFIG_LOCALVERSION and append them to LINUXBIOSRELEASE. +# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE. # LOCALVERSION from the command line override all of this nullstring := @@ -599,60 +772,67 @@ endif localver-full = $(localver)$(localver-auto) -# Store (new) LINUXBIOSRELASE string in .linuxbiosrelease -linuxbiosrelease = $(LINUXBIOSVERSION)$(localver-full) -.linuxbiosrelease: FORCE +# Store (new) KERNELRELASE string in .kernelrelease +kernelrelease = $(KERNELVERSION)$(localver-full) +.kernelrelease: FORCE $(Q)rm -f $@ - $(Q)echo $(linuxbiosrelease) > $@ + $(Q)echo $(kernelrelease) > $@ # Things we need to do before we recursively start building the kernel # or the modules are listed in "prepare". # A multi level approach is used. prepareN is processed before prepareN-1. -# archprepare is used in arch Makefiles and when processed +# archprepare is used in arch Makefiles and when processed asm symlink, # version.h and scripts_basic is processed / created. # Listed in dependency order -PHONY += prepare prepare0 prepare1 prepare2 prepare3 +.PHONY: prepare archprepare prepare0 prepare1 prepare2 prepare3 # prepare-all is deprecated, use prepare as valid replacement -PHONY += prepare-all +.PHONY: prepare-all # prepare3 is used to check if we are building in a separate output directory, # and if so do: # 1) Check that make has not been executed in the kernel src $(srctree) -prepare3: .linuxbiosrelease -ifneq ($(LBBUILD_SRC),) +# 2) Create the include2 directory, used for the second asm symlink +prepare3: .kernelrelease +ifneq ($(KBUILD_SRC),) @echo ' Using $(srctree) as source for kernel' $(Q)if [ -f $(srctree)/.config ]; then \ echo " $(srctree) is not clean, please run 'make mrproper'";\ echo " in the '$(srctree)' directory.";\ /bin/false; \ fi; + $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi; + #$(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include/asm endif # prepare2 creates a makefile if using a separate output directory prepare2: prepare3 outputmakefile -prepare1: prepare2 include/linuxbios/version.h\ +prepare1: prepare2 $(objtree)/include/linuxbios/version.h \ include/config/MARKER -ifneq ($(LBBUILD_MODULES),) +ifneq ($(KBUILD_MODULES),) + $(Q)rm -rf $(MODVERDIR) $(Q)mkdir -p $(MODVERDIR) - $(Q)rm -f $(MODVERDIR)/* endif +archprepare: prepare1 scripts_basic + +prepare0: archprepare FORCE + $(Q)$(MAKE) $(build)=. # All the preparing.. -prepare prepare-all: prepare1 +prepare prepare-all: prepare0 -# Leave this as default for preprocessing vmlinux.lds.S, which is now +# Leave this as default for preprocessing linuxbios.lds.S, which is now # done in arch/$(ARCH)/kernel/Makefile export CPPFLAGS_linuxbios.lds += -P -C -U$(ARCH) # Split autoconf.h into include/linuxbios/config/* -include/config/MARKER: scripts/basic/split-include include/linuxbios/autoconf.h +include/config/MARKER: scripts/basic/split-include $(objtree)/include/linuxbios/autoconf.h @echo ' SPLIT include/linuxbios/autoconf.h -> include/config/*' @scripts/basic/split-include include/linuxbios/autoconf.h include/config @touch $@ @@ -660,31 +840,101 @@ include/config/MARKER: scripts/basic/split-include include/linuxbios/autoconf.h # Generate some files # --------------------------------------------------------------------------- -# LINUXBIOSRELEASE can change from a few different places, meaning version.h +# KERNELRELEASE can change from a few different places, meaning version.h # needs to be updated, so this check is forced on all builds uts_len := 64 define filechk_version.h - if [ `echo -n "$(LINUXBIOSRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ - echo '"$(LINUXBIOSRELEASE)" exceeds $(uts_len) characters' >&2; \ + if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ + echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ exit 1; \ fi; \ - (echo \#define LINUXBIOS_RELEASE \"$(LINUXBIOSRELEASE)\"; \ + (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \ echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \ - echo '#define LINUXBIOS_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \ + echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \ ) endef -include/linuxbios/version.h: $(srctree)/Makefile .config .linuxbiosrelease FORCE +$(objtree)/include/linuxbios/version.h: $(srctree)/Makefile .config .kernelrelease FORCE $(call filechk,version.h) # --------------------------------------------------------------------------- -PHONY += depend dep +.PHONY: depend dep depend dep: @echo '*** Warning: make $@ is unnecessary now.' +# --------------------------------------------------------------------------- +# Modules + +ifdef CONFIG_MODULES + +# By default, build modules as well + +all: modules + +# Build modules + +.PHONY: modules +modules: $(linuxbios-dirs) $(if $(KBUILD_BUILTIN),linuxbios) + @echo ' Building modules, stage 2.'; + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost + + +# Target to prepare building external modules +.PHONY: modules_prepare +modules_prepare: prepare scripts + +# Target to install modules +.PHONY: modules_install +modules_install: _modinst_ _modinst_post + +.PHONY: _modinst_ +_modinst_: + @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ + echo "Warning: you may need to install module-init-tools"; \ + echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\ + sleep 1; \ + fi + @rm -rf $(MODLIB)/kernel + @rm -f $(MODLIB)/source + @mkdir -p $(MODLIB)/kernel + @ln -s $(srctree) $(MODLIB)/source + @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ + rm -f $(MODLIB)/build ; \ + ln -s $(objtree) $(MODLIB)/build ; \ + fi + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst + +# If System.map exists, run depmod. This deliberately does not have a +# dependency on System.map since that would run the dependency tree on +# linuxbios. This depmod is only for convenience to give the initial +# boot a modules.dep even before / is mounted read-write. However the +# boot script depmod is the master version. +ifeq "$(strip $(INSTALL_MOD_PATH))" "" +depmod_opts := +else +depmod_opts := -b $(INSTALL_MOD_PATH) -r +endif +.PHONY: _modinst_post +_modinst_post: _modinst_ + if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi + +else # CONFIG_MODULES + +# Modules not configured +# --------------------------------------------------------------------------- + +modules modules_install: FORCE + @echo + @echo "The present kernel configuration has modules disabled." + @echo "Type 'make config' and enable loadable module support." + @echo "Then build a kernel with module support enabled." + @echo + @exit 1 + +endif # CONFIG_MODULES ### # Cleaning is done on three levels. @@ -695,14 +945,14 @@ depend dep: # Directories & files removed with 'make clean' CLEAN_DIRS += $(MODVERDIR) -CLEAN_FILES += linuxbios.rom System.map \ +CLEAN_FILES += linuxbios System.map \ .tmp_kallsyms* .tmp_version .tmp_linuxbios* .tmp_System.map # Directories & files removed with 'make mrproper' -MRPROPER_DIRS += include/config -MRPROPER_FILES += .config .config.old .old_version \ +MRPROPER_DIRS += include/config include2 +MRPROPER_FILES += .config .config.old .version .old_version \ include/linuxbios/autoconf.h include/linuxbios/version.h \ - .linuxbiosrelease Module.symvers tags TAGS cscope* + .kernelrelease Module.symvers tags TAGS cscope* # clean - Delete most, but leave enough to build external modules # @@ -710,16 +960,17 @@ clean: rm-dirs := $(CLEAN_DIRS) clean: rm-files := $(CLEAN_FILES) clean-dirs := $(addprefix _clean_,$(srctree) $(linuxbios-alldirs)) -PHONY += $(clean-dirs) clean archclean +.PHONY: $(clean-dirs) clean archclean $(clean-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) -clean: $(clean-dirs) +clean: archclean $(clean-dirs) $(call cmd,rmdirs) $(call cmd,rmfiles) @find . $(RCS_FIND_IGNORE) \ \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ - -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ + -o -name '*.symtypes' \) \ -type f -print | xargs rm -f # mrproper - Delete all generated files, including .config @@ -728,17 +979,17 @@ mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) -PHONY += $(mrproper-dirs) mrproper archmrproper +.PHONY: $(mrproper-dirs) mrproper archmrproper $(mrproper-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) -mrproper: clean $(mrproper-dirs) +mrproper: clean archmrproper $(mrproper-dirs) $(call cmd,rmdirs) $(call cmd,rmfiles) # distclean # -PHONY += distclean +.PHONY: distclean distclean: mrproper @find $(srctree) $(RCS_FIND_IGNORE) \ @@ -749,15 +1000,17 @@ distclean: mrproper -type f -print | xargs rm -f -# Packaging of linuxbios to various formats -- compression will go here! +# Packaging of the kernel to various formats # --------------------------------------------------------------------------- # rpm target kept for backward compatibility package-dir := $(srctree)/scripts/package +.PHONY: %-pkg rpm + %pkg: FORCE - $(Q)$(MAKE) $(build)=$(package-dir) $@ + $(Q)$(MAKE) -f $(package-dir)/Makefile $@ rpm: FORCE - $(Q)$(MAKE) $(build)=$(package-dir) $@ + $(Q)$(MAKE) -f $(package-dir)/Makefile $@ # Brief documentation of the typical targets used @@ -776,7 +1029,7 @@ help: @echo '' @echo 'Other generic targets:' @echo ' all - Build all targets marked with [*]' - @echo '* vmlinux - Build the bare kernel' + @echo '* linuxbios - Build the bare kernel' @echo '* modules - Build all modules' @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)' @echo ' dir/ - Build all files in dir and below' @@ -785,15 +1038,17 @@ help: @echo ' rpm - Build a kernel as an RPM package' @echo ' tags/TAGS - Generate tags file for editors' @echo ' cscope - Generate cscope index' - @echo ' linuxbiosrelease - Output the release version string' + @echo ' kernelrelease - Output the release version string' @echo ' kernelversion - Output the version stored in Makefile' @echo '' @echo 'Static analysers' + @echo ' buildcheck - List dangling references to linuxbios discarded sections' + @echo ' and init sections from non-init sections' @echo ' checkstack - Generate a list of stack hogs' @echo ' namespacecheck - Name space analysis on compiled kernel' @echo '' @echo 'Kernel packaging:' - @$(MAKE) $(build)=$(package-dir) help + @$(MAKE) -f $(package-dir)/Makefile help @echo '' @echo 'Documentation targets:' @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp @@ -821,6 +1076,188 @@ help: %docs: scripts_basic FORCE $(Q)$(MAKE) $(build)=Documentation/DocBook $@ +else # KBUILD_EXTMOD + +### +# External module support. +# When building external modules the kernel used as basis is considered +# read-only, and no consistency checks are made and the make +# system is not used on the basis kernel. If updates are required +# in the basis kernel ordinary make commands (without M=...) must +# be used. +# +# The following are the only valid targets when building external +# modules. +# make M=dir clean Delete all automatically generated files +# make M=dir modules Make all modules in specified dir +# make M=dir Same as 'make M=dir modules' +# make M=dir modules_install +# Install the modules build in the module directory +# Assumes install directory is already created + +# We are always building modules +KBUILD_MODULES := 1 +.PHONY: crmodverdir +crmodverdir: + $(Q)rm -rf $(MODVERDIR) + $(Q)mkdir -p $(MODVERDIR) + +.PHONY: $(objtree)/Module.symvers +$(objtree)/Module.symvers: + @test -e $(objtree)/Module.symvers || ( \ + echo; \ + echo " WARNING: Symbol version dump $(objtree)/Module.symvers"; \ + echo " is missing; modules will have no dependencies and modversions."; \ + echo ) + +module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) +.PHONY: $(module-dirs) modules +$(module-dirs): crmodverdir $(objtree)/Module.symvers + $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) + +modules: $(module-dirs) + @echo ' Building modules, stage 2.'; + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost + +.PHONY: modules_add +modules_add: modules_install + +.PHONY: modules_install +modules_install: _emodinst_ _emodinst_post + +install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) +.PHONY: _emodinst_ +_emodinst_: + $(Q)mkdir -p $(MODLIB)/$(install-dir) + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst + +# Run depmod only is we have System.map and depmod is executable +quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) + cmd_depmod = if [ -r System.map -a -x $(DEPMOD) ]; then \ + $(DEPMOD) -ae -F System.map \ + $(if $(strip $(INSTALL_MOD_PATH)), \ + -b $(INSTALL_MOD_PATH) -r) \ + $(KERNELRELEASE); \ + fi + +.PHONY: _emodinst_post +_emodinst_post: _emodinst_ + $(call cmd,depmod) + +clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) + +.PHONY: $(clean-dirs) clean +$(clean-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) + +clean: rm-dirs := $(MODVERDIR) +clean: $(clean-dirs) + $(call cmd,rmdirs) + @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \ + \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \ + -type f -print | xargs rm -f + +help: + @echo ' Building external modules.' + @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target' + @echo '' + @echo ' modules - default target, build the module(s)' + @echo ' modules_install - install the module' + @echo ' clean - remove generated files in module directory only' + @echo '' + +# Dummies... +.PHONY: prepare scripts +prepare: ; +scripts: ; +endif # KBUILD_EXTMOD + +# Generate tags for editors +# --------------------------------------------------------------------------- + +#We want __srctree to totally vanish out when KBUILD_OUTPUT is not set +#(which is the most common case IMHO) to avoid unneeded clutter in the big tags file. +#Adding $(srctree) adds about 20M on i386 to the size of the output file! + +ifeq ($(src),$(obj)) +__srctree = +else +__srctree = $(srctree)/ +endif + +ifeq ($(ALLSOURCE_ARCHS),) +ifeq ($(ARCH),um) +ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH) +else +ALLINCLUDE_ARCHS := $(ARCH) +endif +else +#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour. +ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS) +endif + +ALLSOURCE_ARCHS := $(ARCH) + +define all-sources + ( find $(__srctree) $(RCS_FIND_IGNORE) \ + \( -name include -o -name arch \) -prune -o \ + -name '*.[chS]' -print; \ + for ARCH in $(ALLSOURCE_ARCHS) ; do \ + find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \ + -name '*.[chS]' -print; \ + done ; \ + find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \ + -name '*.[chS]' -print; \ + find $(__srctree)include $(RCS_FIND_IGNORE) \ + \( -name config -o -name 'asm-*' \) -prune \ + -o -name '*.[chS]' -print; \ + for ARCH in $(ALLINCLUDE_ARCHS) ; do \ + find $(__srctree)include/asm-$${ARCH} $(RCS_FIND_IGNORE) \ + -name '*.[chS]' -print; \ + done ; \ + find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ + -name '*.[chS]' -print ) +endef + +quiet_cmd_cscope-file = FILELST cscope.files + cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files + +quiet_cmd_cscope = MAKE cscope.out + cmd_cscope = cscope -b + +cscope: FORCE + $(call cmd,cscope-file) + $(call cmd,cscope) + +quiet_cmd_TAGS = MAKE $@ +define cmd_TAGS + rm -f $@; \ + ETAGSF=`etags --version | grep -i exuberant >/dev/null && \ + echo "-I __initdata,__exitdata,__acquires,__releases \ + -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ + --extra=+f --c-kinds=+px"`; \ + $(all-sources) | xargs etags $$ETAGSF -a +endef + +TAGS: FORCE + $(call cmd,TAGS) + + +quiet_cmd_tags = MAKE $@ +define cmd_tags + rm -f $@; \ + CTAGSF=`ctags --version | grep -i exuberant >/dev/null && \ + echo "-I __initdata,__exitdata,__acquires,__releases \ + -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ + --extra=+f --c-kinds=+px"`; \ + $(all-sources) | xargs ctags $$CTAGSF -a +endef + +tags: FORCE + $(call cmd,tags) + + # Scripts to check various things for consistency # --------------------------------------------------------------------------- @@ -834,47 +1271,66 @@ versioncheck: -name '*.[hcS]' -type f -print | sort \ | xargs $(PERL) -w scripts/checkversion.pl +buildcheck: + $(PERL) $(srctree)/scripts/reference_discarded.pl + $(PERL) $(srctree)/scripts/reference_init.pl + namespacecheck: $(PERL) $(srctree)/scripts/namespace.pl endif #ifeq ($(config-targets),1) endif #ifeq ($(mixed-targets),1) -PHONY += checkstack +.PHONY: checkstack checkstack: - $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ + $(OBJDUMP) -d linuxbios $$(find . -name '*.ko') | \ $(PERL) $(src)/scripts/checkstack.pl $(ARCH) -linuxbiosrelease: - $(if $(wildcard .linuxbiosrelease), $(Q)echo $(LINUXBIOSRELEASE), \ - $(error linuxbiosrelease not valid - run 'make *config' to update it)) -linuxbiosversion: - @echo $(LINUXBIOSVERSION) +kernelrelease: + $(if $(wildcard .kernelrelease), $(Q)echo $(KERNELRELEASE), \ + $(error kernelrelease not valid - run 'make *config' to update it)) +kernelversion: + @echo $(KERNELVERSION) # Single targets # --------------------------------------------------------------------------- -# Single targets are compatible with: -# - build whith mixed source and output -# - build with separate output dir 'make O=...' -# - external modules -# -# target-dir => where to store outputfile -# build-dir => directory in kernel source tree to use +# The directory part is taken from first prerequisite, so this +# works even with external modules +%.s: %.c scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) +%.i: %.c scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) +%.o: %.c scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) +%.lst: %.c scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) +%.s: %.S scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) +%.o: %.S scripts FORCE + $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@) +%.symtypes: %.c scripts FORCE + $(Q)$(MAKE) $(build)=$(@D) $(dir $<)$(notdir $@) +# For external modules we shall include any directory of the target, +# but usual case there is no directory part. +# make M=`pwd` module.o => $(dir $@)=./ +# make M=`pwd` foo/module.o => $(dir $@)=foo/ +# make M=`pwd` / => $(dir $@)=/ + +ifeq ($(KBUILD_EXTMOD),) + target-dir = $(@D) +else + zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) + target-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) +endif -%.s: %.c prepare scripts FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.i: %.c prepare scripts FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.o: %.c prepare scripts FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.lst: %.c prepare scripts FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.s: %.S prepare scripts FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) -%.o: %.S prepare scripts FORCE - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) - +/ %/: scripts prepare FORCE + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(target-dir) +%.ko: scripts FORCE + $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ + $(build)=$(target-dir) $(@:.ko=.o) + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost # FIXME Should go into a make.lib or something # =========================================================================== @@ -886,7 +1342,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) cmd_rmfiles = rm -f $(rm-files) -a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_LINUXBIOS) \ +a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \ $(NOSTDINC_FLAGS) $(CPPFLAGS) \ $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) @@ -906,17 +1362,8 @@ endif # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir # Usage: # $(Q)$(MAKE) $(clean)=dir -clean := -f $(if $(LBBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj +clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj endif # skip-makefile -PHONY += FORCE FORCE: - - -# Declare the contents of the .PHONY variable as phony. We keep that -# information in a variable se we can use it in if_changed and friends. -.PHONY: $(PHONY) - - -endif diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 7db4d77c40..785cba4f8a 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -20,5 +20,4 @@ config ARCH_POWERPC boolean - default n diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 65b0e4f245..d01054c5e3 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -20,5 +20,4 @@ config ARCH_X86 boolean - default n diff --git a/arch/x86/Makefile b/arch/x86/Makefile index d8bf2090dd..27113c00b8 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -18,5 +18,5 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -obj-y += init/ +#obj-y += init/ diff --git a/arch/x86/Makefile.target b/arch/x86/Makefile.target new file mode 100644 index 0000000000..79d4f253ec --- /dev/null +++ b/arch/x86/Makefile.target @@ -0,0 +1,110 @@ +## +## This file is part of the LinuxBIOS project. +## +## Copyright (C) 2006 coresystems GmbH +## +## 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 2 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, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## + +# +# This part builds the last 16 byte containing the jmp to the code +# and a date or stamp or pointer to a data structure that flashrom +# might want to read +# + +linuxbios.jump: FORCE + $(Q)echo "Building jump vector" + $(Q)dd if=/dev/zero of=$(objtree)/linuxbios.jump bs=16 count=1 # 0x10 + touch $(objtree)/linuxbios.jump + + +# +# This part takes care of compression. It should build the compression modules +# in a way that they can be put in the lar. FIXME it belongs in lib/ +# + +lzma: + $(Q)echo "building lzma" + + +# +# initram is always uncompressed. It belongs into the mainboard directory +# and is build from what was auto.c in v2 +# + +initram: + $(Q)echo "building initram" + +# +# this is the rest of linuxbios (v2: linuxbios_ram.rom) +# Is this maybe platform independent, except for the "drivers"? +# Where should it be built? +# +# This needs to be compressed with the default compressor +# + +linuxbios_ram: + $(Q)echo "building linuxbios_ram" + +# +# The payload as we love it. Get it from somewhere. +# Is this a place to incorporate buildrom? +# +# This needs to be compressed with the default compressor +# + +payload: + $(Q)echo "building payload" + +# +# build the lar archive +# + + +linuxbios.lar: lzma initram linuxbios_ram payload + $(Q)echo lar c $(objdir)/linuxbios.lar $^ + $(Q)dd if=/dev/zero of=$(objtree)/linuxbios.lar bs=57088 count=1 + + +# +# this is going to be the enable car code, lar parser and such: +# + + +linuxbios.init: + $(Q)echo Building init from $^ + $(Q)dd if=/dev/zero of=$(objtree)/linuxbios.init bs=8192 count=1 + +# +# VPD or SIP ROM or ... how does nvidia call it? +# Some space to cope with dirty southbridge tricks. +# Do we want to put our own stuff there, too? +# + +linuxbios.vpd: + $(Q)printf "Building dummy VPD ..." + $(Q)dd if=/dev/zero of=$(objtree)/linuxbios.vpd bs=240 count=1 # 0xf0 + $(Q)printf "ok.\n" + +# +# Compose the image: +# + +linuxbios.rom: linuxbios.lar linuxbios.init linuxbios.vpd linuxbios.jump + $(Q)cat $(objtree)/linuxbios.lar $(objtree)/linuxbios.init \ + $(objtree)/linuxbios.vpd $(objtree)/linuxbios.jump > \ + $(objtree)/linuxbios.rom + +.PHONY: linuxbios.rom diff --git a/arch/x86/init/Makefile b/arch/x86/init/Makefile index 8f32c44af7..1a9659ff58 100644 --- a/arch/x86/init/Makefile +++ b/arch/x86/init/Makefile @@ -18,5 +18,5 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -obj-y += init.o +head-y += init.o diff --git a/include/cpu/generic/i386/arch/byteorder.h b/include/cpu/generic/x86/arch/byteorder.h similarity index 100% rename from include/cpu/generic/i386/arch/byteorder.h rename to include/cpu/generic/x86/arch/byteorder.h diff --git a/include/cpu/generic/i386/arch/io.h b/include/cpu/generic/x86/arch/io.h similarity index 62% rename from include/cpu/generic/i386/arch/io.h rename to include/cpu/generic/x86/arch/io.h index ae42133329..049729c7fd 100644 --- a/include/cpu/generic/i386/arch/io.h +++ b/include/cpu/generic/x86/arch/io.h @@ -17,7 +17,7 @@ #ifndef _ARCH_IO_H #define _ARCH_IO_H -#include +#include /* * This file contains the definitions for the x86 IO instructions @@ -26,43 +26,43 @@ * versions of the single-IO instructions (inb_p/inw_p/..). */ -static inline void outb(uint8_t value, uint16_t port) +static inline void outb(u8 value, u16 port) { __asm__ __volatile__ ("outb %b0, %w1" : : "a" (value), "Nd" (port)); } -static inline void outw(uint16_t value, uint16_t port) +static inline void outw(u16 value, u16 port) { __asm__ __volatile__ ("outw %w0, %w1" : : "a" (value), "Nd" (port)); } -static inline void outl(uint32_t value, uint16_t port) +static inline void outl(u32 value, u16 port) { __asm__ __volatile__ ("outl %0, %w1" : : "a" (value), "Nd" (port)); } -static inline uint8_t inb(uint16_t port) +static inline u8 inb(u16 port) { - uint8_t value; + u8 value; __asm__ __volatile__ ("inb %w1, %b0" : "=a"(value) : "Nd" (port)); return value; } -static inline uint16_t inw(uint16_t port) +static inline u16 inw(u16 port) { - uint16_t value; + u16 value; __asm__ __volatile__ ("inw %w1, %w0" : "=a"(value) : "Nd" (port)); return value; } -static inline uint32_t inl(uint16_t port) +static inline u32 inl(u16 port) { - uint32_t value; + u32 value; __asm__ __volatile__ ("inl %w1, %0" : "=a"(value) : "Nd" (port)); return value; } -static inline void outsb(uint16_t port, const void *addr, unsigned long count) +static inline void outsb(u16 port, const void *addr, unsigned long count) { __asm__ __volatile__ ( "cld ; rep ; outsb " @@ -71,7 +71,7 @@ static inline void outsb(uint16_t port, const void *addr, unsigned long count) ); } -static inline void outsw(uint16_t port, const void *addr, unsigned long count) +static inline void outsw(u16 port, const void *addr, unsigned long count) { __asm__ __volatile__ ( "cld ; rep ; outsw " @@ -80,7 +80,7 @@ static inline void outsw(uint16_t port, const void *addr, unsigned long count) ); } -static inline void outsl(uint16_t port, const void *addr, unsigned long count) +static inline void outsl(u16 port, const void *addr, unsigned long count) { __asm__ __volatile__ ( "cld ; rep ; outsl " @@ -90,7 +90,7 @@ static inline void outsl(uint16_t port, const void *addr, unsigned long count) } -static inline void insb(uint16_t port, void *addr, unsigned long count) +static inline void insb(u16 port, void *addr, unsigned long count) { __asm__ __volatile__ ( "cld ; rep ; insb " @@ -99,7 +99,7 @@ static inline void insb(uint16_t port, void *addr, unsigned long count) ); } -static inline void insw(uint16_t port, void *addr, unsigned long count) +static inline void insw(u16 port, void *addr, unsigned long count) { __asm__ __volatile__ ( "cld ; rep ; insw " @@ -108,7 +108,7 @@ static inline void insw(uint16_t port, void *addr, unsigned long count) ); } -static inline void insl(uint16_t port, void *addr, unsigned long count) +static inline void insl(u16 port, void *addr, unsigned long count) { __asm__ __volatile__ ( "cld ; rep ; insl " @@ -117,34 +117,34 @@ static inline void insl(uint16_t port, void *addr, unsigned long count) ); } -static inline void writeb(uint8_t b, volatile void *addr) +static inline void writeb(u8 b, volatile void *addr) { - *(volatile uint8_t *) addr = b; + *(volatile u8 *) addr = b; } -static inline void writew(uint16_t b, volatile void *addr) +static inline void writew(u16 b, volatile void *addr) { - *(volatile uint16_t *) addr = b; + *(volatile u16 *) addr = b; } -static inline void writel(uint32_t b, volatile void *addr) +static inline void writel(u32 b, volatile void *addr) { - *(volatile uint32_t *) addr = b; + *(volatile u32 *) addr = b; } -static inline uint8_t readb(const volatile void *addr) +static inline u8 readb(const volatile void *addr) { - return *(volatile uint8_t *) addr; + return *(volatile u8 *) addr; } -static inline uint16_t readw(const volatile void *addr) +static inline u16 readw(const volatile void *addr) { - return *(volatile uint16_t *) addr; + return *(volatile u16 *) addr; } -static inline uint32_t readl(const volatile void *addr) +static inline u32 readl(const volatile void *addr) { - return *(volatile uint32_t *) addr; + return *(volatile u32 *) addr; } #endif diff --git a/include/cpu/generic/i386/arch/swab.h b/include/cpu/generic/x86/arch/swab.h similarity index 100% rename from include/cpu/generic/i386/arch/swab.h rename to include/cpu/generic/x86/arch/swab.h diff --git a/include/cpu/generic/i386/arch/types.h b/include/cpu/generic/x86/arch/types.h similarity index 100% rename from include/cpu/generic/i386/arch/types.h rename to include/cpu/generic/x86/arch/types.h diff --git a/include/cpu/generic/i386/pci_ops.h b/include/cpu/generic/x86/pci_ops.h similarity index 100% rename from include/cpu/generic/i386/pci_ops.h rename to include/cpu/generic/x86/pci_ops.h diff --git a/lib/Kconfig b/lib/Kconfig new file mode 100644 index 0000000000..c3e13fa2a0 --- /dev/null +++ b/lib/Kconfig @@ -0,0 +1,49 @@ +# +# +# + +menu "Compression methods" + +config COMPRESSION_LZMA + boolean "Support LZMA compression" + default y + ---help--- + This is the preferred compression method, as LZMA + reaches very good compression rates with a small footprint + +config COMPRESSION_NRV2B + boolean "Support NRV2B compression" + ---help--- + This compression method has a smaller memory footprint than + LZMA but also significantly worse results. + +choice + prompt "Default compression method" + default DEFAULT_COMPRESSION_LZMA + +config DEFAULT_COMPRESSION_LZMA + bool "LZMA compression" + depends COMPRESSION_LZMA + ---help--- + Choose this option as a default + +config DEFAULT_COMPRESSION_NRV2B + bool "NRV2B compression" + depends COMPRESSION_NRV2B + ---help--- + Choose this option if you have a too large flash chip + +config DEFAULT_COMPRESSION_NONE + bool "no compression" + ---help--- + Do not compress any LinuxBIOS modules per default + +endchoice + + +endmenu + + + + + diff --git a/lib/Makefile b/lib/Makefile new file mode 100644 index 0000000000..d3e9feefb9 --- /dev/null +++ b/lib/Makefile @@ -0,0 +1,23 @@ +## +## This file is part of the LinuxBIOS project. +## +## Copyright (C) 2006 coresystems GmbH +## +## 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 2 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, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## + +compressors-$(CONFIG_COMPRESSION_LZMA) += lzma.o +compressors-$(CONFIG_COMPRESSION_NRV2B) += nrv2b.o + diff --git a/lib/lzma.c b/lib/lzma.c new file mode 100644 index 0000000000..42746e1029 --- /dev/null +++ b/lib/lzma.c @@ -0,0 +1,39 @@ +/* + +LinuxBIOS interface to memory-saving variant of LZMA decoder +(C)opyright 2006 Carl-Daniel Hailfinger +Released under the GNU GPL + +*/ + +#include "lzmadecode.c" + + +static unsigned long ulzma(unsigned char * src, unsigned char * dst) +{ + unsigned char properties[LZMA_PROPERTIES_SIZE]; + UInt32 outSize; + SizeT inProcessed; + SizeT outProcessed; + int res; + CLzmaDecoderState state; + SizeT mallocneeds; + unsigned char scratchpad[15980]; + + memcpy(properties, src, LZMA_PROPERTIES_SIZE); + outSize = *(UInt32 *)(src + LZMA_PROPERTIES_SIZE); + if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) { + printk_warning("Incorrect stream properties\n"); + } + mallocneeds = (LzmaGetNumProbs(&state.Properties) * sizeof(CProb)); + if (mallocneeds > 15980) { + printk_warning("Decoder scratchpad too small!\n"); + } + state.Probs = (CProb *)scratchpad; + res = LzmaDecode(&state, src + LZMA_PROPERTIES_SIZE + 8, (SizeT)0xffffffff, &inProcessed, + dst, outSize, &outProcessed); + if (res != 0) { + printk_warning("Decoding error = %d\n", res); + } + return outSize; +} diff --git a/lib/lzmadecode.c b/lib/lzmadecode.c new file mode 100644 index 0000000000..1c96283fbb --- /dev/null +++ b/lib/lzmadecode.c @@ -0,0 +1,398 @@ +/* + LzmaDecode.c + LZMA Decoder (optimized for Speed version) + + LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01) + http://www.7-zip.org/ + + LZMA SDK is licensed under two licenses: + 1) GNU Lesser General Public License (GNU LGPL) + 2) Common Public License (CPL) + It means that you can select one of these two licenses and + follow rules of that license. + + SPECIAL EXCEPTION: + Igor Pavlov, as the author of this Code, expressly permits you to + statically or dynamically link your Code (or bind by name) to the + interfaces of this file without subjecting your linked Code to the + terms of the CPL or GNU LGPL. Any modifications or additions + to this file, however, are subject to the LGPL or CPL terms. +*/ + +#include "lzmadecode.h" + +#define kNumTopBits 24 +#define kTopValue ((UInt32)1 << kNumTopBits) + +#define kNumBitModelTotalBits 11 +#define kBitModelTotal (1 << kNumBitModelTotalBits) +#define kNumMoveBits 5 + +#define RC_READ_BYTE (*Buffer++) + +#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \ + { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }} + + +#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; } + +#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2 + + +#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; } + +#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound) +#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits; +#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits; + +#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \ + { UpdateBit0(p); mi <<= 1; A0; } else \ + { UpdateBit1(p); mi = (mi + mi) + 1; A1; } + +#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;) + +#define RangeDecoderBitTreeDecode(probs, numLevels, res) \ + { int i = numLevels; res = 1; \ + do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \ + res -= (1 << numLevels); } + + +#define kNumPosBitsMax 4 +#define kNumPosStatesMax (1 << kNumPosBitsMax) + +#define kLenNumLowBits 3 +#define kLenNumLowSymbols (1 << kLenNumLowBits) +#define kLenNumMidBits 3 +#define kLenNumMidSymbols (1 << kLenNumMidBits) +#define kLenNumHighBits 8 +#define kLenNumHighSymbols (1 << kLenNumHighBits) + +#define LenChoice 0 +#define LenChoice2 (LenChoice + 1) +#define LenLow (LenChoice2 + 1) +#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) +#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) +#define kNumLenProbs (LenHigh + kLenNumHighSymbols) + + +#define kNumStates 12 +#define kNumLitStates 7 + +#define kStartPosModelIndex 4 +#define kEndPosModelIndex 14 +#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) + +#define kNumPosSlotBits 6 +#define kNumLenToPosStates 4 + +#define kNumAlignBits 4 +#define kAlignTableSize (1 << kNumAlignBits) + +#define kMatchMinLen 2 + +#define IsMatch 0 +#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) +#define IsRepG0 (IsRep + kNumStates) +#define IsRepG1 (IsRepG0 + kNumStates) +#define IsRepG2 (IsRepG1 + kNumStates) +#define IsRep0Long (IsRepG2 + kNumStates) +#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) +#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) +#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) +#define LenCoder (Align + kAlignTableSize) +#define RepLenCoder (LenCoder + kNumLenProbs) +#define Literal (RepLenCoder + kNumLenProbs) + +#if Literal != LZMA_BASE_SIZE +StopCompilingDueBUG +#endif + +int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size) +{ + unsigned char prop0; + if (size < LZMA_PROPERTIES_SIZE) + return LZMA_RESULT_DATA_ERROR; + prop0 = propsData[0]; + if (prop0 >= (9 * 5 * 5)) + return LZMA_RESULT_DATA_ERROR; + { + for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5)); + for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9); + propsRes->lc = prop0; + /* + unsigned char remainder = (unsigned char)(prop0 / 9); + propsRes->lc = prop0 % 9; + propsRes->pb = remainder / 5; + propsRes->lp = remainder % 5; + */ + } + + return LZMA_RESULT_OK; +} + +#define kLzmaStreamWasFinishedId (-1) + +int LzmaDecode(CLzmaDecoderState *vs, + const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, + unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed) +{ + CProb *p = vs->Probs; + SizeT nowPos = 0; + Byte previousByte = 0; + UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1; + UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1; + int lc = vs->Properties.lc; + + + int state = 0; + UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1; + int len = 0; + const Byte *Buffer; + const Byte *BufferLim; + UInt32 Range; + UInt32 Code; + + *inSizeProcessed = 0; + *outSizeProcessed = 0; + + { + UInt32 i; + UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp)); + for (i = 0; i < numProbs; i++) + p[i] = kBitModelTotal >> 1; + } + + RC_INIT(inStream, inSize); + + + while(nowPos < outSize) + { + CProb *prob; + UInt32 bound; + int posState = (int)( + (nowPos + ) + & posStateMask); + + prob = p + IsMatch + (state << kNumPosBitsMax) + posState; + IfBit0(prob) + { + int symbol = 1; + UpdateBit0(prob) + prob = p + Literal + (LZMA_LIT_SIZE * + ((( + (nowPos + ) + & literalPosMask) << lc) + (previousByte >> (8 - lc)))); + + if (state >= kNumLitStates) + { + int matchByte; + matchByte = outStream[nowPos - rep0]; + do + { + int bit; + CProb *probLit; + matchByte <<= 1; + bit = (matchByte & 0x100); + probLit = prob + 0x100 + bit + symbol; + RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break) + } + while (symbol < 0x100); + } + while (symbol < 0x100) + { + CProb *probLit = prob + symbol; + RC_GET_BIT(probLit, symbol) + } + previousByte = (Byte)symbol; + + outStream[nowPos++] = previousByte; + if (state < 4) state = 0; + else if (state < 10) state -= 3; + else state -= 6; + } + else + { + UpdateBit1(prob); + prob = p + IsRep + state; + IfBit0(prob) + { + UpdateBit0(prob); + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + state = state < kNumLitStates ? 0 : 3; + prob = p + LenCoder; + } + else + { + UpdateBit1(prob); + prob = p + IsRepG0 + state; + IfBit0(prob) + { + UpdateBit0(prob); + prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState; + IfBit0(prob) + { + UpdateBit0(prob); + + if (nowPos == 0) + return LZMA_RESULT_DATA_ERROR; + + state = state < kNumLitStates ? 9 : 11; + previousByte = outStream[nowPos - rep0]; + outStream[nowPos++] = previousByte; + + continue; + } + else + { + UpdateBit1(prob); + } + } + else + { + UInt32 distance; + UpdateBit1(prob); + prob = p + IsRepG1 + state; + IfBit0(prob) + { + UpdateBit0(prob); + distance = rep1; + } + else + { + UpdateBit1(prob); + prob = p + IsRepG2 + state; + IfBit0(prob) + { + UpdateBit0(prob); + distance = rep2; + } + else + { + UpdateBit1(prob); + distance = rep3; + rep3 = rep2; + } + rep2 = rep1; + } + rep1 = rep0; + rep0 = distance; + } + state = state < kNumLitStates ? 8 : 11; + prob = p + RepLenCoder; + } + { + int numBits, offset; + CProb *probLen = prob + LenChoice; + IfBit0(probLen) + { + UpdateBit0(probLen); + probLen = prob + LenLow + (posState << kLenNumLowBits); + offset = 0; + numBits = kLenNumLowBits; + } + else + { + UpdateBit1(probLen); + probLen = prob + LenChoice2; + IfBit0(probLen) + { + UpdateBit0(probLen); + probLen = prob + LenMid + (posState << kLenNumMidBits); + offset = kLenNumLowSymbols; + numBits = kLenNumMidBits; + } + else + { + UpdateBit1(probLen); + probLen = prob + LenHigh; + offset = kLenNumLowSymbols + kLenNumMidSymbols; + numBits = kLenNumHighBits; + } + } + RangeDecoderBitTreeDecode(probLen, numBits, len); + len += offset; + } + + if (state < 4) + { + int posSlot; + state += kNumLitStates; + prob = p + PosSlot + + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << + kNumPosSlotBits); + RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot); + if (posSlot >= kStartPosModelIndex) + { + int numDirectBits = ((posSlot >> 1) - 1); + rep0 = (2 | ((UInt32)posSlot & 1)); + if (posSlot < kEndPosModelIndex) + { + rep0 <<= numDirectBits; + prob = p + SpecPos + rep0 - posSlot - 1; + } + else + { + numDirectBits -= kNumAlignBits; + do + { + RC_NORMALIZE + Range >>= 1; + rep0 <<= 1; + if (Code >= Range) + { + Code -= Range; + rep0 |= 1; + } + } + while (--numDirectBits != 0); + prob = p + Align; + rep0 <<= kNumAlignBits; + numDirectBits = kNumAlignBits; + } + { + int i = 1; + int mi = 1; + do + { + CProb *prob3 = prob + mi; + RC_GET_BIT2(prob3, mi, ; , rep0 |= i); + i <<= 1; + } + while(--numDirectBits != 0); + } + } + else + rep0 = posSlot; + if (++rep0 == (UInt32)(0)) + { + /* it's for stream version */ + len = kLzmaStreamWasFinishedId; + break; + } + } + + len += kMatchMinLen; + if (rep0 > nowPos) + return LZMA_RESULT_DATA_ERROR; + + + do + { + previousByte = outStream[nowPos - rep0]; + len--; + outStream[nowPos++] = previousByte; + } + while(len != 0 && nowPos < outSize); + } + } + RC_NORMALIZE; + + + *inSizeProcessed = (SizeT)(Buffer - inStream); + *outSizeProcessed = nowPos; + return LZMA_RESULT_OK; +} diff --git a/lib/lzmadecode.h b/lib/lzmadecode.h new file mode 100644 index 0000000000..dedde0de67 --- /dev/null +++ b/lib/lzmadecode.h @@ -0,0 +1,67 @@ +/* + LzmaDecode.h + LZMA Decoder interface + + LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01) + http://www.7-zip.org/ + + LZMA SDK is licensed under two licenses: + 1) GNU Lesser General Public License (GNU LGPL) + 2) Common Public License (CPL) + It means that you can select one of these two licenses and + follow rules of that license. + + SPECIAL EXCEPTION: + Igor Pavlov, as the author of this code, expressly permits you to + statically or dynamically link your code (or bind by name) to the + interfaces of this file without subjecting your linked code to the + terms of the CPL or GNU LGPL. Any modifications or additions + to this file, however, are subject to the LGPL or CPL terms. +*/ + +#ifndef __LZMADECODE_H +#define __LZMADECODE_H + +typedef unsigned char Byte; +typedef unsigned short UInt16; +typedef unsigned int UInt32; +typedef UInt32 SizeT; + +#define CProb UInt16 + +#define LZMA_RESULT_OK 0 +#define LZMA_RESULT_DATA_ERROR 1 + + +#define LZMA_BASE_SIZE 1846 +#define LZMA_LIT_SIZE 768 + +#define LZMA_PROPERTIES_SIZE 5 + +typedef struct _CLzmaProperties +{ + int lc; + int lp; + int pb; +}CLzmaProperties; + +int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size); + +#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp))) + +#define kLzmaNeedInitId (-2) + +typedef struct _CLzmaDecoderState +{ + CLzmaProperties Properties; + CProb *Probs; + + +} CLzmaDecoderState; + + +int LzmaDecode(CLzmaDecoderState *vs, + const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, + unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed); + +#endif diff --git a/lib/nrv2b.c b/lib/nrv2b.c new file mode 100644 index 0000000000..c91eda5047 --- /dev/null +++ b/lib/nrv2b.c @@ -0,0 +1,84 @@ +// This GETBIT is supposed to work on little endian +// 32bit systems. The algorithm will definitely need +// some fixing on other systems, but it might not be +// a problem since the nrv2b binary behaves the same.. + +#ifndef ENDIAN +#define ENDIAN 0 +#endif +#ifndef BITSIZE +#define BITSIZE 32 +#endif + +#define GETBIT_8(bb, src, ilen) \ + (((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1) + +#define GETBIT_LE16(bb, src, ilen) \ + (bb*=2,bb&0xffff ? (bb>>16)&1 : (ilen+=2,((bb=(src[ilen-2]+src[ilen-1]*256u)*2+1)>>16)&1)) +#define GETBIT_LE32(bb, src, ilen) \ + (bc > 0 ? ((bb>>--bc)&1) : (bc=31,\ + bb=*(const uint32_t *)((src)+ilen),ilen+=4,(bb>>31)&1)) + +#if ENDIAN == 0 && BITSIZE == 8 +#define GETBIT(bb, src, ilen) GETBIT_8(bb, src, ilen) +#endif +#if ENDIAN == 0 && BITSIZE == 16 +#define GETBIT(bb, src, ilen) GETBIT_LE16(bb, src, ilen) +#endif +#if ENDIAN == 0 && BITSIZE == 32 +#define GETBIT(bb, src, ilen) GETBIT_LE32(bb, src, ilen) +#endif +static unsigned long unrv2b(uint8_t * src, uint8_t * dst, unsigned long *ilen_p) +{ + unsigned long ilen = 0, olen = 0, last_m_off = 1; + uint32_t bb = 0; + unsigned bc = 0; + const uint8_t *m_pos; + + // skip length + src += 4; + /* FIXME: check olen with the length stored in first 4 bytes */ + + for (;;) { + unsigned int m_off, m_len; + while (GETBIT(bb, src, ilen)) { + dst[olen++] = src[ilen++]; + } + + m_off = 1; + do { + m_off = m_off * 2 + GETBIT(bb, src, ilen); + } while (!GETBIT(bb, src, ilen)); + if (m_off == 2) { + m_off = last_m_off; + } else { + m_off = (m_off - 3) * 256 + src[ilen++]; + if (m_off == 0xffffffffU) + break; + last_m_off = ++m_off; + } + + m_len = GETBIT(bb, src, ilen); + m_len = m_len * 2 + GETBIT(bb, src, ilen); + if (m_len == 0) { + m_len++; + do { + m_len = m_len * 2 + GETBIT(bb, src, ilen); + } while (!GETBIT(bb, src, ilen)); + m_len += 2; + } + m_len += (m_off > 0xd00); + + m_pos = dst + olen - m_off; + dst[olen++] = *m_pos++; + do { + dst[olen++] = *m_pos++; + } while (--m_len > 0); + } + + *ilen_p = ilen; + + return olen; + +} + diff --git a/mainboard/emulation/Kconfig b/mainboard/emulation/Kconfig index 2cb01d5e36..ebf0b59a1c 100644 --- a/mainboard/emulation/Kconfig +++ b/mainboard/emulation/Kconfig @@ -19,3 +19,6 @@ config EMULATION_C64 bla bla bla endchoice + +source "mainboard/emulation/qemu-i386/Kconfig" + diff --git a/mainboard/emulation/qemu-i386/Kconfig b/mainboard/emulation/qemu-i386/Kconfig new file mode 100644 index 0000000000..d4d1307a97 --- /dev/null +++ b/mainboard/emulation/qemu-i386/Kconfig @@ -0,0 +1,7 @@ +config CONFIG_MAINBOARD_NAME + string + default 'emulation/qemu-i386' + depends BOARD_EMULATION_QEMU_X86 + help + This is the default mainboard name. + diff --git a/mainboard/emulation/qemu-i386/Makefile b/mainboard/emulation/qemu-i386/Makefile index 8c9fe38087..7d0e5ea5e6 100644 --- a/mainboard/emulation/qemu-i386/Makefile +++ b/mainboard/emulation/qemu-i386/Makefile @@ -2,15 +2,29 @@ # Makefile for this mainboard # -obj-y = mainboard.o setup_before_car.o -$(obj)/mainboard.o: $(obj)/dtc.h +#obj-y = mainboard.o setup_before_car.o +obj-y = setup_before_car.o +#lib-y = linuxbios.vpd -$(obj)/dtc.h: $(src)/dts $(obj)/dtc - $(obj)/dtc -O lb $(src)/dts >$(obj)/dtc.h +#$(obj)/mainboard.o: $(obj)/dtc.h +# +#$(obj)/dtc.h: $(src)/dts $(obj)/dtc +# $(obj)/dtc -O lb $(src)/dts >$(obj)/dtc.h + + +## this does not belong in this file. +#$(obj)/dtc: +# $(MAKE) -C $(srctree)/util/dtc/ +# cp $(srctree)/util/dtc/dtc $(obj) + +# +# This is duplicate in arch/x86/ where it does not belong. +# How can we cross reference? +# +linuxbios.vpd: + $(Q)printf "Building dummy VPD ..." + $(Q)dd if=/dev/zero of=$(objtree)/linuxbios.vpd bs=$(( 0xf0 )) count=1 + $(Q)printf "ok.\n" -# this does not belong in this file. -$(obj)/dtc: - $(MAKE) -C $(srctree)/util/dtc/ - cp $(srctree)/util/dtc/dtc $(obj)/ diff --git a/mainboard/emulation/qemu-i386/setup_before_car.c b/mainboard/emulation/qemu-i386/setup_before_car.c index d9ee419f8d..505a8ec44c 100644 --- a/mainboard/emulation/qemu-i386/setup_before_car.c +++ b/mainboard/emulation/qemu-i386/setup_before_car.c @@ -14,7 +14,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include #include #include #include @@ -33,6 +33,6 @@ void setup_before_car(void) { outb(5, 0x80); - uart_init(); - console_init(); + //uart_init(); + //console_init(); } diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index b0d067be73..92ce94b58b 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -45,7 +45,7 @@ define filechk endef ###### -# gcc support functions +# cc support functions to be used (only) in arch/$(ARCH)/Makefile # See documentation in Documentation/kbuild/makefiles.txt # as-option @@ -87,13 +87,9 @@ cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \ # $(Q)$(MAKE) $(build)=dir build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj -# Prefix -I with $(srctree) if it is not an absolute path -addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1) -# Find all -I options and call addtree -flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) - # If quiet is set, only print short version of command -cmd = @$(echo-cmd) $(cmd_$(1)) +cmd = @$(if $($(quiet)cmd_$(1)),\ + echo ' $(call escsq,$($(quiet)cmd_$(1)))' &&) $(cmd_$(1)) # Add $(obj)/ for paths that is not absolute objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) @@ -116,33 +112,30 @@ endif echo-cmd = $(if $($(quiet)cmd_$(1)), \ echo ' $(call escsq,$($(quiet)cmd_$(1)))';) -make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))) - # function to only execute the passed command if necessary # >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file # note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars -# -if_changed = $(if $(strip $(filter-out $(PHONY),$?) \ - $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ +# +if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ @set -e; \ - $(echo-cmd) $(cmd_$(1)); \ - echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd) + $(echo-cmd) \ + $(cmd_$(1)); \ + echo 'cmd_$@ := $(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).cmd) # execute the command and also postprocess generated .d dependencies # file -if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \ - $(filter-out FORCE $(wildcard $^),$^) \ - $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ +if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ + $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ @set -e; \ - $(echo-cmd) $(cmd_$(1)); \ - scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \ + $(echo-cmd) \ + $(cmd_$(1)); \ + scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \ rm -f $(depfile); \ mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) # Usage: $(call if_changed_rule,foo) # will check if $(cmd_foo) changed, or any of the prequisites changed, # and if so will execute $(rule_foo) -if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \ - $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ +if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ @set -e; \ $(rule_$(1))) diff --git a/scripts/Makefile b/scripts/Makefile new file mode 100644 index 0000000000..a39460fc9d --- /dev/null +++ b/scripts/Makefile @@ -0,0 +1,7 @@ +### +# scripts contains sources for various helper programs used throughout +# the kernel for the build process. +# --------------------------------------------------------------------------- + +# Let clean descend into subdirs +subdir- += basic kconfig package diff --git a/scripts/Makefile.build b/scripts/Makefile.build index b890bba9df..de036e09bf 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -4,7 +4,7 @@ src := $(obj) -PHONY := __build +.PHONY: __build __build: # Read .config if it exist, otherwise ignore @@ -30,7 +30,7 @@ ifneq ($(hostprogs-y)$(hostprogs-m),) include scripts/Makefile.host endif -ifneq ($(LBBUILD_SRC),) +ifneq ($(KBUILD_SRC),) # Create output directory if not already present _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) @@ -39,6 +39,7 @@ _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) endif + ifndef obj $(warning kbuild: Makefile.build is included improperly) endif @@ -53,15 +54,16 @@ ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target)),) builtin-target := $(obj)/built-in.o endif +# We keep a list of all modules in $(MODVERDIR) -__build: $(builtin-target) $(lib-target) $(extra-y) \ - $(subdir-ym) $(always) - @: - +__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ + $(if $(KBUILD_MODULES),$(obj-m)) \ + $(subdir-ym) $(always) + @: # Linus' kernel sanity checking tool -ifneq ($(LBBUILD_CHECKSRC),0) - ifeq ($(LBBUILD_CHECKSRC),2) +ifneq ($(KBUILD_CHECKSRC),0) + ifeq ($(KBUILD_CHECKSRC),2) quiet_cmd_force_checksrc = CHECK $< cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; else @@ -75,8 +77,35 @@ endif # --------------------------------------------------------------------------- # Default is built-in, unless we know otherwise +modkern_cflags := $(CFLAGS_KERNEL) +quiet_modtag := $(empty) $(empty) -cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< +$(real-objs-m) : modkern_cflags := $(CFLAGS_MODULE) +$(real-objs-m:.o=.i) : modkern_cflags := $(CFLAGS_MODULE) +$(real-objs-m:.o=.s) : modkern_cflags := $(CFLAGS_MODULE) +$(real-objs-m:.o=.lst): modkern_cflags := $(CFLAGS_MODULE) + +$(real-objs-m) : quiet_modtag := [M] +$(real-objs-m:.o=.i) : quiet_modtag := [M] +$(real-objs-m:.o=.s) : quiet_modtag := [M] +$(real-objs-m:.o=.lst): quiet_modtag := [M] + +$(obj-m) : quiet_modtag := [M] + +# Default for not multi-part modules +modname = $(*F) + +$(multi-objs-m) : modname = $(modname-multi) +$(multi-objs-m:.o=.i) : modname = $(modname-multi) +$(multi-objs-m:.o=.s) : modname = $(modname-multi) +$(multi-objs-m:.o=.lst) : modname = $(modname-multi) +$(multi-objs-y) : modname = $(modname-multi) +$(multi-objs-y:.o=.i) : modname = $(modname-multi) +$(multi-objs-y:.o=.s) : modname = $(modname-multi) +$(multi-objs-y:.o=.lst) : modname = $(modname-multi) + +quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ +cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $< %.s: %.c FORCE $(call if_changed_dep,cc_s_c) @@ -87,18 +116,60 @@ cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< %.i: %.c FORCE $(call if_changed_dep,cc_i_c) +quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ +cmd_cc_symtypes_c = \ + $(CPP) -D__GENKSYMS__ $(c_flags) $< \ + | $(GENKSYMS) -T $@ >/dev/null; \ + test -s $@ || rm -f $@ + +%.symtypes : %.c FORCE + $(call if_changed_dep,cc_symtypes_c) + # C (.c) files # The C file is compiled and updated dependency information is generated. # (See cmd_cc_o_c + relevant part of rule_cc_o_c) quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ +ifndef CONFIG_MODVERSIONS cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< +else +# When module versioning is enabled the following steps are executed: +# o compile a .tmp_.o from .c +# o if .tmp_.o doesn't contain a __ksymtab version, i.e. does +# not export symbols, we just rename .tmp_.o to .o and +# are done. +# o otherwise, we calculate symbol versions using the good old +# genksyms on the preprocessed source and postprocess them in a way +# that they are usable as a linker script +# o generate .o from .tmp_.o using the linker to +# replace the unresolved symbols __crc_exported_symbol with +# the actual value of the checksum generated by genksyms + +cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< +cmd_modversions = \ + if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ + $(CPP) -D__GENKSYMS__ $(c_flags) $< \ + | $(GENKSYMS) $(if $(KBUILD_SYMTYPES), \ + -T $(@D)/$(@F:.o=.symtypes)) \ + > $(@D)/.tmp_$(@F:.o=.ver); \ + \ + $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ + -T $(@D)/.tmp_$(@F:.o=.ver); \ + rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ + else \ + mv -f $(@D)/.tmp_$(@F) $@; \ + fi; +endif + define rule_cc_o_c - $(call echo-cmd,checksrc) $(cmd_checksrc) \ - $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ - scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > $(@D)/.$(@F).tmp; \ + $(if $($(quiet)cmd_checksrc),echo ' $($(quiet)cmd_checksrc)';) \ + $(cmd_checksrc) \ + $(if $($(quiet)cmd_cc_o_c),echo ' $(call escsq,$($(quiet)cmd_cc_o_c))';) \ + $(cmd_cc_o_c); \ + $(cmd_modversions) \ + scripts/basic/fixdep $(depfile) $@ '$(call escsq,$(cmd_cc_o_c))' > $(@D)/.$(@F).tmp; \ rm -f $(depfile); \ mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd endef @@ -127,6 +198,11 @@ quiet_cmd_cc_lst_c = MKLST $@ # Compile assembler sources (.S) # --------------------------------------------------------------------------- +modkern_aflags := $(AFLAGS_KERNEL) + +$(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE) +$(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE) + quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< @@ -220,14 +296,14 @@ targets += $(multi-used-y) $(multi-used-m) # Descending # --------------------------------------------------------------------------- -PHONY += $(subdir-ym) +.PHONY: $(subdir-ym) $(subdir-ym): $(Q)$(MAKE) $(build)=$@ # Add FORCE to the prequisites of a target to force it to be always rebuilt. # --------------------------------------------------------------------------- -PHONY += FORCE +.PHONY: FORCE FORCE: @@ -242,9 +318,3 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) include $(cmd_files) endif - - -# Declare the contents of the .PHONY variable as phony. We keep that -# information in a variable se we can use it in if_changed and friends. - -.PHONY: $(PHONY) diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index cff33498fa..8974ea5fc8 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -4,7 +4,7 @@ src := $(obj) -PHONY := __clean +.PHONY: __clean __clean: # Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir @@ -87,16 +87,10 @@ endif # Descending # --------------------------------------------------------------------------- -PHONY += $(subdir-ymn) +.PHONY: $(subdir-ymn) $(subdir-ymn): $(Q)$(MAKE) $(clean)=$@ # If quiet is set, only print short version of command cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) - - -# Declare the contents of the .PHONY variable as phony. We keep that -# information in a variable se we can use it in if_changed and friends. - -.PHONY: $(PHONY) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index b7380ff21b..deb088ad4f 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -1,4 +1,5 @@ - +# Backward compatibility - to be removed... +extra-y += $(EXTRA_TARGETS) # Figure out what we need to build from the various variables # =========================================================================== @@ -98,6 +99,11 @@ __a_flags = $(_a_flags) __cpp_flags = $(_cpp_flags) else +# Prefix -I with $(srctree) if it is not an absolute path +addtree = $(1) $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) +# Find all -I options and call addtree +flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) + # -I$(obj) locates generated .h files # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files # and locates generated .h files diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index ad4e56297d..faf562f2ec 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -16,7 +16,7 @@ * tells make when to remake a file. * * To use this list as-is however has the drawback that virtually - * every file in the kernel includes which then again + * every file in the kernel includes which then again * includes * * If the user re-runs make *config, linuxbios/autoconf.h will be @@ -72,7 +72,7 @@ * cmd_ = * * and then basically copies the ..d file to stdout, in the - * process filtering out the dependency on linuxbios/autoconf.h and adding + * process filtering out the dependency on linux/autoconf.h and adding * dependencies on include/config/my/option.h for every * CONFIG_MY_OPTION encountered in any of the prequisites. * @@ -97,7 +97,7 @@ * Note 2: if somebody writes HELLO_CONFIG_BOOM in a file, it will depend onto * CONFIG_BOOM. This could seem a bug (not too hard to fix), but please do not * fix it! Some UserModeLinux files (look at arch/um/) call CONFIG_BOOM as - * UML_CONFIG_BOOM, to avoid conflicts with /usr/include/linuxbios/autoconf.h, + * UML_CONFIG_BOOM, to avoid conflicts with /usr/include/linux/autoconf.h, * through arch/um/include/uml-config.h; this fixdep "bug" makes sure that * those files will have correct dependencies. */ @@ -132,10 +132,20 @@ void usage(void) /* * Print out the commandline prefixed with cmd_ := - */ + * If commandline contains '#' escape with '\' so make to not see + * the '#' as a start-of-comment symbol + **/ void print_cmdline(void) { - printf("cmd_%s := %s\n\n", target, cmdline); + char *p = cmdline; + + printf("cmd_%s := ", target); + for (; *p; p++) { + if (*p == '#') + printf("\\"); + printf("%c", *p); + } + printf("\n\n"); } char * str_config = NULL; @@ -321,7 +331,6 @@ void parse_dep_file(void *map, size_t len) } memcpy(s, m, p-m); s[p-m] = 0; if (strrcmp(s, "include/linuxbios/autoconf.h") && - strrcmp(s, "arch/um/include/uml-config.h") && strrcmp(s, ".ver")) { printf(" %s \\\n", s); do_config_file(s); diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore deleted file mode 100644 index e8ad1f6b3d..0000000000 --- a/scripts/kconfig/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# -# Generated files -# -config* -lex.*.c -*.tab.c -*.tab.h -zconf.hash.c - -# -# configuration programs -# -conf -mconf -qconf -gconf -kxgettext diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 0f45af5f21..baa96ff8af 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -2,7 +2,7 @@ # Kernel configuration targets # These targets are used from top-level makefile -PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config +.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config xconfig: $(obj)/qconf $< Kconfig @@ -28,10 +28,9 @@ update-po-config: $(obj)/kxgettext --add-comments --keyword=_ --keyword=N_ \ --files-from=scripts/kconfig/POTFILES.in \ --output scripts/kconfig/config.pot - $(Q)ln -fs Kconfig_i386 arch/um/Kconfig_arch $(Q)for i in `ls arch/`; \ do \ - scripts/kconfig/kxgettext arch/$$i/Kconfig \ + scripts/kconfig/kxgettext Kconfig \ | msguniq -o scripts/kconfig/linux_$${i}.pot; \ done $(Q)msgcat scripts/kconfig/config.pot \ @@ -39,10 +38,9 @@ update-po-config: $(obj)/kxgettext --output scripts/kconfig/linux_raw.pot $(Q)msguniq --sort-by-file scripts/kconfig/linux_raw.pot \ --output scripts/kconfig/linux.pot - $(Q)rm -f arch/um/Kconfig_arch $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot -PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig +.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig randconfig: $(obj)/conf $< -r Kconfig @@ -56,16 +54,32 @@ allnoconfig: $(obj)/conf allmodconfig: $(obj)/conf $< -m Kconfig +UNAME_RELEASE := $(shell uname -r) +CLONECONFIG := $(firstword $(wildcard /proc/config.gz \ + /lib/modules/$(UNAME_RELEASE)/.config \ + /etc/kernel-config \ + /boot/config-$(UNAME_RELEASE))) +cloneconfig: $(obj)/conf + $(Q)case "$(CLONECONFIG)" in \ + '') echo -e "The configuration of the running" \ + "kernel could not be determined\n"; \ + false ;; \ + *.gz) gzip -cd $(CLONECONFIG) > .config.running ;; \ + *) cat $(CLONECONFIG) > .config.running ;; \ + esac && \ + echo -e "Cloning configuration file $(CLONECONFIG)\n" + $(Q)$< -D .config.running Kconfig + defconfig: $(obj)/conf ifeq ($(KBUILD_DEFCONFIG),) $< -d Kconfig else @echo *** Default configuration is based on '$(KBUILD_DEFCONFIG)' - $(Q)$< -D arch/$(ARCH)/configs/$(KBUILD_DEFCONFIG) Kconfig + $(Q)$< -D configs/$(KBUILD_DEFCONFIG) Kconfig endif %_defconfig: $(obj)/conf - $(Q)$< -D arch/$(ARCH)/configs/$@ Kconfig + $(Q)$< -D configs/$@ Kconfig # Help text used by make help help: @@ -78,7 +92,7 @@ help: @echo ' defconfig - New config with default answer to all options' @echo ' allmodconfig - New config selecting modules when possible' @echo ' allyesconfig - New config where all options are accepted with yes' - @echo ' allnoconfig - New config where all options are answered with no' + @echo ' allnoconfig - New minimal config' # =========================================================================== # Shared Makefile for the various kconfig executables: diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 8012d10768..10eeae53d8 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -64,6 +63,20 @@ static void check_stdin(void) } } +static char *fgets_check_stream(char *s, int size, FILE *stream) +{ + char *ret = fgets(s, size, stream); + + if (ret == NULL && feof(stream)) { + printf(_("aborted!\n\n")); + printf(_("Console input is closed. ")); + printf(_("Run 'make oldconfig' to update configuration.\n\n")); + exit(1); + } + + return ret; +} + static void conf_askvalue(struct symbol *sym, const char *def) { enum symbol_type type = sym_get_type(sym); @@ -101,7 +114,7 @@ static void conf_askvalue(struct symbol *sym, const char *def) check_stdin(); case ask_all: fflush(stdout); - fgets(line, 128, stdin); + fgets_check_stream(line, 128, stdin); return; case set_default: printf("%s\n", def); @@ -315,7 +328,8 @@ static int conf_choice(struct menu *menu) printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); def_sym = sym_get_choice_value(sym); cnt = def = 0; - line[0] = 0; + line[0] = '0'; + line[1] = 0; for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; @@ -356,7 +370,7 @@ static int conf_choice(struct menu *menu) check_stdin(); case ask_all: fflush(stdout); - fgets(line, 128, stdin); + fgets_check_stream(line, 128, stdin); strip(line); if (line[0] == '?') { printf("\n%s\n", menu->sym->help ? @@ -532,7 +546,7 @@ int main(int ac, char **av) break; case 'h': case '?': - fprintf(stderr, "See README for usage info\n"); + printf("%s [-o|-s] config\n", av[0]); exit(0); } } diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 7bd44b9de1..7fc549498c 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -26,6 +26,7 @@ const char conf_defname[] = "arch/$ARCH/defconfig"; const char *conf_confnames[] = { ".config", + conf_defname, NULL, }; @@ -321,7 +322,7 @@ int conf_read(const char *name) sym->flags |= e->right.sym->flags & SYMBOL_NEW; } - sym_change_count = conf_warnings || conf_unsaved; + sym_change_count = conf_warnings && conf_unsaved; return 0; } @@ -370,7 +371,6 @@ int conf_write(const char *name) out_h = fopen(".tmpconfig.h", "w"); if (!out_h) return 1; - file_write_dep(NULL); } sym = sym_lookup("KERNELVERSION", 0); sym_calc_value(sym); @@ -509,6 +509,7 @@ int conf_write(const char *name) if (out_h) { fclose(out_h); rename(".tmpconfig.h", "include/linuxbios/autoconf.h"); + file_write_dep(NULL); } if (!name || basename != conf_def_filename) { if (!name) diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 665bd5300a..a70c562ca4 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -275,7 +275,7 @@ void init_main_window(const gchar * glade_file) /*"style", PANGO_STYLE_OBLIQUE, */ NULL); - sprintf(title, _("Linux Kernel v%s Configuration"), + sprintf(title, _("LinuxBIOS v%s Configuration"), getenv("KERNELVERSION")); gtk_window_set_title(GTK_WINDOW(main_wnd), title); @@ -742,7 +742,7 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data) GtkWidget *dialog; const gchar *intro_text = _( "Welcome to gkc, the GTK+ graphical kernel configuration tool\n" - "for Linux.\n" + "for LinuxBIOS.\n" "For each option, a blank box indicates the feature is disabled, a\n" "check indicates it is enabled, and a dot indicates that it is to\n" "be compiled as a module. Clicking on the box will cycle through the three states.\n" diff --git a/scripts/kconfig/lxdialog/.gitignore b/scripts/kconfig/lxdialog/.gitignore deleted file mode 100644 index 90b08ff025..0000000000 --- a/scripts/kconfig/lxdialog/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# -# Generated files -# -lxdialog diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile index a8b0263262..bbf4887cff 100644 --- a/scripts/kconfig/lxdialog/Makefile +++ b/scripts/kconfig/lxdialog/Makefile @@ -7,10 +7,10 @@ check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh # we really need to do so. (Do not call gcc as part of make mrproper) HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) + +HOST_EXTRACFLAGS += -DLOCALE -HOST_EXTRACFLAGS += -DLOCALE - -PHONY += dochecklxdialog +.PHONY: dochecklxdialog $(obj)/dochecklxdialog: $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index be0200e9cd..db07ae73e0 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c @@ -196,8 +196,8 @@ int dialog_checklist(const char *title, const char *prompt, int height, print_buttons(dialog, height, width, 0); - wnoutrefresh(dialog); wnoutrefresh(list); + wnoutrefresh(dialog); doupdate(); while (key != ESC) { @@ -225,11 +225,12 @@ int dialog_checklist(const char *title, const char *prompt, int height, } scroll--; print_item(list, items[scroll * 3 + 1], status[scroll], 0, TRUE); + wnoutrefresh(list); + print_arrows(dialog, choice, item_no, scroll, box_y, box_x + check_x + 5, list_height); - wnoutrefresh(dialog); - wrefresh(list); + wrefresh(dialog); continue; /* wait for another key press */ } else @@ -251,12 +252,12 @@ int dialog_checklist(const char *title, const char *prompt, int height, scroll++; print_item(list, items[(scroll + max_choice - 1) * 3 + 1], status[scroll + max_choice - 1], max_choice - 1, TRUE); + wnoutrefresh(list); print_arrows(dialog, choice, item_no, scroll, box_y, box_x + check_x + 5, list_height); - wnoutrefresh(dialog); - wrefresh(list); + wrefresh(dialog); continue; /* wait for another key press */ } else @@ -270,8 +271,8 @@ int dialog_checklist(const char *title, const char *prompt, int height, choice = i; print_item(list, items[(scroll + choice) * 3 + 1], status[scroll + choice], choice, TRUE); - wnoutrefresh(dialog); - wrefresh(list); + wnoutrefresh(list); + wrefresh(dialog); } continue; /* wait for another key press */ } @@ -305,8 +306,8 @@ int dialog_checklist(const char *title, const char *prompt, int height, print_item(list, items[(scroll + i) * 3 + 1], status[scroll + i], i, i == choice); } - wnoutrefresh(dialog); - wrefresh(list); + wnoutrefresh(list); + wrefresh(dialog); for (i = 0; i < item_no; i++) if (status[i]) diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c index bf8052f4fd..09512b5443 100644 --- a/scripts/kconfig/lxdialog/menubox.c +++ b/scripts/kconfig/lxdialog/menubox.c @@ -58,7 +58,8 @@ #include "dialog.h" -static int menu_width, item_x; +#define ITEM_IDENT 1 /* Indent of menu entries. Fixed for all menus */ +static int menu_width; /* * Print menu item @@ -69,7 +70,7 @@ static void do_print_item(WINDOW * win, const char *item, int choice, int j; char *menu_item = malloc(menu_width + 1); - strncpy(menu_item, item, menu_width - item_x); + strncpy(menu_item, item, menu_width - ITEM_IDENT); menu_item[menu_width] = 0; j = first_alpha(menu_item, "YyNnMmHh"); @@ -86,13 +87,13 @@ static void do_print_item(WINDOW * win, const char *item, int choice, wclrtoeol(win); #endif wattrset(win, selected ? item_selected_attr : item_attr); - mvwaddstr(win, choice, item_x, menu_item); + mvwaddstr(win, choice, ITEM_IDENT, menu_item); if (hotkey) { wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); - mvwaddch(win, choice, item_x + j, menu_item[j]); + mvwaddch(win, choice, ITEM_IDENT + j, menu_item[j]); } if (selected) { - wmove(win, choice, item_x + 1); + wmove(win, choice, ITEM_IDENT + 1); } free(menu_item); wrefresh(win); @@ -226,8 +227,6 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, menubox_border_attr, menubox_attr); - item_x = (menu_width - 70) / 2; - /* Set choice to default item */ for (i = 0; i < item_no; i++) if (strcmp(current, items[i * 2]) == 0) @@ -264,10 +263,10 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, wnoutrefresh(menu); print_arrows(dialog, item_no, scroll, - box_y, box_x + item_x + 1, menu_height); + box_y, box_x + ITEM_IDENT + 1, menu_height); print_buttons(dialog, height, width, 0); - wmove(menu, choice, item_x + 1); + wmove(menu, choice, ITEM_IDENT + 1); wrefresh(menu); while (key != ESC) { @@ -350,7 +349,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, print_item(scroll + choice, choice, TRUE); print_arrows(dialog, item_no, scroll, - box_y, box_x + item_x + 1, menu_height); + box_y, box_x + ITEM_IDENT + 1, menu_height); wnoutrefresh(dialog); wrefresh(menu); diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 7f973195e7..ebbf2e88b5 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -29,10 +29,10 @@ static char menu_backtitle[128]; static const char mconf_readme[] = N_( "Overview\n" "--------\n" -"Some kernel features may be built directly into the kernel.\n" +"Some firmware features may be built directly into the firmware.\n" "Some may be made into loadable runtime modules. Some features\n" "may be completely removed altogether. There are also certain\n" -"kernel parameters which are not really features, but must be\n" +"firmware parameters which are not really features, but must be\n" "entered in as decimal or hexadecimal numbers or possibly text.\n" "\n" "Menu items beginning with [*], or [ ] represent features\n" @@ -115,7 +115,7 @@ static const char mconf_readme[] = N_( "-----------------------------\n" "Menuconfig supports the use of alternate configuration files for\n" "those who, for various reasons, find it necessary to switch\n" -"between different kernel configurations.\n" +"between different firmware configurations.\n" "\n" "At the end of the main menu you will find two options. One is\n" "for saving the current configuration to a file of your choosing.\n" @@ -148,7 +148,7 @@ static const char mconf_readme[] = N_( "\n" "Optional personality available\n" "------------------------------\n" -"If you prefer to have all of the kernel options listed in a single\n" +"If you prefer to have all of the firmware options listed in a single\n" "menu, rather than the default multimenu hierarchy, run the menuconfig\n" "with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" "\n" @@ -186,18 +186,18 @@ setmod_text[] = N_( "This feature depends on another which has been configured as a module.\n" "As a result, this feature will be built as a module."), nohelp_text[] = N_( - "There is no help available for this kernel option.\n"), + "There is no help available for this firmware option.\n"), load_config_text[] = N_( "Enter the name of the configuration file you wish to load. " "Accept the name shown to restore the configuration you " "last retrieved. Leave blank to abort."), load_config_help[] = N_( "\n" - "For various reasons, one may wish to keep several different kernel\n" + "For various reasons, one may wish to keep several different firmware\n" "configurations available on a single machine.\n" "\n" "If you have saved a previous configuration in a file other than the\n" - "kernel's default, entering the name of the file here will allow you\n" + "firmware's default, entering the name of the file here will allow you\n" "to modify that configuration.\n" "\n" "If you are uncertain, then you have probably never used alternate\n" @@ -207,7 +207,7 @@ save_config_text[] = N_( "as an alternate. Leave blank to abort."), save_config_help[] = N_( "\n" - "For various reasons, one may wish to keep different kernel\n" + "For various reasons, one may wish to keep different firmware\n" "configurations available on a single machine.\n" "\n" "Entering a file name here will allow you to later retrieve, modify\n" @@ -1053,7 +1053,7 @@ int main(int ac, char **av) sym = sym_lookup("KERNELVERSION", 0); sym_calc_value(sym); - sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"), + sprintf(menu_backtitle, _("LinuxBIOS v%s Configuration"), sym_get_string_value(sym)); mode = getenv("MENUCONFIG_MODE"); @@ -1070,7 +1070,7 @@ int main(int ac, char **av) do { cprint_init(); cprint("--yesno"); - cprint(_("Do you wish to save your new kernel configuration?")); + cprint(_("Do you wish to save your new firmware configuration?")); cprint("5"); cprint("60"); stat = exec_conf(); @@ -1079,18 +1079,18 @@ int main(int ac, char **av) if (stat == 0) { if (conf_write(NULL)) { fprintf(stderr, _("\n\n" - "Error during writing of the kernel configuration.\n" - "Your kernel configuration changes were NOT saved." + "Error during writing of the firmware configuration.\n" + "Your firmware configuration changes were NOT saved." "\n\n")); return 1; } printf(_("\n\n" - "*** End of Linux kernel configuration.\n" - "*** Execute 'make' to build the kernel or try 'make help'." + "*** End of LinuxBIOS configuration.\n" + "*** Execute 'make' to build the firmware or try 'make help'." "\n\n")); } else { fprintf(stderr, _("\n\n" - "Your kernel configuration changes were NOT saved." + "Your firmware configuration changes were NOT saved." "\n\n")); } diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 9bc1a1a234..64484d4c16 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -44,7 +44,7 @@ int file_write_dep(const char *name) else fprintf(out, "\t%s\n", file->name); } - fprintf(out, "\n.config include/linuxbios/autoconf.h: $(deps_config)\n\n$(deps_config):\n"); + fprintf(out, "\n.config $(objtree)/include/linuxbios/autoconf.h: $(deps_config)\n\n$(deps_config):\n"); fclose(out); rename("..config.tmp", name); return 0; diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped index ea7755da82..f6f491f344 100644 --- a/scripts/kconfig/zconf.tab.c_shipped +++ b/scripts/kconfig/zconf.tab.c_shipped @@ -1949,7 +1949,7 @@ void conf_parse(const char *name) sym_init(); menu_init(); modules_sym = sym_lookup("MODULES", 0); - rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); + rootmenu.prompt = menu_add_prompt(P_MENU, "LinuxBIOS Configuration", NULL); #if YYDEBUG if (getenv("ZCONF_DEBUG")) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 1f61fba6aa..ed05caf6b1 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -459,7 +459,7 @@ void conf_parse(const char *name) sym_init(); menu_init(); modules_sym = sym_lookup("MODULES", 0); - rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); + rootmenu.prompt = menu_add_prompt(P_MENU, "LinuxBIOS Configuration", NULL); #if YYDEBUG if (getenv("ZCONF_DEBUG")) diff --git a/scripts/mkmakefile b/scripts/mkmakefile new file mode 100644 index 0000000000..753e764d2e --- /dev/null +++ b/scripts/mkmakefile @@ -0,0 +1,32 @@ +#!/bin/sh +# Generates a small Makefile used in the root of the output +# directory, to allow make to be started from there. +# The Makefile also allow for more convinient build of external modules + +# Usage +# $1 - Kernel src directory +# $2 - Output directory +# $3 - version +# $4 - patchlevel + + +cat << EOF +# Automatically generated by $(basename $0): don't edit + +VERSION = $3 +PATCHLEVEL = $4 + +KERNELSRC := $1 +KERNELOUTPUT := $2 +export ARCH := $ARCH + +MAKEFLAGS += --no-print-directory + +all: + \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) + +%:: + \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@ + +EOF + diff --git a/util/Makefile b/util/Makefile new file mode 100644 index 0000000000..602ce91d78 --- /dev/null +++ b/util/Makefile @@ -0,0 +1,7 @@ +### +# util contains sources for various helper programs used throughout +# the firmware for the build process. +# --------------------------------------------------------------------------- + +# Let clean descend into subdirs +subdir- += dtc lar