-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (47 loc) · 1.38 KB
/
Makefile
File metadata and controls
66 lines (47 loc) · 1.38 KB
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
PROJECT := rocm_callback
CONFIGS := Makefile.config
include $(CONFIGS)
# Compiler
HIPCC = hipcc
CXX = g++
# Directories
SRC_DIR = src
BUILD_DIR = build
LIB_DIR = $(BUILD_DIR)/lib
OBJ_DIR = $(BUILD_DIR)/obj
# Source files
SOURCES = $(notdir $(wildcard $(SRC_DIR)/*.cpp $(SRC_DIR)/*/*.cpp))
OBJECTS = $(addprefix $(OBJ_DIR)/, $(patsubst %.cpp, %.o, $(SOURCES)))
# Include directories
INCLUDE_FLAGS = -I/opt/rocm/include
SANALYZER_INC = -I$(SANALYZER_DIR)/include
SANALYZER_LDFLAGS = -L$(SANALYZER_DIR)/lib -Wl,-rpath=$(SANALYZER_DIR)/lib
SANALYZER_LIB = -lsanalyzer
# Linker flags
LIBS = -lrocprofiler-sdk -lrocprofiler-sdk-roctx -lpthread
LDFLAGS = -L/opt/rocm/lib -Wl,-rpath,/opt/rocm/lib $(LIBS)
# Compiler flags
CXXFLAGS = -std=c++17 -fPIC -Wall
HIPFLAGS = -std=c++17 -fPIC -Wall
# Targets
all: dirs rocm_callback
rocm_callback: $(LIB_DIR)/librocm_callback.so
dirs: $(BUILD_DIR) $(LIB_DIR) $(OBJ_DIR)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(LIB_DIR):
mkdir -p $(LIB_DIR)
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
# Build shared library
$(LIB_DIR)/lib$(PROJECT).so: $(OBJ_DIR)/$(PROJECT).o
$(HIPCC) -shared -o $@ $^ $(LDFLAGS) $(SANALYZER_LDFLAGS) $(SANALYZER_LIB)
# Compile source files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(HIPCC) $(HIPFLAGS) $(INCLUDE_FLAGS) $(SANALYZER_INC) -c $< -o $@
# Run tests
test: all
LD_LIBRARY_PATH=$(LIB_DIR):$$LD_LIBRARY_PATH
# Clean build
clean:
rm -rf $(BUILD_DIR)