include env.sh ifndef STATUS_DB_DRIVER export STATUS_DB_DRIVER:=sqlite3 endif ifndef STATUS_DB_CREDENTIALS export STATUS_DB_CREDENTIALS:=../db/status.db endif ifndef STATUS_DB_IMPORT_DRIVER export STATUS_DB_IMPORT_DRIVER:=github.com/mattn/go-sqlite3 endif ifndef STATUS_REDIS_SERVER export STATUS_REDIS_SERVER:=127.0.0.1 endif ifndef STATUS_REDIS_PORT export STATUS_REDIS_PORT:=6379 endif ifndef STATUS_HTTP_IP export STATUS_HTTP_IP:=127.0.0.1 endif ifndef STATUS_HTTP_PORT export STATUS_HTTP_PORT:=8080 endif IMPORT_FILE:=./import.go APP:=statuspage all: kill build run clean: kill @(rm $(IMPORT_FILE) 2>/dev/null && echo "Removing import file..." ) || true @(rm $(STATUS_DB_CREDENTIALS) 2>/dev/null && echo "Removing sqlite3 database..." ) || true @(rm ../$(APP).tar.gz 1>&2 2>/dev/null echo && "Removing tar archiv...") || true @(rm $(APP) && echo "Removing binary ($(APP))...") || true @echo "Done." build: import go build -o statuspage run: ./$(APP) & kill: @echo "Killing running instances..." @pkill $(APP) || true create_import: @if [ ! -f $(IMPORT_FILE) ] ; \ then \ echo "package main" > $(IMPORT_FILE) ; \ fi import: @if [ ! -f $(IMPORT_FILE) ] ; \ then \ echo "package main" > $(IMPORT_FILE) ; \ echo "import _ \"$(STATUS_DB_IMPORT_DRIVER)\"" >> $(IMPORT_FILE) ; \ fi sqlite3: create_import @echo "import _ \"github.com/mattn/go-sqlite3\"" >> $(IMPORT_FILE) mysql: create_import @echo "import _ \"github.com/go-sql-driver/mysql\"" >> $(IMPORT_FILE) postgresql: create_import @echo "import _ \"github.com/lib/pq\"" >> $(IMPORT_FILE) database_all: sqlite3 mysql postgresql @echo "Created import file for all databases." pack: @cd .. && \ tar czf $(APP).tar.gz app/$(APP) app/env.sh app/Makefile views static db 2>/dev/null && \ echo "../$(APP).tar.gz is ready." || \ (echo "Run \"make build\" first." && exit 1) test: go test -v -race -tags general test_all: import go test -v -race -tags all test_dependencies: import go test -v -race -tags dep