SOURCES=$(shell find -name '*.cr')

LDFLAGS=
DESTDIR=/usr

BUILD_DIR=_build

all: build

$(BUILD_DIR):
	mkdir -p $(BUILD_DIR)

$(BUILD_DIR)/kathmandu_time: $(BUILD_DIR) $(SOURCES)
	crystal build $(LDFLAGS) src/kathmandu_time.cr -o $(BUILD_DIR)/kathmandu_time

build: $(BUILD_DIR)/kathmandu_time

build-release: LDFLAGS=--release --no-debug
build-release: build

install: build
	install -m 0755 -o root -g root \
		$(BUILD_DIR)/kathmandu_time \
		$(DESTDIR)/bin/kathmandu_time

spec:
	crystal spec

test: spec

run:
	crystal run src/kathmandu_time.cr

clean:
	rm -f $(BUILD_DIR)/kathmandu_time