diff --git a/arch/arm/rules.mk b/arch/arm/rules.mk index 53b48cb6..0ad89723 100644 --- a/arch/arm/rules.mk +++ b/arch/arm/rules.mk @@ -332,7 +332,6 @@ endif # try to find toolchain include $(LOCAL_DIR)/toolchain.mk TOOLCHAIN_PREFIX := $(ARCH_$(ARCH)_TOOLCHAIN_PREFIX) -$(info TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX)) ARCH_COMPILEFLAGS += $(ARCH_$(ARCH)_COMPILEFLAGS) ARCH_COMPILEFLAGS_NOFLOAT := diff --git a/arch/arm/toolchain.mk b/arch/arm/toolchain.mk index f1e1a458..62bf8c34 100644 --- a/arch/arm/toolchain.mk +++ b/arch/arm/toolchain.mk @@ -4,7 +4,6 @@ ARCH_arm_TOOLCHAIN_INCLUDED := 1 # try to find the toolchain ifndef ARCH_arm_TOOLCHAIN_PREFIX -$(info $(TOOLCHAIN_PREFIX)) # if TOOLCHAIN_PREFIX is not empty, try to use it first ifneq ($(TOOLCHAIN_PREFIX),) ARCH_arm_TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREFIX) diff --git a/arch/arm64/rules.mk b/arch/arm64/rules.mk index 173a75fd..0664d570 100644 --- a/arch/arm64/rules.mk +++ b/arch/arm64/rules.mk @@ -89,7 +89,6 @@ GLOBAL_DEFINES += \ # try to find the toolchain include $(LOCAL_DIR)/toolchain.mk TOOLCHAIN_PREFIX := $(ARCH_$(ARCH)_TOOLCHAIN_PREFIX) -$(info TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX)) ARCH_COMPILEFLAGS += $(ARCH_$(ARCH)_COMPILEFLAGS) ARCH_COMPILEFLAGS += -fno-omit-frame-pointer diff --git a/arch/x86/rules.mk b/arch/x86/rules.mk index fdb0b380..9db294db 100644 --- a/arch/x86/rules.mk +++ b/arch/x86/rules.mk @@ -106,9 +106,9 @@ TOOLCHAIN_PREFIX := $(ARCH_x86_64_TOOLCHAIN_PREFIX) endif endif # SUBARCH x86-64 -$(warning ARCH_x86_TOOLCHAIN_PREFIX = $(ARCH_x86_TOOLCHAIN_PREFIX)) -$(warning ARCH_x86_64_TOOLCHAIN_PREFIX = $(ARCH_x86_64_TOOLCHAIN_PREFIX)) -$(warning TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX)) +$(info ARCH_x86_TOOLCHAIN_PREFIX = $(ARCH_x86_TOOLCHAIN_PREFIX)) +$(info ARCH_x86_64_TOOLCHAIN_PREFIX = $(ARCH_x86_64_TOOLCHAIN_PREFIX)) +$(info TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX)) cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`"; \ then echo "$(2)"; else echo "$(3)"; fi ;) @@ -148,8 +148,6 @@ GLOBAL_DEFINES += X86_LEGACY=0 endif LIBGCC := $(shell $(TOOLCHAIN_PREFIX)gcc $(GLOBAL_COMPILEFLAGS) $(ARCH_COMPILEFLAGS) -print-libgcc-file-name) -$(warning LIBGCC = $(LIBGCC)) - LINKER_SCRIPT += $(SUBARCH_BUILDDIR)/kernel.ld # potentially generated files that should be cleaned out with clean make rule diff --git a/engine.mk b/engine.mk index 555fa533..4c32fade 100644 --- a/engine.mk +++ b/engine.mk @@ -183,11 +183,25 @@ include platform/$(PLATFORM)/rules.mk ifndef ARCH $(error couldn't find arch or platform doesn't define arch) endif + +# list the architecture specified in the project/target/platform rules.mk and early terminate. +ifeq ($(MAKECMDGOALS), list-arch) +$(info ARCH = $(ARCH)) +.PHONY: list-arch +list-arch: +else + include arch/$(ARCH)/rules.mk ifndef TOOLCHAIN_PREFIX $(error TOOLCHAIN_PREFIX not set in the arch rules.mk) endif +ifeq ($(MAKECMDGOALS), list-toolchain) +$(info TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREFIX)) +.PHONY: list-toolchain +list-toolchain: +else + # default to no ccache CCACHE ?= CC ?= $(CCACHE) $(TOOLCHAIN_PREFIX)gcc @@ -354,12 +368,6 @@ clean: $(EXTRA_CLEANDEPS) install: all scp $(OUTBIN) 192.168.0.4:/tftpboot -list-arch: - @echo ARCH = ${ARCH} - -list-toolchain: - @echo TOOLCHAIN_PREFIX = ${TOOLCHAIN_PREFIX} - tags: $(BUILDDIR)/srcfiles.txt $(BUILDDIR)/include_paths.txt $(info generating tags) @ctags -L $< @@ -382,6 +390,10 @@ ifeq ($(filter $(MAKECMDGOALS), clean), ) -include $(DEPS) endif +endif # ifeq ($(filter $(MAKECMDGOALS), list-toolchain)) + +endif # ifeq ($(filter $(MAKECMDGOALS), list-arch)) + endif # do-nothing = 1 endif # make spotless diff --git a/make/help.mk b/make/help.mk index a389bf3c..dd862871 100644 --- a/make/help.mk +++ b/make/help.mk @@ -12,9 +12,14 @@ help: @echo "LK build system quick help" @echo "Individual projects are built into a build- directory" @echo "Output binary is located at build-/lk.bin" + @echo "" @echo "Environment or command line variables controlling build:" @echo "PROJECT = " @echo "TOOLCHAIN_PREFIX = " + @echo "WERROR = 1 : treat warnings as errors" + @echo "DEBUG = 0,1,2 : set debug level (0=NONE, 1=INFO, 2=DEBUG), default is 2" + @echo "BUILDDIR = (default is build-)" + @echo "BUILDDIR_SUFFIX = (default is empty)" @echo "" @echo "Special make targets:" @echo "make help: This help" @@ -34,6 +39,9 @@ help: @echo "make testproject clean" @echo "" @echo "output will be in build-testproject/" + @echo "" + @echo "Check the project/ directory for available projects" + @echo "and their rules.mk files for more information." endif diff --git a/scripts/buildall b/scripts/buildall index 790c4c1b..009178c8 100755 --- a/scripts/buildall +++ b/scripts/buildall @@ -13,19 +13,22 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" function HELP { echo "help:" - echo "-e build with WERROR=1" - echo "-r also build DEBUG=0" - echo "-q hide output of build" - echo "-h for help" + echo "-a : build for (default: all)" + echo "-e : build with WERROR=1" + echo "-r : also build DEBUG=0" + echo "-q : hide output of build" + echo "-h : for help" exit 1 } RELEASE=0 WERROR=0 QUIET=0 +ARCH="all" -while getopts ehrq FLAG; do +while getopts a:ehrq FLAG; do case $FLAG in + a) ARCH="$OPTARG";; e) WERROR=1;; h) HELP;; r) RELEASE=1;; @@ -48,10 +51,30 @@ function log() fi } -# build everything in the projects directory -PROJECTS=$(echo project/*.mk | xargs -n1 basename | sed 's/\.mk//') +# find all the projects in the project directory +_PROJECTS=$(echo project/*.mk | xargs -n1 basename | sed 's/\.mk//') FAILED="" +# If ARCH is set to all, we build for all architectures, otherwise we +# filter projects based on the ARCH variable. +if [ "$ARCH" != "all" ]; then + for p in $_PROJECTS; do + # Look for ARCH = in the output of make list-arch + PROJECT_ARCH="$(PROJECT=$p make list-arch | grep 'ARCH' | tail -1 | cut -d ' ' -f 3)" + if [ "$PROJECT_ARCH" == "$ARCH" ]; then + PROJECTS+="$p " + else + if (( !QUIET )); then + echo "Skipping $p, not compatible with architecture $ARCH" + fi + fi + done +else + PROJECTS+="$_PROJECTS" +fi + +echo projects to build: "$PROJECTS" + if (( WERROR )); then WERROR_MSG="with WERROR" fi @@ -73,4 +96,5 @@ if [ "$FAILED" != "" ]; then echo echo some projects have failed to build: echo "$FAILED" + exit 1 fi