2021-01-12 18:22:11 +00:00
|
|
|
ARCH := aarch64-linux-gnu-
|
|
|
|
|
2021-03-07 16:31:14 +00:00
|
|
|
ifeq ($(USE_CLANG),1)
|
|
|
|
CC := clang --target=$(ARCH)
|
|
|
|
AS := clang --target=$(ARCH)
|
|
|
|
LD := ld.lld
|
|
|
|
OBJCOPY := llvm-objcopy
|
|
|
|
else
|
|
|
|
CC := $(ARCH)gcc
|
|
|
|
AS := $(ARCH)gcc
|
|
|
|
LD := $(ARCH)ld
|
|
|
|
OBJCOPY := $(ARCH)objcopy
|
|
|
|
endif
|
|
|
|
|
2021-01-12 18:22:11 +00:00
|
|
|
CFLAGS := -O2 -Wall -Wundef -Werror=strict-prototypes -fno-common -fno-PIE \
|
2021-01-14 11:10:42 +00:00
|
|
|
-Werror=implicit-function-declaration -Werror=implicit-int \
|
2021-02-06 06:08:15 +00:00
|
|
|
-Wsign-compare -Wunused-parameter -Wno-multichar \
|
2021-01-16 19:40:46 +00:00
|
|
|
-ffreestanding -fpic -ffunction-sections -fdata-sections \
|
2021-03-07 16:31:14 +00:00
|
|
|
-nostdinc -isystem $(shell $(CC) -print-file-name=include) -isystem sysinc \
|
2021-02-06 06:08:15 +00:00
|
|
|
-fno-stack-protector -mgeneral-regs-only -mstrict-align -march=armv8.2-a
|
2021-01-14 11:10:42 +00:00
|
|
|
|
2021-01-16 19:40:46 +00:00
|
|
|
LDFLAGS := -T m1n1.ld -EL -maarch64elf --no-undefined -X -Bsymbolic \
|
2021-01-14 11:10:42 +00:00
|
|
|
-z notext --no-apply-dynamic-relocs --orphan-handling=warn --strip-debug \
|
|
|
|
-z nocopyreloc --gc-sections -pie
|
2021-01-12 18:22:11 +00:00
|
|
|
|
2021-01-23 13:25:34 +00:00
|
|
|
MINILZLIB_OBJECTS := $(patsubst %,minilzlib/%, \
|
|
|
|
dictbuf.o inputbuf.o lzma2dec.o lzmadec.o rangedec.o xzstream.o)
|
|
|
|
|
|
|
|
TINF_OBJECTS := $(patsubst %,tinf/%, \
|
|
|
|
adler32.o crc32.o tinfgzip.o tinflate.o tinfzlib.o)
|
|
|
|
|
2021-01-29 06:19:34 +00:00
|
|
|
DLMALLOC_OBJECTS := dlmalloc/malloc.o
|
|
|
|
|
2021-01-29 10:54:39 +00:00
|
|
|
LIBFDT_OBJECTS := $(patsubst %,libfdt/%, \
|
2021-03-07 16:31:14 +00:00
|
|
|
fdt_addresses.o fdt_empty_tree.o fdt_ro.o fdt_rw.o fdt_strerror.o fdt_sw.o \
|
2021-01-29 10:54:39 +00:00
|
|
|
fdt_wip.o fdt.o)
|
|
|
|
|
2021-04-14 08:51:41 +00:00
|
|
|
OBJECTS := \
|
|
|
|
adt.o \
|
|
|
|
bootlogo_128.o bootlogo_256.o \
|
|
|
|
chickens.o \
|
|
|
|
dart.o \
|
|
|
|
exception.o exception_asm.o \
|
2021-02-12 21:27:39 +00:00
|
|
|
fb.o font.o font_retina.o \
|
2021-05-08 12:54:07 +00:00
|
|
|
gxf.o gxf_asm.o \
|
2021-04-14 08:51:41 +00:00
|
|
|
heapblock.o \
|
2021-05-27 12:16:17 +00:00
|
|
|
hv.o hv_vm.o hv_exc.o hv_vuart.o hv_wdt.o hv_asm.o \
|
2021-05-29 12:34:41 +00:00
|
|
|
i2c.o \
|
2021-04-15 13:47:33 +00:00
|
|
|
iodev.o \
|
2021-04-14 08:51:41 +00:00
|
|
|
kboot.o \
|
|
|
|
main.o \
|
|
|
|
memory.o memory_asm.o \
|
|
|
|
payload.o \
|
2021-04-11 13:44:23 +00:00
|
|
|
pcie.o \
|
2021-04-14 08:51:41 +00:00
|
|
|
pmgr.o \
|
|
|
|
proxy.o \
|
2021-03-13 19:16:21 +00:00
|
|
|
ringbuffer.o \
|
2021-04-14 08:51:41 +00:00
|
|
|
smp.o \
|
|
|
|
start.o \
|
|
|
|
startup.o \
|
|
|
|
string.o \
|
|
|
|
tunables.o \
|
|
|
|
uart.o \
|
|
|
|
uartproxy.o \
|
2021-03-14 12:03:13 +00:00
|
|
|
usb.o usb_dwc3.o \
|
2021-04-14 08:51:41 +00:00
|
|
|
utils.o utils_asm.o \
|
|
|
|
vsprintf.o \
|
|
|
|
wdt.o \
|
|
|
|
$(MINILZLIB_OBJECTS) $(TINF_OBJECTS) $(DLMALLOC_OBJECTS) $(LIBFDT_OBJECTS)
|
2021-01-12 18:22:11 +00:00
|
|
|
|
2021-03-14 17:26:31 +00:00
|
|
|
DTS := t8103-j274.dts
|
2021-01-23 13:36:17 +00:00
|
|
|
|
2021-01-12 18:22:11 +00:00
|
|
|
BUILD_OBJS := $(patsubst %,build/%,$(OBJECTS))
|
2021-01-23 13:36:17 +00:00
|
|
|
DTBS := $(patsubst %.dts,build/dtb/%.dtb,$(DTS))
|
|
|
|
|
2021-01-12 18:22:11 +00:00
|
|
|
NAME := m1n1
|
|
|
|
TARGET := m1n1.macho
|
|
|
|
|
|
|
|
DEPDIR := build/.deps
|
|
|
|
|
|
|
|
.PHONY: all clean format
|
2021-01-23 13:36:17 +00:00
|
|
|
all: build/$(TARGET) $(DTBS)
|
2021-01-12 18:22:11 +00:00
|
|
|
clean:
|
|
|
|
rm -rf build/*
|
|
|
|
format:
|
2021-03-07 16:31:14 +00:00
|
|
|
clang-format -i src/*.c src/*.h sysinc/*.h
|
2021-04-06 10:18:56 +00:00
|
|
|
format-check:
|
|
|
|
clang-format --dry-run --Werror src/*.c src/*.h sysinc/*.h
|
2021-01-12 18:22:11 +00:00
|
|
|
|
2021-03-14 17:26:31 +00:00
|
|
|
build/dtb/%.dts: dts/%.dts
|
|
|
|
@echo " DTCPP $@"
|
|
|
|
@mkdir -p "$(dir $@)"
|
|
|
|
@$(CC) -E -nostdinc -I dts -x assembler-with-cpp -o $@ $<
|
|
|
|
|
|
|
|
build/dtb/%.dtb: build/dtb/%.dts
|
2021-01-23 13:36:17 +00:00
|
|
|
@echo " DTC $@"
|
|
|
|
@mkdir -p "$(dir $@)"
|
2021-03-14 17:26:31 +00:00
|
|
|
@dtc -I dts -i dts $< -o $@
|
2021-01-23 13:36:17 +00:00
|
|
|
|
2021-01-12 18:22:11 +00:00
|
|
|
build/%.o: src/%.S
|
|
|
|
@echo " AS $@"
|
|
|
|
@mkdir -p $(DEPDIR)
|
2021-01-23 13:36:17 +00:00
|
|
|
@mkdir -p "$(dir $@)"
|
2021-01-12 18:22:11 +00:00
|
|
|
@$(AS) -c $(CFLAGS) -Wp,-MMD,$(DEPDIR)/$(*F).d,-MQ,"$@",-MP -o $@ $<
|
|
|
|
|
|
|
|
build/%.o: src/%.c
|
|
|
|
@echo " CC $@"
|
|
|
|
@mkdir -p $(DEPDIR)
|
2021-01-23 13:36:17 +00:00
|
|
|
@mkdir -p "$(dir $@)"
|
2021-01-12 18:22:11 +00:00
|
|
|
@$(CC) -c $(CFLAGS) -Wp,-MMD,$(DEPDIR)/$(*F).d,-MQ,"$@",-MP -o $@ $<
|
|
|
|
|
|
|
|
build/$(NAME).elf: $(BUILD_OBJS) m1n1.ld
|
|
|
|
@echo " LD $@"
|
|
|
|
@$(LD) $(LDFLAGS) -o $@ $(BUILD_OBJS)
|
2021-01-16 15:45:10 +00:00
|
|
|
|
2021-01-12 18:22:11 +00:00
|
|
|
build/$(NAME).macho: build/$(NAME).elf
|
|
|
|
@echo " MACHO $@"
|
|
|
|
@$(OBJCOPY) -O binary $< $@
|
|
|
|
|
|
|
|
build/build_tag.h:
|
|
|
|
@echo " TAG $@"
|
2021-01-16 15:45:10 +00:00
|
|
|
@echo "#define BUILD_TAG \"$$(git describe --always --dirty)\"" > $@
|
2021-01-12 18:22:11 +00:00
|
|
|
|
|
|
|
build/%.bin: data/%.png
|
|
|
|
@echo " IMG $@"
|
|
|
|
@convert $< -background black -flatten -depth 8 rgba:$@
|
|
|
|
|
|
|
|
build/%.o: build/%.bin
|
|
|
|
@echo " BIN $@"
|
2021-01-15 21:39:32 +00:00
|
|
|
@$(OBJCOPY) -I binary -B aarch64 -O elf64-littleaarch64 $< $@
|
2021-01-12 18:22:11 +00:00
|
|
|
|
2021-02-12 21:27:39 +00:00
|
|
|
build/%.bin: font/%.bin
|
|
|
|
@echo " CP $@"
|
|
|
|
@cp $< $@
|
|
|
|
|
2021-01-12 18:22:11 +00:00
|
|
|
build/main.o: build/build_tag.h src/main.c
|
|
|
|
|
|
|
|
-include $(DEPDIR)/*
|
|
|
|
|
|
|
|
|
|
|
|
|