restructure Make

This commit is contained in:
Emile Clark-Boman 2025-09-09 11:12:09 +10:00
parent 2711027dcf
commit c1d82b5046
2 changed files with 35 additions and 30 deletions

View file

@ -7,8 +7,6 @@ BIN := bin
BUILD := build
LIB := lib
LDLIBS := -lm -lc -lpipewire-0.3
# Macro definitions
define mkbin
$(addprefix $(BIN)/,$1)
@ -20,21 +18,26 @@ define mklib
$(addprefix $(LIB)/,$1)
endef
all: $(BUILD) $(BIN) $(BIN)/pw-test
# === BUILD TARGETS ===
all: $(BUILD) $(BIN) $(call mkbin,pw-test graph sine)
$(BIN)/pw-test: $(call mklib, main.c)
$(CC) $(CFLAGS) -o $(BUILD)/pw-test.o -c $^
$(LD) $(LDFLAGS) $(LDLIBS) -o $@ $(BUILD)/pw-test.o
$(CCOMPILER) $(CFLAGS) -o $(BUILD)/pw-test.o -c $^
$(CLINKER) $(LDFLAGS) -o $@ $(BUILD)/pw-test.o
$(BUILD) $(BIN):
mkdir -p $@
.PHONY: run
run:
command $(BIN)/pw-test
# === DEVELOPMENT TARGETS ===
.PHONY: debug run test
debug:
$(MAKE) all \
CFLAGS="$(CFLAGS) $(CFLAGS_DBG)" \
LDFLAGS="$(LDFLAGS) $(LDFLAGS_DBG)"
run: debug
- command $(BIN)/pw-test
test: clean run
.PHONY: test
test: clean all run
# === UTILITY TARGETS ===
.PHONY: clean
clean:
rm -rf $(BUILD) $(BIN) compile_commands.json
rm -rf $(BUILD) $(BIN)