.PHONY: all build clean daemon client install

all: build

build: daemon client

daemon:
	go build -o cremotedaemon ./daemon/cmd/cremotedaemon

client:
	go build -o cremote .

clean:
	rm -f cremote cremotedaemon

install: build
	@if [ -n "$(GOPATH)" ] && [ -d "$(GOPATH)/bin" ]; then \
		echo "Installing to $(GOPATH)/bin/"; \
		cp cremote $(GOPATH)/bin/; \
		cp cremotedaemon $(GOPATH)/bin/; \
	else \
		echo "GOPATH not set or $(GOPATH)/bin doesn't exist, installing to ~/.local/bin/"; \
		mkdir -p ~/.local/bin; \
		cp cremote ~/.local/bin/; \
		cp cremotedaemon ~/.local/bin/; \
	fi
