This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Makefile
120 lines (95 loc) · 4.24 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
#
# Copyright (C) 2018-2019 Intel Corporation
#
# SPDX-License-Identifier: BSD-3-Clause
#
#
CC = g++
JAVAC = $(JAVA_HOME)/bin/javac
JAVA = $(JAVA_HOME)/bin/java
JAR = $(JAVA_HOME)/bin/jar
JAVADOC = $(JAVA_HOME)/bin/javadoc
JNI_INCLUDES = $(JAVA_HOME)/include $(JAVA_HOME)/include/linux
CFLAGS = -O3 -DNDEBUG -fPIC -shared -D_FORTIFY_SOURCE=2 -z noexecstack -fstack-protector -Wformat -Wformat-security -Werror=format-security
JAVAFLAGS = -Xlint:unchecked -proc:none -XDenableSunApiLintControl
LINK_FLAGS = -fPIC -pie -O3 -DNDEBUG -shared -lpmem -lpmemobj -lpmempool -Wl,-rpath,/usr/local/lib:/usr/local/lib64 -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack
CPP_SOURCE_DIR = src/main/cpp
JAVA_SOURCE_DIR = src/main/java
PACKAGE_NAME = com/intel/pmem/llpl
UTIL_PACKAGE_NAME = com/intel/pmem/llpl/util
HM_PACKAGE_NAME = com/intel/pmem/llpl/util/hashmap
TEST_DIR = src/test/java/$(PACKAGE_NAME)
TARGET_DIR = target
CPP_BUILD_DIR = $(TARGET_DIR)/cppbuild
CLASSES_DIR = $(TARGET_DIR)/classes
TEST_CLASSES_DIR = $(TARGET_DIR)/test_classes
JAR_NATIVE_DIR = $(CLASSES_DIR)/com/intel/pmem/llpl/linux/amd64
BASE_CLASSPATH = $(CLASSES_DIR):com/intel/pmem/
ALL_CPP_SOURCES = $(wildcard $(CPP_SOURCE_DIR)/*.cpp)
ALL_JAVA_SOURCES := $(wildcard $(JAVA_SOURCE_DIR)/$(PACKAGE_NAME)/*.java)
ALL_JAVA_SOURCES := $(ALL_JAVA_SOURCES) $(wildcard $(JAVA_SOURCE_DIR)/$(UTIL_PACKAGE_NAME)/*.java)
ALL_JAVA_SOURCES := $(ALL_JAVA_SOURCES) $(wildcard $(JAVA_SOURCE_DIR)/$(HM_PACKAGE_NAME)/*.java)
ALL_OBJ = $(addprefix $(CPP_BUILD_DIR)/, $(notdir $(ALL_CPP_SOURCES:.cpp=.o)))
ALL_TEST_SOURCES = $(addprefix $(TEST_DIR)/, \
CopyMemoryTest.java \
PersistentMemoryBlockTest.java \
MemoryBlockCollectionTest.java \
MemoryBlockFreeTest.java \
MemoryBlockEqualityTest.java \
MemoryBlockTest.java \
MultipleHeapTest.java \
MultipleTransactionalHeapTest.java \
SetMemoryTest.java \
TransactionTest.java \
TransactionalMemoryBlockTest.java \
CompactMemoryBlockTest.java \
)
ALL_TEST_CLASSES = $(addprefix $(TEST_CLASSES_DIR)/, $(notdir $(ALL_TEST_SOURCES:.java=.class)))
ALL_PERF_TEST_CLASSES = $(addprefix $(TEST_CLASSES_DIR)/, $(notdir $(ALL_PERF_TEST_SOURCES:.java=.class)))
LIBRARIES = $(addprefix $(CPP_BUILD_DIR)/, libllpl.so)
EXAMPLES_DIR = src/examples/com/intel/pmem/llpl/examples
OLD_EXAMPLES_DIR = src/old_examples/com/intel/pmem/llpl/examples
ALL_EXAMPLE_DIRS = $(wildcard $(EXAMPLES_DIR)/*)
ALL_OLD_EXAMPLE_DIRS = $(wildcard $(OLD_EXAMPLES_DIR)/*)
#$(addprefix $(EXAMPLES_DIR)/, reservations employees)
all: sources examples testsources
sources: cpp java
cpp: $(LIBRARIES)
java: classes
docs: classes
$(JAVADOC) -d docs com.intel.pmem.llpl -sourcepath $(JAVA_SOURCE_DIR)
jar: sources
$(JAR) cvf $(TARGET_DIR)/llpl.jar -C $(CLASSES_DIR) com/intel/pmem/
examples: sources
$(foreach example_dir,$(ALL_EXAMPLE_DIRS), $(JAVAC) $(JAVAFLAGS) -cp $(BASE_CLASSPATH):src/examples $(example_dir)/*.java;)
$(foreach old_example_dir,$(ALL_OLD_EXAMPLE_DIRS), $(JAVAC) $(JAVAFLAGS) -cp $(BASE_CLASSPATH):src/old_examples $(old_example_dir)/*.java;)
testsources: sources
#$(JAVAC) $(JAVAFLAGS) -cp $(BASE_CLASSPATH):src -d $(TEST_CLASSES_DIR) $(TEST_DIR)/*.java;
$(JAVAC) $(JAVAFLAGS) -cp $(BASE_CLASSPATH):src -d $(TEST_CLASSES_DIR) $(ALL_TEST_SOURCES);
clean: cleanex
rm -rf target
cleanex:
$(foreach example_dir,$(ALL_EXAMPLE_DIRS), rm -rf $(example_dir)/*.class;)
$(foreach old_example_dir,$(ALL_OLD_EXAMPLE_DIRS), rm -rf $(old_example_dir)/*.class;)
tests: $(ALL_TEST_CLASSES)
$(foreach test,$^, $(JAVA) -ea -cp $(BASE_CLASSPATH):$(TEST_CLASSES_DIR) -Djava.library.path=$(CPP_BUILD_DIR) $(PACKAGE_NAME)/$(notdir $(test:.class=));)
$(LIBRARIES): | $(CPP_BUILD_DIR)
$(ALL_OBJ): | $(CPP_BUILD_DIR)
$(ALL_TEST_CLASSES): | $(TEST_CLASSES_DIR)
classes: | $(CLASSES_DIR) $(TEST_CLASSES_DIR)
$(JAVAC) $(JAVAFLAGS) -d $(CLASSES_DIR) -cp $(BASE_CLASSPATH) $(ALL_JAVA_SOURCES)
$(CPP_BUILD_DIR)/%.so: $(ALL_OBJ)
$(CC) -Wl,-soname,$@ -o $@ $(ALL_OBJ) $(LINK_FLAGS)
mkdir -p $(JAR_NATIVE_DIR)
cp $@ $(CLASSES_DIR)/com/intel/pmem/llpl/linux/amd64
$(CPP_BUILD_DIR)/%.o: $(CPP_SOURCE_DIR)/%.cpp
ifndef JAVA_HOME
$(error JAVA_HOME not set)
endif
$(CC) $(CFLAGS) $(addprefix -I, $(JNI_INCLUDES)) -o $@ -c $<
$(CPP_BUILD_DIR):
mkdir -p $(CPP_BUILD_DIR)
$(CLASSES_DIR):
mkdir -p $(CLASSES_DIR)
$(TEST_CLASSES_DIR):
mkdir -p $(TEST_CLASSES_DIR)