2017-06-16 13:05:37 +00:00
|
|
|
# Makefile for Anime Notifier
|
|
|
|
|
|
|
|
GOCMD=@go
|
|
|
|
GOBUILD=$(GOCMD) build
|
|
|
|
GOINSTALL=$(GOCMD) install
|
2018-03-21 19:22:57 +00:00
|
|
|
GOTEST=@./utils/test/go-test-color.sh
|
2017-06-16 13:05:37 +00:00
|
|
|
BUILDJOBS=@./jobs/build.sh
|
2017-06-16 13:38:10 +00:00
|
|
|
BUILDPATCHES=@./patches/build.sh
|
2017-07-17 20:50:14 +00:00
|
|
|
BUILDBOTS=@./bots/build.sh
|
2017-07-05 23:01:04 +00:00
|
|
|
TSCMD=@tsc
|
2017-06-16 13:21:01 +00:00
|
|
|
IPTABLES=@sudo iptables
|
2018-05-09 22:41:52 +00:00
|
|
|
IP6TABLES=@sudo ip6tables
|
2018-04-07 12:17:33 +00:00
|
|
|
PACK:=$(shell command -v pack 2> /dev/null)
|
|
|
|
RUN:=$(shell command -v run 2> /dev/null)
|
|
|
|
GOIMPORTS:=$(shell command -v goimports 2> /dev/null)
|
2019-04-19 06:38:33 +00:00
|
|
|
SERVICEFILE=/etc/systemd/system/animenotifier.service
|
2018-02-19 05:13:33 +00:00
|
|
|
|
|
|
|
# Determine the name of the platform
|
2017-11-08 11:11:20 +00:00
|
|
|
OSNAME=
|
|
|
|
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
OSNAME = WINDOWS
|
|
|
|
else
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
ifeq ($(UNAME_S),Linux)
|
|
|
|
OSNAME = LINUX
|
|
|
|
endif
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
|
|
OSNAME = OSX
|
|
|
|
endif
|
|
|
|
endif
|
2017-06-16 13:05:37 +00:00
|
|
|
|
2018-02-19 05:13:33 +00:00
|
|
|
# Build targets
|
2017-06-16 13:05:37 +00:00
|
|
|
server:
|
|
|
|
$(GOBUILD)
|
|
|
|
jobs:
|
|
|
|
$(BUILDJOBS)
|
2017-07-17 20:50:14 +00:00
|
|
|
bots:
|
|
|
|
$(BUILDBOTS)
|
2017-06-16 13:38:10 +00:00
|
|
|
patches:
|
|
|
|
$(BUILDPATCHES)
|
2017-07-05 23:01:04 +00:00
|
|
|
js:
|
|
|
|
$(TSCMD)
|
2017-06-16 13:05:37 +00:00
|
|
|
install:
|
|
|
|
$(GOINSTALL)
|
|
|
|
test:
|
2018-03-21 19:22:57 +00:00
|
|
|
$(GOTEST) github.com/animenotifier/notify.moe -v -cover
|
2017-06-16 13:05:37 +00:00
|
|
|
bench:
|
|
|
|
$(GOTEST) -bench .
|
2018-04-07 12:17:33 +00:00
|
|
|
pack:
|
|
|
|
go install github.com/aerogo/pack
|
|
|
|
run:
|
|
|
|
go install github.com/aerogo/run
|
|
|
|
goimports:
|
|
|
|
go install golang.org/x/tools/cmd/goimports
|
2019-04-19 06:38:33 +00:00
|
|
|
service:
|
|
|
|
sudo cp systemd.service $(SERVICEFILE)
|
|
|
|
sudo sed -i "s|MAKEFILE_USER|$(USER)|g" $(SERVICEFILE)
|
|
|
|
sudo sed -i "s|MAKEFILE_PWD|$(PWD)|g" $(SERVICEFILE)
|
|
|
|
sudo sed -i "s|MAKEFILE_EXEC|$(PWD)/notify.moe|g" $(SERVICEFILE)
|
|
|
|
sudo systemctl daemon-reload
|
|
|
|
@echo -e "\nYou can now start the service using:\n\nsudo systemctl start animenotifier"
|
2017-07-05 23:51:42 +00:00
|
|
|
tools:
|
2017-11-08 13:54:43 +00:00
|
|
|
ifeq ($(OSNAME),OSX)
|
|
|
|
brew install coreutils
|
|
|
|
endif
|
2018-04-07 12:17:33 +00:00
|
|
|
ifndef GOIMPORTS
|
|
|
|
@make goimports
|
|
|
|
endif
|
|
|
|
ifndef PACK
|
|
|
|
@make pack
|
|
|
|
endif
|
|
|
|
ifndef RUN
|
|
|
|
@make run
|
|
|
|
endif
|
2017-06-16 13:25:30 +00:00
|
|
|
versions:
|
|
|
|
@go version
|
2018-04-07 12:17:33 +00:00
|
|
|
$(TSCMD) --version
|
2017-06-16 13:29:09 +00:00
|
|
|
assets:
|
2017-07-05 23:01:04 +00:00
|
|
|
$(TSCMD)
|
2017-06-16 13:29:09 +00:00
|
|
|
@pack
|
2017-06-16 13:38:10 +00:00
|
|
|
clean:
|
2017-06-16 13:42:22 +00:00
|
|
|
find . -type f | xargs file | grep "ELF.*executable" | awk -F: '{print $1}' | xargs rm
|
2019-04-14 10:04:08 +00:00
|
|
|
rm -rf ./components
|
|
|
|
find . -type f | grep /scripts/ | grep .js | xargs rm
|
2017-06-16 13:21:01 +00:00
|
|
|
ports:
|
2017-11-08 11:11:20 +00:00
|
|
|
ifeq ($(OSNAME),LINUX)
|
2017-06-16 13:21:01 +00:00
|
|
|
$(IPTABLES) -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 4000
|
|
|
|
$(IPTABLES) -t nat -A OUTPUT -o lo -p tcp --dport 443 -j REDIRECT --to-port 4001
|
2018-05-09 22:41:52 +00:00
|
|
|
$(IP6TABLES) -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 4000
|
|
|
|
$(IP6TABLES) -t nat -A OUTPUT -o lo -p tcp --dport 443 -j REDIRECT --to-port 4001
|
2017-11-08 11:11:20 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(OSNAME),OSX)
|
|
|
|
@echo "rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 4001" | sudo pfctl -ef -
|
|
|
|
endif
|
|
|
|
browser:
|
|
|
|
ifeq ($(OSNAME),LINUX)
|
|
|
|
@google-chrome --ignore-certificate-errors
|
|
|
|
endif
|
|
|
|
ifeq ($(OSNAME),OSX)
|
|
|
|
@/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --ignore-certificate-errors
|
|
|
|
endif
|
2018-04-07 12:17:33 +00:00
|
|
|
all: tools assets server bots jobs patches
|
2017-06-16 13:05:37 +00:00
|
|
|
|
2018-04-07 12:17:33 +00:00
|
|
|
.PHONY: tools assets server bots jobs patches ports clean versions
|