range-gen/Makefile

99 lines
3.3 KiB
Makefile
Raw Normal View History

2020-11-02 14:18:44 +00:00
# range-gen creates a list of scene ranges based on a set of frames from the video.
# Copyright (C) 2020 GenZmeY
# mailto: genzmey@gmail.com
#
# This file is part of range-gen.
#
# range-gen is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2020-11-02 08:29:11 +00:00
NAME = range-gen
VERSION = dev_$(shell date +%F_%T)
GOCMD = go
LDFLAGS := "$(LDFLAGS) -X 'main.Version=$(VERSION)'"
GOBUILD = $(GOCMD) build -ldflags=$(LDFLAGS)
2020-11-02 14:04:58 +00:00
SRCMAIN = ./cmd/$(NAME)
2020-11-02 08:29:11 +00:00
BINDIR = bin
BIN = $(BINDIR)/$(NAME)
2020-11-02 14:04:58 +00:00
README = ./doc/README
LICENSE = LICENSE
2020-11-02 08:29:11 +00:00
PREFIX = /usr
2020-11-02 14:04:58 +00:00
.PHONY: all prep build doc check-build freebsd-386 darwin-386 linux-386 windows-386 freebsd-amd64 darwin-amd64 linux-amd64 windows-amd64 compile install check-install uninstall clean
2020-11-02 02:20:06 +00:00
all: build
prep: clean
2020-11-02 08:29:11 +00:00
go mod init; go mod tidy
2020-11-02 02:20:06 +00:00
mkdir $(BINDIR)
build: prep
$(GOBUILD) -o $(BIN) $(SRCMAIN)
2020-11-02 14:04:58 +00:00
doc: check-build
test -d ./doc || mkdir ./doc
$(BIN) --help > ./doc/README
2020-11-02 02:20:06 +00:00
check-build:
test -e $(BIN)
freebsd-386: prep
GOOS=freebsd GOARCH=386 $(GOBUILD) -o $(BIN)-freebsd-386 $(SRCMAIN)
darwin-386: prep
GOOS=darwin GOARCH=386 $(GOBUILD) -o $(BIN)-darwin-386 $(SRCMAIN)
linux-386: prep
GOOS=linux GOARCH=386 $(GOBUILD) -o $(BIN)-linux-386 $(SRCMAIN)
windows-386: prep
GOOS=windows GOARCH=386 $(GOBUILD) -o $(BIN)-windows-386.exe $(SRCMAIN)
freebsd-amd64: prep
GOOS=freebsd GOARCH=amd64 $(GOBUILD) -o $(BIN)-freebsd-amd64 $(SRCMAIN)
darwin-amd64: prep
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BIN)-darwin-amd64 $(SRCMAIN)
linux-amd64: prep
GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BIN)-linux-amd64 $(SRCMAIN)
windows-amd64: prep
GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BIN)-windows-amd64.exe $(SRCMAIN)
compile: freebsd-386 darwin-386 linux-386 windows-386 freebsd-amd64 darwin-amd64 linux-amd64 windows-amd64
2020-11-02 14:04:58 +00:00
install: check-build doc
install -m 755 -d $(PREFIX)/bin/
install -m 755 $(BIN) $(PREFIX)/bin/
install -m 755 -d $(PREFIX)/share/licenses/$(NAME)/
install -m 644 $(LICENSE) $(PREFIX)/share/licenses/$(NAME)/
install -m 755 -d $(PREFIX)/share/licenses/$(NAME)/go-perceptualhash
install -m 644 ./third_party/go-perceptualhash/LICENSE $(PREFIX)/share/licenses/$(NAME)/go-perceptualhash
install -m 755 -d $(PREFIX)/share/doc/$(NAME)/
install -m 644 $(README) $(PREFIX)/share/doc/$(NAME)/
2020-11-02 02:20:06 +00:00
check-install:
2020-11-02 14:04:58 +00:00
test -e $(PREFIX)/bin/$(NAME) || \
test -d $(PREFIX)/share/licenses/$(NAME) || \
test -d $(PREFIX)/share/doc/$(NAME)
2020-11-02 02:20:06 +00:00
uninstall: check-install
rm -f $(PREFIX)/bin/$(NAME)
2020-11-02 14:04:58 +00:00
rm -rf $(PREFIX)/share/licenses/$(NAME)
rm -rf $(PREFIX)/share/doc/$(NAME)
2020-11-02 02:20:06 +00:00
clean:
rm -rf $(BINDIR)