diff --git a/.gitignore b/.gitignore index 5d9157d..03c5e20 100644 --- a/.gitignore +++ b/.gitignore @@ -61,7 +61,6 @@ # # Generated include files # -include/asm include/asm-*/asm-offsets.h include/config include/linux/compile.h diff --git a/Kbuild b/Kbuild new file mode 100644 index 0000000..3296096 --- /dev/null +++ b/Kbuild @@ -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) diff --git a/Makefile b/Makefile index 811285b..90a7eee 100644 --- a/Makefile +++ b/Makefile @@ -112,9 +112,10 @@ # 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 @@ # 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 @@ # 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 @@ 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 @@ 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 @@ 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 diff --git a/TODO b/TODO index 6350799..8527e57 100644 --- a/TODO +++ b/TODO @@ -4,7 +4,6 @@ [ ] 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 @@ 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 diff --git a/arch/arm/lib/asm-offsets.c b/arch/arm/lib/asm-offsets.c new file mode 100644 index 0000000..7bf6d12 --- /dev/null +++ b/arch/arm/lib/asm-offsets.c @@ -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 + +int main(void) +{ + return 0; +} diff --git a/arch/blackfin/lib/asm-offsets.c b/arch/blackfin/lib/asm-offsets.c new file mode 100644 index 0000000..9003c73 --- /dev/null +++ b/arch/blackfin/lib/asm-offsets.c @@ -0,0 +1,12 @@ +/* + * generate definitions needed by assembly language modules + * + * Licensed under the GPL-2 or later + */ + +#include + +int main(void) +{ + return 0; +} diff --git a/arch/efi/lib/asm-offsets.c b/arch/efi/lib/asm-offsets.c new file mode 100644 index 0000000..22f382b --- /dev/null +++ b/arch/efi/lib/asm-offsets.c @@ -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 + +int main(void) +{ + return 0; +} diff --git a/arch/mips/Makefile b/arch/mips/Makefile index f3f4f67..6ef2bf7 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -148,46 +148,3 @@ $(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) diff --git a/arch/nios2/lib/asm-offsets.c b/arch/nios2/lib/asm-offsets.c new file mode 100644 index 0000000..21e4771 --- /dev/null +++ b/arch/nios2/lib/asm-offsets.c @@ -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 . + * + */ + +#include + +int main(void) +{ + return 0; +} diff --git a/arch/openrisc/lib/asm-offsets.c b/arch/openrisc/lib/asm-offsets.c new file mode 100644 index 0000000..8cee8e0 --- /dev/null +++ b/arch/openrisc/lib/asm-offsets.c @@ -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 + +int main(void) +{ + return 0; +} diff --git a/arch/ppc/lib/asm-offsets.c b/arch/ppc/lib/asm-offsets.c new file mode 100644 index 0000000..bef280e --- /dev/null +++ b/arch/ppc/lib/asm-offsets.c @@ -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 + +int main(void) +{ + return 0; +} diff --git a/arch/sandbox/lib/asm-offsets.c b/arch/sandbox/lib/asm-offsets.c new file mode 100644 index 0000000..22f382b --- /dev/null +++ b/arch/sandbox/lib/asm-offsets.c @@ -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 + +int main(void) +{ + return 0; +} diff --git a/arch/x86/lib/asm-offsets.c b/arch/x86/lib/asm-offsets.c new file mode 100644 index 0000000..b1be3e5 --- /dev/null +++ b/arch/x86/lib/asm-offsets.c @@ -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 + +void common(void) +{ +}