# $Id: Makefile 30 2019-10-27 18:46:09Z umaxx $
# Copyright (c) 2018-2019 Joerg Jung <mail@umaxx.net>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

GO=go
INSTALL?=install
RM?=rm -f

PLATFORM!=uname
PLATFORM?=$(shell uname)

PREFIX_Darwin=/usr
PREFIX_Linux=/usr
PREFIX_OpenBSD=/usr/local
PREFIX?=$(PREFIX_$(PLATFORM))

LIBEXECDIR?=$(PREFIX)/libexec/smtpd
MANDIR_Darwin=$(PREFIX)/share/man
MANDIR_Linux=$(PREFIX)/share/man
MANDIR_OpenBSD=$(PREFIX)/man
MANDIR?=$(MANDIR_$(PLATFORM))

all: filter-dnsbl

filter-dnsbl: filter-dnsbl.go
	$(GO) build -x filter-dnsbl.go

clean:
	$(GO) clean
	$(RM) filter-dnsbl

install: filter-dnsbl
	$(INSTALL) -m0755 filter-dnsbl $(LIBEXECDIR)
	$(INSTALL) -m0444 filter-dnsbl.1 $(MANDIR)/man1

uninstall:
	$(RM) $(LIBEXECDIR)/filter-dnsbl $(MANDIR)/man1/filter-dnsbl.1

style:
	$(GO) fix filter-dnsbl.go
	$(GO) vet -v filter-dnsbl.go
	gofmt -d -s -w filter-dnsbl.go

.PHONY: all clean install uninstall style
