forked from HanumathRao/aerospike-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
185 lines (156 loc) · 5.37 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# Aerospike Server
# Makefile
#
# Main Build Targets:
#
# make {all|server} - Build the Aerospike Server.
# make clean - Remove build products, excluding built packages.
# make cleanpkg - Remove built packages.
# make cleanall - Remove all build products, including built packages.
# make strip - Build stripped versions of the server executables.
#
# Packaging Targets:
#
# make deb - Package server for Debian / Ubuntu platforms as a ".deb" file.
# make rpm - Package server for the Red Hat Package Manager (RPM.)
# make tar - Package server as a compressed tarball for every Linux platform.
# make source - Package the server source code as a compressed "tar" archive.
#
# Building a distribution release is a two step process:
#
# 1). The initial "make" builds the server itself.
#
# 2). The second step packages up the server using "make" with one of the following targets:
#
# rpm: Suitable for building and installing on Red Hat-derived systems.
# deb: Suitable for building and installing on Debian-derived systems.
# tar: Makes an "Every Linux" distribution, packaged as a compressed "tar" archive.
#
# Targets for running the Aerospike Server in the source tree:
#
# make init - Initialize the server run-time directories.
# make start - Start the server.
# make stop - Stop the server.
#
# Advanced Targets:
#
# make asm - Build with support for the ASMalloc memory allocation tracking tool.
#
# Intermediate Targets Used for ASMalloc Support:
#
# make gen - Generate the "cf/include/mallocation.h" file via "cpp" & Python.
# make mexp - Build server using 2-phase macro expansion to transform and instrument the source tree.
# make mexp1 - Macroexpand Phase 1: Create the macroexpanded source tree using "m4" & Python.
# make mexp2 - Macroexpand Phase 2: Build the macroexpanded source tree.
#
# Common variable definitions:
include make_in/Makefile.vars
.PHONY: all server
all server: targetdirs version $(JANSSON)/Makefile $(JEMALLOC)/Makefile
ifeq ($(USE_ASM),1)
$(MAKE) -C $(ASMALLOC) jem SRCDIR=src
endif
ifeq ($(USE_JEM),1)
$(MAKE) -C $(JEMALLOC)
endif
$(MAKE) -C $(JANSSON)
$(MAKE) -C $(COMMON) CF=$(CF) EXT_CFLAGS="$(EXT_CFLAGS)"
$(MAKE) -C $(CF)
$(MAKE) -C $(MOD_LUA) CF=$(CF) COMMON=$(COMMON) LUA_CORE=$(LUA_CORE) EXT_CFLAGS="$(EXT_CFLAGS)"
$(MAKE) -C xdr
$(MAKE) -C ai
$(MAKE) -C as
.PHONY: targetdirs
targetdirs:
mkdir -p $(GEN_DIR) $(LIBRARY_DIR) $(BIN_DIR)
mkdir -p $(MEXP_DIR)/base $(MEXP_DIR)/fabric $(MEXP_DIR)/storage
mkdir -p $(OBJECT_DIR)/base $(OBJECT_DIR)/fabric $(OBJECT_DIR)/storage
strip: server
$(MAKE) -C xdr strip
$(MAKE) -C as strip
.PHONY: init start stop
init:
@echo "Creating and initializing working directories..."
mkdir -p run/log run/work/smd run/work/sys/udf/lua run/work/usr/udf/lua
cp -pr modules/lua-core/src/* run/work/sys/udf/lua
start:
@echo "Running the Aerospike Server locally..."
$(BIN_DIR)/asd --config-file as/etc/aerospike_dev.conf
stop:
@echo "Stopping the local Aerospike Server..."
PIDFILE=run/asd.pid ; if [ -f $$PIDFILE ]; then kill `cat $$PIDFILE`; rm $$PIDFILE; fi
.PHONY: clean
clean: cleanmodules cleandist
$(RM) $(VERSION_SRC) $(VERSION_OBJ)
$(RM) -rf $(TARGET_DIR)
.PHONY: cleanmodules
cleanmodules:
if [ -e "$(JANSSON)/Makefile" ]; then \
$(MAKE) -C $(JANSSON) clean; \
$(MAKE) -C $(JANSSON) distclean; \
fi;
if [ -e "$(JEMALLOC)/Makefile" ]; then \
$(MAKE) -C $(JEMALLOC) clean; \
$(MAKE) -C $(JEMALLOC) distclean; \
fi;
$(MAKE) -C $(ASMALLOC) cleanest cleanest.jem
$(MAKE) -C $(COMMON) clean
$(MAKE) -C $(MOD_LUA) COMMON=$(COMMON) LUA_CORE=$(LUA_CORE) clean
.PHONY: cleandist
cleandist:
$(RM) -r pkg/dist/*
.PHONY: cleanall
cleanall: clean cleanpkg
.PHONY: cleanpkg
cleanpkg:
$(RM) pkg/packages/*
.PHONY: rpm deb tar
rpm deb tar:
$(MAKE) -C pkg/$@ EDITION=$(EDITION)
$(VERSION_SRC): targetdirs
build/gen_version $(EDITION) > $(VERSION_SRC)
$(VERSION_OBJ): $(VERSION_SRC)
$(CC) -o $@ -c $<
.PHONY: version
version: $(VERSION_OBJ)
.PHONY: asm mexp
asm: version
$(MAKE) mexp USE_ASM=1 LD_JEM=dynamic
GEN_TAG = GEN_TAG_001
GEN_FILE = $(GEN_DIR)/CPPMallocations.py
gen:
$(RM) $(GEN_FILE)
touch $(GEN_FILE)
$(MAKE) PREPRO=1 GEN_TAG=$(GEN_TAG)
echo "def AddLocs(AddLoc):" > $(GEN_FILE)
find -L . -name "*.o.cpp" -exec grep $(GEN_TAG) {} \; | grep -v "#define" | sed 's/.*GEN_TAG_001\( .*\)GEN_TAG_001.*/\1/g' | sort | uniq >> $(GEN_FILE)
build/GenMallocations.py $(GEN_DIR)
mexp: mexp2
mexp1: gen
$(MAKE) MEXP_PHASE=1 SRCDIR=$(realpath $(MEXP_DIR))/ TOOLS_DIR=$(realpath build)
mexp2: mexp1
$(MAKE) MEXP_PHASE=2 SRCDIR=$(realpath $(MEXP_DIR))/
$(JANSSON)/configure:
cd $(JANSSON) && autoreconf -i
$(JANSSON)/Makefile: $(JANSSON)/configure
cd $(JANSSON) && ./configure
$(JEMALLOC)/configure:
cd $(JEMALLOC) && autoconf
$(JEMALLOC)/Makefile: $(JEMALLOC)/configure
cd $(JEMALLOC) && ./configure
.PHONY: source
source:
$(eval EDITION := community)
$(RM) $(VERSION_SRC)
$(MAKE) $(VERSION_SRC) EDITION=$(EDITION)
cp -p $(VERSION_SRC) $(DEPTH)
tar cvfj $(SRCTAR) \
-C .. `git ls-files | sed 's|^|aerospike-server/|'` \
"aerospike-server/version.c"
$(RM) $(DEPTH)/version.c
tags etags:
etags `find ai as cf modules xdr $(EEREPO) -name "*.[ch]" | egrep -v '(target/Linux|m4)'` `find /usr/include -name "*.h"`
# Common target definitions:
ifneq ($(EEREPO),)
include $(EEREPO)/make_in/Makefile.targets
endif