First go at a makefile, woo-hoo!
This commit is contained in:
parent
74ada2b8ed
commit
7ed2b46b32
|
@ -0,0 +1,51 @@
|
||||||
|
BINARY := bombadillo
|
||||||
|
man1dir := /usr/local/share/man/man1
|
||||||
|
#PKGS := $(shell go list ./... |grep -v /vendor)
|
||||||
|
VERSION := $(shell git describe --tags 2> /dev/null)
|
||||||
|
BUILD := $(shell date)
|
||||||
|
GOPATH ?= $(HOME)/go
|
||||||
|
GOBIN ?= ${GOPATH}/bin
|
||||||
|
BUILD_PATH ?= ${GOBIN}
|
||||||
|
|
||||||
|
# If VERSION is empty or not deffined use the contents of the VERSION file
|
||||||
|
ifndef VERSION
|
||||||
|
VERSION := $(shell cat ./VERSION)
|
||||||
|
endif
|
||||||
|
|
||||||
|
LDFLAGS :=
|
||||||
|
ifdef CONF_PATH
|
||||||
|
LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD} -X main.conf_path${conf_path}"
|
||||||
|
else
|
||||||
|
LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD}"
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test:
|
||||||
|
@echo ${LDFLAGS}
|
||||||
|
@echo ${VERSION}
|
||||||
|
@echo ${BUILD_PATH}
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build:
|
||||||
|
@go build ${LDFLAGS} -o ${BINARY}
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: install-man
|
||||||
|
@go build ${LDFLAGS} -o ${BUILD_PATH}/${BINARY}
|
||||||
|
|
||||||
|
.PHONY: install-man
|
||||||
|
install-man: bombadillo.1
|
||||||
|
@gzip -k ./bombadillo.1
|
||||||
|
@install -d ${man1dir}
|
||||||
|
@install -m 0644 ./bombadillo.1.gz ${man1dir}
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
@go clean -i
|
||||||
|
@rm ./bombadillo.1.gz 2> /dev/null
|
||||||
|
|
||||||
|
.PHONY: uninstall
|
||||||
|
uninstall: clean
|
||||||
|
@rm -f ${man1dir}/bombadillo.1.gz
|
||||||
|
@echo Removing ${BINARY}
|
||||||
|
@rm -f ${BUILD_PATH}/${BINARY}
|
14
main.go
14
main.go
|
@ -32,7 +32,9 @@ import (
|
||||||
"tildegit.org/sloum/mailcap"
|
"tildegit.org/sloum/mailcap"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "2.0.0"
|
var version string
|
||||||
|
var build string
|
||||||
|
var conf_path string
|
||||||
|
|
||||||
var bombadillo *client
|
var bombadillo *client
|
||||||
var helplocation string = "gopher://colorfield.space:70/1/bombadillo-info"
|
var helplocation string = "gopher://colorfield.space:70/1/bombadillo-info"
|
||||||
|
@ -95,6 +97,11 @@ func lowerCaseOpt(opt, val string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfig() error {
|
func loadConfig() error {
|
||||||
|
// If a compile time override exists for configlocation
|
||||||
|
// set it before loading the config.
|
||||||
|
if conf_path != "" {
|
||||||
|
bombadillo.Options["configlocation"] = conf_path
|
||||||
|
}
|
||||||
file, err := os.Open(bombadillo.Options["configlocation"] + "/.bombadillo.ini")
|
file, err := os.Open(bombadillo.Options["configlocation"] + "/.bombadillo.ini")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = saveConfig()
|
err = saveConfig()
|
||||||
|
@ -109,8 +116,9 @@ func loadConfig() error {
|
||||||
for _, v := range settings.Settings {
|
for _, v := range settings.Settings {
|
||||||
lowerkey := strings.ToLower(v.Key)
|
lowerkey := strings.ToLower(v.Key)
|
||||||
if lowerkey == "configlocation" {
|
if lowerkey == "configlocation" {
|
||||||
// The config should always be stored in home
|
// The config defaults to the home folder.
|
||||||
// folder. Users cannot really edit this value.
|
// Users cannot really edit this value. But
|
||||||
|
// a compile time override is available.
|
||||||
// It is still stored in the ini and as a part
|
// It is still stored in the ini and as a part
|
||||||
// of the options map.
|
// of the options map.
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue