# - BOOTSTRAP_SEARCH_PATH
# - BOOTSTRAP_ELF_NAME
# - BOOTSTRAP_MODULES_LIST
-# - BOOTSTRAP_OMIT_RAW
-# - BOOTSTRAP_OMIT_UIMAGE
+# - BOOTSTRAP_DO_RAW_IMAGE
+# - BOOTSTRAP_DO_UIMAGE
+# - BOOTSTRAP_NO_STRIP if set no stripping of iamge
# - BOOTSTRAP_UIMAGE_COMPRESSION: set to none, gzip, or bzip2
# - BOOTSTRAP_CMDLINE: compiled-in command line, only used if no cmdline
# given via multi-boot boot loader (e.g. on arm)
+# - BOOTSTRAP_OUTPUT_DIR: Optional alternative output directory for all
+# images (and generated files), preferable some
+# tmpfs directory
DEFAULT_RELOC_arm := 0x01000000
DEFAULT_RELOC_x86 := 0x002d0000
DEFAULT_RELOC_amd64 := 0x002d0000
DEFAULT_RELOC_ppc32 := 0x002d0000
+DEFAULT_RELOC_sparc := 0x00800000
RELOC_PHYS := y
LDFLAGS = -Bstatic
-EXTRA_GENERAL_D_DEP = .redo-change-tracker
+EXTRA_GENERAL_D_DEP += .redo-change-tracker $(BID_RAM_BASE_DEP) \
+ $(wildcard $(L4DIR)/conf/Makeconf.boot $(OBJ_BASE)/conf/Makeconf.boot) \
+ $(SRC_DIR)/build.pl
INCLUDE_MAKE_RULES = $(SRC_DIR)/*/Make.rules
BOOTSTRAP_LD_dep := $(SRC_DIR)/ldscript.inc
#REQUIRES_LIBS = libbsd-lite
include $(L4DIR)/mk/Makeconf
-include $(OBJ_DIR)/Makeconf.local
--include $(L4DIR)/conf/Makeconf.bootstrap
--include $(OBJ_BASE)/Makeconf.bootstrap
+-include $(L4DIR)/conf/Makeconf.boot
+-include $(OBJ_BASE)/conf/Makeconf.boot
+
+# Checks added Nov 2010:
+ifneq ($(wildcard $(L4DIR)/conf/Makeconf.bootstrap),)
+$(error $(L4DIR)/conf/Makeconf.bootstrap not used anymore. Please use $(L4DIR)/conf/Makeconf.boot now)
+endif
+ifneq ($(wildcard $(OBJ_BASE)/Makeconf.bootstrap),)
+$(error $(OBJ_BASE)/Makeconf.bootstrap not used anymore. Please use $(OBJ_BASE)/conf/Makeconf.boot now)
+endif
BOOTSTRAP_SEARCH_PATH ?= .
BOOTSTRAP_MODULES_LIST ?= $(SRC_DIR)/modules.list
MKIMAGE ?= mkimage
BOOTSTRAP_UIMAGE_COMPRESSION ?= none
-ifeq ($(BUILD_ARCH),$(filter $(BUILD_ARCH),arm ppc32))
- # ARM/PPC always uses single image mode
+ifeq ($(BUILD_ARCH),$(filter $(BUILD_ARCH),arm ppc32 sparc))
+ # ARM/PPC/SPARC always uses single image mode
# when no entry is given we build the useless auto-build target
ifeq ($(E)$(ENTRY),)
BOOTSTRAP_ELF_NAME := bootstrap.auto-build-useless.elf
ENTRY := auto-build-entry
endif
+od := $(if $(BOOTSTRAP_OUTPUT_DIR),$(if $(wildcard $(BOOTSTRAP_OUTPUT_DIR)),,$(shell mkdir $(BOOTSTRAP_OUTPUT_DIR))))
+od := $(if $(BOOTSTRAP_OUTPUT_DIR),$(BOOTSTRAP_OUTPUT_DIR)/)
PRIVATE_INCDIR = $(SRC_DIR) $(SRC_DIR)/ARCH-$(ARCH)
-# special include directories only needed for <l4/sys/kernel.h>
-PRIVATE_INCDIR_init_kip_v2.o = $(OBJ_BASE)/include/$(ARCH)/l4f \
- $(DROPS_STDDIR)/include/$(ARCH)/l4f
-PRIVATE_INCDIR_init_arm_kip.o = $(OBJ_BASE)/include/$(ARCH)/l4f \
- $(DROPS_STDDIR)/include/$(ARCH)/l4f
-
-TARGET := $(BOOTSTRAP_ELF_NAME)
-TARGET_BIN = $(BOOTSTRAP_ELF_NAME)
+TARGET := $(od)$(BOOTSTRAP_ELF_NAME)
+TARGET_BIN = $(od)$(BOOTSTRAP_ELF_NAME)
MODE = lib
-ifeq ($(PLATFORM_TYPE),)
-ifeq ($(X86_PLATFORM_TYPE),)
-X86_PLATFORM_TYPE = pc
-endif
-
-PLATFORM_TYPE-arm = $(ARM_PLATFORM_TYPE)
-PLATFORM_TYPE-ppc32 = $(PPC_PLATFORM_TYPE)
-PLATFORM_TYPE-x86 = $(X86_PLATFORM_TYPE)
-PLATFORM_TYPE-amd64 = $(X86_PLATFORM_TYPE)
-PLATFORM_TYPE = $(PLATFORM_TYPE-$(ARCH))
-endif
-
-SUPPORT_CC_arm-sa1000 := support_sa1000.cc
-SUPPORT_CC_arm-pxa := support_pxa.cc
-SUPPORT_CC_arm-integrator := support_integrator.cc
-SUPPORT_CC_arm-rv := support_rv.cc
-SUPPORT_CC_arm-omap3evm := support_omap3evm.cc
-SUPPORT_CC_arm-beagleboard:= support_beagleboard.cc
-SUPPORT_CC_arm-tegra2 := support_tegra2.cc
-SUPPORT_CC_arm-imx21 := support_imx.cc
-SUPPORT_CC_arm-imx51 := support_imx.cc
-SUPPORT_CC_arm-om := support_om.cc
-SUPPORT_CC_arm-kirkwood := support_kirkwood.cc
-DEFAULT_RELOC_arm-imx21 := 0x00200000 # because of blob
+SUPPORT_CC_arm-sa1000 := platform/sa1000.cc
+SUPPORT_CC_arm-pxa := platform/pxa.cc
+SUPPORT_CC_arm-integrator := platform/integrator.cc
+SUPPORT_CC_arm-rv := platform/rv.cc
+SUPPORT_CC_arm-rv_pbx := platform/rv.cc
+SUPPORT_CC_arm-rv_vexpress := platform/rv_vexpress.cc
+SUPPORT_CC_arm-omap3evm := platform/omap.cc
+SUPPORT_CC_arm-omap3_am33xx:= platform/omap.cc
+SUPPORT_CC_arm-beagleboard := platform/omap.cc
+SUPPORT_CC_arm-pandaboard := platform/omap.cc
+SUPPORT_CC_arm-tegra2 := platform/tegra2.cc
+SUPPORT_CC_arm-imx21 := platform/imx.cc
+SUPPORT_CC_arm-imx35 := platform/imx.cc
+SUPPORT_CC_arm-imx51 := platform/imx.cc
+SUPPORT_CC_arm-imx6 := platform/imx.cc
+SUPPORT_CC_arm-om := platform/om.cc
+SUPPORT_CC_arm-kirkwood := platform/kirkwood.cc
+DEFAULT_RELOC_arm-imx21 := 0x00200000 # because of blob
ifneq ($(DEFAULT_RELOC_arm-$(PLATFORM_TYPE)),)
DEFAULT_RELOC_arm := $(DEFAULT_RELOC_arm-$(PLATFORM_TYPE))
endif
-SUPPORT_CC_ppc32-mpc5200 := support_mpc5200.cc
+SUPPORT_CC_ppc32-mpc5200 := platform/mpc5200.cc
+
+SUPPORT_CC_x86-pc := platform/x86_pc.cc
-SUPPORT_CC_x86-pc := support_x86_pc.cc
+SUPPORT_CC_amd64-pc := platform/x86_pc.cc
-SUPPORT_CC_amd64-pc := support_x86_pc.cc
+SUPPORT_CC_sparc-leon3 := platform/leon3.cc
SRC_C += exec.c module.c
SRC_CC += region.cc startup.cc init_kip_v2.cc init_kip_v4.cc \
- libc_support+.cc patch.cc
+ libc_support+.cc patch.cc koptions.cc
SRC_CC_x86 += ARCH-x86/reboot.cc
SRC_CC_amd64 += ARCH-x86/reboot.cc
-SRC_C_x86 += base_critical.c ARCH-x86/serial.c
-SRC_C_amd64 += base_critical.c ARCH-x86/serial.c
+SRC_C_x86 += base_critical.c
+SRC_C_amd64 += base_critical.c
SRC_CC_arm += ARCH-arm/reboot.cc
SRC_CC_ppc32 += ARCH-ppc32/init_kip_v2-arch.cc \
ARCH-ppc32/reboot.cc
+SRC_CC_sparc += ARCH-sparc/reboot.cc
SRC_CC += $(SUPPORT_CC_$(ARCH)-$(PLATFORM_TYPE))
SRC_S += ARCH-$(ARCH)/crt0.S
-OPTS = -g -Os $(CARCHFLAGS_$(ARCH)) $(CARCHFLAGS_$(ARCH)_$(CPU))
-DEFINES += -DRAM_BASE=$(RAM_BASE)
+OPTS = -g -Os $(CARCHFLAGS_$(ARCH)) $(CARCHFLAGS_$(ARCH)_$(CPU)) \
+ $(GCCNOFPU_$(ARCH))
+DEFINES += -DRAM_BASE=$(RAM_BASE) -DL4_MINIMAL_LIBC=1
DEFINES += -DCMDLINE="\"$(BOOTSTRAP_CMDLINE)\""
DEFINES += -DPLATFORM_TYPE=\"$(PLATFORM_TYPE)\"
DEFINES += -DPLATFORM_TYPE_$(PLATFORM_TYPE)
MOD_ADDR = 0x02000000
+CPPFLAGS += $(CPPFLAGS_$(ARCH)-$(PLATFORM_TYPE))
CPPFLAGS += $(BID_PKG_CONFIG_CFLAGS)
+ifeq ($(filter clean cleanall,$(MAKECMDGOALS)),)
ifeq ($(SUPPORT_CC_$(ARCH)-$(PLATFORM_TYPE)),)
- $(error A proper PLATFORM_TYPE must be set for a build.)
+ $(info ERROR: PLATFORM_TYPE=$(PLATFORM_TYPE) has no assigned platform support file)
+ $(info ERROR: A proper PLATFORM_TYPE must be set for a build)
+ $(error .)
+endif
endif
DRV_LIBS-ppc32 = -ldrivers_of
ENTRY_FN := $(shell echo "$(ENTRY)" | tr '[ ]' '[_]' )
+
+ifneq ($(ENTRY),)
+ ifeq ($(filter clean cleanall,$(MAKECMDGOALS)),)
+ BUILD_MOD_CMD = ( SEARCHPATH="$(BOOTSTRAP_SEARCH_PATH):$(BOOTSTRAP_MODULE_PATH_BINLIB)" \
+ CROSS_COMPILE=$(SYSTEM_TARGET) MAKE_INC_FILE=$(PWD)/mod.make.inc \
+ OUTPUT_DIR="$(BOOTSTRAP_OUTPUT_DIR)" \
+ OPT_ARCH=$(ARCH) OPT_COMPRESS=$(COMPRESS) L4DIR=$(L4DIR) \
+ $(SRC_DIR)/build.pl $(1) $(BOOTSTRAP_MODULES_LIST) "$(ENTRY)" || \
+ (echo "processing-of-module-list-failed"; exit 1))
+ endif
+endif
+
+
# we need to re-do if some things change
-# we do not need to track BOOTSTRACE_CMDLINE as it's only used in startup.cc
-# and that is regenerated every time
-REDO_TEXT_CMD = echo "$(ENTRY) '$(COMPRESS)' '$(RAM_SIZE_MB)' '$(PLATFORM_TYPE)' '$(LOADER_MBI)'"
.redo-change-tracker: FORCE
- $(VERBOSE)if test ! -r "$@" || \
- ! $(REDO_TEXT_CMD) | cmp -s "$@"; then \
- $(REDO_TEXT_CMD) > $@; \
+ $(VERBOSE)echo "$(ENTRY) '$(COMPRESS)' '$(BOOTSTRAP_CMDLINE)' '$(BOOTSTRAP_SEARCH_PATH):$(BOOTSTRAP_MODULE_PATH_BINLIB)' '$(RAM_SIZE_MB)' '$(PLATFORM_TYPE)' '$(LOADER_MBI)' '$(od)'" > $@.tmp
+ $(if $(BUILD_MOD_CMD),$(VERBOSE)$(call BUILD_MOD_CMD,dump) >> $@.tmp)
+ $(VERBOSE)if test ! -r "$@" || ! cmp -s $@ $@.tmp; then \
+ mv $@.tmp $@; \
+ else \
+ rm $@.tmp; \
fi
ifneq ($(ENTRY),)
-INSTALL_TARGET = $(BOOTSTRAP_ELF_NAME) bootstrap_$(ENTRY_FN) bootstrap_$(ENTRY_FN).elf
+INSTALL_FILES = $(BOOTSTRAP_ELF_NAME) bootstrap_$(ENTRY_FN) bootstrap_$(ENTRY_FN).elf
ifeq ($(ARCH),amd64)
-INSTALL_TARGET += bootstrap32.elf
+INSTALL_FILES += bootstrap32.elf
BOOTSTRAP_LINK_SOURCE = bootstrap32.elf
else
BOOTSTRAP_LINK_SOURCE = $(BOOTSTRAP_ELF_NAME)
endif
-bootstrap_$(ENTRY_FN): $(BOOTSTRAP_LINK_SOURCE)
+$(od)bootstrap_$(ENTRY_FN): $(od)$(BOOTSTRAP_LINK_SOURCE)
$(VERBOSE)$(LN) -f $< $@
-bootstrap_$(ENTRY_FN).elf: $(BOOTSTRAP_LINK_SOURCE)
+$(od)bootstrap_$(ENTRY_FN).elf: $(od)$(BOOTSTRAP_LINK_SOURCE)
$(VERBOSE)$(LN) -f $< $@
-bootstrap_$(ENTRY_FN).raw: bootstrap.raw
+$(od)bootstrap_$(ENTRY_FN).raw: $(od)bootstrap.raw
$(VERBOSE)$(LN) -f $< $@
-bootstrap_$(ENTRY_FN).uimage: bootstrap.uimage
+$(od)bootstrap_$(ENTRY_FN).uimage: $(od)bootstrap.uimage
$(VERBOSE)$(LN) -f $< $@
ifeq ($(ARCH),$(filter $(ARCH),arm ppc32))
- BID_POST_PROG_LINK_MSG_$(BOOTSTRAP_ELF_NAME) = echo -e " ==> Stripping $@"
+ BID_POST_PROG_LINK_MSG_$(BOOTSTRAP_ELF_NAME) = echo -e " ==> Post-processing $@"
BID_POST_PROG_LINK_$(BOOTSTRAP_ELF_NAME) = \
$(VERBOSE)LANG=C $(NM) -C $@ | \
LANG=C $(GREP) -q "V vtable for Platform_base" || \
{ echo -e "\nERROR: Missing at least one platform instantiation.\n"; \
- exit 1; } ; $(STRIP) $@
+ exit 1; } ; $(if $(BOOTSTRAP_NO_STRIP),,$(STRIP) $@)
- ifeq ($(BOOTSTRAP_OMIT_RAW),)
- BOOTSTRAP_RAW := bootstrap.raw
- INSTALL_TARGET += bootstrap.raw bootstrap_$(ENTRY_FN).raw
- ifeq ($(BOOTSTRAP_OMIT_UIMAGE),)
+ ifneq ($(BOOTSTRAP_DO_RAW_IMAGE)$(BOOTSTRAP_DO_UIMAGE),)
+ BOOTSTRAP_RAW := $(od)bootstrap.raw
+ INSTALL_FILES += bootstrap.raw bootstrap_$(ENTRY_FN).raw
+ ifneq ($(BOOTSTRAP_DO_UIMAGE),)
ifneq ($(shell command -v $(MKIMAGE)),)
- BOOTSTRAP_UIMAGE := bootstrap.uimage
- INSTALL_TARGET += bootstrap.uimage bootstrap_$(ENTRY_FN).uimage
+ BOOTSTRAP_UIMAGE := $(od)bootstrap.uimage
+ INSTALL_FILES += bootstrap.uimage bootstrap_$(ENTRY_FN).uimage
else
- $(info mkimage($(MKIMAGE)) missing, not building bootstrap.uimage)
+ $(error mkimage($(MKIMAGE)) host tool missing, cannot build bootstrap.uimage)
endif
endif
endif
endif
-all:: $(addprefix $(IMAGES_DIR)/,$(INSTALL_TARGET))
- $(VERBOSE)echo "Image size(s) in bytes:"
- $(VERBOSE)for f in $(filter bootstrap_$(ENTRY_FN).elf bootstrap.raw bootstrap.uimage, $(INSTALL_TARGET)); do \
- find . -name $$f -printf " %20f: %s\n"; \
+all:: $(addprefix $(IMAGES_DIR)/,$(INSTALL_FILES))
+ $(VERBOSE)echo " Image size(s) in bytes:"
+ $(VERBOSE)for f in $(filter bootstrap_$(ENTRY_FN).elf bootstrap.raw bootstrap.uimage, $(INSTALL_FILES)); do \
+ find $(if $(od),$(od),.) -name $$f -printf " %30f: %s\n"; \
done
+ $(if $(LDFLAGS_bootstrap.elf),$(VERBOSE)echo " Start address: $(patsubst --defsym=__executable_start=%,%,$(LDFLAGS_bootstrap.elf))")
$(VERBOSE)echo " --> Build-Nr: $$(cat .build_nr)"
# install images into easy to reach directory in build dir
-$(IMAGES_DIR)/%: % $(IMAGES_DIR)/Makefile
+$(IMAGES_DIR)/%: $(od)%
$(VERBOSE)if [ "$(ENTRY)" != "auto-build-entry" ]; then \
echo " ==> Installing $< in image directory"; \
- $(LN) -sf $(PWD)/$< $(dir $@); \
+ (cd $(dir $@) && $(LN) -sf $(if $(od),,$(PWD)/)$<); \
fi
-
-$(IMAGES_DIR)/Makefile: $(SRC_DIR)/Make.rules
- @echo " ==> Preparing image directory"
- $(VERBOSE)install -d $(dir $@)
- $(VERBOSE)$(ECHO) "# Automatically generated by bootstrap" > $@
- $(VERBOSE)$(ECHO) "\$$(if \$$(MAKECMDGOALS),%,a):" >> $@
- $(VERBOSE)$(ECHO) " \$$(MAKE) -C .. image \$$(if \$$(MAKECMDGOALS),E=\"\$$@\")" >> $@
else
- INSTALL_TARGET = bootstrap
+ INSTALL_FILES = bootstrap
endif # ENTRY
ifneq ($(REALMODE_LOADING),0)
LOADER_MBI = 1
CPPFLAGS += -DREALMODE_LOADING -DSINGLE_SECTION
# don't install bootstrap_$(ENTRY_FN).elf
-INSTALL_TARGET = bootstrap.load
+INSTALL_FILES = bootstrap.load
endif
ifneq ($(LOADER_MBI),0)
CXXFLAGS += -fno-rtti -fno-exceptions
CXXFLAGS += $(call checkcxx,-fno-threadsafe-statics)
-ifneq ($(ENTRY),)
+ifneq ($(BUILD_MOD_CMD),)
ifeq ($(filter clean cleanall,$(MAKECMDGOALS)),)
- $(info Building entry "$(ENTRY)".)
- BUILD_DUMMY := $(shell SEARCHPATH="$(BOOTSTRAP_SEARCH_PATH):$(BOOTSTRAP_MODULE_PATH_BINLIB)" \
- CROSS_COMPILE=$(SYSTEM_TARGET) \
- OPT_ARCH=$(ARCH) \
- OPT_COMPRESS=$(COMPRESS) \
- L4DIR=$(L4DIR) \
- $(SRC_DIR)/build.pl $(BOOTSTRAP_MODULES_LIST) "$(ENTRY)" 1>&2 \
- || echo X-build-failed-X)
- ifeq ($(BUILD_DUMMY),X-build-failed-X)
- $(error Processing of module list failed!)
- else
- BUILD_DUMMY := $(shell echo $(BUILD_DUMMY))
- endif
- # mod.make.inc is generated by build.pl
- include mod.make.inc
+
+processing-of-module-list-failed:
+ @echo
+ @echo " Processing of $(BOOTSTRAP_MODULES_LIST) failed!"
+ @echo
+ @exit 1
+
+mod.make.inc $(od)mbi_modules.bin: $(GENERAL_D_LOC) $(shell $(call BUILD_MOD_CMD,list))
+ @echo Building entry \""$(ENTRY)"\".
+ $(VERBOSE)$(call BUILD_MOD_CMD,build)
+
+ -include mod.make.inc
+ BOOTSTRAP_LD_dep += mod.make.inc
+ STARTUP_C_dep := mod.make.inc
+ OBJS_$(od)$(BOOTSTRAP_ELF_NAME) += $(MODULE_OBJECT_FILES)
endif
- OBJS_$(BOOTSTRAP_ELF_NAME) += $(MODULE_OBJECT_FILES)
CPPFLAGS += -DIMAGE_MODE
- BOOTSTRAP_LD_dep += mod.make.inc
- STARTUP_C_dep := mod.make.inc
endif
CPPFLAGS += -DMODADDR=$(MOD_ADDR)
LIBS =
L4_LIBS = -static -nostdlib $(DRV_LIBS) -lcxx_base -lcxx_io
-L4_LIBS += -luc_c $(GCCLIB)
+L4_LIBS += -luc_c_minimal $(GCCLIB)
all:: $(BOOTSTRAP_RAW)
@$(GEN_MESSAGE)
$(VERBOSE)cp $< $@.tmp
$(VERBOSE)$(OBJCOPY) -O binary $@.tmp $@
+ $(VERBOSE)chmod -x $@
$(VERBOSE)$(RM) $@.tmp
%.gzip: %
$(VERBOSE)$(MKIMAGE) -e $(call default_reloc,$(ARCH)) \
-a $(call default_reloc,$(ARCH)) -A $(MKIMAGE_ARCH) \
-C $(BOOTSTRAP_UIMAGE_COMPRESSION) \
+ -n "L4 Image #$$(cat .build_nr)" \
-d $^ $@
$(TARGET): $(LDSCRIPT) $(OBJS_$(TARGET))
$(LDSCRIPT): $(LDSCRIPT).in $(GENERAL_D_LOC) $(BOOTSTRAP_LD_dep)
@$(GEN_MESSAGE)
- $(VERBOSE)cpp -P $(CPPFLAGS) -DLINKADDR=$(DEFAULT_RELOC_$(ARCH)) $< $@;
+ $(VERBOSE)$(SYSTEM_TARGET)cpp -P $(CPPFLAGS) -DLINKADDR=$(strip $(call default_reloc,$(ARCH))) $< $@;
clean::
$(VERBOSE)$(RM) mod.make.inc mod*.bin mbi_modules.bin $(LDSCRIPT)
$(VERBOSE)$(RM) .redo-change-tracker
cleanall::
- $(VERBOSE)$(RM) bootstrap_* bootstrap.*
+ $(VERBOSE)$(RM) $(od)bootstrap_* $(od)bootstrap.*
ifeq ($(ARCH),amd64)
bootstrap: $(BOOTSTRAP_ELF_NAME)
$(VERBOSE)$(LN) -f $^ $@
endif
+
+INSTALL_TARGET := $(if $(od),,$(INSTALL_FILES))