improve example makefile

This commit is contained in:
jacekpoz 2024-08-08 21:54:54 +02:00
parent c1d26dc69c
commit e1ea3c764f
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -11,8 +11,7 @@ NAMES = $(OBJ:$(EXAMPLE_DIR)/%=%)
all:
ifdef EXAMPLE
$(MAKE) -f $(EXAMPLE_DIR)/Makefile $(BIN)/$(EXAMPLE_DIR)/$(EXAMPLE)
$(BIN)/$(EXAMPLE_DIR)/$(EXAMPLE)
$(MAKE) -f $(EXAMPLE_DIR)/Makefile example-$(EXAMPLE)
else
@echo "you need to pick a test: make example EXAMPLE=<example_name>"
@echo -n "available examples:"
@ -20,6 +19,9 @@ else
@echo
endif
example-%: $(BIN)/$(EXAMPLE_DIR)/%
$(BIN)/$(EXAMPLE_DIR)/$(EXAMPLE)
$(BIN)/%: %.c
@mkdir -p $(@D)
$(CC) $< $(LDFLAGS) $(CFLAGS) -o $@