blob: 5ce61a1bda9ca863cbcd4c327f2abd8f621bf1f6 [file] [log] [blame]
Stephane Eranian209045a2015-11-30 10:02:22 +01001ARCH=$(shell uname -m)
2
3ifeq ($(ARCH), x86_64)
4JARCH=amd64
5endif
6ifeq ($(ARCH), armv7l)
7JARCH=armhf
8endif
9ifeq ($(ARCH), armv6l)
10JARCH=armhf
11endif
12ifeq ($(ARCH), aarch64)
13JARCH=aarch64
14endif
15ifeq ($(ARCH), ppc64)
16JARCH=powerpc
17endif
18ifeq ($(ARCH), ppc64le)
19JARCH=powerpc
20endif
21
22DESTDIR=/usr/local
23
24VERSION=1
25REVISION=0
26AGE=0
27
28LN=ln -sf
29RM=rm
30
31SLIBJVMTI=libjvmti.so.$(VERSION).$(REVISION).$(AGE)
32VLIBJVMTI=libjvmti.so.$(VERSION)
33SLDFLAGS=-shared -Wl,-soname -Wl,$(VLIBJVMTI)
34SOLIBEXT=so
35
36# The following works at least on fedora 23, you may need the next
37# line for other distros.
Stephane Eranian7e9551b2016-02-25 06:27:36 +010038ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
Stephane Eraniand646ae02016-02-16 07:37:41 +010039JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | cut -d ' ' -f 3)
Stephane Eranian7e9551b2016-02-25 06:27:36 +010040else
41 ifneq (,$(wildcard /usr/sbin/alternatives))
42 JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
43 endif
Stephane Eraniand646ae02016-02-16 07:37:41 +010044endif
Stephane Eranian7e9551b2016-02-25 06:27:36 +010045ifndef JDIR
46$(error Could not find alternatives command, you need to set JDIR= to point to the root of your Java directory)
47else
48 ifeq (,$(wildcard $(JDIR)/include/jvmti.h))
49 $(error the openjdk development package appears to me missing, install and try again)
50 endif
51endif
52$(info Using Java from $(JDIR))
Stephane Eranian209045a2015-11-30 10:02:22 +010053# -lrt required in 32-bit mode for clock_gettime()
54LIBS=-lelf -lrt
55INCDIR=-I $(JDIR)/include -I $(JDIR)/include/linux
56
57TARGETS=$(SLIBJVMTI)
58
59SRCS=libjvmti.c jvmti_agent.c
60OBJS=$(SRCS:.c=.o)
61SOBJS=$(OBJS:.o=.lo)
62OPT=-O2 -g -Werror -Wall
63
64CFLAGS=$(INCDIR) $(OPT)
65
66all: $(TARGETS)
67
68.c.o:
69 $(CC) $(CFLAGS) -c $*.c
70.c.lo:
71 $(CC) -fPIC -DPIC $(CFLAGS) -c $*.c -o $*.lo
72
73$(OBJS) $(SOBJS): Makefile jvmti_agent.h ../util/jitdump.h
74
75$(SLIBJVMTI): $(SOBJS)
76 $(CC) $(CFLAGS) $(SLDFLAGS) -o $@ $(SOBJS) $(LIBS)
77 $(LN) $@ libjvmti.$(SOLIBEXT)
78
79clean:
80 $(RM) -f *.o *.so.* *.so *.lo
81
82install:
83 -mkdir -p $(DESTDIR)/lib
84 install -m 755 $(SLIBJVMTI) $(DESTDIR)/lib/
85 (cd $(DESTDIR)/lib; $(LN) $(SLIBJVMTI) $(VLIBJVMTI))
86 (cd $(DESTDIR)/lib; $(LN) $(SLIBJVMTI) libjvmti.$(SOLIBEXT))
87 ldconfig
88
89.SUFFIXES: .c .S .o .lo