saproc.make 4.7 KB
Newer Older
D
duke 已提交
1
#
2
# Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
19 20 21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
D
duke 已提交
22 23
#  
#
24 25
include $(GAMMADIR)/make/defs.make
include $(GAMMADIR)/make/altsrc.make
D
duke 已提交
26 27 28

# Rules to build serviceability agent library, used by vm.make

29
# libsaproc.so: serviceability agent
30 31

SAPROC = saproc
D
duke 已提交
32 33
LIBSAPROC = lib$(SAPROC).so

34
LIBSAPROC_DEBUGINFO   = lib$(SAPROC).debuginfo
35
LIBSAPROC_DIZ         = lib$(SAPROC).diz
36

D
duke 已提交
37 38 39 40 41 42 43 44 45
AGENT_DIR = $(GAMMADIR)/agent

SASRCDIR = $(AGENT_DIR)/src/os/$(Platform_os_family)

SASRCFILES = $(SASRCDIR)/salibelf.c                   \
             $(SASRCDIR)/symtab.c                     \
             $(SASRCDIR)/libproc_impl.c               \
             $(SASRCDIR)/ps_proc.c                    \
             $(SASRCDIR)/ps_core.c                    \
46 47
             $(SASRCDIR)/LinuxDebuggerLocal.c         \
             $(AGENT_DIR)/src/share/native/sadis.c
D
duke 已提交
48

49 50
-include $(HS_ALT_MAKE)/linux/makefiles/saproc.make

D
duke 已提交
51 52
SAMAPFILE = $(SASRCDIR)/mapfile

53 54
DEST_SAPROC           = $(JDK_LIBDIR)/$(LIBSAPROC)
DEST_SAPROC_DEBUGINFO = $(JDK_LIBDIR)/$(LIBSAPROC_DEBUGINFO)
55
DEST_SAPROC_DIZ       = $(JDK_LIBDIR)/$(LIBSAPROC_DIZ)
D
duke 已提交
56

57 58 59 60 61
# DEBUG_BINARIES overrides everything, use full -g debug information
ifeq ($(DEBUG_BINARIES), true)
  SA_DEBUG_CFLAGS = -g
endif

D
duke 已提交
62
# if $(AGENT_DIR) does not exist, we don't build SA
63
# also, we don't build SA on Itanium or zero.
D
duke 已提交
64

65
ifneq ($(wildcard $(AGENT_DIR)),)
66
ifneq ($(filter-out ia64 zero,$(SRCARCH)),)
67 68 69 70
  BUILDLIBSAPROC = $(LIBSAPROC)
endif
endif

71
ifneq ($(ALT_SASRCDIR),)
72
ALT_SAINCDIR=-I$(ALT_SASRCDIR) -DALT_SASRCDIR
73 74 75
else
ALT_SAINCDIR=
endif
76
SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE)) $(LDFLAGS_HASH_STYLE) \
77
            $(LDFLAGS_NO_EXEC_STACK) $(EXTRA_LDFLAGS)
D
duke 已提交
78

79 80
SAARCH ?= $(BUILDARCH)

D
duke 已提交
81 82 83 84 85 86
$(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE)
	$(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
	  echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \
	  exit 1; \
	fi
	@echo Making SA debugger back-end...
87
	$(QUIETLY) $(CC) -D$(SAARCH) -D_GNU_SOURCE                      \
88
		   -D_FILE_OFFSET_BITS=64                               \
D
duke 已提交
89 90 91 92 93
                   $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG)     \
	           -I$(SASRCDIR)                                        \
	           -I$(GENERATED)                                       \
	           -I$(BOOT_JAVA_HOME)/include                          \
	           -I$(BOOT_JAVA_HOME)/include/$(Platform_os_family)    \
94
			   $(ALT_SAINCDIR) 										\
D
duke 已提交
95 96
	           $(SASRCFILES)                                        \
	           $(SA_LFLAGS)                                         \
97
	           $(SA_DEBUG_CFLAGS)                                   \
98
	           $(EXTRA_CFLAGS)                                      \
D
duke 已提交
99 100
	           -o $@                                                \
	           -lthread_db
101
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
102 103
	$(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBSAPROC_DEBUGINFO)
  ifeq ($(STRIP_POLICY),all_strip)
104
	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@
105 106 107
	$(QUIETLY) $(STRIP) $@
  else
    ifeq ($(STRIP_POLICY),min_strip)
108
	$(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBSAPROC_DEBUGINFO) $@
109 110
	$(QUIETLY) $(STRIP) -g $@
    endif
111
    # implied else here is no stripping at all
112
  endif
113
  ifeq ($(ZIP_DEBUGINFO_FILES),1)
114 115
	$(ZIPEXE) -q -y $(LIBSAPROC_DIZ) $(LIBSAPROC_DEBUGINFO)
	$(RM) $(LIBSAPROC_DEBUGINFO)
116
  endif
117
endif
D
duke 已提交
118

119
install_saproc: $(BUILDLIBSAPROC)
D
duke 已提交
120 121
	$(QUIETLY) if [ -e $(LIBSAPROC) ] ; then             \
	  echo "Copying $(LIBSAPROC) to $(DEST_SAPROC)";     \
122 123
	  test -f $(LIBSAPROC_DEBUGINFO) &&                  \
	    cp -f $(LIBSAPROC_DEBUGINFO) $(DEST_SAPROC_DEBUGINFO); \
124 125
	  test -f $(LIBSAPROC_DIZ) &&                  \
	    cp -f $(LIBSAPROC_DIZ) $(DEST_SAPROC_DIZ); \
D
duke 已提交
126 127 128
	  cp -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done";  \
	fi

129
.PHONY: install_saproc