Skip to content

Commit

Permalink
Make portable Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Mar 10, 2024
1 parent b168486 commit 3b232b2
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions GNUmakefile → Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
BIN = xhash
BINDIR = $(HOME)/bin
INSTALL:sh = type -p ginstall || type -p install

# Optionally create these hard-links
ALL = b2sum b3sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum
ALL = b2sum b3sum md5sum sha1sum sha256sum sha512sum

.PHONY: all
all: $(BIN)
Expand Down Expand Up @@ -29,20 +31,13 @@ gen:
@go mod init $(BIN)
@go mod tidy

euid = $(shell id -u)
ifeq ($(euid),0)
BINDIR = /usr/local/bin
else
BINDIR = $(HOME)/bin
endif

.PHONY: install
install: $(BIN)
@install -s -m 0755 $(BIN) $(BINDIR)
$(INSTALL) -s -m 0755 $(BIN) $(BINDIR)

.PHONY: uninstall
uninstall:
@rm -f $(BINDIR)/$(BIN)
rm -f $(BINDIR)/$(BIN)

$(ALL): $(BIN)
@for f in $(ALL) ; do ln -f $(BIN) $$f ; done
Expand All @@ -52,8 +47,8 @@ ALL: $(ALL)

.PHONY: install-all
install-all: $(ALL)
@for f in $(ALL) ; do install -m 0755 $$f $(BINDIR) ; done
for f in $(ALL) ; do $(INSTALL) -s -m 0755 $$f $(BINDIR) ; done

.PHONY: uninstall-all
uninstall-all:
@for f in $(ALL) ; do rm -vf $(BINDIR)/$$f ; done
for f in $(ALL) ; do rm -f $(BINDIR)/$$f ; done

0 comments on commit 3b232b2

Please sign in to comment.