-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
115 lines (86 loc) · 2.52 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
VERSION = $(shell grep -E '^\#define\s+VERSION' smf-spf.c | cut -d\" -f2)
CC = gcc
PREFIX = /usr/local
SBINDIR = $(PREFIX)/sbin
DATADIR = /var/run/smfs
CONFDIR = /etc/mail/smfs
USER = smfs
GROUP = smfs
CFLAGS = -O2 -D_REENTRANT -fomit-frame-pointer -I/usr/local/include
# Linux
LDFLAGS = -lmilter -lpthread -L/usr/lib/libmilter -L/usr/local/lib -lspf2
# FreeBSD
#LDFLAGS = -lmilter -pthread -L/usr/local/lib -lspf2
# Solaris
#LDFLAGS = -lmilter -lpthread -lsocket -lnsl -lresolv -lspf2
# Sendmail v8.11
#LDFLAGS += -lsmutil
all: smf-spf
smf-spf: smf-spf.o
$(CC) -o smf-spf smf-spf.o $(LDFLAGS)
strip smf-spf
smf-spf.o: smf-spf.c
$(CC) $(CFLAGS) -c smf-spf.c
coverage: clean
$(CC) $(CFLAGS) -c smf-spf.c -coverage
$(CC) -o smf-spf smf-spf.o $(LDFLAGS) -lgcov
strip smf-spf
showcov:
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info 'tests/*' '/usr/*' --output-file coverage.info
genhtml coverage.info --output-directory out
lcov --list coverage.info
clean:
rm -f smf-spf.o smf-spf smf.spf.gcno sample coverage.info smf-spf.gc*
rm -rf ./out
install:
@./install.sh
@cp -f -p smf-spf $(SBINDIR)
@if test ! -d $(DATADIR); then \
mkdir -m 700 $(DATADIR); \
chown $(USER):$(GROUP) $(DATADIR); \
fi
@if test ! -d $(CONFDIR); then \
mkdir -m 755 $(CONFDIR); \
fi
@if test ! -f $(CONFDIR)/smf-spf.conf; then \
cp -p smf-spf.conf $(CONFDIR)/smf-spf.conf; \
else \
cp -p smf-spf.conf $(CONFDIR)/smf-spf.conf.new; \
fi
@echo Please, inspect and edit the $(CONFDIR)/smf-spf.conf file.
test: coverage
tests/bin/run_tests.sh
#
# Making Docker stuff.
#
DOCKER_IMAGE_NAME := smf-spf/smf-spf
DOCKER_TAGS := $(VERSION),latest
# Helper definitions
comma := ,
empty :=
space := $(empty) $(empty)
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
$(findstring $(2),$(1))),1)
# Build Docker image.
#
# Usage:
# make docker-image [no-cache=(yes|no)] [VERSION=]
no-cache ?= no
no-cache-arg = $(if $(call eq, $(no-cache), yes), --no-cache, $(empty))
docker-image:
docker build -t $(DOCKER_IMAGE_NAME):$(VERSION) ./
# Tag Docker image with given tags.
#
# Usage:
# make docker-tags [VERSION=] [DOCKER_TAGS=t1,t2,...]
tags:
$(foreach tag, $(subst $(comma), $(space), $(DOCKER_TAGS)), \
docker tag $(DOCKER_IMAGE_NAME):$(VERSION) $(IMAGE_NAME):$(tag) ;)
# Manually push Docker images to Docker Hub.
#
# Usage:
# make docker-push [DOCKER_TAGS=t1,t2,...]
docker-push:
$(foreach tag, $(subst $(comma), $(space), $(DOCKER_TAGS)), \
docker push $(DOCKER_IMAGE_NAME):$(tag) ;)