Skip to content

Commit faa1e44

Browse files
authored
Merge pull request cli#2455 from ismaell/install-target
Add make (un)install targets for POSIX systems Fixes cli#293
2 parents 34d549e + 6f689ff commit faa1e44

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,22 @@ endif
5858
git -C site commit -m '$(GITHUB_REF:refs/tags/v%=%)' index.html
5959
.PHONY: site-bump
6060

61-
6261
.PHONY: manpages
6362
manpages:
6463
go run ./cmd/gen-docs --man-page --doc-path ./share/man/man1/
64+
65+
DESTDIR :=
66+
prefix := /usr/local
67+
bindir := ${prefix}/bin
68+
mandir := ${prefix}/share/man
69+
70+
.PHONY: install
71+
install: bin/gh manpages
72+
install -d ${DESTDIR}${bindir}
73+
install -m755 bin/gh ${DESTDIR}${bindir}/
74+
install -d ${DESTDIR}${mandir}/man1
75+
install -m644 ./share/man/man1/* ${DESTDIR}${mandir}/man1/
76+
77+
.PHONY: uninstall
78+
uninstall:
79+
rm -f ${DESTDIR}${bindir}/gh ${DESTDIR}${mandir}/man1/gh.1 ${DESTDIR}${mandir}/man1/gh-*.1

docs/source.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515
$ cd gh-cli
1616
```
1717

18-
2. Build the project
18+
2. Build and install
1919

20-
```
21-
$ make
20+
```sh
21+
# installs to '/usr/local' by default; sudo may be required
22+
$ make install
2223
```
2324

24-
3. Move the resulting `bin/gh` executable to somewhere in your PATH
25-
25+
To install to a different location:
2626
```sh
27-
$ sudo mv ./bin/gh /usr/local/bin/
27+
$ make install prefix=/path/to/gh
2828
```
2929

30-
4. Run `gh version` to check if it worked.
30+
Make sure that the `${prefix}/bin` directory is in your PATH.
31+
32+
3. Run `gh version` to check if it worked.

0 commit comments

Comments
 (0)