os-workshop

same materials and sample source for RV32 OS projects
git clone http://frotz.net/git/os-workshop.git
Log | Files | Refs

Makefile (1436B)


      1 ## Copyright 2022, Brian Swetland <swetland@frotz.net>
      2 ## Licensed under the Apache License, Version 2.0
      3 
      4 all:: build-all
      5 
      6 -include local.mk
      7 
      8 V := @
      9 
     10 # defaults for Ubuntu, can override with local.mk
     11 XTOOLCHAIN ?= /usr/bin/riscv64-unknown-elf-
     12 QEMU ?= /usr/bin/qemu-system-riscv32
     13 QEMUBIOS := out/boot.elf
     14 
     15 QFLAGS := -machine micro -bios $(QEMUBIOS)
     16 QFLAGS.GDB := $(QFLAGS) -gdb tcp::7777 -S
     17 QFLAGS.FB := -serial stdio
     18 QFLAGS.TTY := -nographic -monitor none -serial stdio
     19 
     20 ifeq ($(wildcard $(XTOOLCHAIN)gcc),)
     21 $(warning Cannot find toolchain $(XTOOLCHAIN))
     22 $(error Please set XTOOLCHAIN in local.mk)
     23 endif
     24 
     25 ifeq ($(wildcard $(QEMU)),)
     26 $(warning Cannot find qemu-system-riscv32)
     27 $(error Please set QEMU in local.mk)
     28 endif
     29 
     30 XGCC := $(XTOOLCHAIN)gcc
     31 XOBJDUMP := $(XTOOLCHAIN)objdump
     32 XOBJCOPY := $(XTOOLCHAIN)objcopy
     33 XAR := $(XTOOLCHAIN)ar
     34 
     35 ARCHFLAGS := -march=rv32ima -mabi=ilp32 -mcmodel=medany
     36 ARCHFLAGS += -static -nostdlib -nostartfiles -ffreestanding
     37 ARCHFLAGS += -ffunction-sections -fdata-sections
     38 ARCHFLAGS += -fno-builtin -fno-strict-aliasing
     39 
     40 LDSCRIPT := make/app.ram.ld
     41 
     42 BUILD := out
     43 
     44 CFLAGS := -g -Wall -Ihw/inc
     45 CFLAGS += -O2
     46 
     47 ALL := out/netboot
     48 
     49 LIBC_SRC := libc/src/printf.c $(wildcard libc/src/string/*.c)
     50 
     51 include $(wildcard project/*.lib.mk)
     52 include $(wildcard project/*.app.mk)
     53 
     54 build-all: $(ALL)
     55 
     56 clean::
     57 	rm -rf $(BUILD)
     58 
     59 out/netboot: tools/netboot.c tools/netboot.h
     60 	$(CC) -Wall -O2 -g -o out/netboot tools/netboot.c
     61