]> git.ipfire.org Git - thirdparty/kernel/stable.git/blob - tools/perf/jvmti/Makefile
perf jvmti: Add check for java alternatives cmd in Makefile
[thirdparty/kernel/stable.git] / tools / perf / jvmti / Makefile
1 ARCH=$(shell uname -m)
2
3 ifeq ($(ARCH), x86_64)
4 JARCH=amd64
5 endif
6 ifeq ($(ARCH), armv7l)
7 JARCH=armhf
8 endif
9 ifeq ($(ARCH), armv6l)
10 JARCH=armhf
11 endif
12 ifeq ($(ARCH), aarch64)
13 JARCH=aarch64
14 endif
15 ifeq ($(ARCH), ppc64)
16 JARCH=powerpc
17 endif
18 ifeq ($(ARCH), ppc64le)
19 JARCH=powerpc
20 endif
21
22 DESTDIR=/usr/local
23
24 VERSION=1
25 REVISION=0
26 AGE=0
27
28 LN=ln -sf
29 RM=rm
30
31 SLIBJVMTI=libjvmti.so.$(VERSION).$(REVISION).$(AGE)
32 VLIBJVMTI=libjvmti.so.$(VERSION)
33 SLDFLAGS=-shared -Wl,-soname -Wl,$(VLIBJVMTI)
34 SOLIBEXT=so
35
36 # The following works at least on fedora 23, you may need the next
37 # line for other distros.
38 ifeq (,$(wildcard /usr/sbin/update-java-alternatives))
39 JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
40 else
41 JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | cut -d ' ' -f 3)
42 endif
43
44 # -lrt required in 32-bit mode for clock_gettime()
45 LIBS=-lelf -lrt
46 INCDIR=-I $(JDIR)/include -I $(JDIR)/include/linux
47
48 TARGETS=$(SLIBJVMTI)
49
50 SRCS=libjvmti.c jvmti_agent.c
51 OBJS=$(SRCS:.c=.o)
52 SOBJS=$(OBJS:.o=.lo)
53 OPT=-O2 -g -Werror -Wall
54
55 CFLAGS=$(INCDIR) $(OPT)
56
57 all: $(TARGETS)
58
59 .c.o:
60 $(CC) $(CFLAGS) -c $*.c
61 .c.lo:
62 $(CC) -fPIC -DPIC $(CFLAGS) -c $*.c -o $*.lo
63
64 $(OBJS) $(SOBJS): Makefile jvmti_agent.h ../util/jitdump.h
65
66 $(SLIBJVMTI): $(SOBJS)
67 $(CC) $(CFLAGS) $(SLDFLAGS) -o $@ $(SOBJS) $(LIBS)
68 $(LN) $@ libjvmti.$(SOLIBEXT)
69
70 clean:
71 $(RM) -f *.o *.so.* *.so *.lo
72
73 install:
74 -mkdir -p $(DESTDIR)/lib
75 install -m 755 $(SLIBJVMTI) $(DESTDIR)/lib/
76 (cd $(DESTDIR)/lib; $(LN) $(SLIBJVMTI) $(VLIBJVMTI))
77 (cd $(DESTDIR)/lib; $(LN) $(SLIBJVMTI) libjvmti.$(SOLIBEXT))
78 ldconfig
79
80 .SUFFIXES: .c .S .o .lo