src/share/tools/hsdis/Makefile

Thu, 04 Apr 2019 17:56:29 +0800

author
aoqi
date
Thu, 04 Apr 2019 17:56:29 +0800
changeset 9572
624a0741915c
parent 9493
882a55369341
parent 9226
80768a44078a
permissions
-rw-r--r--

Merge

aoqi@0 1 #
aoqi@0 2 # Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 #
dbuck@9473 5 # The Universal Permissive License (UPL), Version 1.0
aoqi@0 6 #
dbuck@9473 7 # Subject to the condition set forth below, permission is hereby granted to
dbuck@9473 8 # any person obtaining a copy of this software, associated documentation
dbuck@9473 9 # and/or data (collectively the "Software"), free of charge and under any
dbuck@9473 10 # and all copyright rights in the Software, and any and all patent rights
dbuck@9473 11 # owned or freely licensable by each licensor hereunder covering either (i)
dbuck@9473 12 # the unmodified Software as contributed to or provided by such licensor,
dbuck@9473 13 # or (ii) the Larger Works (as defined below), to deal in both
aoqi@0 14 #
dbuck@9473 15 # (a) the Software, and
dbuck@9473 16 #
dbuck@9473 17 # (b) any piece of software and/or hardware listed in the lrgrwrks.txt file
dbuck@9476 18 # if one is included with the Software (each a "Larger Work" to which the
dbuck@9473 19 # Software is contributed by such licensors),
dbuck@9473 20 #
dbuck@9473 21 # without restriction, including without limitation the rights to copy,
dbuck@9473 22 # create derivative works of, display, perform, and distribute the Software
dbuck@9473 23 # and make, use, sell, offer for sale, import, export, have made, and have
dbuck@9473 24 # sold the Software and the Larger Work(s), and to sublicense the foregoing
dbuck@9473 25 # rights on either these or other terms.
dbuck@9473 26 #
dbuck@9473 27 # This license is subject to the following condition:
dbuck@9473 28 #
dbuck@9473 29 # The above copyright notice and either this complete permission notice or
dbuck@9473 30 # at a minimum a reference to the UPL must be included in all copies or
dbuck@9473 31 # substantial portions of the Software.
dbuck@9473 32 #
dbuck@9473 33 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
dbuck@9473 34 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
dbuck@9473 35 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
dbuck@9473 36 # NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
dbuck@9473 37 # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
dbuck@9473 38 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
dbuck@9473 39 # USE OR OTHER DEALINGS IN THE SOFTWARE.
aoqi@0 40 #
aoqi@0 41 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 42 # or visit www.oracle.com if you need additional information or have any
aoqi@0 43 # questions.
aoqi@0 44 #
aoqi@0 45 #
aoqi@0 46
aoqi@0 47 # Single gnu makefile for solaris, linux and windows (windows requires cygwin and mingw)
aoqi@0 48
aoqi@0 49 # Default arch; it is changed below as needed.
aoqi@0 50 ARCH = i386
aoqi@0 51 OS = $(shell uname)
aoqi@0 52 AR = ar
aoqi@0 53
aoqi@0 54 ## OS = SunOS ##
aoqi@0 55 ifeq ($(OS),SunOS)
aoqi@0 56 CPU = $(shell uname -p)
aoqi@0 57 ARCH1=$(CPU:i586=i386)
aoqi@0 58 ARCH=$(ARCH1:i686=i386)
aoqi@0 59 OS = solaris
aoqi@0 60 CC = cc
aoqi@0 61 CFLAGS += -KPIC
aoqi@0 62 ifdef LP64
aoqi@0 63 ifeq ($(ARCH),sparc)
aoqi@0 64 ARCH = sparcv9
aoqi@0 65 endif
aoqi@0 66 ifeq ($(ARCH),i386)
aoqi@0 67 ARCH = amd64
aoqi@0 68 endif
aoqi@0 69 endif
aoqi@0 70 CFLAGS/sparcv9 += -xarch=v9
aoqi@0 71 CFLAGS/amd64 += -m64
aoqi@0 72 CFLAGS += $(CFLAGS/$(ARCH))
aoqi@0 73 DLDFLAGS += -G
aoqi@0 74 LDFLAGS += -ldl
aoqi@0 75 OUTFLAGS += -o $@
aoqi@0 76 LIB_EXT = .so
aoqi@0 77 else
aoqi@0 78 ## OS = Linux ##
aoqi@0 79 ifeq ($(OS),Linux)
aoqi@0 80 ifneq ($(MINGW),)
aoqi@0 81 LIB_EXT = .dll
aoqi@0 82 CPPFLAGS += -I$(TARGET_DIR)/include
aoqi@0 83 LDFLAGS += -L$(TARGET_DIR)/lib
aoqi@0 84 OS=windows
aoqi@0 85 ifneq ($(findstring x86_64-,$(MINGW)),)
aoqi@0 86 ARCH=amd64
aoqi@0 87 else
aoqi@0 88 ARCH=i386
aoqi@0 89 endif
aoqi@0 90 CC = $(MINGW)-gcc
aoqi@0 91 CONFIGURE_ARGS= --host=$(MINGW) --target=$(MINGW)
aoqi@0 92 else #linux
aoqi@0 93 CPU = $(shell uname -m)
aoqi@0 94 ARCH1=$(CPU:x86_64=amd64)
aoqi@0 95 ARCH=$(ARCH1:i686=i386)
aoqi@0 96 ifdef LP64
aoqi@0 97 CFLAGS/sparcv9 += -m64
aoqi@0 98 CFLAGS/amd64 += -m64
aoqi@0 99 CFLAGS/ppc64 += -m64
sgehwolf@9493 100 CFLAGS/ppc64le += -m64 -DABI_ELFv2
aoqi@0 101 else
aoqi@0 102 ARCH=$(ARCH1:amd64=i386)
aoqi@0 103 CFLAGS/i386 += -m32
aoqi@0 104 CFLAGS/sparc += -m32
aoqi@0 105 endif
aoqi@0 106 CFLAGS += $(CFLAGS/$(ARCH))
aoqi@0 107 CFLAGS += -fPIC
aoqi@432 108 ifeq ($(ARCH), mips64)
aoqi@432 109 CPUINFO = $(shell cat /proc/cpuinfo)
aoqi@432 110 ifneq ($(findstring Loongson,$(CPUINFO)),)
aoqi@432 111 CFLAGS += -DLOONGSON
aoqi@432 112 endif
aoqi@432 113 endif
aoqi@0 114 OS = linux
aoqi@0 115 LIB_EXT = .so
aoqi@0 116 CC = gcc
aoqi@0 117 endif
aoqi@0 118 CFLAGS += -O
aoqi@0 119 DLDFLAGS += -shared
zhaixiang@9226 120 ifeq ($(ARCH), mips64)
zhaixiang@9225 121 DLDFLAGS += -Wl,-z,noexecstack
zhaixiang@9226 122 endif
aoqi@0 123 LDFLAGS += -ldl
aoqi@0 124 OUTFLAGS += -o $@
aoqi@0 125 else
aoqi@0 126 ## OS = AIX ##
aoqi@0 127 ifeq ($(OS),AIX)
aoqi@0 128 OS = aix
aoqi@0 129 ARCH = ppc64
aoqi@0 130 CC = xlc_r
aoqi@0 131 CFLAGS += -DAIX -g -qpic=large -q64
aoqi@0 132 CFLAGS/ppc64 += -q64
aoqi@0 133 AR = ar -X64
aoqi@0 134 DLDFLAGS += -qmkshrobj -lz
aoqi@0 135 OUTFLAGS += -o $@
aoqi@0 136 LIB_EXT = .so
aoqi@0 137 else
aoqi@0 138 ## OS = Darwin ##
aoqi@0 139 ifeq ($(OS),Darwin)
aoqi@0 140 CPU = $(shell uname -m)
aoqi@0 141 ARCH1=$(CPU:x86_64=amd64)
aoqi@0 142 ARCH=$(ARCH1:i686=i386)
aoqi@0 143 ifdef LP64
aoqi@0 144 CFLAGS/sparcv9 += -m64
aoqi@0 145 CFLAGS/amd64 += -m64
aoqi@0 146 else
aoqi@0 147 ARCH=$(ARCH1:amd64=i386)
aoqi@0 148 CFLAGS/i386 += -m32
aoqi@0 149 CFLAGS/sparc += -m32
aoqi@0 150 endif # LP64
aoqi@0 151 CFLAGS += $(CFLAGS/$(ARCH))
aoqi@0 152 CFLAGS += -fPIC
aoqi@0 153 OS = macosx
aoqi@0 154 LIB_EXT = .dylib
aoqi@0 155 CC = gcc
aoqi@0 156 CFLAGS += -O
aoqi@0 157 # CFLAGS += -DZ_PREFIX
aoqi@0 158 DLDFLAGS += -shared
aoqi@0 159 DLDFLAGS += -lz
aoqi@0 160 LDFLAGS += -ldl
aoqi@0 161 OUTFLAGS += -o $@
aoqi@0 162 else
aoqi@0 163 ## OS = Windows ##
aoqi@0 164 OS = windows
aoqi@0 165 CC = gcc
aoqi@0 166 CFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi-
aoqi@0 167 CFLAGS += LIBARCH=\"$(LIBARCH)\"
aoqi@0 168 DLDFLAGS += /dll /subsystem:windows /incremental:no \
aoqi@0 169 /export:decode_instruction
aoqi@0 170 OUTFLAGS += /link /out:$@
aoqi@0 171 LIB_EXT = .dll
aoqi@0 172 endif # Darwin
aoqi@0 173 endif # AIX
aoqi@0 174 endif # Linux
aoqi@0 175 endif # SunOS
aoqi@0 176
aoqi@0 177 LIBARCH = $(ARCH)
aoqi@0 178 ifdef LP64
aoqi@0 179 LIBARCH64/sparc = sparcv9
aoqi@0 180 LIBARCH64/i386 = amd64
aoqi@0 181 LIBARCH64 = $(LIBARCH64/$(ARCH))
aoqi@0 182 ifneq ($(LIBARCH64),)
aoqi@0 183 LIBARCH = $(LIBARCH64)
aoqi@0 184 endif # LIBARCH64/$(ARCH)
aoqi@0 185 endif # LP64
aoqi@0 186
aoqi@0 187 JDKARCH=$(LIBARCH:i386=i586)
aoqi@0 188
aoqi@0 189 ifeq ($(BINUTILS),)
aoqi@0 190 # Pop all the way out of the workspace to look for binutils.
aoqi@0 191 # ...You probably want to override this setting.
aoqi@0 192 BINUTILSDIR = $(shell cd build/binutils;pwd)
aoqi@0 193 else
aoqi@0 194 BINUTILSDIR = $(shell cd $(BINUTILS);pwd)
aoqi@0 195 endif
aoqi@0 196
aoqi@0 197 CPPFLAGS += -I$(BINUTILSDIR)/include -I$(BINUTILSDIR)/bfd -I$(TARGET_DIR)/bfd
aoqi@0 198 CPPFLAGS += -DLIBARCH_$(LIBARCH) -DLIBARCH=\"$(LIBARCH)\" -DLIB_EXT=\"$(LIB_EXT)\"
aoqi@0 199
aoqi@0 200 TARGET_DIR = build/$(OS)-$(JDKARCH)
aoqi@0 201 TARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT)
aoqi@0 202
aoqi@0 203 SOURCE = hsdis.c
aoqi@0 204
aoqi@0 205 LIBRARIES = $(TARGET_DIR)/bfd/libbfd.a \
aoqi@0 206 $(TARGET_DIR)/opcodes/libopcodes.a \
aoqi@0 207 $(TARGET_DIR)/libiberty/libiberty.a
aoqi@0 208
aoqi@0 209 DEMO_TARGET = $(TARGET_DIR)/hsdis-demo
aoqi@0 210 DEMO_SOURCE = hsdis-demo.c
aoqi@0 211
aoqi@0 212 .PHONY: all clean demo both
aoqi@0 213
aoqi@0 214 all: $(TARGET)
aoqi@0 215
aoqi@0 216 both: all all64
aoqi@0 217
aoqi@0 218 %64:
aoqi@0 219 $(MAKE) LP64=1 ${@:%64=%}
aoqi@0 220
aoqi@0 221 demo: $(TARGET) $(DEMO_TARGET)
aoqi@0 222
aoqi@0 223 $(LIBRARIES): $(TARGET_DIR) $(TARGET_DIR)/Makefile
aoqi@0 224 if [ ! -f $@ ]; then cd $(TARGET_DIR); make all-opcodes; fi
aoqi@0 225
aoqi@0 226 $(TARGET_DIR)/Makefile:
aoqi@0 227 (cd $(TARGET_DIR); CC=$(CC) CFLAGS="$(CFLAGS)" AR="$(AR)" $(BINUTILSDIR)/configure --disable-nls $(CONFIGURE_ARGS))
aoqi@0 228
aoqi@0 229 $(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)
aoqi@0 230 $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES)
aoqi@0 231
aoqi@0 232 $(DEMO_TARGET): $(DEMO_SOURCE) $(TARGET) $(TARGET_DIR)
aoqi@0 233 $(CC) $(OUTFLAGS) -DTARGET_DIR=\"$(TARGET_DIR)\" $(CPPFLAGS) -g $(CFLAGS/$(ARCH)) $(DEMO_SOURCE) $(LDFLAGS)
aoqi@0 234
aoqi@0 235 $(TARGET_DIR):
aoqi@0 236 [ -d $@ ] || mkdir -p $@
aoqi@0 237
aoqi@0 238 clean:
aoqi@0 239 rm -rf $(TARGET_DIR)

mercurial