Skip to content

Commit

Permalink
Follow GNU coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
roehling committed Mar 7, 2020
1 parent 09e911b commit 8a25b51
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,46 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
ifneq ($(PREFIX),)
prefix ?= $(PREFIX)
endif
ifneq ($(DESTDIR),)
prefix ?= /usr
endif
ifneq ($(shell id -u),0)
ifneq ($(if $(DESTDIR),0,$(shell id -u)),0)
# If the current user is not root and DESTDIR is not set, install to user home
prefix ?= $(HOME)/.local
else
prefix ?= /usr/local
endif

bindir ?= bin
mandir ?= share/man/man1
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/bin
mandir ?= $(prefix)/share/man
man1dir ?= $(mandir)/man1

help:
@echo
@echo "* Run 'make install' to install the script to $(prefix)/$(bindir)"
@echo "* Run 'make install' to install the script to $(bindir)"
@echo "* Run 'make uninstall' to uninstall the script again."
@echo "* You can pick a different install prefix than $(prefix) with"
@echo " make prefix=/other/prefix install"
@echo

install: $(DESTDIR)$(prefix)/$(bindir)/git-archive-all $(DESTDIR)$(prefix)/$(mandir)/git-archive-all.1.gz
all:

clean:

install: $(DESTDIR)$(bindir)/git-archive-all $(DESTDIR)$(man1dir)/git-archive-all.1.gz

uninstall:
rm $(DESTDIR)$(prefix)/$(bindir)/git-archive-all
rm -f $(DESTDIR)$(prefix)/$(mandir)/git-archive-all.1.gz
rm $(DESTDIR)$(bindir)/git-archive-all
rm -f $(DESTDIR)$(man1dir)/git-archive-all.1*

check:
./test.bats

$(DESTDIR)$(prefix)/$(bindir)/git-archive-all: git-archive-all $(DESTDIR)$(prefix)/$(bindir)
install -m755 $< $(DESTDIR)$(prefix)/$(bindir)
$(DESTDIR)$(bindir)/git-archive-all: git-archive-all $(DESTDIR)$(bindir)
install -m755 $< $(DESTDIR)$(bindir)

$(DESTDIR)$(prefix)/$(mandir)/git-archive-all.1.gz: git-archive-all $(DESTDIR)$(prefix)/$(mandir)
$(DESTDIR)$(man1dir)/git-archive-all.1.gz: git-archive-all $(DESTDIR)$(man1dir)
pod2man -r "" -c "Git Manual" $< > $(basename $@) && gzip -9fn $(basename $@)

$(DESTDIR)$(prefix)/$(bindir) $(DESTDIR)$(prefix)/$(mandir):
$(DESTDIR)$(bindir) $(DESTDIR)$(man1dir):
mkdir -p $@

.PHONY: install uninstall
.PHONY: all check clean help install uninstall

0 comments on commit 8a25b51

Please sign in to comment.