forked from paravmellanox/rtool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (62 loc) · 1.96 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
CFLAGS ?= -g -O2 -funroll-loops -ftree-vectorize
CFLAGS += -std=gnu99 -Wall -Wextra -pedantic
LIBS=-lm -lrt -libverbs -lhugetlbfs
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
MAN1DIR=$(PREFIX)/share/man/man1
SRCS=rdma_mr_lat.c options.c
OBJS=$(SRCS:.c=.o)
BINARY=rdma_mr_lat
MANS=rdma_mr_lat.1
MANS_F=$(MANS:.1=.txt) $(MANS:.1=.pdf)
DOCS=README.md LICENSE changelog
SPEC=rdma_mr_lat.spec
PACKAGE=rdma_mr_lat
GIT_VER:=$(shell test -d .git && git describe --tags --match 'v[0-9]*' \
--abbrev=0 | sed 's/v//')
SRC_VER:=$(shell sed -ne 's/\#define VERSION \"\(.*\)\"/\1/p' rdma_mr_lat.c)
VERSION:=$(SRC_VER)
DISTDIR=$(PACKAGE)-$(VERSION)
DISTFILES=$(SRCS) $(MANS) $(DOCS) $(SPEC) Makefile
PACKFILES=$(BINARY) $(MANS) $(MANS_F) $(DOCS)
STRIP=strip
TARGET=$(shell ${CC} -dumpmachine)
all: checkver $(BINARY)
version: checkver
@echo ${VERSION}
checkver:
@if test -n "$(GIT_VER)" -a "$(GIT_VER)" != "$(SRC_VER)"; then \
echo "ERROR: Version mismatch between git and source"; \
echo git: $(GIT_VER), src: $(SRC_VER); \
exit 1; \
fi
clean:
$(RM) -f $(OBJS) $(BINARY) $(MANS_F) rdma_mr_lat.tmp
strip: $(BINARY)
$(STRIP) $^
install: $(BINARY) $(MANS)
mkdir -p $(DESTDIR)$(BINDIR)
install -m 0755 $(BINARY) $(DESTDIR)$(BINDIR)
mkdir -p $(DESTDIR)$(MAN1DIR)
install -m 644 $(MANS) $(DESTDIR)$(MAN1DIR)
%.o: %.c %.h
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
%.ps: %.1
man -t ./$< > $@
%.pdf: %.ps
ps2pdf $< $@
%.txt: %.1
MANWIDTH=80 man ./$< | col -b > $@
$(BINARY): $(OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LIBS)
dist: checkver $(DISTFILES)
tar -cz --transform='s,^,$(DISTDIR)/,S' $^ -f $(DISTDIR).tar.gz
binary-tgz: checkver $(PACKFILES)
${STRIP} ${BINARY}
tar -cz --transform='s,^,$(DISTDIR)/,S' -f ${PACKAGE}-${VERSION}-${TARGET}.tgz $^
binary-zip: checkver $(PACKFILES)
${STRIP} ${BINARY}
ln -s . $(DISTDIR)
zip ${PACKAGE}-${VERSION}-${TARGET}.zip $(addprefix $(DISTDIR)/,$^)
rm $(DISTDIR)
.PHONY: all version checkver clean strip test install dist binary-tgz binary-zip