CC = gcc
CFLAGS = -Wall -std=c99
TARGET = selection

file ?= sample.in

all: $(TARGET)

build: $(TARGET)

$(TARGET): main.c
	$(CC) $(CFLAGS) main.c -o $(TARGET)

run:
	@./$(TARGET) $(file)

clean:
	rm -f $(TARGET)

help:
	@echo "Usage:"
	@echo "  make              - Compile the selection program"
	@echo "  make run          - Run with sample.in (default)"
	@echo "  make run file=<filename>"
	@echo "  make clean        - Remove the selection executable"
	
.PHONY: all run clean help build