forked from async-profiler/async-profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (47 loc) · 1.49 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
PROFILER_VERSION=1.5-ea
JATTACH_VERSION=1.4
LIB_PROFILER=libasyncProfiler.so
JATTACH=jattach
PROFILER_JAR=async-profiler.jar
CC=gcc
CFLAGS=-O2
CPP=g++
CPPFLAGS=-O2
INCLUDES=-I$(JAVA_HOME)/include
JAVAC=$(JAVA_HOME)/bin/javac
JAR=$(JAVA_HOME)/bin/jar
ifeq ($(JAVA_HOME),)
export JAVA_HOME:=$(shell java -cp . JavaHome)
endif
OS:=$(shell uname -s)
ifeq ($(OS), Darwin)
CPPFLAGS += -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
INCLUDES += -I$(JAVA_HOME)/include/darwin
RELEASE_TAG:=$(PROFILER_VERSION)-macos-x64
else
INCLUDES += -I$(JAVA_HOME)/include/linux
RELEASE_TAG:=$(PROFILER_VERSION)-linux-x64
endif
.PHONY: all release test clean
all: build build/$(LIB_PROFILER) build/$(JATTACH) build/$(PROFILER_JAR)
release: build async-profiler-$(RELEASE_TAG).tar.gz
async-profiler-$(RELEASE_TAG).tar.gz: build/$(LIB_PROFILER) build/$(JATTACH) \
build/$(PROFILER_JAR) profiler.sh LICENSE *.md
tar cvzf $@ $^
build:
mkdir -p build
build/$(LIB_PROFILER): src/*.cpp src/*.h
$(CPP) $(CPPFLAGS) -DPROFILER_VERSION=\"$(PROFILER_VERSION)\" $(INCLUDES) -fPIC -shared -o $@ src/*.cpp -ldl -lpthread
build/$(JATTACH): src/jattach/jattach.c
$(CC) $(CFLAGS) -DJATTACH_VERSION=\"$(JATTACH_VERSION)\" -o $@ $^
build/$(PROFILER_JAR): src/java/one/profiler/*.java
mkdir -p build/classes
$(JAVAC) -source 6 -target 6 -d build/classes $^
$(JAR) cvf $@ -C build/classes .
rm -rf build/classes
test: all
test/smoke-test.sh
test/alloc-smoke-test.sh
echo "All tests passed"
clean:
rm -rf build