From bef73dfbafd6606bea435067bdaf2fe69ed20498 Mon Sep 17 00:00:00 2001 From: Justin Reichardt Date: Sun, 12 Jun 2022 20:10:47 -0500 Subject: [PATCH] Created a Makefile to build and install Also updated the Readme with instructions Added a version file so the version can be included in the build --- Makefile | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ Readme.md | 17 ++++++++++++++ version | 1 + 3 files changed, 84 insertions(+) create mode 100644 Makefile create mode 100644 version diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..66c245c --- /dev/null +++ b/Makefile @@ -0,0 +1,66 @@ +PREFIX=/usr/local +EXEC_PREFIX=$(DESTDIR)$(PREFIX) +BINDIR=$(EXEC_PREFIX)/bin +DATAROOTDIR=$(DESTDIR)$(PREFIX)/share +DATADIR=$(DATAROOTDIR) +$MANDIR=$DATAROOTDIR/man +#$INFODIR=$DATAROOTDIR/info +#$DOCDIR=$DATAROOTDIR/doc +VERSION=`cat version` +PROJROOT=$(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +TARBALLPREFIX=rhosts-$(VERSION) +TARBALLNAME=$(TARBALLPREFIX).tar.gz +GOBUILDFLAGS= +GITOFF=0 + +build: + if [ ! -d $(PROJROOT)/build ]; then \ + mkdir -p $(PROJROOT)build/share/rhosts/systemd $(PROJROOT)build/bin \ + ;fi + + + cd $(PROJROOT)src && go build -o $(PROJROOT)build/bin/ $(GOBUILDFLAGS) ./ + cp -r $(PROJROOT)src/systemd $(PROJROOT)/build/share/rhosts/ +build-win: + if [ ! -d $(PROJROOT)/build ]; then \ + mkdir -p $(PROJROOT)build \ + ;fi + cd $(PROJROOT)src && GOOS=windows go build -o $(PROJROOT)build/ $(GOBUILDFLAGS) ./ +install: build + install -D $(PROJROOT)build/bin/rhosts $(BINDIR)/ + cp -r $(PROJROOT)build/share/rhosts $(DATADIR) + ln -s $(DATADIR)rhosts/systemd/rhosts.service /usr/lib/systemd/system/rhosts.service + ln -s $(DATADIR)rhosts/systemd/rhosts.path /usr/lib/systemd/system/rhosts.path + ln -s $(DATADIR)rhosts/systemd/rhosts.timer /usr/lib/systemd/system/rhosts.timer +uninstall: + if [ -f $(BINDIR)/rhosts ]; then \ + rm $(BINDIR)/rhosts \ + ;fi + if [ -d $(DATADIR)/rhosts ]; then \ + rm -r $(DATADIR)/rhosts \ + ;fi + if [ -h /usr/lib/systemd/system/rhosts.service ]; then \ + rm /usr/lib/systemd/system/rhosts.service \ + ;fi + if [ -h /usr/lib/systemd/system/rhosts.path ]; then \ + rm /usr/lib/systemd/system/rhosts.path \ + ;fi + if [ -h /usr/lib/systemd/system/rhosts.timer ]; then \ + rm /usr/lib/systemd/system/rhosts.timer \ + ;fi +clean: + if [ -d $(PROJROOT)build ]; then \ + rm -r $(PROJROOT)build \ + ;fi + if [ -f $(PROJROOT)$(TARBALLNAME) ]; then \ + rm $(PROJROOT)$(TARBALLNAME) \ + ;fi +dist: clean + if [ -d $(PROJROOT).git ] && [ $(GITOFF) = 0 ]; then \ + git archive --format=tar.gz -o $(PROJROOT)$(TARBALLNAME) --prefix=$(TARBALLPREFIX)/ `git branch --show-current` \ + ;else \ + mkdir $(PROJROOT)$(TARBALLPREFIX) && \ + find $(PROJECTROOT)* -maxdepth 0 -name $(TARBALLPREFIX) -prune -o -exec cp -r {} $(PROJROOT)$(TARBALLPREFIX)/ \; && \ + tar -czf $(PROJROOT)$(TARBALLNAME) -C $(PROJROOT) $(TARBALLPREFIX) && \ + rm -r $(PROJROOT)$(TARBALLPREFIX) \ + ;fi diff --git a/Readme.md b/Readme.md index 52019e1..b810b65 100644 --- a/Readme.md +++ b/Readme.md @@ -21,3 +21,20 @@ Example: download=w3.site.xyz/location/to/config.txt # This is a whitelist entry whitelist=www.site.xyz + +## How to Install + +Build Dependencies: + +- make +- golang + +Linux/Systemd: + + make install + +Windows: + + make build-win + +The windows build can be performed on a Linux system and moved to Windows. diff --git a/version b/version new file mode 100644 index 0000000..ba66466 --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.0