smithy

commit 8fc1697ba97b7bc463a169f90fe8f2f2bbade514

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

Add install/uninstall rules to Makefile

Also add a rule to generate a sample config file which during the
install process will be installed as a reference for the user

 .gitignore | 2 ++
 Makefile | 25 +++++++++++++++++++++++--
 README.md | 19 +++++++++++++++++--


diff --git a/.gitignore b/.gitignore
index 7146a403d6fc4cc9749a2243e53996064d0a9702..28bf40089f5f6c0aca207626b2d6a2bb2043152f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
 repos
 bin
 pkg/statik
+smithy.yml
+smithy




diff --git a/Makefile b/Makefile
index e5f42c4b9b7dad9cc7e7207bdfe7d015dea6f89e..e4628a1e7387410d5e1b3f9bd9cca7d61ccdca3e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,32 @@
 BUILD_VERSION ?= $(shell git describe --always --abbrev=40 --dirty)
 
+PREFIX?=/usr/local
+BINDIR?=$(PREFIX)/bin
+SHAREDIR?=$(PREFIX)/share/smithy
+
 LDFLAGS="-X github.com/honza/smithy/cmd.SmithyVersion=${BUILD_VERSION}"
 MODCACHE := $(shell go env GOMODCACHE)
 
 export CGO_ENABLED=0
 
-all: bin/statik
+all: smithy smithy.yml
+
+smithy: bin/statik
 	bin/statik -src=include -dest=pkg -f -m
 	go build -ldflags $(LDFLAGS) -o smithy main.go
 
+smithy.yml:
+	./smithy generate > smithy.yml
+
+install: all
+	mkdir -m755 -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(SHAREDIR)
+	install -m755 smithy $(DESTDIR)$(BINDIR)/smithy
+	install -m644 smithy.yml $(DESTDIR)$(SHAREDIR)/smithy.yml
+
+uninstall: all
+	rm -r $(DESTDIR)$(BINDIR)/smithy
+	rm -fr $(DESTDIR)$(SHAREDIR)
+
 bin/statik:
 	mkdir -p bin
 	go mod download
@@ -18,5 +36,8 @@ gofmt:
 	go fmt ./pkg/... ./cmd/...
 
 clean:
-	rm smithy
+	rm smithy smithy.yml
 	rm -rf pkg/statik
+
+.PHONY:
+	smithy smithy.yml clean




diff --git a/README.md b/README.md
index bb5511d2a7e2ea92272ee7fbbf222f0b0a164c62..5bfb063776fa19c4c29515b9b2caf559ab05e728 100644
--- a/README.md
+++ b/README.md
@@ -30,13 +30,28 @@
 Installing
 -------------------------------------------------------------------------------
 
+We provide a make rule for installing/uninstall smithy. It will also install a
+sample configuration file at `/usr/local/share/smithy/smithy.yml` that you can
+later use as a guide.
+
 ```
+$ make install
+$ make uninstall
+```
+
+Configuration
+-------------------------------------------------------------------------------
+
+You can generate a sample configuration by issuing `make smithy.yml` command or
+directly using the smithy binary:
+
+```
+$ make smithy.yml # will generate a smithy.yml file
 $ smithy generate > config.yml
 $ smithy serve --config config.yml
 ```
 
-Configuration
--------------------------------------------------------------------------------
+A sample configuration can be:
 
 ``` yaml
 title: Smithy, a lightweight git forge