-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
138 lines (110 loc) · 3.67 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
## Copyright 2020-2021 Seagate Technology LLC.
#
# This Source Code Form is subject to the terms of the Mozilla
# Public License, v. 2.0. If a copy of the MPL was not
# distributed with this file, You can obtain one at
# https://mozilla.org/MP:/2.0/.
#
# This program is distributed in the hope that it will be useful,
# but is provided AS-IS, WITHOUT ANY WARRANTY; including without
# the implied warranty of MERCHANTABILITY, NON-INFRINGEMENT or
# FITNESS FOR A PARTICULAR PURPOSE. See the Mozilla Public
# License for more details.
#
TLD := $(shell pwd)
BUILDDIR = $(TLD)/build
BUILDINC = $(BUILDDIR)/include
BUILDLIB = $(BUILDDIR)/lib
BUILDBIN = $(BUILDDIR)/bin
KCTLDIR = $(TLD)/toolbox/kctl
BKVDIR = $(TLD)/toolbox/bkv
LISTDIR = $(TLD)/vendor/list
PROTOBUFDIR = $(TLD)/vendor/protobuf-c
SRCDIR = $(TLD)/src
TBDIR = $(TLD)/toolbox
LPROTOBUF = $(BUILDLIB)/libprotobuf-c.so
LLIST = $(BUILDLIB)/liblist.a
LKINETIC = $(BUILDLIB)/libkinetic.a
KCTL = $(BUILDBIN)/kctl
# These are being deprecated for now
# TESTDIR = $(TLD)/tests
# GTESTDIR = $(TLD)/vendor/googletest
# LGTEST = $(BUILDLIB)/libgtest.a
CC = gcc
CFLAGS = -g -I$(BUILDDIR)/include
LDFLAGS = -L$(BUILDDIR)/lib
DISTFILES = \
./bin/kctl \
./include/kinetic \
./include/protobuf-c \
./lib/libkinetic.a \
./lib/libkinetic.so \
./lib/libkinetic.so.1 \
./lib/libkinetic.so.1.0.0 \
./src \
all: $(BUILDDIR) $(LPROTOBUF) $(LLIST) $(LKINETIC) $(TBDIR) # $(TESTDIR) $(LGTEST)
dist: all
@( \
cd $(BUILDDIR); \
A=`/usr/bin/arch`; \
V=`$(KCTL) -V | grep "Library Vers" | awk '{print $$4}'`; \
D=libkinetic-dev_$${V}_$${A}; \
echo Creating Distribution tarfile in $(BUILDDIR)/$${D}.tgz; \
tar -czf $${D}.tgz --xform "s,^\.,$${D}," $(DISTFILES) \
)
$(BUILDDIR):
@mkdir -p $(BUILDDIR)
@mkdir -p $(BUILDINC)
@mkdir -p $(BUILDLIB)
@mkdir -p $(BUILDBIN)
$(TBDIR): FORCE
(cd $@; BUILDDIR=$(BUILDDIR) make -e all install)
$(LPROTOBUF):
(cd $(PROTOBUFDIR); [ ! -f ./configure ] && ./autogen.sh; true)
(cd $(PROTOBUFDIR); [ ! -f ./Makefile ] && ./configure --prefix=$(BUILDDIR); true)
(cd $(PROTOBUFDIR); make install)
$(LLIST):
(cd $(LISTDIR); INCDIR=$(BUILDINC) LIBDIR=$(BUILDLIB) make -e)
(cd $(LISTDIR); INCDIR=$(BUILDINC) LIBDIR=$(BUILDLIB) make -e install)
$(LKINETIC): FORCE
(cd $(SRCDIR); BUILDDIR=$(BUILDDIR) make -e all install)
# The sanity target only works if you have a kineticd server running locally.
sanity:
(cd $(KCTLDIR); make all sanity)
(cd $(BKVDIR); make all sanity)
clean: protobufclean listclean kineticclean toolboxclean # gtestclean testclean
rm -rf $(BUILDDIR)
protobufclean:
(cd $(PROTOBUFDIR); [ -f ./Makefile ] && make clean; true)
kctlclean:
(cd $(KCTLDIR); make clean)
listclean:
(cd $(LISTDIR); make clean)
kineticclean:
(cd $(SRCDIR); make clean)
toolboxclean:
(cd $(TBDIR); make clean)
distclean:
(cd $(PROTOBUFDIR); [ -f ./Makefile ] && make distclean; true)
(cd $(LISTDIR); make clean)
(cd $(SRCDIR); make clean)
(cd $(TBDIR); make clean)
# (cd $(TESTDIR); make clean)
# (cd $(GTESTDIR); bazel clean)
rm -rf $(BUILDDIR)
.PHONY: FORCE
FORCE:
# ------------------------------
# Deprecated portions, here for reference (and to make bringing it back in the future easier)
# We are deprecating googletest unit tests for now
# $(LGTEST): FORCE
# (cd $(GTESTDIR); BUILDDIR=$(BUILDDIR) bazel build gtest)
# /usr/bin/install -c -m 755 $(GTESTDIR)/bazel-bin/libgtest.a $(BUILDLIB)
# gtestclean:
# (cd $(GTESTDIR); bazel clean)
# Deprecating the test directory, which will only contain google tests
# test: $(TESTDIR)
# $(TESTDIR): FORCE
# (cd $@; BUILDDIR=$(BUILDDIR) make -e all install)
# testclean:
# (cd $(TESTDIR); make clean)