src/share/tools/hsdis/Makefile

Fri, 02 Nov 2012 13:30:47 -0700

author
minqi
date
Fri, 02 Nov 2012 13:30:47 -0700
changeset 4244
3d701c802d01
parent 4093
5a98bf7d847b
child 4942
f36e073d56a4
permissions
-rw-r--r--

8000489: older builds of hsdis don't work anymore after 6879063
Summary: The old function not defined properly, need a definition for export in dll. Also changes made to let new jvm work with old hsdis.
Reviewed-by: jrose, sspitsyn, kmo
Contributed-by: yumin.qi@oracle.com

jrose@535 1 #
minqi@4093 2 # Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
jrose@535 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jrose@535 4 #
jrose@535 5 # This code is free software; you can redistribute it and/or modify it
jrose@535 6 # under the terms of the GNU General Public License version 2 only, as
jrose@535 7 # published by the Free Software Foundation.
jrose@535 8 #
jrose@535 9 # This code is distributed in the hope that it will be useful, but WITHOUT
jrose@535 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jrose@535 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jrose@535 12 # version 2 for more details (a copy is included in the LICENSE file that
jrose@535 13 # accompanied this code).
jrose@535 14 #
jrose@535 15 # You should have received a copy of the GNU General Public License version
jrose@535 16 # 2 along with this work; if not, write to the Free Software Foundation,
jrose@535 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jrose@535 18 #
trims@1907 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 # or visit www.oracle.com if you need additional information or have any
trims@1907 21 # questions.
jrose@535 22 #
jrose@535 23 #
jrose@535 24
never@1155 25 # Single gnu makefile for solaris, linux and windows (windows requires cygwin and mingw)
jrose@535 26
jrose@535 27 # Default arch; it is changed below as needed.
jrose@535 28 ARCH = i386
jrose@535 29 OS = $(shell uname)
jrose@535 30
jrose@535 31 ## OS = SunOS ##
jrose@535 32 ifeq ($(OS),SunOS)
never@1155 33 CPU = $(shell uname -p)
never@1155 34 ARCH1=$(CPU:i586=i386)
never@1155 35 ARCH=$(ARCH1:i686=i386)
jrose@535 36 OS = solaris
jrose@535 37 CC = cc
never@1155 38 CFLAGS += -KPIC
never@1155 39 ifdef LP64
never@1155 40 ifeq ($(ARCH),sparc)
never@1155 41 ARCH = sparcv9
never@1155 42 endif
never@1155 43 ifeq ($(ARCH),i386)
never@1155 44 ARCH = amd64
never@1155 45 endif
never@1155 46 endif
never@1155 47 CFLAGS/sparcv9 += -xarch=v9
never@1155 48 CFLAGS/amd64 += -m64
never@1155 49 CFLAGS += $(CFLAGS/$(ARCH))
jrose@535 50 DLDFLAGS += -G
never@1155 51 LDFLAGS += -ldl
jrose@535 52 OUTFLAGS += -o $@
jrose@535 53 LIB_EXT = .so
jrose@535 54 else
jrose@535 55 ## OS = Linux ##
jrose@535 56 ifeq ($(OS),Linux)
never@1155 57 ifneq ($(MINGW),)
never@1155 58 LIB_EXT = .dll
never@1155 59 CPPFLAGS += -I$(TARGET_DIR)/include
never@1155 60 LDFLAGS += -L$(TARGET_DIR)/lib
never@1155 61 OS=windows
never@1155 62 ifneq ($(findstring x86_64-,$(MINGW)),)
never@1155 63 ARCH=amd64
never@1155 64 else
never@1155 65 ARCH=i386
never@1155 66 endif
never@1155 67 CC = $(MINGW)-gcc
never@1155 68 CONFIGURE_ARGS= --host=$(MINGW) --target=$(MINGW)
minqi@4093 69 else #linux
jrose@535 70 CPU = $(shell uname -m)
never@1155 71 ARCH1=$(CPU:x86_64=amd64)
never@1155 72 ARCH=$(ARCH1:i686=i386)
minqi@4093 73 ifdef LP64
minqi@4093 74 CFLAGS/sparcv9 += -m64
minqi@4093 75 CFLAGS/amd64 += -m64
minqi@4093 76 else
minqi@4093 77 ARCH=$(ARCH1:amd64=i386)
never@1155 78 CFLAGS/i386 += -m32
never@1155 79 CFLAGS/sparc += -m32
minqi@4093 80 endif
never@1155 81 CFLAGS += $(CFLAGS/$(ARCH))
never@1155 82 CFLAGS += -fPIC
jrose@535 83 OS = linux
never@1155 84 LIB_EXT = .so
jrose@535 85 CC = gcc
never@1155 86 endif
never@1155 87 CFLAGS += -O
jrose@535 88 DLDFLAGS += -shared
never@1155 89 LDFLAGS += -ldl
jrose@535 90 OUTFLAGS += -o $@
jrose@535 91 ## OS = Windows ##
minqi@4093 92 else # !SunOS, !Linux => Darwin or Windows
minqi@4093 93 ifeq ($(OS),Darwin)
minqi@4093 94 CPU = $(shell uname -m)
minqi@4093 95 ARCH1=$(CPU:x86_64=amd64)
minqi@4093 96 ARCH=$(ARCH1:i686=i386)
minqi@4093 97 ifdef LP64
minqi@4093 98 CFLAGS/sparcv9 += -m64
minqi@4093 99 CFLAGS/amd64 += -m64
minqi@4093 100 else
minqi@4093 101 ARCH=$(ARCH1:amd64=i386)
minqi@4093 102 CFLAGS/i386 += -m32
minqi@4093 103 CFLAGS/sparc += -m32
minqi@4093 104 endif # LP64
minqi@4093 105 CFLAGS += $(CFLAGS/$(ARCH))
minqi@4093 106 CFLAGS += -fPIC
minqi@4093 107 OS = macosx
minqi@4093 108 LIB_EXT = .dylib
minqi@4093 109 CC = gcc
minqi@4093 110 CFLAGS += -O
minqi@4093 111 # CFLAGS += -DZ_PREFIX
minqi@4093 112 DLDFLAGS += -shared
minqi@4093 113 DLDFLAGS += -lz
minqi@4093 114 LDFLAGS += -ldl
minqi@4093 115 OUTFLAGS += -o $@
minqi@4093 116 else #Windows
never@1155 117 OS = windows
never@1155 118 CC = gcc
jrose@535 119 #CPPFLAGS += /D"WIN32" /D"_WINDOWS" /D"DEBUG" /D"NDEBUG"
never@1155 120 CFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi-
minqi@4093 121 CFLAGS += LIBARCH=\"$(LIBARCH)\"
jrose@535 122 DLDFLAGS += /dll /subsystem:windows /incremental:no \
jrose@535 123 /export:decode_instruction
jrose@535 124 OUTFLAGS += /link /out:$@
jrose@535 125 LIB_EXT = .dll
minqi@4093 126 endif # Darwin
jrose@535 127 endif # Linux
jrose@535 128 endif # SunOS
jrose@535 129
jrose@535 130 LIBARCH = $(ARCH)
jrose@535 131 ifdef LP64
jrose@535 132 LIBARCH64/sparc = sparcv9
jrose@535 133 LIBARCH64/i386 = amd64
jrose@535 134 LIBARCH64 = $(LIBARCH64/$(ARCH))
jrose@535 135 ifneq ($(LIBARCH64),)
jrose@535 136 LIBARCH = $(LIBARCH64)
jrose@535 137 endif # LIBARCH64/$(ARCH)
jrose@535 138 endif # LP64
jrose@535 139
never@1155 140 JDKARCH=$(LIBARCH:i386=i586)
never@1155 141
never@1155 142 ifeq ($(BINUTILS),)
never@1155 143 # Pop all the way out of the workspace to look for binutils.
never@1155 144 # ...You probably want to override this setting.
never@1155 145 BINUTILSDIR = $(shell cd build/binutils;pwd)
never@1155 146 else
never@1155 147 BINUTILSDIR = $(shell cd $(BINUTILS);pwd)
never@1155 148 endif
never@1155 149
minqi@4093 150 CPPFLAGS += -I$(BINUTILSDIR)/include -I$(BINUTILSDIR)/bfd -I$(TARGET_DIR)/bfd
never@1155 151 CPPFLAGS += -DLIBARCH_$(LIBARCH) -DLIBARCH=\"$(LIBARCH)\" -DLIB_EXT=\"$(LIB_EXT)\"
never@1155 152
never@1155 153 TARGET_DIR = build/$(OS)-$(JDKARCH)
jrose@535 154 TARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT)
jrose@535 155
jrose@535 156 SOURCE = hsdis.c
jrose@535 157
never@1155 158 LIBRARIES = $(TARGET_DIR)/bfd/libbfd.a \
never@1155 159 $(TARGET_DIR)/opcodes/libopcodes.a \
never@1155 160 $(TARGET_DIR)/libiberty/libiberty.a
jrose@535 161
never@1155 162 DEMO_TARGET = $(TARGET_DIR)/hsdis-demo
jrose@535 163 DEMO_SOURCE = hsdis-demo.c
jrose@535 164
jrose@535 165 .PHONY: all clean demo both
jrose@535 166
never@1155 167 all: $(TARGET)
jrose@535 168
jrose@535 169 both: all all64
jrose@535 170
jrose@535 171 %64:
jrose@535 172 $(MAKE) LP64=1 ${@:%64=%}
jrose@535 173
jrose@535 174 demo: $(TARGET) $(DEMO_TARGET)
jrose@535 175
never@1155 176 $(LIBRARIES): $(TARGET_DIR) $(TARGET_DIR)/Makefile
never@1155 177 if [ ! -f $@ ]; then cd $(TARGET_DIR); make all-opcodes; fi
never@1155 178
never@1155 179 $(TARGET_DIR)/Makefile:
never@1155 180 (cd $(TARGET_DIR); CC=$(CC) CFLAGS="$(CFLAGS)" $(BINUTILSDIR)/configure --disable-nls $(CONFIGURE_ARGS))
jrose@535 181
jrose@535 182 $(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)
never@1155 183 $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES)
jrose@535 184
jrose@535 185 $(DEMO_TARGET): $(DEMO_SOURCE) $(TARGET) $(TARGET_DIR)
never@1155 186 $(CC) $(OUTFLAGS) -DTARGET_DIR=\"$(TARGET_DIR)\" $(CPPFLAGS) -g $(CFLAGS/$(ARCH)) $(DEMO_SOURCE) $(LDFLAGS)
jrose@535 187
jrose@535 188 $(TARGET_DIR):
jrose@535 189 [ -d $@ ] || mkdir -p $@
jrose@535 190
jrose@535 191 clean:
jrose@535 192 rm -rf $(TARGET_DIR)

mercurial