summaryrefslogtreecommitdiff
path: root/tools/perf/jvmti/Makefile
blob: df14e6b67b63b781846d71b80cbc6e8ee1edc0e3 (plain)
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
ARCH=$(shell uname -m)

ifeq ($(ARCH), x86_64)
JARCH=amd64
endif
ifeq ($(ARCH), armv7l)
JARCH=armhf
endif
ifeq ($(ARCH), armv6l)
JARCH=armhf
endif
ifeq ($(ARCH), aarch64)
JARCH=aarch64
endif
ifeq ($(ARCH), ppc64)
JARCH=powerpc
endif
ifeq ($(ARCH), ppc64le)
JARCH=powerpc
endif

DESTDIR=/usr/local

VERSION=1
REVISION=0
AGE=0

LN=ln -sf
RM=rm

SLIBJVMTI=libjvmti.so.$(VERSION).$(REVISION).$(AGE)
VLIBJVMTI=libjvmti.so.$(VERSION)
SLDFLAGS=-shared -Wl,-soname -Wl,$(VLIBJVMTI)
SOLIBEXT=so

# The following works at least on fedora 23, you may need the next
# line for other distros.
ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
else
  ifneq (,$(wildcard /usr/sbin/alternatives))
    JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
  endif
endif
ifndef JDIR
$(error Could not find alternatives command, you need to set JDIR= to point to the root of your Java directory)
else
  ifeq (,$(wildcard $(JDIR)/include/jvmti.h))
  $(error the openjdk development package appears to me missing, install and try again)
  endif
endif
$(info Using Java from $(JDIR))
# -lrt required in 32-bit mode for clock_gettime()
LIBS=-lelf -lrt
INCDIR=-I $(JDIR)/include -I $(JDIR)/include/linux

TARGETS=$(SLIBJVMTI)

SRCS=libjvmti.c jvmti_agent.c
OBJS=$(SRCS:.c=.o)
SOBJS=$(OBJS:.o=.lo)
OPT=-O2 -g -Werror -Wall

CFLAGS=$(INCDIR) $(OPT)

all: $(TARGETS)

.c.o:
	$(CC) $(CFLAGS) -c $*.c
.c.lo:
	$(CC) -fPIC -DPIC $(CFLAGS) -c $*.c -o $*.lo

$(OBJS) $(SOBJS): Makefile jvmti_agent.h ../util/jitdump.h

$(SLIBJVMTI):  $(SOBJS)
	$(CC) $(CFLAGS) $(SLDFLAGS)  -o $@ $(SOBJS) $(LIBS)
	$(LN) $@ libjvmti.$(SOLIBEXT)

clean:
	$(RM) -f *.o *.so.* *.so *.lo

install:
	-mkdir -p $(DESTDIR)/lib
	install -m 755 $(SLIBJVMTI) $(DESTDIR)/lib/
	(cd $(DESTDIR)/lib; $(LN) $(SLIBJVMTI) $(VLIBJVMTI))
	(cd $(DESTDIR)/lib; $(LN) $(SLIBJVMTI) libjvmti.$(SOLIBEXT))
	ldconfig

.SUFFIXES: .c .S .o .lo