Makefile 1.9 KB

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