forked from foglamp/FogLAMP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
232 lines (189 loc) · 8.84 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
###############################################################################
################################### COMMANDS ##################################
###############################################################################
MKDIR_PATH := mkdir -p
CD := cd
LN := ln -sf
CMAKE := cmake
PIP_USER_FLAG = --user
PIP_INSTALL_REQUIREMENTS := pip3 install -Ir
PYTHON_BUILD_PACKAGE = python3 setup.py build -b ../$(PYTHON_BUILD_DIR)
RM_DIR := rm -r
RM_FILE := rm
MAKE_INSTALL = $(MAKE) install
CP_DIR := cp -r
CP := cp
###############################################################################
################################### DIRS/FILES ################################
###############################################################################
# PARENT DIR
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CURRENT_DIR := $(dir $(MKFILE_PATH))
# C BUILD DIRS/FILES
CMAKE_FILE := $(CURRENT_DIR)/CMakeLists.txt
CMAKE_BUILD_DIR := cmake_build
CMAKE_GEN_MAKEFILE := $(CURRENT_DIR)/$(CMAKE_BUILD_DIR)/Makefile
CMAKE_SERVICES_DIR := $(CURRENT_DIR)/$(CMAKE_BUILD_DIR)/C/services
CMAKE_STORAGE_BINARY := $(CMAKE_SERVICES_DIR)/storage/storage
CMAKE_PLUGINS_DIR := $(CURRENT_DIR)/$(CMAKE_BUILD_DIR)/C/plugins
DEV_SERVICES_DIR := $(CURRENT_DIR)/services
SYMLINK_PLUGINS_DIR := $(CURRENT_DIR)/plugins
SYMLINK_STORAGE_BINARY := $(DEV_SERVICES_DIR)/storage
# PYTHON BUILD DIRS/FILES
PYTHON_SRC_DIR := python
PYTHON_BUILD_DIR := python_build
PYTHON_LIB_DIR := $(PYTHON_BUILD_DIR)/lib
PYTHON_REQUIREMENTS_FILE := $(PYTHON_SRC_DIR)/requirements.txt
PYTHON_SETUP_FILE := $(PYTHON_SRC_DIR)/setup.py
# INSTALL DIRS
INSTALL_DIR=$(DESTDIR)/usr/local/foglamp
PYTHON_INSTALL_DIR=$(INSTALL_DIR)/python
SCRIPTS_INSTALL_DIR=$(INSTALL_DIR)/scripts
BIN_INSTALL_DIR=$(INSTALL_DIR)/bin
EXTRAS_INSTALL_DIR=$(INSTALL_DIR)/extras
SCRIPT_PLUGINS_STORAGE_INSTALL_DIR = $(SCRIPTS_INSTALL_DIR)/plugins/storage
SCRIPT_SERVICES_INSTALL_DIR = $(SCRIPTS_INSTALL_DIR)/services
SCRIPT_TASKS_INSTALL_DIR = $(SCRIPTS_INSTALL_DIR)/tasks
FOGBENCH_PYTHON_INSTALL_DIR = $(EXTRAS_INSTALL_DIR)/python
# SCRIPTS TO INSTALL IN BIN DIR
FOGBENCH_SCRIPT_SRC := scripts/extras/foglamp.fogbench
FOGLAMP_SCRIPT_SRC := scripts/foglamp
# SCRIPTS TO INSTALL IN SCRIPTS DIR
POSTGRES_SCRIPT_SRC := scripts/plugins/storage/postgres
SOUTH_SCRIPT_SRC := scripts/services/south
STORAGE_SCRIPT_SRC := scripts/services/storage
NORTH_SCRIPT_SRC := scripts/tasks/north
PURGE_SCRIPT_SRC := scripts/tasks/purge
STATISTICS_SCRIPT_SRC := scripts/tasks/statistics
# FOGBENCH
FOGBENCH_PYTHON_SRC_DIR := extras/python/fogbench
###############################################################################
################################### OTHER VARS ################################
###############################################################################
# ETC
PACKAGE_NAME=FogLAMP
###############################################################################
############################ PRIMARY TARGETS ##################################
###############################################################################
# default
# compile any code that must be compiled
# generally prepare the development tree to allow for core to be run
default : c_build $(SYMLINK_STORAGE_BINARY) $(SYMLINK_PLUGINS_DIR) \
python_build python_requirements_user
# install
# Creates a deployment structure in the default destination, /usr/local/foglamp
# Destination may be overridden by use of the DESTDIR=<location> directive
# This first does a make to build anything needed for the installation.
install : $(INSTALL_DIR) c_install python_install python_requirements \
scripts_install bin_install extras_install
###############################################################################
############################ C BUILD/INSTALL TARGETS ##########################
###############################################################################
# run make execute makefiles producer by cmake
c_build : $(CMAKE_GEN_MAKEFILE)
$(CD) $(CMAKE_BUILD_DIR) ; $(MAKE)
# run cmake to generate makefiles
# always rerun cmake because:
# parent CMakeLists.txt may have changed
# CMakeLists.txt files in subdirectories may have changed
$(CMAKE_GEN_MAKEFILE) : $(CMAKE_FILE) $(CMAKE_BUILD_DIR)
$(CD) $(CMAKE_BUILD_DIR) ; $(CMAKE) $(CURRENT_DIR)
# create build dir
$(CMAKE_BUILD_DIR) :
$(MKDIR_PATH) $@
# create symlink to storage binary
$(SYMLINK_STORAGE_BINARY) : $(DEV_SERVICES_DIR)
$(LN) $(CMAKE_STORAGE_BINARY) $(SYMLINK_STORAGE_BINARY)
# create services dir
$(DEV_SERVICES_DIR) :
$(MKDIR_PATH) $(DEV_SERVICES_DIR)
# create symlink for plugins dir
$(SYMLINK_PLUGINS_DIR) :
$(LN) $(CMAKE_PLUGINS_DIR) $(SYMLINK_PLUGINS_DIR)
# run make install on cmake based components
c_install : c_build
$(CD) $(CMAKE_BUILD_DIR) ; $(MAKE_INSTALL)
###############################################################################
###################### PYTHON BUILD/INSTALL TARGETS ###########################
###############################################################################
# build python source
python_build : $(PYTHON_SETUP_FILE)
$(CD) $(PYTHON_SRC_DIR) ; $(PYTHON_BUILD_PACKAGE)
# install python requirements without --user
python_requirements : $(PYTHON_REQUIREMENTS_FILE)
$(PIP_INSTALL_REQUIREMENTS) $(PYTHON_REQUIREMENTS_FILE)
# install python requirements for user
python_requirements_user : $(PYTHON_REQUIREMENTS_FILE)
$(PIP_INSTALL_REQUIREMENTS) $(PYTHON_REQUIREMENTS_FILE) $(PIP_USER_FLAG)
# create python install dir
$(PYTHON_INSTALL_DIR) :
$(MKDIR_PATH) $@
# copy python package into install dir
python_install : python_build $(PYTHON_INSTALL_DIR)
$(CP_DIR) $(PYTHON_LIB_DIR)/* $(PYTHON_INSTALL_DIR)
###############################################################################
###################### SCRIPTS INSTALL TARGETS ################################
###############################################################################
# install scripts
scripts_install : $(SCRIPTS_INSTALL_DIR) install_postgres_script \
install_south_script install_storage_script install_north_script \
install_purge_script install_statistics_script
# create scripts install dir
$(SCRIPTS_INSTALL_DIR) :
$(MKDIR_PATH) $@
install_postgres_script : $(SCRIPT_PLUGINS_STORAGE_INSTALL_DIR) $(POSTGRES_SCRIPT_SRC)
$(CP) $(POSTGRES_SCRIPT_SRC) $(SCRIPT_PLUGINS_STORAGE_INSTALL_DIR)
install_south_script : $(SCRIPT_SERVICES_INSTALL_DIR) $(SOUTH_SCRIPT_SRC)
$(CP) $(SOUTH_SCRIPT_SRC) $(SCRIPT_SERVICES_INSTALL_DIR)
install_storage_script : $(SCRIPT_SERVICES_INSTALL_DIR) $(STORAGE_SCRIPT_SRC)
$(CP) $(STORAGE_SCRIPT_SRC) $(SCRIPT_SERVICES_INSTALL_DIR)
install_north_script : $(SCRIPT_TASKS_INSTALL_DIR) $(NORTH_SCRIPT_SRC)
$(CP) $(NORTH_SCRIPT_SRC) $(SCRIPT_TASKS_INSTALL_DIR)
install_purge_script : $(SCRIPT_TASKS_INSTALL_DIR) $(PURGE_SCRIPT_SRC)
$(CP) $(PURGE_SCRIPT_SRC) $(SCRIPT_TASKS_INSTALL_DIR)
install_statistics_script : $(SCRIPT_TASKS_INSTALL_DIR) $(STATISTICS_SCRIPT_SRC)
$(CP) $(STATISTICS_SCRIPT_SRC) $(SCRIPT_TASKS_INSTALL_DIR)
$(SCRIPT_PLUGINS_STORAGE_INSTALL_DIR) :
$(MKDIR_PATH) $@
$(SCRIPT_SERVICES_INSTALL_DIR) :
$(MKDIR_PATH) $@
$(SCRIPT_TASKS_INSTALL_DIR) :
$(MKDIR_PATH) $@
###############################################################################
########################## BIN INSTALL TARGETS ################################
###############################################################################
# install bin
bin_install : $(BIN_INSTALL_DIR) $(FOGBENCH_SCRIPT_SRC) $(FOGLAMP_SCRIPT_SRC)
$(CP) $(FOGBENCH_SCRIPT_SRC) $(BIN_INSTALL_DIR)
$(CP) $(FOGLAMP_SCRIPT_SRC) $(BIN_INSTALL_DIR)
# create bin install dir
$(BIN_INSTALL_DIR) :
$(MKDIR_PATH) $@
###############################################################################
####################### EXTRAS INSTALL TARGETS ################################
###############################################################################
# install bin
extras_install : $(EXTRAS_INSTALL_DIR) install_python_fogbench
install_python_fogbench : $(FOGBENCH_PYTHON_INSTALL_DIR) $(FOGBENCH_PYTHON_SRC_DIR)
$(CP_DIR) $(FOGBENCH_PYTHON_SRC_DIR) $(FOGBENCH_PYTHON_INSTALL_DIR)
$(FOGBENCH_PYTHON_INSTALL_DIR) :
$(MKDIR_PATH) $@
# create extras install dir
$(EXTRAS_INSTALL_DIR) :
$(MKDIR_PATH) $@
###############################################################################
######################## SUPPORTING BUILD/INSTALL TARGETS #####################
###############################################################################
# create install directory
$(INSTALL_DIR) :
$(MKDIR_PATH) $@
###############################################################################
###############################################################################
###################### CLEAN/UNINSTALL TARGETS ################################
###############################################################################
# clean
clean :
-$(RM_DIR) $(CMAKE_BUILD_DIR)
-$(RM_DIR) $(PYTHON_BUILD_DIR)
-$(RM_DIR) $(DEV_SERVICES_DIR)
-$(RM) $(SYMLINK_PLUGINS_DIR)