ptk/examples/Makefile

28 lines
567 B
Makefile
Raw Normal View History

LDFLAGS = -L$(BIN) -lptk
EXAMPLE_DIR = examples
EXAMPLES = $(shell find $(EXAMPLE_DIR) -type f -name "*.c")
2024-08-08 21:54:37 +02:00
OBJ = $(EXAMPLES:.c=)
NAMES = $(OBJ:$(EXAMPLE_DIR)/%=%)
.PHONY: all
all:
ifdef EXAMPLE
2024-08-08 21:54:54 +02:00
$(MAKE) -f $(EXAMPLE_DIR)/Makefile example-$(EXAMPLE)
else
@echo "you need to pick a test: make example EXAMPLE=<example_name>"
@echo -n "available examples:"
@$(foreach example,$(NAMES),echo -n " $(example)";)
@echo
endif
2024-08-08 21:54:54 +02:00
example-%: $(BIN)/$(EXAMPLE_DIR)/%
$(BIN)/$(EXAMPLE_DIR)/$(EXAMPLE)
$(BIN)/%: %.c
@mkdir -p $(@D)
$(CC) $< $(LDFLAGS) $(CFLAGS) -o $@