diff --git a/Makefile b/Makefile index 859461984..8ee9e7dc6 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,22 @@ endif git -C site commit -m '$(GITHUB_REF:refs/tags/v%=%)' index.html .PHONY: site-bump - .PHONY: manpages manpages: go run ./cmd/gen-docs --man-page --doc-path ./share/man/man1/ + +DESTDIR := +prefix := /usr/local +bindir := ${prefix}/bin +mandir := ${prefix}/share/man + +.PHONY: install +install: bin/gh manpages + install -d ${DESTDIR}${bindir} + install -m755 bin/gh ${DESTDIR}${bindir}/ + install -d ${DESTDIR}${mandir}/man1 + install -m644 ./share/man/man1/* ${DESTDIR}${mandir}/man1/ + +.PHONY: uninstall +uninstall: + rm -f ${DESTDIR}${bindir}/gh ${DESTDIR}${mandir}/man1/gh.1 ${DESTDIR}${mandir}/man1/gh-*.1 diff --git a/docs/source.md b/docs/source.md index fc90ef94f..1c6a8470a 100644 --- a/docs/source.md +++ b/docs/source.md @@ -15,16 +15,18 @@ $ cd gh-cli ``` -2. Build the project - - ``` - $ make - ``` - -3. Move the resulting `bin/gh` executable to somewhere in your PATH +2. Build and install ```sh - $ sudo mv ./bin/gh /usr/local/bin/ + # installs to '/usr/local' by default; sudo may be required + $ make install ``` -4. Run `gh version` to check if it worked. + To install to a different location: + ```sh + $ make install prefix=/path/to/gh + ``` + + Make sure that the `${prefix}/bin` directory is in your PATH. + +3. Run `gh version` to check if it worked.