all: cmds external

install: all
	cp bin/launcher /usr/local/bin/town
	cp bin/stats /town/bin/
	cp bin/contrib /town/bin/
	cp bin/request /town/bin/
	cp bin/appendkeyfile /town/bin/
	cp bin/createkeyfile /town/bin/
	cp bin/emailtouser /town/bin/
	cp bin/registeruser /town/bin/
	cp bin/help /town/bin/external/
	cp bin/welcome /town/bin/external/
	cp bin/signup /town/bin/external/

clean:
	rm -rf bin

external: bin/help bin/welcome bin/signup exthelpers

bin/help: external/cmd/help/main.go bin
	go build -o bin/help ./external/cmd/help

bin/welcome: external/cmd/welcome/main.go bin
	go build -o bin/welcome ./external/cmd/welcome

bin/signup: external/cmd/signup/main.go bin
	go build -o bin/signup ./external/cmd/signup

exthelpers: bin/appendkeyfile bin/createkeyfile bin/emailtouser bin/registeruser

bin/appendkeyfile: external/cmd/helpers/appendkeyfile/main.go bin
	go build -o bin/appendkeyfile ./external/cmd/helpers/appendkeyfile

bin/createkeyfile: external/cmd/helpers/createkeyfile/main.go bin
	go build -o bin/createkeyfile ./external/cmd/helpers/createkeyfile

bin/emailtouser: external/cmd/helpers/emailtouser/main.go bin
	go build -o bin/emailtouser ./external/cmd/helpers/emailtouser

bin/registeruser: external/cmd/helpers/registeruser/main.go bin
	go build -o bin/registeruser ./external/cmd/helpers/registeruser

cmds: bin/launcher bin/stats bin/contrib bin/request

bin/launcher: cmd/launcher/main.go bin
	go build -o bin/launcher ./cmd/launcher

bin/stats: cmd/stats/main.go bin
	go build -o bin/stats ./cmd/stats

bin/contrib: cmd/contrib/main.go bin
	go build -o bin/contrib ./cmd/contrib

bin/request: cmd/request/main.go bin
	go build -o bin/request ./cmd/request

bin:
	mkdir -p bin
