mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-25 16:10:16 +00:00
Makefile: Make it build out-of-the-box on macOS
This requires a few dependencies installed with Homebrew. Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
a4e922ecaf
commit
1e6c856f5f
2 changed files with 36 additions and 12 deletions
39
Makefile
39
Makefile
|
@ -1,15 +1,30 @@
|
||||||
ARCH := aarch64-linux-gnu-
|
ARCH ?= aarch64-linux-gnu-
|
||||||
|
|
||||||
|
ifeq ($(shell uname),Darwin)
|
||||||
|
USE_CLANG ?= 1
|
||||||
|
$(info INFO: Building on Darwin)
|
||||||
|
ifeq ($(shell uname -p),arm)
|
||||||
|
TOOLCHAIN ?= /opt/homebrew/opt/llvm/bin/
|
||||||
|
else
|
||||||
|
TOOLCHAIN ?= /usr/local/opt/llvm/bin/
|
||||||
|
endif
|
||||||
|
$(info INFO: Toolchain path: $(TOOLCHAIN))
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(USE_CLANG),1)
|
ifeq ($(USE_CLANG),1)
|
||||||
CC := clang --target=$(ARCH)
|
CC := $(TOOLCHAIN)clang --target=$(ARCH)
|
||||||
AS := clang --target=$(ARCH)
|
AS := $(TOOLCHAIN)clang --target=$(ARCH)
|
||||||
LD := ld.lld
|
LD := $(TOOLCHAIN)ld.lld
|
||||||
OBJCOPY := llvm-objcopy
|
OBJCOPY := $(TOOLCHAIN)llvm-objcopy
|
||||||
|
CLANG_FORMAT := $(TOOLCHAIN)clang-format
|
||||||
|
EXTRA_CFLAGS ?=
|
||||||
else
|
else
|
||||||
CC := $(ARCH)gcc
|
CC := $(TOOLCHAIN)$(ARCH)gcc
|
||||||
AS := $(ARCH)gcc
|
AS := $(TOOLCHAIN)$(ARCH)gcc
|
||||||
LD := $(ARCH)ld
|
LD := $(TOOLCHAIN)$(ARCH)ld
|
||||||
OBJCOPY := $(ARCH)objcopy
|
OBJCOPY := $(TOOLCHAIN)$(ARCH)objcopy
|
||||||
|
CLANG_FORMAT := clang-format
|
||||||
|
EXTRA_CFLAGS ?= -Wstack-usage=1024
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS := -O2 -Wall -g -Wundef -Werror=strict-prototypes -fno-common -fno-PIE \
|
CFLAGS := -O2 -Wall -g -Wundef -Werror=strict-prototypes -fno-common -fno-PIE \
|
||||||
|
@ -18,7 +33,7 @@ CFLAGS := -O2 -Wall -g -Wundef -Werror=strict-prototypes -fno-common -fno-PIE \
|
||||||
-ffreestanding -fpic -ffunction-sections -fdata-sections \
|
-ffreestanding -fpic -ffunction-sections -fdata-sections \
|
||||||
-nostdinc -isystem $(shell $(CC) -print-file-name=include) -isystem sysinc \
|
-nostdinc -isystem $(shell $(CC) -print-file-name=include) -isystem sysinc \
|
||||||
-fno-stack-protector -mgeneral-regs-only -mstrict-align -march=armv8.2-a \
|
-fno-stack-protector -mgeneral-regs-only -mstrict-align -march=armv8.2-a \
|
||||||
-Wstack-usage=1024
|
$(EXTRA_CFLAGS)
|
||||||
|
|
||||||
LDFLAGS := -T m1n1.ld -EL -maarch64elf --no-undefined -X -Bsymbolic \
|
LDFLAGS := -T m1n1.ld -EL -maarch64elf --no-undefined -X -Bsymbolic \
|
||||||
-z notext --no-apply-dynamic-relocs --orphan-handling=warn \
|
-z notext --no-apply-dynamic-relocs --orphan-handling=warn \
|
||||||
|
@ -87,9 +102,9 @@ all: build/$(TARGET) $(DTBS)
|
||||||
clean:
|
clean:
|
||||||
rm -rf build/*
|
rm -rf build/*
|
||||||
format:
|
format:
|
||||||
clang-format -i src/*.c src/*.h sysinc/*.h
|
$(CLANG_FORMAT) -i src/*.c src/*.h sysinc/*.h
|
||||||
format-check:
|
format-check:
|
||||||
clang-format --dry-run --Werror src/*.c src/*.h sysinc/*.h
|
$(CLANG_FORMAT) --dry-run --Werror src/*.c src/*.h sysinc/*.h
|
||||||
|
|
||||||
build/dtb/%.dts: dts/%.dts
|
build/dtb/%.dts: dts/%.dts
|
||||||
@echo " DTCPP $@"
|
@echo " DTCPP $@"
|
||||||
|
|
|
@ -17,6 +17,15 @@ The output will be in build/m1n1.macho.
|
||||||
|
|
||||||
To build on a native arm64 machine, use `make ARCH=`.
|
To build on a native arm64 machine, use `make ARCH=`.
|
||||||
|
|
||||||
|
Building on ARM64 macOS is supported with clang and LLVM; you need to use Homebrew to
|
||||||
|
install the required dependencies:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ brew install llvm imagemagick dtc
|
||||||
|
```
|
||||||
|
|
||||||
|
After that, just type `make`.
|
||||||
|
|
||||||
### Building using the container setup
|
### Building using the container setup
|
||||||
|
|
||||||
If you have a container runtime installed, like Podman or Docker, you can make use of the compose setup, which contains all build dependencies.
|
If you have a container runtime installed, like Podman or Docker, you can make use of the compose setup, which contains all build dependencies.
|
||||||
|
|
Loading…
Reference in a new issue