Parts of busybox's Makefile are generic to all apps that we'll build. Instead of just copying bits and pieces, we can have all of the apps include a Makefrag.
It's far from perfect. We could detect the cross compiler instead of being told what it is, and if AKAROS_ROOT (e.g. from .bashrc) doesn't point to the repo we're in, then weird things could happen. Signed-off-by: Barret Rhoden <[email protected]> --- tools/Makefrag | 66 ++++++++++++++++++++++++++++++++++++++++++++ tools/apps/busybox/Makefile | 67 +++------------------------------------------ 2 files changed, 70 insertions(+), 63 deletions(-) create mode 100644 tools/Makefrag diff --git a/tools/Makefrag b/tools/Makefrag new file mode 100644 index 000000000000..6d494fd619d4 --- /dev/null +++ b/tools/Makefrag @@ -0,0 +1,66 @@ +# Helper for writing application Makefiles +# +# Those apps should include this directly and be located three directories down +# from the AKAROS_ROOT. +# +# Other than providing defaults for things like AKAROS_ROOT, the main thing +# this does is set the cross compiler. You can override some things with a +# Makelocal. +# +# Exports CROSS_COMPILE, ARCH, KBUILD_VERBOSE, Q, MAKEFLAGS, BUILDDIR, +# AKAROS_ROOT, MAKE_JOBS FIRST_KFS_PATH, KFS_ROOT + +# Do not: +# o use make's built-in rules and variables +# (this increases performance and avoids hard-to-debug behaviour); +# o print "Entering directory ..."; +MAKEFLAGS += -rR --no-print-directory + +# Overrides +-include Makelocal +BUILDDIR ?= $(shell pwd) +AKAROS_ROOT ?= $(BUILDDIR)/../../.. +MAKE_JOBS ?= 4 +FIRST_KFS_PATH ?= $(AKAROS_ROOT)/kern/kfs +KFS_ROOT = $(FIRST_KFS_PATH) + +# To put more focus on warnings, be less verbose as default +# Use 'make V=1' to see the full commands +# Yanked this from the top-level. It might work with V=1 from there too. +# Interestingly enough, V=1 gets passed to busybox, which also uses Kbuild, +# allowing us to control it's verbosity too. +ifeq ("$(origin V)", "command line") + KBUILD_VERBOSE ?= $(V) +endif +ifndef KBUILD_VERBOSE + KBUILD_VERBOSE = 0 +endif +ifeq ($(KBUILD_VERBOSE),1) + Q ?= +else + Q ?= @ +endif + + +# CC prefix detection. If we're called from the top-level Makefile, CC will be +# set. + +# So that valid-arches aren't the default goal +.DEFAULT_GOAL = all +# Helper target, so users can say make x86_64 and get ARCH=x86_64 +valid-arches := riscv x86_64 +PHONY += $(valid-arches) +$(valid-arches): + $(MAKE) ARCH=$@ + +ifeq ($(CROSS_COMPILE),) + # ARCH will only be set if they called make (valid-arches) directly. + ifneq ($(ARCH),) + ifeq ($(filter $(valid-arches), $(ARCH)),) + $(error ARCH $(ARCH) invalid, must be one of: $(valid-arches)) + endif + else + ARCH := x86_64 + endif + CROSS_COMPILE := $(ARCH)-ucb-akaros- +endif diff --git a/tools/apps/busybox/Makefile b/tools/apps/busybox/Makefile index 4439677f2cff..b0387a5614df 100644 --- a/tools/apps/busybox/Makefile +++ b/tools/apps/busybox/Makefile @@ -4,8 +4,8 @@ # make [all] will do a full install with the default config. # # make x86_64|riscv will set the cross compiler in the .config. You can also -# pass ARCH or CROSS_COMPILE. The top-level Makefile should be able to call -# this, but it is not necessary to do so. +# pass CROSS_COMPILE. The top-level Makefile should be able to call this, but +# it is not necessary to do so. # # Uppercase variables are 'global', in the sense that we may have them exported # from parent makefiles or overridden by a Makelocal. @@ -25,73 +25,16 @@ # - make busybox target from the top-level Makefile # - port to the latest busybox version -busybox-version := 1.17.3 +include ../../Makefrag -# Do not: -# o use make's built-in rules and variables -# (this increases performance and avoids hard-to-debug behaviour); -# o print "Entering directory ..."; -MAKEFLAGS += -rR --no-print-directory +busybox-version := 1.17.3 -# Overrides --include Makelocal -BUILDDIR ?= $(shell pwd) -AKAROS_ROOT ?= $(BUILDDIR)/../../.. -MAKE_JOBS ?= 4 -FIRST_KFS_PATH ?= $(AKAROS_ROOT)/kern/kfs install-prefix ?= $(FIRST_KFS_PATH) BUSYBOX_CONFIG ?= defconfig-$(busybox-version) -# To put more focus on warnings, be less verbose as default -# Use 'make V=1' to see the full commands -# Yanked this from the top-level. It might work with V=1 from there too. -# Interestingly enough, V=1 gets passed to busybox, which also uses Kbuild, -# allowing us to control it's verbosity too. -ifeq ("$(origin V)", "command line") - KBUILD_VERBOSE ?= $(V) -endif -ifndef KBUILD_VERBOSE - KBUILD_VERBOSE = 0 -endif -ifeq ($(KBUILD_VERBOSE),1) - Q ?= -else - Q ?= @ -endif - - -# If we only call busybox's make from the top level, all of the CC detection -# goes away. -valid-arches := riscv x86_64 - -# ARCH / CC prefix detection. Only using ARCH to help with the CC. If we're -# called from the top-level Makefile, CC will be set. ARCH might be x86. -# -# All we do is use this to set the CC in busybox's .config down below. If they -# don't have an arch or a CC set, they'll get whatever is in the defconfig. -ifeq ($(CROSS_COMPILE),) - ifneq ($(ARCH),) - # Accept x86 - ifeq ($(ARCH),x86) - override ARCH := x86_64 - endif - ifeq ($(filter $(valid-arches), $(ARCH)),) - $(error ARCH $(ARCH) invalid, must be one of: $(valid-arches)) - endif - CROSS_COMPILE := $(ARCH)-ucb-akaros- - endif -endif - - PHONY := all all: busybox-install -# Helper target, so users can say make x86_64 and get ARCH=x86_64 -PHONY += $(valid-arches) -$(valid-arches): - $(MAKE) ARCH=$@ - - akaros-patches := $(sort $(wildcard akaros-patches/$(busybox-version)/*)) upstream-patches := $(sort $(wildcard upstream-patches/$(busybox-version)/*)) @@ -117,9 +60,7 @@ busybox-$(busybox-version)-akaros: busybox-$(busybox-version).tar.bz2 \ PHONY += busybox-config busybox-config: busybox-$(busybox-version)-akaros $(Q)sed -i '/CONFIG_PREFIX/ c CONFIG_PREFIX="$(install-prefix)"' $</.config -ifneq ($(CROSS_COMPILE),) $(Q)sed -i '/CROSS_COMPILER_PREFIX/ c CONFIG_CROSS_COMPILER_PREFIX="$(CROSS_COMPILE)"' $</.config -endif PHONY += busybox-make busybox-make: busybox-config -- 2.8.0.rc3.226.g39d4020 -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
