summaryrefslogtreecommitdiff
path: root/app/Makefile
blob: 06aed05302d161593fa1db37d330712c2434db0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
	@echo "Removing import file..."
	@rm $(IMPORT_FILE) || true
	@echo "Removing sqlite3 database..."
	@rm $(STATUS_DB_CREDENTIALS) || true
	@echo "Removing binary..."
	@rm $(APP)
	@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: create_import sqlite3 mysql postgresql