SHELL := /bin/bash SOURCE_DIR := scribbled WATCH_FILES := $(shell find -type f -iname "*.go" -or -iname "*.html") GO_FILES := $(shell find $(SOURCE_DIR) -type f -iname "*.go") APP := scribbled PID := /tmp/scribbled.pid CONFIG_FILE := config.json TEMPLATE_DIR := templates all: run build serve build: $(APP) cd $(SOURCE_DIR) && go build -o $(APP) $(APP) := $(GO_FILES) run: kill $(CONFIG_FILE) @#PORT=8765 $(SOURCE_DIR)/$(APP) -config $(CONFIG_FILE) & echo $$! > $(PID) @$(SOURCE_DIR)/$(APP) -config $(CONFIG_FILE) & echo $$! > $(PID) kill: @kill `cat $(PID)` 2>/dev/null || true serve: @#@while true; do inotifywait -r -e modify $(WATCH_FILES) && make restart; done @while true; do inotifywait --excludei ".*\.swp" -r -e modify $(SOURCE_DIR) $(TEMPLATE_DIR) 1>/dev/null 2>&1 && make restart 1>/dev/null; done restart: kill run @echo "Restartet $(APP)" rebuild: kill build run config: $(SOURCE_DIR)/$(APP) -genconfig $(CONFIG_FILE) $(CONFIG_FILE): $(SOURCE_DIR)/$(APP) -genconfig $(CONFIG_FILE) clean: $(RM) $(RMFLAGS) $(SOURCE_DIR)/$(APP) .PHONY: $(APP)