1# 2# Copyright 2014, General Dynamics C4 Systems 3# 4# This software may be distributed and modified according to the terms of 5# the GNU General Public License version 2. Note that NO WARRANTY is provided. 6# See "LICENSE_GPLv2.txt" for details. 7# 8# @TAG(GD_GPL) 9# 10 11BOOT_MODULES = Kernel/CSpace Kernel/Thread Kernel/FaultHandler \ 12 Kernel/VSpace Kernel/Init Model/PSpace Object/TCB Object/CNode \ 13 Object/ObjectType Object/Endpoint Object/Interrupt \ 14 Object/IOPort/X64 15 16BOOT_FILES=$(BOOT_MODULES:%=src/SEL4/%.lhs-boot) 17CUSTOM_BOOT_FILES = src/SEL4/Object/Structures.lhs-boot 18 19# We use the cabal executable that we installed via stack, 20# and use the PATH from `stack exec` to find it. 21# However, cabal refuses to run when the GHC_PACKAGE_PATH 22# variable is set, so we use `stack-path` to clear 23# GHC_PACKAGE_PATH first. 24CABAL=stack exec -- ./stack-path cabal 25 26# warnings that are useless during large Haskell updates 27GHC_DEV_OPTS=--ghc-options="" 28 29all: build-riscv build-arm build-arm-hyp-nosmmu build-x64 30 31sandbox: .stack-work 32 $(CABAL) sandbox init 33 $(CABAL) install --dependencies-only 34 35build-arm: sandbox $(BOOT_FILES) 36 $(CABAL) configure --configure-option="arm-kzm" \ 37 --flags="ArchArm" \ 38 --builddir="dist/arm" 39 $(CABAL) build --builddir="dist/arm" 40 41build-arm-hyp: sandbox $(BOOT_FILES) $(CUSTOM_BOOT_FILES) 42 $(CABAL) configure --configure-option="arm-tk1" \ 43 --flags="ArchArmHyp -FFI" \ 44 --builddir="dist/arm-hyp" 45 $(CABAL) build --builddir="dist/arm-hyp" 46 47build-arm-hyp-nosmmu: sandbox $(BOOT_FILES) $(CUSTOM_BOOT_FILES) 48 $(CABAL) configure --configure-option="arm-tk1-nosmmu" \ 49 --flags="ArchArmHyp -FFI" \ 50 --builddir="dist/arm-hyp-nosmmu" 51 $(CABAL) build --builddir="dist/arm-hyp-nosmmu" 52 53build-x64: sandbox $(BOOT_FILES) 54 $(CABAL) configure --configure-option="x64-pc99" \ 55 --flags="ArchX64 -FFI" \ 56 --builddir="dist/x64" 57 $(CABAL) build --builddir="dist/x64" 58 59build-riscv: sandbox $(BOOT_FILES) 60 $(CABAL) configure --configure-option="riscv-spike" \ 61 --flags="ArchRiscV -FFI" \ 62 --builddir="dist/riscv" 63 $(CABAL) build --builddir="dist/riscv" 64 65# We assume that if the .stack-work directory exists, 66# we don't need to install ghc, cabal, nor fetch the cabal 67# package database. 68# We make this assumption to avoid hitting the network on 69# every build. 70# However, this means that if .stack-work exists, but the 71# cabal package database is missing, the build will fail. 72 73.stack-work: 74 stack --install-ghc build cabal-install 75 $(CABAL) update 76 77$(CUSTOM_BOOT_FILES): 78 echo "never run mkhsboot for hand-crafted lhs-boot files" 79 80%.lhs-boot: %.lhs mkhsboot.pl 81 perl mkhsboot.pl -l < $< > $@ 82 83clean: 84 rm -f $(BOOT_FILES) 85 $(CABAL) clean 86 87realclean: 88 rm -rf $(BOOT_FILES) dist .stack-work .cabal-sandbox cabal.sandbox.config 89 90.PHONY: all build-arm build-arm-hyp build-x64 clean sandbox realclean 91