GO ?= go
BUNDLE ?= bundle
SPHINX_BUILD ?= sphinx-build
OUTPUT ?= rtcord-v81
INSTALL_DIR ?= /srv/rtcord

.PHONY: all build frontend backend docs install clean

all: build

build: frontend backend

frontend:
	rm -rf public/assets public/admin public/admin-warnings public/account-warnings public/conversations public/home public/invite public/server
	$(BUNDLE) exec jekyll build --source site --destination public

backend:
	$(GO) build -o $(OUTPUT) .

docs:
	$(SPHINX_BUILD) -W -b html DOCUMENTATION DOCUMENTATION/_build/html

install: build
	@echo "Installing into $(INSTALL_DIR)..."
	mkdir -p $(INSTALL_DIR)
	cp $(OUTPUT) $(INSTALL_DIR)/
	cp -r public/ $(INSTALL_DIR)/

clean:
	rm -rf public _site DOCUMENTATION/_build $(OUTPUT)
