diff --git a/Makefile b/Makefile index b54be4159d..fa5b9e660c 100644 --- a/Makefile +++ b/Makefile @@ -1,1356 +1,94 @@ +## +## This file is part of the LinuxBIOS project. +## +## LinuxBIOS build system Lbuild +## +## Copyright (C) 2007 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 +## + VERSION = 3 PATCHLEVEL = 0 SUBLEVEL = 0 -EXTRAVERSION = -wth -NAME=Gonna Kick It -# *DOCUMENTATION* -# To see a list of typical targets execute "make help" -# More info can be located in ./README -# Comments in this file are targeted only to the developer, do not -# expect to learn how to build the kernel reading this file. + +ARCH := $(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/ ) + +KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) + +have_dotconfig := $(wildcard .config) + +srcdir:=$(shell pwd) +src:=$(srcdir) +objdir:=$(shell pwd)/lbobj +obj:=$(objdir) + # Do not print "Entering directory ..." MAKEFLAGS += --no-print-directory -# We are using a recursive build, so we need to do a little thinking -# to get the ordering right. -# -# Most importantly: sub-Makefiles should only ever modify files in -# 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 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. -# -# The only cases where we need to modify files which have global -# effects are thus separated out and done before the recursive -# descending is started. They are now explicitly listed as the -# prepare rule. +CC := gcc +CFLAGS := -Os -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -Werror-implicit-function-declaration \ + -fno-strict-aliasing -fno-common \ + -ffreestanding -fno-builtin -# To put more focus on warnings, be less verbose as default -# Use 'make V=1' to see the full commands +HOSTCC := gcc +HOSTCFLAGS := -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -ifdef V - ifeq ("$(origin V)", "command line") - KBUILD_VERBOSE = $(V) - endif -endif -ifndef KBUILD_VERBOSE - KBUILD_VERBOSE = 0 -endif +LINUXBIOSINCLUDE := -I$(src) -Iinclude \ + -I$(src)/include \ + -I$(src)/include/cpu/generic/$(ARCH)/ \ + -include $(obj)/config.h -# Call sparse as part of compilation of C files -# Use 'make C=1' to enable sparse checking +CPPFLAGS := $(LINUXBIOSINCLUDE) -ifdef C - ifeq ("$(origin C)", "command line") - KBUILD_CHECKSRC = $(C) - endif -endif -ifndef KBUILD_CHECKSRC - KBUILD_CHECKSRC = 0 -endif +export srcdir src objdir obj KERNELVERSION -# Use make M=dir to specify directory of external module to build -# Old syntax make ... SUBDIRS=$PWD is still supported -# Setting the environment variable KBUILD_EXTMOD take precedence -ifdef SUBDIRS - KBUILD_EXTMOD ?= $(SUBDIRS) -endif -ifdef M - ifeq ("$(origin M)", "command line") - KBUILD_EXTMOD := $(M) - endif -endif - - -# kbuild supports saving output files in a separate directory. -# To locate output files in a separate directory two syntaxes are supported. -# In both cases the working directory must be the root of the kernel src. -# 1) O= -# Use "make O=dir/to/store/output/files/" -# -# 2) Set KBUILD_OUTPUT -# Set the environment variable KBUILD_OUTPUT to point to the directory -# where the output files shall be placed. -# export KBUILD_OUTPUT=dir/to/store/output/files/ -# make -# -# The O= assignment takes precedence over the KBUILD_OUTPUT environment -# variable. - - -# 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") - KBUILD_OUTPUT := $(O) - endif -endif - -# That's our default target when none is given on the command line -.PHONY: _all -_all: - -ifneq ($(KBUILD_OUTPUT),) -# Invoke a second make in the output directory, passing relevant variables -# check that the output directory actually exists -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) - -$(filter-out _all,$(MAKECMDGOALS)) _all: - $(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 ($(KBUILD_OUTPUT),) -endif # ifeq ($(KBUILD_SRC),) - -# We process the rest of the Makefile if this is the final invocation of make -ifeq ($(skip-makefile),) - -# 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 +ifeq ($(strip $(have_dotconfig)),) +all: + @echo "run make menuconfig first" else -_all: modules +include $(src)/.config +all: prepare prepare2 $(obj)/linuxbios.rom + @echo "build process finished." 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 $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) - -export srctree objtree VPATH TOPDIR - - -# SUBARCH tells the usermode build what the underlying arch is. That is set -# first, and if a usermode build is happening, the "ARCH=um" on the command -# line overrides the setting of ARCH below. If a native build is happening, -# then ARCH is assigned, getting whatever value it gets normally, and -# SUBARCH is subsequently ignored. - -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/ ) - -# Cross compiling and selecting different set of gcc/bin-utils -# --------------------------------------------------------------------------- -# -# When performing cross compilation for other architectures ARCH shall be set -# to the target architecture. (See arch/* for the possibilities). -# ARCH can be set during invocation of make: -# make ARCH=ia64 -# Another way is to have ARCH set in the environment. -# The default ARCH is the host where make is executed. - -# CROSS_COMPILE specify the prefix used for all executables used -# during compilation. Only gcc and related bin-utils executables -# are prefixed with $(CROSS_COMPILE). -# CROSS_COMPILE can be set on the command line -# make CROSS_COMPILE=ia64-linux- -# Alternatively CROSS_COMPILE can be set in the environment. -# Default value for CROSS_COMPILE is not to prefix executables -# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile - -ARCH ?= $(SUBARCH) -CROSS_COMPILE ?= - -# Architecture as present in compile.h -UTS_MACHINE := $(ARCH) - -# SHELL used by kbuild -CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ - else if [ -x /bin/bash ]; then echo /bin/bash; \ - else echo sh; fi ; fi) - -HOSTCC = gcc -HOSTCXX = g++ -HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -HOSTCXXFLAGS = -O2 - -# 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 -# --------------------------------------------------------------------------- -# -# Normally, we echo the whole command before executing it. By making -# that echo $($(quiet)$(cmd)), we now have the possibility to set -# $(quiet) to choose other forms of output instead, e.g. -# -# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ -# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< -# -# If $(quiet) is empty, the whole command will be printed. -# If it is set to "quiet_", only the short version will be printed. -# If it is set to "silent_", nothing wil be printed at all, since -# the variable $(silent_cmd_cc_o_c) doesn't exist. -# -# A simple variant is to prefix commands with $(Q) - that's useful -# for commands that shall be hidden in non-verbose mode. -# -# $(Q)ln $@ :< -# -# If KBUILD_VERBOSE equals 0 then the above command will be hidden. -# If KBUILD_VERBOSE equals 1 then the above command is displayed. - -ifeq ($(KBUILD_VERBOSE),1) - quiet = - Q = -else - quiet=quiet_ - Q = @ -endif - -# If the user is running make -s (silent mode), suppress echoing of -# commands - -ifneq ($(findstring s,$(MAKEFLAGS)),) - quiet=silent_ -endif - -export quiet Q KBUILD_VERBOSE - - -# Look for make include files relative to root of kernel src -MAKEFLAGS += --include-dir=$(srctree) - -# We need some generic definitions -include $(srctree)/scripts/Kbuild.include - -# For maximum performance (+ possibly random breakage, uncomment -# the following) - -#MAKEFLAGS += -rR - -# Make variables (CC, etc...) - -AS = $(CROSS_COMPILE)as -LD = $(CROSS_COMPILE)ld -CC = $(CROSS_COMPILE)gcc -CPP = $(CC) -E -AR = $(CROSS_COMPILE)ar -NM = $(CROSS_COMPILE)nm -STRIP = $(CROSS_COMPILE)strip -OBJCOPY = $(CROSS_COMPILE)objcopy -OBJDUMP = $(CROSS_COMPILE)objdump -AWK = awk -GENKSYMS = scripts/genksyms/genksyms -DEPMOD = /sbin/depmod -KALLSYMS = scripts/kallsyms -PERL = perl -CHECK = sparse - -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 := -I$(srctree) -Iinclude \ - -I$(srctree)/include \ - -I$(srctree)/include/cpu/generic/$(ARCH)/ \ - -include $(srctree)/include/linuxbios/autoconf.h - -#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 \ - -Werror-implicit-function-declaration \ - -fno-strict-aliasing -fno-common \ - -ffreestanding -AFLAGS := -D__ASSEMBLY__ - -# Warn about unsupported modules in kernels built inside Autobuild -ifneq ($(wildcard /.buildenv),) -CFLAGS += -DUNSUPPORTED_MODULES=1 -endif - -# 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 LDFLAGS_MODULE CHECK CHECKFLAGS - -export CPPFLAGS NOSTDINC_FLAGS LINUXBIOSINCLUDE OBJCOPYFLAGS LDFLAGS -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 - -RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o -export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git - -# =========================================================================== -# Rules shared between *config targets and build targets - -# Basic helpers built in scripts/ -.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 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: - $(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 -# It is allowed to specify more targets when calling make, including -# mixing *config targets and build targets. -# For example 'make oldconfig all'. -# Detect when mixed targets is specified, and make a second invocation -# of make so .config is not included in this case either (for *config). - -no-dot-config-targets := clean mrproper distclean \ - cscope TAGS tags help %docs check% - -config-targets := 0 -mixed-targets := 0 -dot-config := 1 - -ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) - ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) - dot-config := 0 - endif -endif - -ifeq ($(KBUILD_EXTMOD),) - ifneq ($(filter config %config,$(MAKECMDGOALS)),) - config-targets := 1 - ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) - mixed-targets := 1 - endif - endif -endif - -ifeq ($(mixed-targets),1) -# =========================================================================== -# We're called with mixed targets (*config and build targets). -# Handle them one by one. - -%:: FORCE - $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@ - -else -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 KBUILD_DEFCONFIG as needed. -# KBUILD_DEFCONFIG may point out an alternative default configuration -# used for 'make defconfig' -include $(srctree)/arch/$(ARCH)/Makefile -export KBUILD_DEFCONFIG - -config %config: scripts_basic outputmakefile FORCE - $(Q)mkdir -p include/linuxbios - $(Q)$(MAKE) $(build)=scripts/kconfig $@ - $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease - -else -# =========================================================================== -# 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 - -# Read in dependencies to all Kconfig* files, make sure to run -# oldconfig if changes are detected. --include .kconfig.d - -include .config - -# If .config needs to be updated, it will be done via the dependency -# that autoconf has on .config. -# To avoid any implicit rule to kick in, define an empty command -.config .kconfig.d: ; +include util/Makefile +#include mainboards/Makefile +include arch/$(ARCH)/Makefile MAINBOARDDIR=$(shell echo $(CONFIG_MAINBOARD_NAME)) +include mainboard/$(MAINBOARDDIR)/Makefile -include mainboard/$(MAINBOARDDIR)/Makefile.target -# If .config is newer than include/linuxbios/autoconf.h, someone tinkered -# 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 -$(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 -$(objtree)/include/linuxbios/autoconf.h: ; -endif +prepare: + @mkdir -p $(objdir) -# 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 linuxbios but it is usually overriden in the arch makefile -all: linuxbios +prepare2: + @cp $(src)/.tmpconfig.h $(obj)/config.h -ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE -CFLAGS += -Os -else -CFLAGS += -O2 -endif +clean: + @echo "Cleaning up..." + rm -rf $(objdir) -#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_DEBUG_INFO -CFLAGS += -g -endif - -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 -CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) - -# disable pointer signedness warnings in gcc 4.0 -CFLAGS += $(call cc-option,-Wno-pointer-sign,) - -# Default kernel image to build when no specific target is given. -# 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 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 - - -ifeq ($(KBUILD_EXTMOD),) -#core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ -#core-$(CONFIG_KDB) += kdb/ - -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) $(patsubst %/,%,$(filter %/, \ - $(init-n) $(init-) \ - $(core-n) $(core-) $(drivers-n) $(drivers-) \ - $(net-n) $(net-) $(libs-n) $(libs-)))) - -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 -# --------------------------------------------------------------------------- -# 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. -# -# linuxbios -# ^ -# | -# +-< $(linuxbios-init) -# | +--< init/version.o + more -# | -# +--< $(linuxbios-main) -# | +--< driver/built-in.o mm/built-in.o + more -# | -# +-< kallsyms.o (see description in CONFIG_KALLSYMS section) -# -# linuxbios version (uname -v) cannot be updated during normal -# descending-into-subdirs phase since we do not yet know if we need to -# 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. -# -# System.map is generated to document addresses of all kernel symbols - -linuxbios-init := $(head-y) $(init-y) -linuxbios-main := $(core-y) $(libs-y) $(drivers-y) $(net-y) -linuxbios-all := $(linuxbios-init) $(linuxbios-main) -#linuxbios-lds := arch/$(ARCH)/kernel/linuxbios.lds - -# Rule to link linuxbios - also used during CONFIG_KALLSYMS -# May be overridden by arch/$(ARCH)/Makefile -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 linuxbios version -quiet_cmd_linuxbios_version = GEN .version - cmd_linuxbios_version = set -e; \ - if [ ! -r .version ]; then \ - rm -f .version; \ - echo 1 >.version; \ - else \ - mv .version .old_version; \ - expr 0$$(cat .old_version) + 1 >.version; \ - fi; \ - -# Generate System.map -quiet_cmd_sysmap = SYSMAP - cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap - -# 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 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,linuxbios_version)) - - $(call cmd,linuxbios__) - $(Q)echo 'cmd_$@ := $(cmd_linuxbios__)' > $(@D)/.$(@F).cmd - - $(Q)$(if $($(quiet)cmd_sysmap), \ - echo ' $($(quiet)cmd_sysmap) System.map' &&) \ - $(cmd_sysmap) $@ System.map; \ - if [ $$? -ne 0 ]; then \ - rm -f $@; \ - /bin/false; \ - fi; - $(verify_kallsyms) -endef - - -ifdef CONFIG_KALLSYMS -# Generate section listing all symbols and add it into linuxbios $(kallsyms.o) -# It's a three stage process: -# 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 - 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 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_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 - -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, -# make sure no implicit rule kicks in -$(sort $(linuxbios-init) $(linuxbios-main)) $(linuxbios-lds): $(linuxbios-dirs) ; - -# Handle descending into subdirectories listed in $(linuxbios-dirs) -# Preset locale variables to speed up the build process. Limit locale -# tweaks to this spot to avoid wrong language settings when running -# make menuconfig etc. -# Error messages still appears in the original language - -.PHONY: $(linuxbios-dirs) -$(linuxbios-dirs): prepare scripts - $(Q)$(MAKE) $(build)=$@ - -# Build the kernel release string -# 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 KERNELRELEASE. -# LOCALVERSION from the command line override all of this - -nullstring := -space := $(nullstring) # end of line - -___localver = $(objtree)/localversion* $(srctree)/localversion* -__localver = $(sort $(wildcard $(___localver))) -# skip backup files (containing '~') -_localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f))) - -localver = $(subst $(space),, \ - $(shell cat /dev/null $(_localver)) \ - $(patsubst "%",%,$(CONFIG_LOCALVERSION))) - -# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called -# and if the SCM is know a tag from the SCM is appended. -# The appended tag is determinded by the SCM used. -# -# Currently, only git is supported. -# Other SCMs can edit scripts/setlocalversion and add the appropriate -# checks as needed. -ifdef CONFIG_LOCALVERSION_AUTO - _localver-auto = $(shell $(CONFIG_SHELL) \ - $(srctree)/scripts/setlocalversion $(srctree)) - localver-auto = $(LOCALVERSION)$(_localver-auto) -endif - -localver-full = $(localver)$(localver-auto) - -# Store (new) KERNELRELASE string in .kernelrelease -kernelrelease = $(KERNELVERSION)$(localver-full) -.kernelrelease: FORCE - $(Q)rm -f $@ - $(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 asm symlink, -# version.h and scripts_basic is processed / created. - -# Listed in dependency order -.PHONY: prepare archprepare prepare0 prepare1 prepare2 prepare3 - -# prepare-all is deprecated, use prepare as valid replacement -.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) -# 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 $(objtree)/include/linuxbios/version.h \ - include/config/MARKER -ifneq ($(KBUILD_MODULES),) - $(Q)rm -rf $(MODVERDIR) - $(Q)mkdir -p $(MODVERDIR) -endif - -archprepare: prepare1 scripts_basic - -prepare0: archprepare FORCE - $(Q)$(MAKE) $(build)=. - -# All the preparing.. -prepare prepare-all: prepare0 - -# 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 $(objtree)/include/linuxbios/autoconf.h - @echo ' SPLIT include/linuxbios/autoconf.h -> include/config/*' - @scripts/basic/split-include include/linuxbios/autoconf.h include/config - @touch $@ - -# Generate some files -# --------------------------------------------------------------------------- - -# 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 "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ - echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ - exit 1; \ - fi; \ - (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \ - echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \ - echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \ - ) -endef - -$(objtree)/include/linuxbios/version.h: $(srctree)/Makefile .config .kernelrelease FORCE - $(call filechk,version.h) - -# --------------------------------------------------------------------------- - -.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. -# make clean Delete most generated files -# Leave enough to build external modules -# make mrproper Delete the current configuration, and all generated files -# make distclean Remove editor backup files, patch leftover files and the like - -# Directories & files removed with 'make clean' -CLEAN_DIRS += $(MODVERDIR) -CLEAN_FILES += linuxbios System.map \ - .tmp_kallsyms* .tmp_version .tmp_linuxbios* .tmp_System.map - -# Directories & files removed with 'make mrproper' -MRPROPER_DIRS += include/config include2 -MRPROPER_FILES += .config .config.old .version .old_version \ - include/linuxbios/autoconf.h include/linuxbios/version.h \ - .kernelrelease Module.symvers tags TAGS cscope* - -# clean - Delete most, but leave enough to build external modules -# -clean: rm-dirs := $(CLEAN_DIRS) -clean: rm-files := $(CLEAN_FILES) -clean-dirs := $(addprefix _clean_,$(srctree) $(linuxbios-alldirs)) - -.PHONY: $(clean-dirs) clean archclean -$(clean-dirs): - $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) - -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 '*.symtypes' \) \ - -type f -print | xargs rm -f - -# mrproper - Delete all generated files, including .config -# -mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) -mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) -mrproper-dirs := $(addprefix _mrproper_,doc scripts) - -.PHONY: $(mrproper-dirs) mrproper archmrproper -$(mrproper-dirs): - $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) - -mrproper: clean archmrproper $(mrproper-dirs) - $(call cmd,rmdirs) - $(call cmd,rmfiles) - -# distclean -# -.PHONY: distclean - -distclean: mrproper - @find $(srctree) $(RCS_FIND_IGNORE) \ - \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ - -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ - -o -name '.*.rej' -o -size 0 \ - -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ - -type f -print | xargs rm -f - - -# Brief documentation of the typical targets used -# --------------------------------------------------------------------------- - -boards := $(wildcard $(srctree)/arch/$(ARCH)/configs/*_defconfig) -boards := $(notdir $(boards)) - -help: - @echo 'Cleaning targets:' - @echo ' clean - remove most generated files but keep the config' - @echo ' mrproper - remove all generated files + config + various backup files' - @echo '' - @echo 'Configuration targets:' - @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help - @echo '' - @echo 'Other generic targets:' - @echo ' all - Build all targets marked with [*]' - @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' - @echo ' dir/file.[ois] - Build specified target only' - @echo ' dir/file.ko - Build module including final link' - @echo ' tags/TAGS - Generate tags file for editors' - @echo ' cscope - Generate cscope index' - @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 'Documentation targets:' - @$(MAKE) -f $(srctree)/doc/Makefile dochelp - @echo '' - @echo 'Architecture specific targets ($(ARCH)):' - @$(if $(archhelp),$(archhelp),\ - echo ' No architecture specific help defined for $(ARCH)') - @echo '' - @$(if $(boards), \ - $(foreach b, $(boards), \ - printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \ - echo '') - - @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' - @echo ' make O=dir [targets] Locate all output files in "dir", including .config' - @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse)' - @echo ' make C=2 [targets] Force check of all c source with $$CHECK (sparse)' - @echo '' - @echo 'Execute "make" or "make all" to build all targets marked with [*] ' - @echo 'For further info see the ./README file' - - -# Documentation targets -# --------------------------------------------------------------------------- -%docs: scripts_basic FORCE - $(Q)$(MAKE) $(build)=doc $@ - -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 -# --------------------------------------------------------------------------- - -includecheck: - find * $(RCS_FIND_IGNORE) \ - -name '*.[hcS]' -type f -print | sort \ - | xargs $(PERL) -w scripts/checkincludes.pl - -versioncheck: - find * $(RCS_FIND_IGNORE) \ - -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 -checkstack: - $(OBJDUMP) -d linuxbios $$(find . -name '*.ko') | \ - $(PERL) $(src)/scripts/checkstack.pl $(ARCH) - -kernelrelease: - $(if $(wildcard .kernelrelease), $(Q)echo $(KERNELRELEASE), \ - $(error kernelrelease not valid - run 'make *config' to update it)) -kernelversion: - @echo $(KERNELVERSION) - -# Single targets -# --------------------------------------------------------------------------- -# 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 - -/ %/: 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 -# =========================================================================== - -quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) - cmd_rmdirs = rm -rf $(rm-dirs) - -quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) - cmd_rmfiles = rm -f $(rm-files) - - -a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \ - $(NOSTDINC_FLAGS) $(CPPFLAGS) \ - $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) - -quiet_cmd_as_o_S = AS $@ -cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< - -# read all saved command lines - -targets := $(wildcard $(sort $(targets))) -cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) - -ifneq ($(cmd_files),) - $(cmd_files): ; # Do not try to update included dependency files - include $(cmd_files) -endif - -# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir -# Usage: -# $(Q)$(MAKE) $(clean)=dir -clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj - -endif # skip-makefile - -FORCE: +%.o: %.c + $(CC) $(CFLAGS) -o $@ -c $< diff --git a/arch/Makefile b/arch/Makefile deleted file mode 100644 index cb5cefe04f..0000000000 --- a/arch/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -## -## 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 -## - -obj-$(CONFIG_ARCH_X86) += x86/ -obj-$(CONFIG_ARCH_POWERPC) += powerpc/ - diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 6328ccc6fe..e2a31dc1ee 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -1,7 +1,7 @@ ## ## This file is part of the LinuxBIOS project. ## -## Copyright (C) 2006 coresystems GmbH +## Copyright (C) 2006-2007 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 @@ -18,12 +18,104 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -#obj-y += init/ +obj:=$(objdir) +src:=$(srcdir) + +$(obj)/linuxbios.rom: $(obj)/linuxbios.lar $(obj)/stage0.init $(obj)/linuxbios.vpd + @cat $(obj)/linuxbios.lar \ + $(obj)/linuxbios.vpd \ + $(obj)/stage0.init > \ + $(obj)/linuxbios.rom + +# +# 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: $(obj)/statictree.o + $(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 +# + +$(obj)/linuxbios.lar: $(obj)/util/lar/lar lzma linuxbios.initram linuxbios_ram payload + $(Q)echo "Building LinuxBIOS archive..." + $(Q)rm -rf $(obj)/lar.tmp + $(Q)mkdir $(obj)/lar.tmp + $(Q)mkdir $(obj)/lar.tmp/normal + $(Q)cp $(obj)/linuxbios.initram $(obj)/lar.tmp/normal/initram + $(Q)cd $(obj)/lar.tmp && ../util/lar/lar c ../linuxbios.lar.pre normal/initram + # TODO: dynamically pad the lar archive. bs is image size - bootblock size (8k) + $(Q)dd if=$(obj)/linuxbios.lar.pre of=$(obj)/linuxbios.lar bs=253952 count=1 conv=sync + + +# +# this is going to be the enable car code, lar parser and such: +# + +INITCFLAGS := $(CFLAGS) -I$(src)/include/cpu/generic/x86 -I$(src)/include -fno-builtin + +$(obj)/stage0.init: + @echo Building linuxbios.init + # Building asm stub + @$(CC) -E $(LINUXBIOSINCLUDE) $(src)/arch/x86/stage0_i586.S -o $(obj)/stage0_i586.s -DBOOTBLK=0x1f00 -DRESRVED=0xf0 -DDATE=\"`date +%Y/%m/%d`\" + @$(AS) $(obj)/stage0_i586.s -o $(obj)/stage0_i586.o + # Building cachemain + $(CC) $(INITCFLAGS) -c $(src)/arch/x86/cachemain.c -o $(obj)/cachemain.o + # + @$(CC) $(INITCFLAGS) -c $(src)/lib/lar.c -o $(obj)/lar.o + # + # console lib + @$(CC) $(INITCFLAGS) -c $(src)/arch/x86/console.c -o $(obj)/console.o + @$(CC) $(INITCFLAGS) -c $(src)/arch/x86/serial.c -o $(obj)/serial.o + @$(CC) $(INITCFLAGS) -c $(src)/console/vtxprintf.c -o $(obj)/vtxprintf.o + @$(CC) $(INITCFLAGS) -c $(src)/lib/uart8250.c -o $(obj)/uart8250.o + # other lib parts + @$(CC) $(INITCFLAGS) -c $(src)/lib/memcpy.c -o $(obj)/memcpy.o + + @cd $(obj); $(CC) -m32 -nostdlib -static -T $(src)/arch/x86/ldscript.ld cachemain.o console.o uart8250.o \ + serial.o vtxprintf.o lar.o memcpy.o stage0_i586.o -o stage0.o + @objcopy -O binary $(obj)/stage0.o $(obj)/stage0.init.pre + + # Pad boot block to 0x2000 - 0x100 + # we will probably remove this step -- not needed if we continue with ldscript.ld + @dd if=$(obj)/stage0.init.pre of=$(obj)/stage0.init bs=7936 conv=sync + @echo "Len: `wc -c < $(obj)/stage0.init.pre`" + # + @test `wc -c < $(obj)/stage0.init.pre` -gt 7936 && echo "Error. Bootblock got too big" || true + + -define archhelp - echo '* linuxbios.rom - Compressed kernel image (arch/$(ARCH)/linuxbios.rom)' - echo ' install - Install kernel using' - echo ' fdimage - Create a bios update floppy image' -endef - diff --git a/arch/x86/Makefile.target b/arch/x86/Makefile.target deleted file mode 100644 index a872c8ab62..0000000000 --- a/arch/x86/Makefile.target +++ /dev/null @@ -1,150 +0,0 @@ -## -## This file is part of the LinuxBIOS project. -## -## Copyright (C) 2006 coresystems GmbH -## Copyright (C) 2007 Ron G. Minnich -## -## 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 -# - -CFLAGS := - -#linuxbios.jump: FORCE -# $(Q)echo "Building jump vector" -# $(Q)$(CC) -E $(srctree)/arch/x86/reset.S -o $(objtree)/reset.s -DBOOTBLK=0x1f00 -DRESRVED=0xf0 -DDATE=\"`date +%Y/%m/%d`\" -# $(Q)$(AS) $(objtree)/reset.s -o $(objtree)/reset.o -# $(Q)$(LD) -Ttext 0xfffffff0 -s --oformat binary $(objtree)/reset.o -o $(objtree)/linuxbios.jump -# $(Q)chmod 644 $(objtree)/linuxbios.jump -# $(Q)echo "Len: `wc -c < 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: statictree.o - $(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: $(objtree)/lar lzma linuxbios.initram linuxbios_ram payload - $(Q)echo "Building LinuxBIOS archive..." - $(Q)mkdir $(objtree)/lar.tmp - $(Q)mkdir $(objtree)/lar.tmp/normal - $(Q)cp $(objtree)/linuxbios.initram $(objtree)/lar.tmp/normal/initram - $(Q)cd $(objtree)/lar.tmp && ../lar c ../linuxbios.lar.pre normal/initram - # TODO: dynamically pad the lar archive. bs is image size - bootblock size (8k) - $(Q)dd if=$(objtree)/linuxbios.lar.pre of=$(objtree)/linuxbios.lar bs=253952 count=1 conv=sync - -# -# this is going to be the enable car code, lar parser and such: -# - -INITCFLAGS=-I$(srctree)/include/cpu/generic/x86 -I$(srctree)/include -fno-builtin -Os - -# Note: we could cat .o files together, but one important goal is to leave us with a complete gdb-debuggable -# .o for use with popular ICE and other tools. We go to some effort here to end up with a -# stage0.o that has debug symbols. This stage0 will actually load the first LAR file and execute it. -stage0.init: - echo "You will need to create variables for arch/$(CONFIG_ARCH)" - echo "and CC flags for architecture, and to select the stage0_$(CONFIG_STAGE0_1)" - echo "these will be set in mainboard Kconfig. Also, you need to define the .c files for " - echo "stage0 in that file as well. " - $(Q)echo Building linuxbios.init - # - # asm stub - $(Q)$(CC) -E $(LINUXBIOSINCLUDE) $(srctree)/arch/x86/stage0_i586.S -o $(objtree)/stage0_i586.s -DBOOTBLK=0x1f00 -DRESRVED=0xf0 -DDATE=\"`date +%Y/%m/%d`\" - $(Q)$(AS) $(objtree)/stage0_i586.s -o $(objtree)/stage0_i586.o - # - # main - $(Q)$(CC) $(INITCFLAGS) -c $(srctree)/arch/x86/cachemain.c -o cachemain.o - # - $(Q)$(CC) $(INITCFLAGS) -c $(srctree)/lib/lar.c -o lar.o - # - # console lib - $(Q)$(CC) $(INITCFLAGS) -c $(srctree)/arch/x86/console.c -o console.o - $(Q)$(CC) $(INITCFLAGS) -c $(srctree)/arch/x86/serial.c -o serial.o - $(Q)$(CC) $(INITCFLAGS) -c $(srctree)/console/vtxprintf.c -o vtxprintf.o - $(Q)$(CC) $(INITCFLAGS) -c $(srctree)/lib/uart8250.c -o uart8250.o - - # leave a .o around for debugging etc. - # we did not want to use a ldscript. But the outstanding bugs in gld make it impossible to do - # anything else. - # Google Not enough room for program headers (allocated 3, need 4) - $(Q)$(CC) -m32 -nostdlib -static -T $(srctree)/arch/x86/ldscript.ld cachemain.o console.o uart8250.o \ - serial.o vtxprintf.o lar.o stage0_i586.o -o stage0.o - $(Q)objcopy -O binary stage0.o stage0.init.pre - - # Pad boot block to 0x2000 - 0x100 - # we will probably remove this step -- not needed if we continue with ldscript.ld - $(Q)dd if=stage0.init.pre of=stage0.init bs=7936 conv=sync - $(Q)echo "Len: `wc -c < stage0.init.pre`" - # - $(Q)test `wc -c < stage0.init.pre` -gt 7936 && echo "Error. Bootblock got too big" || true - -# -# Compose the image: -# - -linuxbios.rom: linuxbios.lar stage0.init linuxbios.vpd - $(Q)cat $(objtree)/linuxbios.lar \ - $(objtree)/linuxbios.vpd $(objtree)/stage0.init> \ - $(objtree)/linuxbios.rom - -$(objtree)/lar: - $(MAKE) -C $(srctree)/util/lar - cp $(srctree)/util/lar/lar $(objtree) - - -.PHONY: linuxbios.rom diff --git a/arch/x86/cachemain.c b/arch/x86/cachemain.c index 48cd1e2373..8c8c03c379 100644 --- a/arch/x86/cachemain.c +++ b/arch/x86/cachemain.c @@ -23,6 +23,13 @@ #include #include "config.h" +/* these prototypes should go into headers */ +void uart_init(void); +int printk(int msg_level, const char *fmt, ...); +void console_init(void); +void die(const char *msg); +int find_file(struct mem_file *archive, char *filename, struct mem_file *result); + static void post_code(u8 value) { outb(value, 0x80); @@ -70,7 +77,8 @@ void stage1_main(u32 bist) console_init(); // print banner if (bist!=0) { - die("BIST FAILED: %08x", bist); + printk(BIOS_INFO, "BIST FAILED: %08x", bist); + die(""); } // enable rom diff --git a/lib/lar.c b/lib/lar.c index 6d2908afda..6159310c29 100644 --- a/lib/lar.c +++ b/lib/lar.c @@ -31,6 +31,10 @@ #define ntohl(x) (x) #endif +// FIXME: this should go into a header +int printk(int msg_level, const char *fmt, ...); + + int find_file(struct mem_file *archive, char *filename, struct mem_file *result) { char * walk, *fullname; @@ -83,7 +87,7 @@ int copy_file(struct mem_file *archive, char *filename, void *where) int run_file(struct mem_file *archive, char *filename, void *where) { - int (*v)(); + int (*v)(void); if (copy_file(archive, filename, where)){ printk(BIOS_INFO, "run file %s failed: ENOENT\n", filename); diff --git a/mainboard/Makefile b/mainboard/Makefile deleted file mode 100644 index 219446c3f5..0000000000 --- a/mainboard/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -## -## 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 -## - -obj-$(CONFIG_VENDOR_EMULATION) += emulation/ - diff --git a/mainboard/emulation/Makefile b/mainboard/emulation/Makefile deleted file mode 100644 index d2d15918fa..0000000000 --- a/mainboard/emulation/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -## -## 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 -## - -obj-$(CONFIG_BOARD_EMULATION_QEMU_X86) += qemu-i386/ - diff --git a/mainboard/emulation/qemu-i386/Makefile b/mainboard/emulation/qemu-i386/Makefile index 1f58f8aa05..548f06f29f 100644 --- a/mainboard/emulation/qemu-i386/Makefile +++ b/mainboard/emulation/qemu-i386/Makefile @@ -1,21 +1,65 @@ +## +## This file is part of the LinuxBIOS project. +## +## Copyright (C) 2006-2007 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 +## + # -# Makefile for this mainboard +# 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? # +$(obj)/linuxbios.vpd: + @printf "Building dummy VPD ..." + @dd if=/dev/zero of=$(obj)/linuxbios.vpd bs=240 count=1 + @printf "ok.\n" -#obj-y = mainboard.o setup_before_car.o -obj-y = setup_before_car.o -#lib-y = linuxbios.vpd -#$(obj)/mainboard.o: $(obj)/dtc.h # -#$(obj)/dtc.h: $(src)/dts $(obj)/dtc -# $(obj)/dtc -O lb $(src)/dts >$(obj)/dtc.h +# this is going to be the enable car code, lar parser and such: +# + +linuxbios.initram: + $(Q)echo Building linuxbios.initram + # + # main + $(Q)$(CC) $(INITCFLAGS) -c $(src)/mainboard/$(MAINBOARDDIR)/initram.c -o $(obj)/initram.o + # + # console lib + $(Q)$(CC) $(INITCFLAGS) -c $(src)/arch/x86/console.c -o $(obj)/console.o + $(Q)$(CC) $(INITCFLAGS) -c $(src)/arch/x86/serial.c -o $(obj)/serial.o + $(Q)$(CC) $(INITCFLAGS) -c $(src)/console/vtxprintf.c -o $(obj)/vtxprintf.o + $(Q)$(CC) $(INITCFLAGS) -c $(src)/lib/uart8250.c -o $(obj)/uart8250.o + + cd $(obj); $(Q)$(LD) -Ttext 0x00000000 -s --oformat binary initram.o console.o uart8250.o \ + serial.o vtxprintf.o -o $(obj)/linuxbios.initram + + $(Q)chmod 644 $(obj)/linuxbios.initram -## this does not belong in this file. -#$(obj)/dtc: -# $(MAKE) -C $(srctree)/util/dtc/ -# cp $(srctree)/util/dtc/dtc $(obj) +# miscellaneous important targets. +$(obj)/mainboard.o: $(obj)/statictree.o + +$(obj)/statictree.o: $(obj)/statictree.c + $(CC) $(CFLAGS) $(LINUXBIOSINCLUDE) -c -o $(obj)/statictree.o $(obj)/statictree.c + +$(obj)/statictree.c: mainboard/$(MAINBOARDDIR)/dts $(obj)/util/dtc/dtc + $(obj)/util/dtc/dtc -O lb mainboard/$(MAINBOARDDIR)/dts >$(obj)/statictree.c + diff --git a/mainboard/emulation/qemu-i386/Makefile.target b/mainboard/emulation/qemu-i386/Makefile.target deleted file mode 100644 index f1651004f4..0000000000 --- a/mainboard/emulation/qemu-i386/Makefile.target +++ /dev/null @@ -1,70 +0,0 @@ -## -## 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 -## - - -# -# 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 - $(Q)printf "ok.\n" - - -# -# this is going to be the enable car code, lar parser and such: -# - -INITCFLAGS=-I$(srctree)/include/cpu/generic/x86 -I$(srctree)/include -fno-builtin -Os -fPIC - -linuxbios.initram: - $(Q)echo Building linuxbios.initram - # - # main - $(Q)$(CC) $(INITCFLAGS) -c $(srctree)/mainboard/$(MAINBOARDDIR)/initram.c -o initram.o - # - # console lib - $(Q)$(CC) $(INITCFLAGS) -c $(srctree)/arch/x86/console.c -o console.o - $(Q)$(CC) $(INITCFLAGS) -c $(srctree)/arch/x86/serial.c -o serial.o - $(Q)$(CC) $(INITCFLAGS) -c $(srctree)/console/vtxprintf.c -o vtxprintf.o - $(Q)$(CC) $(INITCFLAGS) -c $(srctree)/lib/uart8250.c -o uart8250.o - - $(Q)$(LD) -Ttext 0x00000000 -s --oformat binary initram.o console.o uart8250.o \ - serial.o vtxprintf.o -o $(objtree)/linuxbios.initram - - $(Q)chmod 644 $(objtree)/linuxbios.initram - - -# miscellaneous important targets. -$(objtree)/mainboard.o: $(objtree)/statictree.o - -$(objtree)/statictree.o: $(objtree)/statictree.c - $(CC) $(CFLAGS) $(LINUXBIOSINCLUDE) -c -o $(objtree)/statictree.o $(objtree)/statictree.c - -$(objtree)/statictree.c: mainboard/$(MAINBOARDDIR)/dts $(objtree)/dtc - $(objtree)/dtc -O lb mainboard/$(MAINBOARDDIR)/dts >$(objtree)/statictree.c - -$(objtree)/dtc: - $(MAKE) -C $(srctree)/util/dtc/ - cp $(srctree)/util/dtc/dtc $(objtree) - diff --git a/mainboard/emulation/qemu-i386/initram.c b/mainboard/emulation/qemu-i386/initram.c index b930d38f4e..cd35dfab99 100644 --- a/mainboard/emulation/qemu-i386/initram.c +++ b/mainboard/emulation/qemu-i386/initram.c @@ -21,6 +21,10 @@ #include #include +int printk(int msg_level, const char *fmt, ...); +void die(const char *msg); + + static void post_code(u8 value) { outb(value, 0x80); diff --git a/scripts/Makefile b/scripts/Makefile deleted file mode 100644 index a39460fc9d..0000000000 --- a/scripts/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -### -# 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 deleted file mode 100644 index de036e09bf..0000000000 --- a/scripts/Makefile.build +++ /dev/null @@ -1,320 +0,0 @@ -# ========================================================================== -# Building -# ========================================================================== - -src := $(obj) - -.PHONY: __build -__build: - -# Read .config if it exist, otherwise ignore --include .config - -include scripts/Kbuild.include - -# The filename Kbuild has precedence over Makefile -kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) -include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) - -include scripts/Makefile.lib - -ifdef host-progs -ifneq ($(hostprogs-y),$(host-progs)) -$(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!) -hostprogs-y += $(host-progs) -endif -endif - -# Do not include host rules unles needed -ifneq ($(hostprogs-y)$(hostprogs-m),) -include scripts/Makefile.host -endif - -ifneq ($(KBUILD_SRC),) -# Create output directory if not already present -_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) - -# Create directories for object files if directory does not exist -# Needed when obj-y := dir/file.o syntax is used -_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) -endif - - -ifndef obj -$(warning kbuild: Makefile.build is included improperly) -endif - -# =========================================================================== - -ifneq ($(strip $(lib-y) $(lib-m) $(lib-n) $(lib-)),) -lib-target := $(obj)/lib.a -endif - -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: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ - $(if $(KBUILD_MODULES),$(obj-m)) \ - $(subdir-ym) $(always) - @: - -# Linus' kernel sanity checking tool -ifneq ($(KBUILD_CHECKSRC),0) - ifeq ($(KBUILD_CHECKSRC),2) - quiet_cmd_force_checksrc = CHECK $< - cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; - else - quiet_cmd_checksrc = CHECK $< - cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; - endif -endif - - -# Compile C sources (.c) -# --------------------------------------------------------------------------- - -# Default is built-in, unless we know otherwise -modkern_cflags := $(CFLAGS_KERNEL) -quiet_modtag := $(empty) $(empty) - -$(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) - -quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@ -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 - $(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 - -# Built-in and composite module parts - -%.o: %.c FORCE - $(call cmd,force_checksrc) - $(call if_changed_rule,cc_o_c) - -# Single-part modules are special since we need to mark them in $(MODVERDIR) - -$(single-used-m): %.o: %.c FORCE - $(call cmd,force_checksrc) - $(call if_changed_rule,cc_o_c) - @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) - -quiet_cmd_cc_lst_c = MKLST $@ - cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ - $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ - System.map $(OBJDUMP) > $@ - -%.lst: %.c FORCE - $(call if_changed_dep,cc_lst_c) - -# 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 $@ $< - -%.s: %.S FORCE - $(call if_changed_dep,as_s_S) - -quiet_cmd_as_o_S = AS $(quiet_modtag) $@ -cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< - -%.o: %.S FORCE - $(call if_changed_dep,as_o_S) - -targets += $(real-objs-y) $(real-objs-m) $(lib-y) -targets += $(extra-y) $(MAKECMDGOALS) $(always) - -# Linker scripts preprocessor (.lds.S -> .lds) -# --------------------------------------------------------------------------- -quiet_cmd_cpp_lds_S = LDS $@ - cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $< - -%.lds: %.lds.S FORCE - $(call if_changed_dep,cpp_lds_S) - -# Build the compiled-in targets -# --------------------------------------------------------------------------- - -# To build objects in subdirs, we need to descend into the directories -$(sort $(subdir-obj-y)): $(subdir-ym) ; - -# -# Rule to compile a set of .o files into one .o file -# -ifdef builtin-target -quiet_cmd_link_o_target = LD $@ -# If the list of objects to link is empty, just create an empty built-in.o -cmd_link_o_target = $(if $(strip $(obj-y)),\ - $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\ - rm -f $@; $(AR) rcs $@) - -$(builtin-target): $(obj-y) FORCE - $(call if_changed,link_o_target) - -targets += $(builtin-target) -endif # builtin-target - -# -# Rule to compile a set of .o files into one .a file -# -ifdef lib-target -quiet_cmd_link_l_target = AR $@ -cmd_link_l_target = rm -f $@; $(AR) $(EXTRA_ARFLAGS) rcs $@ $(lib-y) - -$(lib-target): $(lib-y) FORCE - $(call if_changed,link_l_target) - -targets += $(lib-target) -endif - -# -# Rule to link composite objects -# -# Composite objects are specified in kbuild makefile as follows: -# -objs := -# or -# -y := -link_multi_deps = \ -$(filter $(addprefix $(obj)/, \ -$($(subst $(obj)/,,$(@:.o=-objs))) \ -$($(subst $(obj)/,,$(@:.o=-y)))), $^) - -quiet_cmd_link_multi-y = LD $@ -cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) - -quiet_cmd_link_multi-m = LD [M] $@ -cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps) - -# We would rather have a list of rules like -# foo.o: $(foo-objs) -# but that's not so easy, so we rather make all composite objects depend -# on the set of all their parts -$(multi-used-y) : %.o: $(multi-objs-y) FORCE - $(call if_changed,link_multi-y) - -$(multi-used-m) : %.o: $(multi-objs-m) FORCE - $(call if_changed,link_multi-m) - @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod) - -targets += $(multi-used-y) $(multi-used-m) - - -# Descending -# --------------------------------------------------------------------------- - -.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 - -FORCE: - -# Read all saved command lines and dependencies for the $(targets) we -# may be building above, using $(if_changed{,_dep}). As an -# optimization, we don't need to read them if the target does not -# exist, we will rebuild anyway in that case. - -targets := $(wildcard $(sort $(targets))) -cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) - -ifneq ($(cmd_files),) - include $(cmd_files) -endif diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean deleted file mode 100644 index 8974ea5fc8..0000000000 --- a/scripts/Makefile.clean +++ /dev/null @@ -1,96 +0,0 @@ -# ========================================================================== -# Cleaning up -# ========================================================================== - -src := $(obj) - -.PHONY: __clean -__clean: - -# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir -# Usage: -# $(Q)$(MAKE) $(clean)=dir -clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj - -# The filename Kbuild has precedence over Makefile -kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) -include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) - -# Figure out what we need to build from the various variables -# ========================================================================== - -__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) -subdir-y += $(__subdir-y) -__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) -subdir-m += $(__subdir-m) -__subdir-n := $(patsubst %/,%,$(filter %/, $(obj-n))) -subdir-n += $(__subdir-n) -__subdir- := $(patsubst %/,%,$(filter %/, $(obj-))) -subdir- += $(__subdir-) - -# Subdirectories we need to descend into - -subdir-ym := $(sort $(subdir-y) $(subdir-m)) -subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-)) - -# Add subdir path - -subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) - -# build a list of files to remove, usually releative to the current -# directory - -__clean-files := $(extra-y) $(EXTRA_TARGETS) $(always) \ - $(targets) $(clean-files) \ - $(host-progs) \ - $(hostprogs-y) $(hostprogs-m) $(hostprogs-) - -# as clean-files is given relative to the current directory, this adds -# a $(obj) prefix, except for absolute paths - -__clean-files := $(wildcard \ - $(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \ - $(filter /%, $(__clean-files))) - -# as clean-dirs is given relative to the current directory, this adds -# a $(obj) prefix, except for absolute paths - -__clean-dirs := $(wildcard \ - $(addprefix $(obj)/, $(filter-out /%, $(clean-dirs))) \ - $(filter /%, $(clean-dirs))) - -# ========================================================================== - -quiet_cmd_clean = CLEAN $(obj) - cmd_clean = rm -f $(__clean-files) -quiet_cmd_cleandir = CLEAN $(__clean-dirs) - cmd_cleandir = rm -rf $(__clean-dirs) - - -__clean: $(subdir-ymn) -ifneq ($(strip $(__clean-files)),) - +$(call cmd,clean) -endif -ifneq ($(strip $(__clean-dirs)),) - +$(call cmd,cleandir) -endif -ifneq ($(strip $(clean-rule)),) - +$(clean-rule) -endif - @: - - -# =========================================================================== -# Generic stuff -# =========================================================================== - -# Descending -# --------------------------------------------------------------------------- - -.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)) diff --git a/scripts/Makefile.host b/scripts/Makefile.host deleted file mode 100644 index 2d519704b8..0000000000 --- a/scripts/Makefile.host +++ /dev/null @@ -1,156 +0,0 @@ -# ========================================================================== -# Building binaries on the host system -# Binaries are used during the compilation of the kernel, for example -# to preprocess a data file. -# -# Both C and C++ is supported, but preferred language is C for such utilities. -# -# Samle syntax (see Documentation/kbuild/makefile.txt for reference) -# hostprogs-y := bin2hex -# Will compile bin2hex.c and create an executable named bin2hex -# -# hostprogs-y := lxdialog -# lxdialog-objs := checklist.o lxdialog.o -# Will compile lxdialog.c and checklist.c, and then link the executable -# lxdialog, based on checklist.o and lxdialog.o -# -# hostprogs-y := qconf -# qconf-cxxobjs := qconf.o -# qconf-objs := menu.o -# Will compile qconf as a C++ program, and menu as a C program. -# They are linked as C++ code to the executable qconf - -# hostprogs-y := conf -# conf-objs := conf.o libkconfig.so -# libkconfig-objs := expr.o type.o -# Will create a shared library named libkconfig.so that consist of -# expr.o and type.o (they are both compiled as C code and the object file -# are made as position independent code). -# conf.c is compiled as a c program, and conf.o is linked together with -# libkconfig.so as the executable conf. -# Note: Shared libraries consisting of C++ files are not supported - -__hostprogs := $(sort $(hostprogs-y)$(hostprogs-m)) - -# hostprogs-y := tools/build may have been specified. Retreive directory -obj-dirs += $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f)))) -obj-dirs := $(strip $(sort $(filter-out ./,$(obj-dirs)))) - - -# C code -# Executables compiled from a single .c file -host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))) - -# C executables linked based on several .o files -host-cmulti := $(foreach m,$(__hostprogs),\ - $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))) - -# Object (.o) files compiled from .c files -host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs))) - -# C++ code -# C++ executables compiled from at least on .cc file -# and zero or more .c files -host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m))) - -# C++ Object (.o) files compiled from .cc files -host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) - -# Shared libaries (only .c supported) -# Shared libraries (.so) - all .so files referenced in "xxx-objs" -host-cshlib := $(sort $(filter %.so, $(host-cobjs))) -# Remove .so files from "xxx-objs" -host-cobjs := $(filter-out %.so,$(host-cobjs)) - -#Object (.o) files used by the shared libaries -host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) - -__hostprogs := $(addprefix $(obj)/,$(__hostprogs)) -host-csingle := $(addprefix $(obj)/,$(host-csingle)) -host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) -host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) -host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) -host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) -host-cshlib := $(addprefix $(obj)/,$(host-cshlib)) -host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) -obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) - -##### -# Handle options to gcc. Support building with separate output directory - -_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(*F).o) -_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o) - -ifeq ($(KBUILD_SRC),) -__hostc_flags = $(_hostc_flags) -__hostcxx_flags = $(_hostcxx_flags) -else -__hostc_flags = -I$(obj) $(call flags,_hostc_flags) -__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) -endif - -hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) -hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) - -##### -# Compile programs on the host - -# Create executable from a single .c file -# host-csingle -> Executable -quiet_cmd_host-csingle = HOSTCC $@ - cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \ - $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) -$(host-csingle): %: %.c FORCE - $(call if_changed_dep,host-csingle) - -# Link an executable based on list of .o files, all plain c -# host-cmulti -> executable -quiet_cmd_host-cmulti = HOSTLD $@ - cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \ - $(addprefix $(obj)/,$($(@F)-objs)) \ - $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) -$(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE - $(call if_changed,host-cmulti) - -# Create .o file from a single .c file -# host-cobjs -> .o -quiet_cmd_host-cobjs = HOSTCC $@ - cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $< -$(host-cobjs): %.o: %.c FORCE - $(call if_changed_dep,host-cobjs) - -# Link an executable based on list of .o files, a mixture of .c and .cc -# host-cxxmulti -> executable -quiet_cmd_host-cxxmulti = HOSTLD $@ - cmd_host-cxxmulti = $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \ - $(foreach o,objs cxxobjs,\ - $(addprefix $(obj)/,$($(@F)-$(o)))) \ - $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) -$(host-cxxmulti): %: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE - $(call if_changed,host-cxxmulti) - -# Create .o file from a single .cc (C++) file -quiet_cmd_host-cxxobjs = HOSTCXX $@ - cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $< -$(host-cxxobjs): %.o: %.cc FORCE - $(call if_changed_dep,host-cxxobjs) - -# Compile .c file, create position independent .o file -# host-cshobjs -> .o -quiet_cmd_host-cshobjs = HOSTCC -fPIC $@ - cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $< -$(host-cshobjs): %.o: %.c FORCE - $(call if_changed_dep,host-cshobjs) - -# Link a shared library, based on position independent .o files -# *.o -> .so shared library (host-cshlib) -quiet_cmd_host-cshlib = HOSTLLD -shared $@ - cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \ - $(addprefix $(obj)/,$($(@F:.so=-objs))) \ - $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) -$(host-cshlib): %: $(host-cshobjs) FORCE - $(call if_changed,host-cshlib) - -targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) - diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib deleted file mode 100644 index deb088ad4f..0000000000 --- a/scripts/Makefile.lib +++ /dev/null @@ -1,170 +0,0 @@ -# Backward compatibility - to be removed... -extra-y += $(EXTRA_TARGETS) -# Figure out what we need to build from the various variables -# =========================================================================== - -# When an object is listed to be built compiled-in and modular, -# only build the compiled-in version - -obj-m := $(filter-out $(obj-y),$(obj-m)) - -# Libraries are always collected in one lib file. -# Filter out objects already built-in - -lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) - - -# Handle objects in subdirs -# --------------------------------------------------------------------------- -# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o -# and add the directory to the list of dirs to descend into: $(subdir-y) -# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) -# and add the directory to the list of dirs to descend into: $(subdir-m) - -__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) -subdir-y += $(__subdir-y) -__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) -subdir-m += $(__subdir-m) -obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) -obj-m := $(filter-out %/, $(obj-m)) - -# Subdirectories we need to descend into - -subdir-ym := $(sort $(subdir-y) $(subdir-m)) - -# if $(foo-objs) exists, foo.o is a composite object -multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) -multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) -multi-used := $(multi-used-y) $(multi-used-m) -single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m))) - -# Build list of the parts of our composite objects, our composite -# objects depend on those (obviously) -multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y))) -multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) -multi-objs := $(multi-objs-y) $(multi-objs-m) - -# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live -# in the local directory -subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o))) - -# $(obj-dirs) is a list of directories that contain object files -obj-dirs := $(dir $(multi-objs) $(subdir-obj-y)) - -# Replace multi-part objects by their individual parts, look at local dir only -real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y) -real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) - -# Add subdir path - -extra-y := $(addprefix $(obj)/,$(extra-y)) -always := $(addprefix $(obj)/,$(always)) -targets := $(addprefix $(obj)/,$(targets)) -obj-y := $(addprefix $(obj)/,$(obj-y)) -obj-m := $(addprefix $(obj)/,$(obj-m)) -lib-y := $(addprefix $(obj)/,$(lib-y)) -subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) -real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) -real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) -single-used-m := $(addprefix $(obj)/,$(single-used-m)) -multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) -multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) -multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) -multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) -subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) -obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) - -# These flags are needed for modversions and compiling, so we define them here -# already -# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will -# end up in (or would, if it gets compiled in) -# Note: It's possible that one object gets potentially linked into more -# than one module. In that case KBUILD_MODNAME will be set to foo_bar, -# where foo and bar are the name of the modules. -name-fix = $(subst $(comma),_,$(subst -,_,$1)) -basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(*F)))" -modname_flags = $(if $(filter 1,$(words $(modname))),\ - -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") - -_c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) -_a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) -_cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F)) - -# If building the kernel in a separate objtree expand all occurrences -# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). - -ifeq ($(KBUILD_SRC),) -__c_flags = $(_c_flags) -__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 -# FIXME: Replace both with specific CFLAGS* statements in the makefiles -__c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags) -__a_flags = $(call flags,_a_flags) -__cpp_flags = $(call flags,_cpp_flags) -endif - -c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \ - $(__c_flags) $(modkern_cflags) \ - -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) - -a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \ - $(__a_flags) $(modkern_aflags) - -cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags) - -ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS) - -# Finds the multi-part object the current object will be linked into -modname-multi = $(sort $(foreach m,$(multi-used),\ - $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) - -# Shipped files -# =========================================================================== - -quiet_cmd_shipped = SHIPPED $@ -cmd_shipped = cat $< > $@ - -$(obj)/%:: $(src)/%_shipped - $(call cmd,shipped) - -# Commands useful for building a boot image -# =========================================================================== -# -# Use as following: -# -# target: source(s) FORCE -# $(if_changed,ld/objcopy/gzip) -# -# and add target to EXTRA_TARGETS so that we know we have to -# read in the saved command line - -# Linking -# --------------------------------------------------------------------------- - -quiet_cmd_ld = LD $@ -cmd_ld = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \ - $(filter-out FORCE,$^) -o $@ - -# Objcopy -# --------------------------------------------------------------------------- - -quiet_cmd_objcopy = OBJCOPY $@ -cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ - -# Gzip -# --------------------------------------------------------------------------- - -quiet_cmd_gzip = GZIP $@ -cmd_gzip = gzip -f -9 < $< > $@ - - diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile deleted file mode 100644 index bbf4887cff..0000000000 --- a/scripts/kconfig/lxdialog/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile to build lxdialog package -# - -check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh - -# Use reursively expanded variables so we do not call gcc unless -# 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 - -.PHONY: dochecklxdialog -$(obj)/dochecklxdialog: - $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) - -hostprogs-y := lxdialog -always := $(hostprogs-y) dochecklxdialog - -lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \ - util.o lxdialog.o msgbox.o diff --git a/util/Makefile b/util/Makefile index 602ce91d78..50a591504d 100644 --- a/util/Makefile +++ b/util/Makefile @@ -1,7 +1,27 @@ -### -# util contains sources for various helper programs used throughout -# the firmware for the build process. -# --------------------------------------------------------------------------- +## +## This file is part of the LinuxBIOS project. +## +## Copyright (C) 2007 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 +## + + +include util/lar/Makefile +include util/dtc/Makefile +include util/kconfig/Makefile + + -# Let clean descend into subdirs -subdir- += dtc lar diff --git a/util/dtc/Makefile b/util/dtc/Makefile index 8439f560bd..b7d709dd81 100644 --- a/util/dtc/Makefile +++ b/util/dtc/Makefile @@ -10,31 +10,50 @@ OBJS = $(DTC_OBJS) libdt.o ftdump.o DEPFILES = $(DTC_OBJS:.o=.d) -all: $(TARGETS) +#all: $(TARGETS) -dtc: $(DTC_OBJS) +$(obj)/util/dtc/dtc: $(patsubst %,$(obj)/%,$(DTC_OBJS)) + mkdir -p $(obj)/util/dtc/ $(LINK.c) -o $@ $^ ftdump: ftdump.o $(LINK.c) -o $@ $^ -dtc-parser.tab.c dtc-parser.tab.h dtc-parser.output: dtc-parser.y - $(BISON) -d $< +$(obj)/dtc-parser.tab.c $(obj)/dtc-parser.tab.h $(obj)/dtc-parser.output: $(src)/util/dtc/dtc-parser.y + cd $(obj); $(BISON) -d $< -lex.yy.c: dtc-lexer.l - $(LEX) $< +$(obj)/lex.yy.c: $(src)/util/dtc/dtc-lexer.l + cd $(obj); $(LEX) $< -lex.yy.o: lex.yy.c dtc-parser.tab.h +#lex.yy.o: lex.yy.c dtc-parser.tab.h check: all cd tests && $(MAKE) check -clean: - rm -f *~ *.o a.out core $(TARGETS) - rm -f *.tab.[ch] lex.yy.c - rm -f *.i *.output vgcore.* - rm -f *.d - cd tests && $(MAKE) clean +$(obj)/dtc.o: $(src)/util/dtc/dtc.c + $(HOSTCC) $(HOSTCFLAGS) -o $@ -c $< +$(obj)/livetree.o: $(src)/util/dtc/livetree.c + $(HOSTCC) $(HOSTCFLAGS) -o $@ -c $< +$(obj)/flattree.o: $(src)/util/dtc/flattree.c + $(HOSTCC) $(HOSTCFLAGS) -o $@ -c $< +$(obj)/data.o: $(src)/util/dtc/data.c + $(HOSTCC) $(HOSTCFLAGS) -o $@ -c $< +$(obj)/treesource.o: $(src)/util/dtc/treesource.c + $(HOSTCC) $(HOSTCFLAGS) -o $@ -c $< +$(obj)/fstree.o: $(src)/util/dtc/fstree.c + $(HOSTCC) $(HOSTCFLAGS) -o $@ -c $< +$(obj)/dtc-parser.tab.o: $(obj)/dtc-parser.tab.c + $(HOSTCC) -I$(src)/util/dtc $(HOSTCFLAGS) -o $@ -c $< +$(obj)/lex.yy.o: $(obj)/lex.yy.c $(obj)/dtc-parser.tab.h + $(HOSTCC) -I$(src)/util/dtc $(HOSTCFLAGS) -o $@ -c $< + +#clean: +# rm -f *~ *.o a.out core $(TARGETS) +# rm -f *.tab.[ch] lex.yy.c +# rm -f *.i *.output vgcore.* +# rm -f *.d +# cd tests && $(MAKE) clean + %.d: %.c $(CC) -MM -MG -MT "$*.o $@" $< > $@ diff --git a/scripts/kconfig/Makefile b/util/kconfig/Makefile similarity index 88% rename from scripts/kconfig/Makefile rename to util/kconfig/Makefile index baa96ff8af..47b327c469 100644 --- a/scripts/kconfig/Makefile +++ b/util/kconfig/Makefile @@ -10,9 +10,9 @@ xconfig: $(obj)/qconf gconfig: $(obj)/gconf $< Kconfig -menuconfig: $(obj)/mconf - $(Q)$(MAKE) $(build)=scripts/kconfig/lxdialog - $< Kconfig +menuconfig: prepare $(obj)/lxdialog $(obj)/mconf + #$(Q)$(MAKE) $(build)=scripts/kconfig/lxdialog + $(obj)/mconf Kconfig config: $(obj)/conf $< Kconfig @@ -94,6 +94,32 @@ help: @echo ' allyesconfig - New config where all options are accepted with yes' @echo ' allnoconfig - New minimal config' + + +mconf-objects := mconf.o zconf.tab.o +$(obj)/mconf: $(patsubst %,$(obj)/%,$(mconf-objects)) + $(HOSTCC) -lncurses -o $@ $^ + +$(obj)/mconf.o: $(src)/util/kconfig/mconf.c + $(HOSTCC) -I$(src)/util/kconfig -c -o $@ $< + +$(obj)/zconf.tab.o: $(obj)/zconf.tab.c $(obj)/zconf.hash.c $(obj)/lex.zconf.c + $(HOSTCC) -I$(src)/util/kconfig -c -o $@ $(obj)/zconf.tab.c + +$(obj)/lex.zconf.c: $(src)/util/kconfig/lex.zconf.c_shipped + cp $< $@ + +$(obj)/zconf.hash.c: $(src)/util/kconfig/zconf.hash.c_shipped + cp $< $@ + +$(obj)/zconf.tab.c: $(src)/util/kconfig/zconf.tab.c_shipped + cp $< $@ + +include $(src)/util/kconfig/lxdialog/Makefile + +###################### +# kbuild crap follows + # =========================================================================== # Shared Makefile for the various kconfig executables: # conf: Used for defconfig, oldconfig and related targets @@ -226,7 +252,7 @@ $(obj)/.tmp_gtkcheck: fi endif -$(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c +#$(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c $(obj)/kconfig_load.o: $(obj)/lkc_defs.h @@ -249,9 +275,9 @@ $(obj)/lkc_defs.h: $(src)/lkc_proto.h ifdef LKC_GENPARSER -$(obj)/zconf.tab.c: $(src)/zconf.y -$(obj)/lex.zconf.c: $(src)/zconf.l -$(obj)/zconf.hash.c: $(src)/zconf.gperf +$(obj)/zconf.tab.c: $(src)/util/kconfig/zconf.y +$(obj)/lex.zconf.c: $(src)/util/kconfig/zconf.l +$(obj)/zconf.hash.c: $(src)/util/kconfig/zconf.gperf %.tab.c: %.y bison -l -b $* -p $(notdir $*) $< diff --git a/scripts/kconfig/POTFILES.in b/util/kconfig/POTFILES.in similarity index 100% rename from scripts/kconfig/POTFILES.in rename to util/kconfig/POTFILES.in diff --git a/scripts/kconfig/conf.c b/util/kconfig/conf.c similarity index 100% rename from scripts/kconfig/conf.c rename to util/kconfig/conf.c diff --git a/scripts/kconfig/confdata.c b/util/kconfig/confdata.c similarity index 100% rename from scripts/kconfig/confdata.c rename to util/kconfig/confdata.c diff --git a/scripts/kconfig/expr.c b/util/kconfig/expr.c similarity index 100% rename from scripts/kconfig/expr.c rename to util/kconfig/expr.c diff --git a/scripts/kconfig/expr.h b/util/kconfig/expr.h similarity index 100% rename from scripts/kconfig/expr.h rename to util/kconfig/expr.h diff --git a/scripts/kconfig/gconf.c b/util/kconfig/gconf.c similarity index 100% rename from scripts/kconfig/gconf.c rename to util/kconfig/gconf.c diff --git a/scripts/kconfig/gconf.glade b/util/kconfig/gconf.glade similarity index 100% rename from scripts/kconfig/gconf.glade rename to util/kconfig/gconf.glade diff --git a/scripts/kconfig/images.c b/util/kconfig/images.c similarity index 100% rename from scripts/kconfig/images.c rename to util/kconfig/images.c diff --git a/scripts/kconfig/kconfig_load.c b/util/kconfig/kconfig_load.c similarity index 100% rename from scripts/kconfig/kconfig_load.c rename to util/kconfig/kconfig_load.c diff --git a/scripts/kconfig/kxgettext.c b/util/kconfig/kxgettext.c similarity index 100% rename from scripts/kconfig/kxgettext.c rename to util/kconfig/kxgettext.c diff --git a/scripts/kconfig/lex.zconf.c_shipped b/util/kconfig/lex.zconf.c_shipped similarity index 100% rename from scripts/kconfig/lex.zconf.c_shipped rename to util/kconfig/lex.zconf.c_shipped diff --git a/scripts/kconfig/lkc.h b/util/kconfig/lkc.h similarity index 100% rename from scripts/kconfig/lkc.h rename to util/kconfig/lkc.h diff --git a/scripts/kconfig/lkc_proto.h b/util/kconfig/lkc_proto.h similarity index 100% rename from scripts/kconfig/lkc_proto.h rename to util/kconfig/lkc_proto.h diff --git a/scripts/kconfig/lxdialog/BIG.FAT.WARNING b/util/kconfig/lxdialog/BIG.FAT.WARNING similarity index 100% rename from scripts/kconfig/lxdialog/BIG.FAT.WARNING rename to util/kconfig/lxdialog/BIG.FAT.WARNING diff --git a/util/kconfig/lxdialog/Makefile b/util/kconfig/lxdialog/Makefile new file mode 100644 index 0000000000..7059de67ea --- /dev/null +++ b/util/kconfig/lxdialog/Makefile @@ -0,0 +1,54 @@ +# Makefile to build lxdialog package +# + +CONFIG_SHELL:=sh + +check-lxdialog := $(src)/util/kconfig/lxdialog/check-lxdialog.sh + +# Use reursively expanded variables so we do not call gcc unless +# 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 + +.PHONY: dochecklxdialog +$(obj)/dochecklxdialog: + $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) + +hostprogs-y := lxdialog +always := $(hostprogs-y) dochecklxdialog + +lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \ + util.o lxdialog.o msgbox.o + + +$(obj)/lxdialog: $(obj)/dochecklxdialog $(patsubst %,$(obj)/%,$(lxdialog-objs)) + $(HOSTCC) $(HOST_LOADLIBES) $(patsubst %,$(obj)/%,$(lxdialog-objs)) -o $@ + +$(obj)/checklist.o: $(src)/util/kconfig/lxdialog/checklist.c + $(HOSTCC) $(HOST_EXTRACFLAGS) $^ -c -o $@ + +$(obj)/menubox.o: $(src)/util/kconfig/lxdialog/menubox.c + $(HOSTCC) $(HOST_EXTRACFLAGS) $^ -c -o $@ + +$(obj)/textbox.o: $(src)/util/kconfig/lxdialog/textbox.c + $(HOSTCC) $(HOST_EXTRACFLAGS) $^ -c -o $@ + +$(obj)/yesno.o: $(src)/util/kconfig/lxdialog/yesno.c + $(HOSTCC) $(HOST_EXTRACFLAGS) $^ -c -o $@ + +$(obj)/inputbox.o: $(src)/util/kconfig/lxdialog/inputbox.c + $(HOSTCC) $(HOST_EXTRACFLAGS) $^ -c -o $@ + +$(obj)/util.o: $(src)/util/kconfig/lxdialog/util.c + $(HOSTCC) $(HOST_EXTRACFLAGS) $^ -c -o $@ + +$(obj)/lxdialog.o: $(src)/util/kconfig/lxdialog/lxdialog.c + $(HOSTCC) $(HOST_EXTRACFLAGS) $^ -c -o $@ + +$(obj)/msgbox.o: $(src)/util/kconfig/lxdialog/msgbox.c + $(HOSTCC) $(HOST_EXTRACFLAGS) $^ -c -o $@ + + + diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/util/kconfig/lxdialog/check-lxdialog.sh similarity index 100% rename from scripts/kconfig/lxdialog/check-lxdialog.sh rename to util/kconfig/lxdialog/check-lxdialog.sh diff --git a/scripts/kconfig/lxdialog/checklist.c b/util/kconfig/lxdialog/checklist.c similarity index 100% rename from scripts/kconfig/lxdialog/checklist.c rename to util/kconfig/lxdialog/checklist.c diff --git a/scripts/kconfig/lxdialog/colors.h b/util/kconfig/lxdialog/colors.h similarity index 100% rename from scripts/kconfig/lxdialog/colors.h rename to util/kconfig/lxdialog/colors.h diff --git a/scripts/kconfig/lxdialog/dialog.h b/util/kconfig/lxdialog/dialog.h similarity index 100% rename from scripts/kconfig/lxdialog/dialog.h rename to util/kconfig/lxdialog/dialog.h diff --git a/scripts/kconfig/lxdialog/inputbox.c b/util/kconfig/lxdialog/inputbox.c similarity index 100% rename from scripts/kconfig/lxdialog/inputbox.c rename to util/kconfig/lxdialog/inputbox.c diff --git a/scripts/kconfig/lxdialog/lxdialog.c b/util/kconfig/lxdialog/lxdialog.c similarity index 100% rename from scripts/kconfig/lxdialog/lxdialog.c rename to util/kconfig/lxdialog/lxdialog.c diff --git a/scripts/kconfig/lxdialog/menubox.c b/util/kconfig/lxdialog/menubox.c similarity index 100% rename from scripts/kconfig/lxdialog/menubox.c rename to util/kconfig/lxdialog/menubox.c diff --git a/scripts/kconfig/lxdialog/msgbox.c b/util/kconfig/lxdialog/msgbox.c similarity index 100% rename from scripts/kconfig/lxdialog/msgbox.c rename to util/kconfig/lxdialog/msgbox.c diff --git a/scripts/kconfig/lxdialog/textbox.c b/util/kconfig/lxdialog/textbox.c similarity index 100% rename from scripts/kconfig/lxdialog/textbox.c rename to util/kconfig/lxdialog/textbox.c diff --git a/scripts/kconfig/lxdialog/util.c b/util/kconfig/lxdialog/util.c similarity index 100% rename from scripts/kconfig/lxdialog/util.c rename to util/kconfig/lxdialog/util.c diff --git a/scripts/kconfig/lxdialog/yesno.c b/util/kconfig/lxdialog/yesno.c similarity index 100% rename from scripts/kconfig/lxdialog/yesno.c rename to util/kconfig/lxdialog/yesno.c diff --git a/scripts/kconfig/mconf.c b/util/kconfig/mconf.c similarity index 99% rename from scripts/kconfig/mconf.c rename to util/kconfig/mconf.c index ebbf2e88b5..6ea7cf8675 100644 --- a/scripts/kconfig/mconf.c +++ b/util/kconfig/mconf.c @@ -25,6 +25,8 @@ #define LKC_DIRECT_LINK #include "lkc.h" +static char *mconf_lxdialogpath; + static char menu_backtitle[128]; static const char mconf_readme[] = N_( "Overview\n" @@ -325,7 +327,7 @@ static void cprint_init(void) memset(args, 0, sizeof(args)); indent = 0; child_count = 0; - cprint("./scripts/kconfig/lxdialog/lxdialog"); + cprint("%s/lxdialog", mconf_lxdialogpath); cprint("--backtitle"); cprint(menu_backtitle); } @@ -1062,6 +1064,8 @@ int main(int ac, char **av) single_menu_mode = 1; } + mconf_lxdialogpath = getenv("obj"); + tcgetattr(1, &ios_org); atexit(conf_cleanup); init_wsize(); diff --git a/scripts/kconfig/menu.c b/util/kconfig/menu.c similarity index 100% rename from scripts/kconfig/menu.c rename to util/kconfig/menu.c diff --git a/scripts/kconfig/qconf.cc b/util/kconfig/qconf.cc similarity index 100% rename from scripts/kconfig/qconf.cc rename to util/kconfig/qconf.cc diff --git a/scripts/kconfig/qconf.h b/util/kconfig/qconf.h similarity index 100% rename from scripts/kconfig/qconf.h rename to util/kconfig/qconf.h diff --git a/scripts/kconfig/symbol.c b/util/kconfig/symbol.c similarity index 100% rename from scripts/kconfig/symbol.c rename to util/kconfig/symbol.c diff --git a/scripts/kconfig/util.c b/util/kconfig/util.c similarity index 100% rename from scripts/kconfig/util.c rename to util/kconfig/util.c diff --git a/scripts/kconfig/zconf.gperf b/util/kconfig/zconf.gperf similarity index 100% rename from scripts/kconfig/zconf.gperf rename to util/kconfig/zconf.gperf diff --git a/scripts/kconfig/zconf.hash.c_shipped b/util/kconfig/zconf.hash.c_shipped similarity index 100% rename from scripts/kconfig/zconf.hash.c_shipped rename to util/kconfig/zconf.hash.c_shipped diff --git a/scripts/kconfig/zconf.l b/util/kconfig/zconf.l similarity index 100% rename from scripts/kconfig/zconf.l rename to util/kconfig/zconf.l diff --git a/scripts/kconfig/zconf.tab.c_shipped b/util/kconfig/zconf.tab.c_shipped similarity index 100% rename from scripts/kconfig/zconf.tab.c_shipped rename to util/kconfig/zconf.tab.c_shipped diff --git a/scripts/kconfig/zconf.y b/util/kconfig/zconf.y similarity index 100% rename from scripts/kconfig/zconf.y rename to util/kconfig/zconf.y diff --git a/util/lar/Makefile b/util/lar/Makefile index 3998cc475f..9513871404 100644 --- a/util/lar/Makefile +++ b/util/lar/Makefile @@ -18,21 +18,28 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA ## -SOURCE = lar.c create.c extract.c list.c lib.c +SOURCE := lar.c create.c extract.c list.c lib.c -CC=gcc -CFLAGS=-O2 -Wall -W -lar: $(SOURCE) - $(CC) $(CFLAGS) -o $@ $^ - strip -s $@ +HOSTCC=gcc +HOSTCFLAGS=-O2 -Wall -W + +obj:=$(objdir) + +$(obj)/util/lar/lar: $(patsubst %,$(src)/util/lar/%,$(SOURCE)) + @mkdir -p $(obj)/util/lar + @$(HOSTCC) $(HOSTCFLAGS) -o $@ $^ + @echo "Built LAR." + + +## -------------------------------------------------------------------- +## stuff below this line should be fixed or go away example: example.c $(CC) $(CFLAGS) -o $@ $^ -clean: - rm -rf lar tree.lar tree tree2 example - +#clean: +# rm -rf lar tree.lar tree tree2 example tree: @printf "creating sample tree... "