-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
241 lines (212 loc) · 8.04 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
232
233
234
235
236
237
238
239
240
241
###############################################################################
#
# Copyright (c) 2015, ParaTools, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# (1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# (2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# (3) Neither the name of ParaTools, Inc. nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################
# TAU configuration level:
# minimal: Install just enough to support the default project (`tau initialize` without any args).
# full : Install as many TAU configurations as possible for the current environment.
# <path> : Use the TAU installation provided at <path>.
TAU ?= minimal
# If set to "true" then show commands as they are executed.
# Otherwise only the command's output will be shown.
VERBOSE = true
DOCKER_IMG_NAME = cmdr-dev-0.1.0
DOCKER_TAG = latest
# Set this if you are a TAU Commander developer
__TAUCMDR_DEVELOPER__?=
# Shell utilities
RM = rm -f
MV = mv -f
MKDIR = mkdir -p
VERSION = $(shell cat VERSION 2>/dev/null || ./.version.sh || echo "0.0.0")
# Allow INSTALL_DIR too
ifneq ($(INSTALL_DIR),)
INSTALLDIR ?= $(INSTALL_DIR)
endif
# Get build system locations from configuration file or command line
ifneq ("$(wildcard setup.cfg)","")
BUILDDIR ?= $(shell grep '^build-base =' setup.cfg | sed 's/build-base = //')
INSTALLDIR ?= $(shell grep '^prefix =' setup.cfg | sed 's/prefix = //')
endif
ifeq ($(BUILDDIR),)
BUILDDIR=build
endif
ifeq ($(INSTALLDIR),)
INSTALLDIR=$(HOME)/taucmdr-$(VERSION)
endif
# Get target OS and architecture
ifeq ($(HOST_OS),)
HOST_OS = $(shell uname -s)
endif
ifeq ($(HOST_ARCH),)
HOST_ARCH = $(shell uname -m)
endif
ifeq ($(VERBOSE),false)
ECHO=@
CURL_FLAGS=-s
WGET_FLAGS=--quiet
else
ECHO=
CURL_FLAGS=
WGET_FLAGS=
endif
# Build download macro
# Usage: $(call download,source,dest)
WGET = $(shell command -pv wget || type -P wget || which wget)
ifneq ($(WGET),)
download = $(WGET) --no-check-certificate $(WGET_FLAGS) -O "$(2)" "$(1)"
else
CURL = $(shell command -pv curl || type -P curl || which curl)
ifneq ($(CURL),)
download = $(CURL) --insecure $(CURL_FLAGS) -L "$(1)" > "$(2)"
else
$(warning Either curl or wget must be in PATH to download packages)
endif
endif
# CommanderConda configuration
USE_COMMANDERCONDA = true
ifeq ($(HOST_OS),Darwin)
ifeq ($(HOST_ARCH),i386)
USE_COMMANDERCONDA = false
endif
endif
ifeq ($(HOST_OS),Darwin)
CONDA_OS = MacOSX
else
ifeq ($(HOST_OS),Linux)
CONDA_OS = Linux
else
USE_COMMANDERCONDA = false
endif
endif
ifeq ($(HOST_ARCH),x86_64)
CONDA_ARCH = x86_64
else
ifeq ($(HOST_ARCH),i386)
CONDA_ARCH = x86
else
ifeq ($(HOST_ARCH),ppc64le)
CONDA_ARCH = ppc64le
else
USE_COMMANDERCONDA = false
endif
endif
endif
CONDA_VERSION = v2.2.0
CONDA_REPO = https://github.com/ParaToolsInc/CommanderConda/releases/download/$(CONDA_VERSION)
CONDA_PKG = CommanderConda3-$(CONDA_OS)-$(CONDA_ARCH).sh
CONDA_URL = $(CONDA_REPO)/$(CONDA_PKG)
CONDA_SRC = system/src/$(CONDA_PKG)
CONDA_DEST = $(INSTALLDIR)/conda
CONDA = $(CONDA_DEST)/bin/python
ifeq ($(USE_COMMANDERCONDA),true)
PYTHON_EXE = $(CONDA)
PYTHON_FLAGS = -EOu
else
$(warning WARNING: There are no CommanderConda packages for this system: $(HOST_OS), $(HOST_ARCH).)
CONDA_SRC =
PYTHON_EXE = $(shell command -pv python || type -P python || which python)
PYTHON_FLAGS = -O
ifeq ($(PYTHON_EXE),)
$(error python not found in PATH.)
else
$(warning WARNING: Trying to use '$(PYTHON_EXE)' instead.)
endif
endif
PYTHON = $(PYTHON_EXE) $(PYTHON_FLAGS)
.PHONY: help build install clean python_check python_download dev-container run-container
.DEFAULT: help
help:
@echo "-------------------------------------------------------------------------------"
@echo "TAU Commander installation"
@echo
@echo "Usage: make install [INSTALLDIR=$(INSTALLDIR)] [TAU=(minimal|full|<path>)]"
@echo "-------------------------------------------------------------------------------"
ifneq ($(__TAUCMDR_DEVELOPER__),)
INSTALL_DEV_REQS=$(ECHO)$(PYTHON) -m pip install -U -r requirements-dev.txt
endif
build: python_check
$(INSTALL_DEV_REQS)
$(ECHO)$(PYTHON) setup.py build_scripts --executable "$(PYTHON)"
$(ECHO)$(PYTHON) setup.py build
install: build
$(ECHO)$(PYTHON) setup.py install --prefix $(INSTALLDIR)
$(ECHO)$(INSTALLDIR)/system/configure --tau-config=$(TAU)
@chmod -R a+rX,g+w $(INSTALLDIR)
@echo
@echo "-------------------------------------------------------------------------------"
@echo "Hooray! TAU Commander is installed!"
@echo
@echo "INSTALLDIR=\"$(INSTALLDIR)\""
@echo
@echo "What's next?"
@echo
@echo "TAU Commander will automatically generate new TAU configurations for each new"
@echo "experiment, so if you're just trying to get some performance data then go add"
@echo "TAU Commander's \"bin\" directory to your path and maybe have a look at"
@echo "the quick start guide at http://www.taucommander.com/guide."
@echo
@echo "If you'd like to pre-configure TAU for a particular experiment then go use"
@echo "the \"$(INSTALLDIR)/system/configure\" script to generate TAU configurations."
@echo "This is especially a good idea if you are a system administrator installing"
@echo "TAU Commander so that someone else can use it. Without arguments, the"
@echo "\"configure\" script will generate as many TAU configurations as it can."
@echo
@echo "In short:"
@echo " If you are a sysadmin then go run \"$(INSTALLDIR)/system/configure\"."
@echo " Otherwise just add \"$(INSTALLDIR)/bin\" to your PATH and get to work."
@echo "-------------------------------------------------------------------------------"
@echo
python_check: $(PYTHON_EXE)
@$(PYTHON) -c "import sys; import setuptools;" || (echo "ERROR: setuptools is required." && false)
python_download: $(CONDA_SRC)
$(CONDA): $(CONDA_SRC)
$(ECHO)bash $< -b -u -p $(CONDA_DEST)
$(ECHO)touch $(CONDA_DEST)/bin/*
$(CONDA_SRC):
@$(ECHO)$(MKDIR) `dirname "$(CONDA_SRC)"`
@$(call download,$(CONDA_URL),$(CONDA_SRC)) || \
(rm -f "$(CONDA_SRC)" ; \
echo "**************************************************************************" ; \
echo "*" ; \
echo "* ERROR" ; \
echo "*" ; \
echo "* Unable to download $(CONDA_URL)." ; \
echo "* Please use an all-in-one package from www.taucommander.com" ; \
echo "*" ; \
echo "**************************************************************************" ; \
false)
clean:
$(ECHO)$(RM) -r $(BUILDDIR) VERSION
dev-container:
$(ECHO)docker build --pull -t $(DOCKER_IMG_NAME) .
run-container:
$(ECHO)docker run -it --rm --tmpfs=/dev/shm:rw,nosuid,nodev,exec --privileged -v ${PWD}:/home/tau/src \
$(DOCKER_IMG_NAME):$(DOCKER_TAG) $(ARGS)
test-container:
$(ECHO)docker run -it --rm --tmpfs=/dev/shm:rw,nosuid,nodev,exec --privileged -v ${PWD}:/home/tau/src \
$(DOCKER_IMG_NAME):$(DOCKER_TAG) test $(ARGS)