forked from dcapwell/lightweight-java-profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (64 loc) · 2.42 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
SHELL:=/bin/bash
UNAME:=$(shell uname | tr '[A-Z]' '[a-z]')
PWD:=$(shell pwd)
BITS?=64
ifeq ($(UNAME), darwin)
READLINK_ARGS:=""
PLATFORM_WARNINGS:=-Weverything -Wno-c++98-compat-pedantic -Wno-padded \
-Wno-missing-prototypes -Wno-poison-system-directories \
-Wno-global-constructors -Wno-unused-variable
PLATFORM_COPTS:=-std=c++20 -stdlib=libc++ -DTARGET_RT_MAC_CFM=0
HEADERS:=include
CC=clang++
LDFLAGS=-Wl,-fatal_warnings -Wl,-std=c++20 -Wl,-stdlib=libc++
else ifeq ($(UNAME), linux)
READLINK_ARGS:="-f"
PLATFORM_COPTS:= -std=c++20
PLATFORM_WARNINGS:=-Wframe-larger-than=16384 -Wno-unused-but-set-variable \
-Wunused-but-set-parameter -Wvla -Wno-conversion-null \
-Wno-builtin-macro-redefined -Wno-class-memaccess
HEADERS:=include
CC=g++
LDFLAGS=-Wl,--fatal-warnings -stdlib=libstdc++
endif
JAVA_HOME := $(shell \
[[ -n "$${JAVA_HOME}" ]] || \
JAVA_HOME=$$(dirname $$(readlink $(READLINK_ARGS) $$(which java)))/../; \
[[ "$${JAVA_HOME}" =~ /jre/ ]] && JAVA_HOME=$${JAVA_HOME}/../; \
[[ -n "$${JAVA_HOME}" ]] || (echo "Cannot find JAVA_HOME" && exit) ; \
echo $${JAVA_HOME})
AGENT=libtigerprof.so
LIBS=-ldl
BUILD_DIR ?= $(shell mkdir build 2> /dev/null ; echo build)
SRC_DIR:=${PWD}/src
OPT?=-O2
GLOBAL_WARNINGS=-Wall -Werror -Wformat-security -Wno-char-subscripts \
-Wno-sign-compare -Wno-strict-overflow -Wwrite-strings -Wnon-virtual-dtor \
-Woverloaded-virtual -Wno-unused-variable
GLOBAL_COPTS=-fdiagnostics-show-option -fno-exceptions \
-fno-omit-frame-pointer -fno-strict-aliasing -funsigned-char \
-fno-asynchronous-unwind-tables -g \
-D__STDC_FORMAT_MACROS
COPTS:=$(PLATFORM_COPTS) $(GLOBAL_COPTS) $(PLATFORM_WARNINGS) \
$(GLOBAL_WARNINGS) $(OPT)
INCLUDES=-I$(JAVA_HOME)/$(HEADERS)
ifeq ($(UNAME), linux)
INCLUDES=-I$(JAVA_HOME)/$(HEADERS) -I$(JAVA_HOME)/$(HEADERS)/linux
endif
# LDFLAGS+=-Wl,--export-dynamic-symbol=Agent_OnLoad
SOURCES=$(wildcard $(SRC_DIR)/*.cc)
_OBJECTS=$(SOURCES:.cc=.pic.o)
OBJECTS = $(patsubst $(SRC_DIR)/%,$(BUILD_DIR)/%,$(_OBJECTS))
$(BUILD_DIR)/%.pic.o: $(SRC_DIR)/%.cc
$(CC) $(INCLUDES) $(COPTS) -Fvisibility=hidden -fPIC -c $< -o $@
$(AGENT): $(OBJECTS)
$(CC) $(COPTS) -shared -o $(BUILD_DIR)/$(AGENT) \
-Bsymbolic $(OBJECTS) $(LIBS)
all: $(AGENT)
clean:
rm -rf $(BUILD_DIR)/*
DOCKER_IMAGE_NAME="lightweight_java_profiler/build"
docker-build:
@docker build -t $(DOCKER_IMAGE_NAME) .
docker-run:
@docker run -t -i -v $(PWD):$(PWD) -w $(PWD) $(DOCKER_IMAGE_NAME) bash