# 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=" @echo -n "available examples:" @$(foreach example,$(NAMES),echo -n " $(example)";) @echo endif example-%: $(BIN)/$(EXAMPLE_DIR)/% $(BIN)/$(EXAMPLE_DIR)/$(EXAMPLE) $(BIN)/%: %.c @mkdir -p $(@D) $(CC) $< $(LDFLAGS) $(CFLAGS) -o $@