ptk/examples/Makefile

25 lines
535 B
Makefile
Raw Normal View History

LDFLAGS = -L$(BIN) -lptk
EXAMPLE_DIR = examples
EXAMPLES = $(shell find $(EXAMPLE_DIR) -type f -name "*.c")
NAMES = $($(EXAMPLES:.c=):$(EXAMPLE_DIR)/%=%)
.PHONY: all
all:
ifdef EXAMPLE
$(MAKE) -f $(EXAMPLE_DIR)/Makefile $(BIN)/$(EXAMPLE_DIR)/$(EXAMPLE)
$(BIN)/$(EXAMPLE_DIR)/$(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
$(BIN)/%: %.c
@mkdir -p $(@D)
$(CC) $< $(LDFLAGS) $(CFLAGS) -o $@