2021-01-12 18:22:11 +00:00
|
|
|
ARCH := aarch64-linux-gnu-
|
|
|
|
|
|
|
|
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-01-16 19:40:46 +00:00
|
|
|
-ffreestanding -fpic -ffunction-sections -fdata-sections \
|
2021-01-23 13:25:34 +00:00
|
|
|
-fno-stack-protector -mgeneral-regs-only -mstrict-align
|
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-16 15:45:10 +00:00
|
|
|
OBJECTS := adt.o bootlogo_128.o bootlogo_256.o exception.o exception_asm.o fb.o \
|
|
|
|
main.o memory.o proxy.o start.o startup.o string.o uart.o uartproxy.o utils.o \
|
2021-01-23 13:25:34 +00:00
|
|
|
utils_asm.o vsprintf.o $(MINILZLIB_OBJECTS) $(TINF_OBJECTS)
|
2021-01-12 18:22:11 +00:00
|
|
|
|
|
|
|
BUILD_OBJS := $(patsubst %,build/%,$(OBJECTS))
|
|
|
|
NAME := m1n1
|
|
|
|
TARGET := m1n1.macho
|
|
|
|
|
|
|
|
DEPDIR := build/.deps
|
|
|
|
|
2021-01-16 19:40:46 +00:00
|
|
|
ifeq ($(USE_CLANG),1)
|
|
|
|
CC := clang --target=$(ARCH)
|
|
|
|
AS := clang --target=$(ARCH)
|
|
|
|
LD := ld.lld
|
|
|
|
OBJCOPY := llvm-objcopy
|
|
|
|
else
|
2021-01-12 18:22:11 +00:00
|
|
|
CC := $(ARCH)gcc
|
|
|
|
AS := $(ARCH)gcc
|
|
|
|
LD := $(ARCH)ld
|
|
|
|
OBJCOPY := $(ARCH)objcopy
|
2021-01-16 19:40:46 +00:00
|
|
|
endif
|
2021-01-12 18:22:11 +00:00
|
|
|
|
|
|
|
.PHONY: all clean format
|
|
|
|
all: build/$(TARGET)
|
|
|
|
clean:
|
|
|
|
rm -rf build/*
|
|
|
|
format:
|
|
|
|
clang-format -i src/*.c src/*.h
|
|
|
|
|
|
|
|
build/%.o: src/%.S
|
|
|
|
@echo " AS $@"
|
|
|
|
@mkdir -p $(DEPDIR)
|
2021-01-23 13:25:34 +00:00
|
|
|
@mkdir -p "$(basename $@)"
|
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:25:34 +00:00
|
|
|
@mkdir -p "$(basename $@)"
|
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
|
|
|
|
|
|
|
build/main.o: build/build_tag.h src/main.c
|
|
|
|
|
|
|
|
-include $(DEPDIR)/*
|
|
|
|
|
|
|
|
|
|
|
|
|