summaryrefslogtreecommitdiff
path: root/app/Makefile
diff options
context:
space:
mode:
authorHorus32015-02-20 23:43:36 +0100
committerHorus32015-02-20 23:43:36 +0100
commitc92989a8fc738094b205094a1bdd458a40c23d9c (patch)
tree45910c30216c81912d981e467582278c4fa35143 /app/Makefile
parenta8d9e02831d4b01e47f24a30144b5522c03b2b8c (diff)
downloadstatuspage-c92989a8fc738094b205094a1bdd458a40c23d9c.tar.gz
Add more targets for make, env.sh and check for configuration.
Diffstat (limited to 'app/Makefile')
-rw-r--r--app/Makefile39
1 files changed, 32 insertions, 7 deletions
diff --git a/app/Makefile b/app/Makefile
index 49e8b5d..06aed05 100644
--- a/app/Makefile
+++ b/app/Makefile
@@ -1,3 +1,5 @@
+include env.sh
+
ifndef STATUS_DB_DRIVER
export STATUS_DB_DRIVER:=sqlite3
endif
@@ -20,7 +22,8 @@ ifndef STATUS_HTTP_PORT
export STATUS_HTTP_PORT:=8080
endif
-IMPORT_FILE:=import.go
+IMPORT_FILE:=./import.go
+APP:=statuspage
all: kill build run
@@ -30,17 +33,39 @@ clean: kill
@echo "Removing sqlite3 database..."
@rm $(STATUS_DB_CREDENTIALS) || true
@echo "Removing binary..."
- @rm statuspage
+ @rm $(APP)
@echo "Done."
-build:
- @echo "package main" > $(IMPORT_FILE)
- @echo "import (_ \"$(STATUS_DB_IMPORT_DRIVER)\")" >> $(IMPORT_FILE)
+build: import
go build -o statuspage
run:
- ./statuspage &
+ ./$(APP) &
kill:
@echo "Killing running instances..."
- @pkill statuspage || true
+ @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