clean up .PHONY and all
This commit is contained in:
parent
a4699b9bc8
commit
4d9c9e2ac4
3 changed files with 21 additions and 20 deletions
|
@ -34,6 +34,7 @@ FEATURES := ""#"env_logger"
|
|||
|
||||
THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
REPO_ROOT := $(realpath $(THIS_DIR)/..)
|
||||
CARGO_OBJDIR := cargo/$(RUST_TARGET)/$(_profile)
|
||||
|
||||
# TODO: check if override is needed
|
||||
_rust_cli_profile := $(if $(filter $(_profile),debug),dev,$(_profile))
|
||||
|
@ -68,12 +69,19 @@ size_optimized_CFLAGS += -Oz \
|
|||
-fno-ident \
|
||||
-fno-exceptions \
|
||||
$(_no_debug_cflags)
|
||||
|
||||
release_CFLAGS += -O2 \
|
||||
$(_no_debug_cflags)
|
||||
debug_CFLAGS += -Og
|
||||
static_CFLAGS += -static $(STATIC_LINK_LIBS)
|
||||
dynamic_CFLAGS += -Wl,-Bstatic $(STATIC_LINK_LIBS) -Wl,-Bdynamic
|
||||
|
||||
_servicepoint_cflags := -I $(REPO_ROOT)/include -L $(CARGO_OBJDIR)
|
||||
CFLAGS += $($(_libc)_CFLAGS) $($(_profile)_CFLAGS) $($(_link_type)_CFLAGS) $(_servicepoint_cflags)
|
||||
ifeq ($(LTO), 1)
|
||||
CFLAGS += -flto
|
||||
endif
|
||||
|
||||
size_optimized_RUSTFLAGS += -Zlocation-detail=none \
|
||||
-Zfmt-debug=none \
|
||||
-C link-arg=-z,norelro \
|
||||
|
@ -86,39 +94,28 @@ ifneq ($(_profile), debug)
|
|||
RUSTFLAGS += -C link-arg=-s -C link-arg=-Wl,--gc-sections
|
||||
endif
|
||||
|
||||
CARGO_OBJDIR := cargo/$(RUST_TARGET)/$(_profile)
|
||||
_servicepoint_cflags := -I $(REPO_ROOT)/include -L $(CARGO_OBJDIR)
|
||||
|
||||
CFLAGS += $($(_libc)_CFLAGS) $($(_profile)_CFLAGS) $($(_link_type)_CFLAGS) $(_servicepoint_cflags)
|
||||
ifeq ($(LTO), 1)
|
||||
CFLAGS += -flto
|
||||
endif
|
||||
|
||||
# TODO: wildcard does not work with VPATH
|
||||
_c_src := src/announce.c src/brightness_tester.c src/header_logger.c \
|
||||
src/moving_line.c src/random_stuff.c src/wiping_clear.c
|
||||
_programs := $(basename $(notdir $(_c_src)))
|
||||
_bins := $(_programs)
|
||||
_unstripped_bins := $(addsuffix _unstripped, $(_bins))
|
||||
_run_programs := $(addprefix run_, $(_programs))
|
||||
|
||||
# TODO: use cargo --target-dir to put rust binaries into same dir
|
||||
.SUFFIXES:
|
||||
|
||||
.PHONY: all build-rust
|
||||
|
||||
all: $(_bins)
|
||||
|
||||
.PHONY: all clean sizes $(_run_programs) clean-c clean-rust build-rust help FORCE
|
||||
|
||||
$(_unstripped_bins): %_unstripped: src/%.c src/helpers.h build-rust
|
||||
$(CC) $< $(CFLAGS) -o $@
|
||||
|
||||
$(_bins): %: %_unstripped
|
||||
$(STRIP) $(STRIPFLAGS) $^ -o $@
|
||||
|
||||
build-rust: FORCE
|
||||
build-rust:
|
||||
# generate servicepoint header and library to link against
|
||||
$(CARGO) rustc $(CARGOFLAGS) -- $(RUSTFLAGS)
|
||||
|
||||
FORCE: ;
|
||||
|
||||
#----- Begin Boilerplate
|
||||
endif
|
Loading…
Add table
Add a link
Reference in a new issue