akaros/tools/Makefrag
<<
>>
Prefs
   1# Helper for writing application Makefiles
   2#
   3# Those apps should include this directly.
   4#
   5# Other than providing defaults for things like AKAROS_ROOT, the main thing
   6# this does is set the cross compiler.  You can override some things with a
   7# Makelocal.
   8#
   9# The calling environment must have AKAROS_ROOT set.
  10#
  11# Exports CROSS_COMPILE, ARCH, KBUILD_VERBOSE, Q, MAKEFLAGS, AKAROS_ROOT,
  12# AKAROS_PREFIX, AKAROS_SYSROOT, MAKE_JOBS, FIRST_KFS_PATH, KFS_ROOT
  13
  14# Do not print "Entering directory ...";
  15MAKEFLAGS += --no-print-directory
  16
  17# Overrides
  18-include Makelocal
  19
  20ifndef AKAROS_ROOT
  21    $(error AKAROS_ROOT is empty!  You must set it!)
  22endif
  23
  24FIRST_KFS_PATH ?= $(AKAROS_ROOT)/kern/kfs
  25KFS_ROOT = $(FIRST_KFS_PATH)
  26
  27# To put more focus on warnings, be less verbose as default
  28# Use 'make V=1' to see the full commands
  29# Yanked this from the top-level.  It might work with V=1 from there too.
  30# Interestingly enough, V=1 gets passed to busybox, which also uses Kbuild,
  31# allowing us to control it's verbosity too.
  32ifeq ("$(origin V)", "command line")
  33  KBUILD_VERBOSE ?= $(V)
  34endif
  35ifndef KBUILD_VERBOSE
  36  KBUILD_VERBOSE = 0
  37endif
  38ifeq ($(KBUILD_VERBOSE),1)
  39  Q ?=
  40else
  41  Q ?= @
  42endif
  43
  44
  45# CC prefix detection.  If we're called from the top-level Makefile, CC will be
  46# set.
  47
  48# So that valid-arches aren't the default goal
  49.DEFAULT_GOAL = all
  50# Helper target, so users can say make x86_64 and get ARCH=x86_64
  51valid-arches := riscv x86_64
  52PHONY += $(valid-arches)
  53$(valid-arches):
  54        $(MAKE) ARCH=$@
  55
  56ifeq ($(CROSS_COMPILE),)
  57    # ARCH will only be set if they called make (valid-arches) directly.
  58    ifneq ($(ARCH),)
  59        ifeq ($(filter $(valid-arches), $(ARCH)),)
  60            $(error ARCH $(ARCH) invalid, must be one of: $(valid-arches))
  61        endif
  62    else
  63        ARCH := x86_64
  64    endif
  65    CROSS_COMPILE := $(ARCH)-ucb-akaros-
  66endif
  67
  68AKAROS_PREFIX = $(shell x86_64-ucb-akaros-gcc -dumpmachine)
  69AKAROS_SYSROOT = $(shell x86_64-ucb-akaros-gcc -print-sysroot)
  70