29 lines
658 B
Makefile
29 lines
658 B
Makefile
# Copyright (jacekpoz 2024). Licensed under the EUPL-1.2 or later.
|
|
|
|
LDFLAGS = -L$(BIN) -lptk
|
|
|
|
EXAMPLE_DIR = examples
|
|
|
|
EXAMPLES = $(shell find $(EXAMPLE_DIR) -type f -name "*.c")
|
|
|
|
OBJ = $(EXAMPLES:.c=)
|
|
NAMES = $(OBJ:$(EXAMPLE_DIR)/%=%)
|
|
|
|
.PHONY: all
|
|
|
|
all:
|
|
ifdef 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:"
|
|
@$(foreach example,$(NAMES),echo -n " $(example)";)
|
|
@echo
|
|
endif
|
|
|
|
example-%: $(BIN)/$(EXAMPLE_DIR)/%
|
|
LD_LIBRARY_PATH=$(BIN) $(BIN)/$(EXAMPLE_DIR)/$(EXAMPLE)
|
|
|
|
$(BIN)/%: %.c
|
|
@mkdir -p $(@D)
|
|
$(CC) $< $(LDFLAGS) $(CFLAGS) -o $@
|