Add option for building verbosely

Signed-off-by: Gregor Haas <gregorhaas1997@gmail.com>
This commit is contained in:
Gregor Haas 2023-11-27 11:06:38 -08:00 committed by Hector Martin
parent 9065c700df
commit a26e439489
2 changed files with 53 additions and 41 deletions

View file

@ -33,6 +33,16 @@ CLANG_FORMAT := clang-format
EXTRA_CFLAGS ?= -Wstack-usage=2048 EXTRA_CFLAGS ?= -Wstack-usage=2048
endif endif
ifeq ($(V),)
QUIET := @
else
ifeq ($(V),0)
QUIET := @
else
QUIET :=
endif
endif
BASE_CFLAGS := -O2 -Wall -g -Wundef -Werror=strict-prototypes -fno-common -fno-PIE \ BASE_CFLAGS := -O2 -Wall -g -Wundef -Werror=strict-prototypes -fno-common -fno-PIE \
-Werror=implicit-function-declaration -Werror=implicit-int \ -Werror=implicit-function-declaration -Werror=implicit-int \
-Wsign-compare -Wunused-parameter -Wno-multichar \ -Wsign-compare -Wunused-parameter -Wno-multichar \
@ -173,79 +183,79 @@ rustfmt-check:
cd rust && cargo fmt --check cd rust && cargo fmt --check
build/$(RUST_LIB): rust/src/* rust/* build/$(RUST_LIB): rust/src/* rust/*
@echo " RS $@" $(QUIET)echo " RS $@"
@mkdir -p $(DEPDIR) $(QUIET)mkdir -p $(DEPDIR)
@mkdir -p "$(dir $@)" $(QUIET)mkdir -p "$(dir $@)"
@cargo build --target $(RUSTARCH) --lib --release --manifest-path rust/Cargo.toml --target-dir build $(QUIET)cargo build --target $(RUSTARCH) --lib --release --manifest-path rust/Cargo.toml --target-dir build
@cp "build/$(RUSTARCH)/release/${RUST_LIB}" "$@" $(QUIET)cp "build/$(RUSTARCH)/release/${RUST_LIB}" "$@"
build/%.o: src/%.S build/%.o: src/%.S
@echo " AS $@" $(QUIET)echo " AS $@"
@mkdir -p $(DEPDIR) $(QUIET)mkdir -p $(DEPDIR)
@mkdir -p "$(dir $@)" $(QUIET)mkdir -p "$(dir $@)"
@$(AS) -c $(CFLAGS) -MMD -MF $(DEPDIR)/$(*F).d -MQ "$@" -MP -o $@ $< $(QUIET)$(AS) -c $(CFLAGS) -MMD -MF $(DEPDIR)/$(*F).d -MQ "$@" -MP -o $@ $<
$(BUILD_FP_OBJS): build/%.o: src/%.c $(BUILD_FP_OBJS): build/%.o: src/%.c
@echo " CC FP $@" $(QUIET)echo " CC FP $@"
@mkdir -p $(DEPDIR) $(QUIET)mkdir -p $(DEPDIR)
@mkdir -p "$(dir $@)" $(QUIET)mkdir -p "$(dir $@)"
@$(CC) -c $(BASE_CFLAGS) -MMD -MF $(DEPDIR)/$(*F).d -MQ "$@" -MP -o $@ $< $(QUIET)$(CC) -c $(BASE_CFLAGS) -MMD -MF $(DEPDIR)/$(*F).d -MQ "$@" -MP -o $@ $<
build/%.o: src/%.c build/%.o: src/%.c
@echo " CC $@" $(QUIET)echo " CC $@"
@mkdir -p $(DEPDIR) $(QUIET)mkdir -p $(DEPDIR)
@mkdir -p "$(dir $@)" $(QUIET)mkdir -p "$(dir $@)"
@$(CC) -c $(CFLAGS) -MMD -MF $(DEPDIR)/$(*F).d -MQ "$@" -MP -o $@ $< $(QUIET)$(CC) -c $(CFLAGS) -MMD -MF $(DEPDIR)/$(*F).d -MQ "$@" -MP -o $@ $<
# special target for usage by m1n1.loadobjs # special target for usage by m1n1.loadobjs
invoke_cc: invoke_cc:
@$(CC) -c $(CFLAGS) -Isrc -o $(OBJFILE) $(CFILE) $(QUIET)$(CC) -c $(CFLAGS) -Isrc -o $(OBJFILE) $(CFILE)
build/$(NAME).elf: $(BUILD_ALL_OBJS) m1n1.ld build/$(NAME).elf: $(BUILD_ALL_OBJS) m1n1.ld
@echo " LD $@" $(QUIET)echo " LD $@"
@$(LD) -T m1n1.ld $(LDFLAGS) -o $@ $(BUILD_ALL_OBJS) $(QUIET)$(LD) -T m1n1.ld $(LDFLAGS) -o $@ $(BUILD_ALL_OBJS)
build/$(NAME)-raw.elf: $(BUILD_ALL_OBJS) m1n1-raw.ld build/$(NAME)-raw.elf: $(BUILD_ALL_OBJS) m1n1-raw.ld
@echo " LDRAW $@" $(QUIET)echo " LDRAW $@"
@$(LD) -T m1n1-raw.ld $(LDFLAGS) -o $@ $(BUILD_ALL_OBJS) $(QUIET)$(LD) -T m1n1-raw.ld $(LDFLAGS) -o $@ $(BUILD_ALL_OBJS)
build/$(NAME).macho: build/$(NAME).elf build/$(NAME).macho: build/$(NAME).elf
@echo " MACHO $@" $(QUIET)echo " MACHO $@"
@$(OBJCOPY) -O binary --strip-debug $< $@ $(QUIET)$(OBJCOPY) -O binary --strip-debug $< $@
build/$(NAME).bin: build/$(NAME)-raw.elf build/$(NAME).bin: build/$(NAME)-raw.elf
@echo " RAW $@" $(QUIET)echo " RAW $@"
@$(OBJCOPY) -O binary --strip-debug $< $@ $(QUIET)$(OBJCOPY) -O binary --strip-debug $< $@
update_tag: update_tag:
@mkdir -p build $(QUIET)mkdir -p build
@./version.sh > build/build_tag.tmp $(QUIET)./version.sh > build/build_tag.tmp
@cmp -s build/build_tag.h build/build_tag.tmp 2>/dev/null || \ $(QUIET)cmp -s build/build_tag.h build/build_tag.tmp 2>/dev/null || \
( mv -f build/build_tag.tmp build/build_tag.h && echo " TAG build/build_tag.h" ) ( mv -f build/build_tag.tmp build/build_tag.h && echo " TAG build/build_tag.h" )
update_cfg: update_cfg:
@mkdir -p build $(QUIET)mkdir -p build
@for i in $(CFG); do echo "#define $$i"; done > build/build_cfg.tmp $(QUIET)for i in $(CFG); do echo "#define $$i"; done > build/build_cfg.tmp
@cmp -s build/build_cfg.h build/build_cfg.tmp 2>/dev/null || \ $(QUIET)cmp -s build/build_cfg.h build/build_cfg.tmp 2>/dev/null || \
( mv -f build/build_cfg.tmp build/build_cfg.h && echo " CFG build/build_cfg.h" ) ( mv -f build/build_cfg.tmp build/build_cfg.h && echo " CFG build/build_cfg.h" )
build/build_tag.h: update_tag build/build_tag.h: update_tag
build/build_cfg.h: update_cfg build/build_cfg.h: update_cfg
build/%.bin: data/%.bin build/%.bin: data/%.bin
@echo " IMG $@" $(QUIET)echo " IMG $@"
@mkdir -p "$(dir $@)" $(QUIET)mkdir -p "$(dir $@)"
@cp $< $@ $(QUIET)cp $< $@
build/%.o: build/%.bin build/%.o: build/%.bin
@echo " BIN $@" $(QUIET)echo " BIN $@"
@mkdir -p "$(dir $@)" $(QUIET)mkdir -p "$(dir $@)"
@$(OBJCOPY) -I binary -B aarch64 -O elf64-littleaarch64 $< $@ $(QUIET)$(OBJCOPY) -I binary -B aarch64 -O elf64-littleaarch64 $< $@
build/%.bin: font/%.bin build/%.bin: font/%.bin
@echo " CP $@" $(QUIET)echo " CP $@"
@mkdir -p "$(dir $@)" $(QUIET)mkdir -p "$(dir $@)"
@cp $< $@ $(QUIET)cp $< $@
build/main.o: build/build_tag.h build/build_cfg.h src/main.c build/main.o: build/build_tag.h build/build_cfg.h src/main.c
build/usb_dwc3.o: build/build_tag.h src/usb_dwc3.c build/usb_dwc3.o: build/build_tag.h src/usb_dwc3.c

View file

@ -16,6 +16,8 @@ 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=`.
To build verbosely, use `make V=1`.
Building on ARM64 macOS is supported with clang and LLVM; you need to use Homebrew to Building on ARM64 macOS is supported with clang and LLVM; you need to use Homebrew to
install the required dependencies: install the required dependencies: