2024-08-08 21:48:39 +02:00
|
|
|
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)/%=%)
|
2024-08-08 21:48:39 +02:00
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
|
|
|
|
all:
|
|
|
|
ifdef EXAMPLE
|
2024-08-08 21:54:54 +02:00
|
|
|
$(MAKE) -f $(EXAMPLE_DIR)/Makefile example-$(EXAMPLE)
|
2024-08-08 21:48:39 +02:00
|
|
|
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)
|
|
|
|
|
2024-08-08 21:48:39 +02:00
|
|
|
$(BIN)/%: %.c
|
|
|
|
@mkdir -p $(@D)
|
|
|
|
$(CC) $< $(LDFLAGS) $(CFLAGS) -o $@
|