Skip to content

Commit 8fc1697

Browse files
pedrolucasphonza
authored andcommitted
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
1 parent 75dc900 commit 8fc1697

3 files changed

Lines changed: 42 additions & 4 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
repos
22
bin
33
pkg/statik
4+
smithy.yml
5+
smithy

‎Makefile‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
BUILD_VERSION ?= $(shell git describe --always --abbrev=40 --dirty)
22

3+
PREFIX?=/usr/local
4+
BINDIR?=$(PREFIX)/bin
5+
SHAREDIR?=$(PREFIX)/share/smithy
6+
37
LDFLAGS="-X github.com/honza/smithy/cmd.SmithyVersion=${BUILD_VERSION}"
48
MODCACHE := $(shell go env GOMODCACHE)
59

610
export CGO_ENABLED=0
711

8-
all: bin/statik
12+
all: smithy smithy.yml
13+
14+
smithy: bin/statik
915
bin/statik -src=include -dest=pkg -f -m
1016
go build -ldflags $(LDFLAGS) -o smithy main.go
1117

18+
smithy.yml:
19+
./smithy generate > smithy.yml
20+
21+
install: all
22+
mkdir -m755 -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(SHAREDIR)
23+
install -m755 smithy $(DESTDIR)$(BINDIR)/smithy
24+
install -m644 smithy.yml $(DESTDIR)$(SHAREDIR)/smithy.yml
25+
26+
uninstall: all
27+
rm -r $(DESTDIR)$(BINDIR)/smithy
28+
rm -fr $(DESTDIR)$(SHAREDIR)
29+
1230
bin/statik:
1331
mkdir -p bin
1432
go mod download
@@ -18,5 +36,8 @@ gofmt:
1836
go fmt ./pkg/... ./cmd/...
1937

2038
clean:
21-
rm smithy
39+
rm smithy smithy.yml
2240
rm -rf pkg/statik
41+
42+
.PHONY:
43+
smithy smithy.yml clean

‎README.md‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,29 @@ $ ./smithy --help
3030
Installing
3131
-------------------------------------------------------------------------------
3232

33+
We provide a make rule for installing/uninstall smithy. It will also install a
34+
sample configuration file at `/usr/local/share/smithy/smithy.yml` that you can
35+
later use as a guide.
36+
3337
```
34-
$ smithy generate > config.yml
35-
$ smithy serve --config config.yml
38+
$ make install
39+
$ make uninstall
3640
```
3741

3842
Configuration
3943
-------------------------------------------------------------------------------
4044

45+
You can generate a sample configuration by issuing `make smithy.yml` command or
46+
directly using the smithy binary:
47+
48+
```
49+
$ make smithy.yml # will generate a smithy.yml file
50+
$ smithy generate > config.yml
51+
$ smithy serve --config config.yml
52+
```
53+
54+
A sample configuration can be:
55+
4156
``` yaml
4257
title: Smithy, a lightweight git forge
4358
description: Publish your git repositories with ease

0 commit comments

Comments
 (0)