9
0
Fork 0

Merge branch 'for-next/kbuild'

This commit is contained in:
Sascha Hauer 2015-01-09 17:38:26 +01:00
commit 2af31fbc23
13 changed files with 176 additions and 92 deletions

1
.gitignore vendored
View File

@ -61,7 +61,6 @@ barebox_default_env*
#
# Generated include files
#
include/asm
include/asm-*/asm-offsets.h
include/config
include/linux/compile.h

43
Kbuild Normal file
View File

@ -0,0 +1,43 @@
#####
# 1) Generate asm-offsets.h
#
offsets-file := include/generated/asm-offsets.h
always += $(offsets-file)
targets += $(offsets-file)
targets += arch/$(SRCARCH)/lib/asm-offsets.s
# Default sed regexp - multiline due to syntax constraints
define sed-y
"/^->/{s:->#\(.*\):/* \1 */:; \
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:->::; p;}"
endef
quiet_cmd_offsets = GEN $@
define cmd_offsets
(set -e; \
echo "#ifndef __ASM_OFFSETS_H__"; \
echo "#define __ASM_OFFSETS_H__"; \
echo "/*"; \
echo " * DO NOT MODIFY."; \
echo " *"; \
echo " * This file was generated by Kbuild"; \
echo " *"; \
echo " */"; \
echo ""; \
sed -ne $(sed-y) $<; \
echo ""; \
echo "#endif" ) > $@
endef
# We use internal kbuild rules to avoid the "is up to date" message from make
arch/$(SRCARCH)/lib/asm-offsets.s: arch/$(SRCARCH)/lib/asm-offsets.c FORCE
$(Q)mkdir -p $(dir $@)
$(call if_changed_dep,cc_s_c)
$(obj)/$(offsets-file): arch/$(SRCARCH)/lib/asm-offsets.s Kbuild
$(call cmd,offsets)

View File

@ -112,9 +112,10 @@ 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)
KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
&& /bin/pwd)
$(if $(KBUILD_OUTPUT),, \
$(error output directory "$(saved-output)" does not exist))
$(error failed to create output directory "$(saved-output)"))
PHONY += $(MAKECMDGOALS)
@ -291,10 +292,9 @@ export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_ve
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
LINUXINCLUDE := -Iinclude -I$(srctree)/dts/include \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
-I$(srctree)/arch/$(ARCH)/include \
-I$(objtree)/arch/$(ARCH)/include \
-include include/generated/autoconf.h \
-include $(srctree)/include/linux/kconfig.h
CPPFLAGS := -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin -ffreestanding
@ -790,7 +790,6 @@ 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: include/config/kernel.release
ifneq ($(KBUILD_SRC),)
@echo ' Using $(srctree) as source for kernel'
@ -799,17 +798,13 @@ ifneq ($(KBUILD_SRC),)
echo " in the '$(srctree)' directory.";\
false; \
fi;
$(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
$(Q)if [ -e $(srctree)/include/asm-$(SRCARCH)/barebox.h ]; then \
ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm; \
fi
endif
# prepare2 creates a makefile if using a separate output directory
prepare2: prepare3 outputmakefile
prepare1: prepare2 include/generated/version.h include/generated/utsrelease.h \
include/asm include/config.h include/config/auto.conf
include/config.h include/config/auto.conf
ifneq ($(KBUILD_MODULES),)
$(Q)mkdir -p $(MODVERDIR)
@ -829,39 +824,6 @@ prepare prepare-all: prepare0
export CPPFLAGS_barebox.lds += -C -U$(ARCH)
# FIXME: The asm symlink changes when $(ARCH) changes. That's
# hard to detect, but I suppose "make mrproper" is a good idea
# before switching between archs anyway.
define check-symlink
set -e; \
if [ -L include/asm ]; then \
asmlink=`readlink include/asm | cut -d '-' -f 2`; \
if [ "$$asmlink" != "$(SRCARCH)" ]; then \
echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \
echo " set ARCH or save .config and run 'make mrproper' to fix it"; \
exit 1; \
fi; \
fi
endef
# We create the target directory of the symlink if it does
# not exist so the test in chack-symlink works and we have a
# directory for generated filesas used by some architectures.
define create-symlink
if [ ! -L include/asm ]; then \
$(kecho) ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
if [ ! -d include/asm-$(SRCARCH) ]; then \
mkdir -p include/asm-$(SRCARCH); \
fi; \
ln -fsn asm-$(SRCARCH) $@; \
fi
endef
include/asm:
$(Q)$(check-symlink)
$(Q)$(create-symlink)
define symlink-config-h
if [ -f $(srctree)/$(BOARD)/config.h ]; then \
$(kecho) ' SYMLINK $@ -> $(BOARD)/config.h'; \
@ -998,10 +960,9 @@ CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \
barebox.efi barebox.canon-a1100.bin
# Directories & files removed with 'make mrproper'
MRPROPER_DIRS += include/config include2 usr/include
MRPROPER_FILES += .config .config.old include/asm .version .old_version \
include/generated/autoconf.h include/generated/version.h \
include/generated/utsrelease.h include/config.h \
MRPROPER_DIRS += include/config usr/include include/generated
MRPROPER_FILES += .config .config.old .version .old_version \
include/config.h \
Module.symvers tags TAGS cscope*
# clean - Delete most, but leave enough to build external modules

2
TODO
View File

@ -4,7 +4,6 @@ TODO
[ ] ask jbe about:
./commands/Makefile:40:obj-$(CONFIG_SIMPLE_PARSER) += setenv.o
[ ] bark on partition not ending on flash sector boundaries
[ ] distclean doesn't work without a config
[ ] Every driver should have a remove function.
(It must have. Currently there is no provision to given to remove my
interrupt handlers and to reset all hardware in use, before the target
@ -108,3 +107,4 @@ DONE
countdown -m msg -t timeout -x [ctrl-c|anykey|string]
If done, remove the corresponding stuff from common/main.c
[X] Board support should go to arch/*/boards/*
[X] distclean doesn't work without a config

View File

@ -0,0 +1,16 @@
/*
* Generate definitions needed by assembly language modules.
* This code generates raw asm output which is post-processed to extract
* and format the required data.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/kbuild.h>
int main(void)
{
return 0;
}

View File

@ -0,0 +1,12 @@
/*
* generate definitions needed by assembly language modules
*
* Licensed under the GPL-2 or later
*/
#include <linux/kbuild.h>
int main(void)
{
return 0;
}

View File

@ -0,0 +1,12 @@
/*
* Generate definitions needed by assembly language modules.
* This code generates raw asm output which is post-processed to extract
* and format the required data.
*/
#include <linux/kbuild.h>
int main(void)
{
return 0;
}

View File

@ -148,46 +148,3 @@ dts := arch/mips/dts
$(Q)$(MAKE) $(build)=$(dts) $(dts)/$@
KBUILD_IMAGE ?= $(KBUILD_BINARY)
#####
# Generate asm-offsets.h
#
offsets-file := include/generated/asm-offsets.h
always += $(offsets-file)
targets += $(offsets-file)
targets += arch/$(SRCARCH)/lib/asm-offsets.s
# Default sed regexp - multiline due to syntax constraints
define sed-y
"/^->/{s:->#\(.*\):/* \1 */:; \
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:->::; p;}"
endef
quiet_cmd_offsets = GEN $@
define cmd_offsets
(set -e; \
echo "#ifndef __ASM_OFFSETS_H__"; \
echo "#define __ASM_OFFSETS_H__"; \
echo "/*"; \
echo " * DO NOT MODIFY."; \
echo " *"; \
echo " * This file was generated by Kbuild"; \
echo " *"; \
echo " */"; \
echo ""; \
sed -ne $(sed-y) $<; \
echo ""; \
echo "#endif" ) > $@
endef
# We use internal kbuild rules to avoid the "is up to date" message from make
arch/$(SRCARCH)/lib/asm-offsets.s: arch/$(SRCARCH)/lib/asm-offsets.c FORCE
$(Q)mkdir -p $(dir $@)
$(call if_changed_dep,cc_s_c)
$(obj)/$(offsets-file): arch/$(SRCARCH)/lib/asm-offsets.s Makefile
$(call cmd,offsets)

View File

@ -0,0 +1,22 @@
/*
* 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, see <http://www.gnu.org/licenses/>.
*
*/
#include <linux/kbuild.h>
int main(void)
{
return 0;
}

View File

@ -0,0 +1,18 @@
/*
* OpenRISC asm-offsets.c
*
* This program is used to generate definitions needed by
* assembly language modules.
*
* We use the technique used in the OSF Mach kernel code:
* generate asm statements containing #defines,
* compile this file to assembler, and then extract the
* #defines from the assembly-language output.
*/
#include <linux/kbuild.h>
int main(void)
{
return 0;
}

View File

@ -0,0 +1,21 @@
/*
* This program is used to generate definitions needed by
* assembly language modules.
*
* We use the technique used in the OSF Mach kernel code:
* generate asm statements containing #defines,
* compile this file to assembler, and then extract the
* #defines from the assembly-language output.
*
* 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.
*/
#include <linux/kbuild.h>
int main(void)
{
return 0;
}

View File

@ -0,0 +1,12 @@
/*
* Generate definitions needed by assembly language modules.
* This code generates raw asm output which is post-processed to extract
* and format the required data.
*/
#include <linux/kbuild.h>
int main(void)
{
return 0;
}

View File

@ -0,0 +1,11 @@
/*
* Generate definitions needed by assembly language modules.
* This code generates raw asm output which is post-processed to extract
* and format the required data.
*/
#include <linux/kbuild.h>
void common(void)
{
}