src/share/tools/hsdis/Makefile

Tue, 25 Sep 2018 16:23:35 +0200

author
sgehwolf
date
Tue, 25 Sep 2018 16:23:35 +0200
changeset 9493
882a55369341
parent 9476
9a18c71dbd25
child 9572
624a0741915c
permissions
-rw-r--r--

8073139: PPC64: User-visible arch directory and os.arch value on ppc64le cause issues with Java tooling
Reviewed-by: erikj, goetz, dholmes

jrose@535 1 #
drchase@4942 2 # Copyright (c) 2008, 2013, 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 #
dbuck@9473 5 # The Universal Permissive License (UPL), Version 1.0
jrose@535 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
jrose@535 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.
jrose@535 40 #
trims@1907 41 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 42 # or visit www.oracle.com if you need additional information or have any
trims@1907 43 # questions.
drchase@4942 44 #
jrose@535 45 #
jrose@535 46
never@1155 47 # Single gnu makefile for solaris, linux and windows (windows requires cygwin and mingw)
jrose@535 48
jrose@535 49 # Default arch; it is changed below as needed.
jrose@535 50 ARCH = i386
jrose@535 51 OS = $(shell uname)
simonis@6456 52 AR = ar
jrose@535 53
jrose@535 54 ## OS = SunOS ##
jrose@535 55 ifeq ($(OS),SunOS)
never@1155 56 CPU = $(shell uname -p)
never@1155 57 ARCH1=$(CPU:i586=i386)
never@1155 58 ARCH=$(ARCH1:i686=i386)
jrose@535 59 OS = solaris
jrose@535 60 CC = cc
never@1155 61 CFLAGS += -KPIC
never@1155 62 ifdef LP64
never@1155 63 ifeq ($(ARCH),sparc)
never@1155 64 ARCH = sparcv9
never@1155 65 endif
never@1155 66 ifeq ($(ARCH),i386)
never@1155 67 ARCH = amd64
never@1155 68 endif
never@1155 69 endif
never@1155 70 CFLAGS/sparcv9 += -xarch=v9
never@1155 71 CFLAGS/amd64 += -m64
never@1155 72 CFLAGS += $(CFLAGS/$(ARCH))
jrose@535 73 DLDFLAGS += -G
never@1155 74 LDFLAGS += -ldl
jrose@535 75 OUTFLAGS += -o $@
jrose@535 76 LIB_EXT = .so
jrose@535 77 else
jrose@535 78 ## OS = Linux ##
jrose@535 79 ifeq ($(OS),Linux)
never@1155 80 ifneq ($(MINGW),)
never@1155 81 LIB_EXT = .dll
never@1155 82 CPPFLAGS += -I$(TARGET_DIR)/include
never@1155 83 LDFLAGS += -L$(TARGET_DIR)/lib
never@1155 84 OS=windows
never@1155 85 ifneq ($(findstring x86_64-,$(MINGW)),)
never@1155 86 ARCH=amd64
never@1155 87 else
never@1155 88 ARCH=i386
never@1155 89 endif
never@1155 90 CC = $(MINGW)-gcc
never@1155 91 CONFIGURE_ARGS= --host=$(MINGW) --target=$(MINGW)
drchase@4942 92 else #linux
jrose@535 93 CPU = $(shell uname -m)
never@1155 94 ARCH1=$(CPU:x86_64=amd64)
never@1155 95 ARCH=$(ARCH1:i686=i386)
minqi@4093 96 ifdef LP64
minqi@4093 97 CFLAGS/sparcv9 += -m64
minqi@4093 98 CFLAGS/amd64 += -m64
simonis@6456 99 CFLAGS/ppc64 += -m64
sgehwolf@9493 100 CFLAGS/ppc64le += -m64 -DABI_ELFv2
minqi@4093 101 else
minqi@4093 102 ARCH=$(ARCH1:amd64=i386)
never@1155 103 CFLAGS/i386 += -m32
never@1155 104 CFLAGS/sparc += -m32
minqi@4093 105 endif
never@1155 106 CFLAGS += $(CFLAGS/$(ARCH))
never@1155 107 CFLAGS += -fPIC
jrose@535 108 OS = linux
never@1155 109 LIB_EXT = .so
jrose@535 110 CC = gcc
never@1155 111 endif
never@1155 112 CFLAGS += -O
jrose@535 113 DLDFLAGS += -shared
never@1155 114 LDFLAGS += -ldl
jrose@535 115 OUTFLAGS += -o $@
simonis@6456 116 else
simonis@6456 117 ## OS = AIX ##
simonis@6456 118 ifeq ($(OS),AIX)
simonis@6456 119 OS = aix
simonis@6456 120 ARCH = ppc64
simonis@6456 121 CC = xlc_r
simonis@6456 122 CFLAGS += -DAIX -g -qpic=large -q64
simonis@6456 123 CFLAGS/ppc64 += -q64
simonis@6456 124 AR = ar -X64
simonis@6456 125 DLDFLAGS += -qmkshrobj -lz
simonis@6456 126 OUTFLAGS += -o $@
simonis@6456 127 LIB_EXT = .so
simonis@6456 128 else
simonis@6456 129 ## OS = Darwin ##
minqi@4093 130 ifeq ($(OS),Darwin)
minqi@4093 131 CPU = $(shell uname -m)
minqi@4093 132 ARCH1=$(CPU:x86_64=amd64)
minqi@4093 133 ARCH=$(ARCH1:i686=i386)
minqi@4093 134 ifdef LP64
minqi@4093 135 CFLAGS/sparcv9 += -m64
minqi@4093 136 CFLAGS/amd64 += -m64
minqi@4093 137 else
minqi@4093 138 ARCH=$(ARCH1:amd64=i386)
minqi@4093 139 CFLAGS/i386 += -m32
minqi@4093 140 CFLAGS/sparc += -m32
minqi@4093 141 endif # LP64
minqi@4093 142 CFLAGS += $(CFLAGS/$(ARCH))
minqi@4093 143 CFLAGS += -fPIC
minqi@4093 144 OS = macosx
minqi@4093 145 LIB_EXT = .dylib
minqi@4093 146 CC = gcc
minqi@4093 147 CFLAGS += -O
minqi@4093 148 # CFLAGS += -DZ_PREFIX
minqi@4093 149 DLDFLAGS += -shared
minqi@4093 150 DLDFLAGS += -lz
minqi@4093 151 LDFLAGS += -ldl
minqi@4093 152 OUTFLAGS += -o $@
simonis@6456 153 else
simonis@6456 154 ## OS = Windows ##
never@1155 155 OS = windows
never@1155 156 CC = gcc
never@1155 157 CFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi-
minqi@4093 158 CFLAGS += LIBARCH=\"$(LIBARCH)\"
jrose@535 159 DLDFLAGS += /dll /subsystem:windows /incremental:no \
jrose@535 160 /export:decode_instruction
jrose@535 161 OUTFLAGS += /link /out:$@
jrose@535 162 LIB_EXT = .dll
minqi@4093 163 endif # Darwin
simonis@6456 164 endif # AIX
jrose@535 165 endif # Linux
jrose@535 166 endif # SunOS
jrose@535 167
jrose@535 168 LIBARCH = $(ARCH)
jrose@535 169 ifdef LP64
jrose@535 170 LIBARCH64/sparc = sparcv9
jrose@535 171 LIBARCH64/i386 = amd64
jrose@535 172 LIBARCH64 = $(LIBARCH64/$(ARCH))
jrose@535 173 ifneq ($(LIBARCH64),)
jrose@535 174 LIBARCH = $(LIBARCH64)
jrose@535 175 endif # LIBARCH64/$(ARCH)
jrose@535 176 endif # LP64
jrose@535 177
never@1155 178 JDKARCH=$(LIBARCH:i386=i586)
never@1155 179
never@1155 180 ifeq ($(BINUTILS),)
never@1155 181 # Pop all the way out of the workspace to look for binutils.
never@1155 182 # ...You probably want to override this setting.
never@1155 183 BINUTILSDIR = $(shell cd build/binutils;pwd)
never@1155 184 else
never@1155 185 BINUTILSDIR = $(shell cd $(BINUTILS);pwd)
never@1155 186 endif
never@1155 187
minqi@4093 188 CPPFLAGS += -I$(BINUTILSDIR)/include -I$(BINUTILSDIR)/bfd -I$(TARGET_DIR)/bfd
never@1155 189 CPPFLAGS += -DLIBARCH_$(LIBARCH) -DLIBARCH=\"$(LIBARCH)\" -DLIB_EXT=\"$(LIB_EXT)\"
never@1155 190
never@1155 191 TARGET_DIR = build/$(OS)-$(JDKARCH)
jrose@535 192 TARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT)
jrose@535 193
jrose@535 194 SOURCE = hsdis.c
jrose@535 195
never@1155 196 LIBRARIES = $(TARGET_DIR)/bfd/libbfd.a \
never@1155 197 $(TARGET_DIR)/opcodes/libopcodes.a \
never@1155 198 $(TARGET_DIR)/libiberty/libiberty.a
jrose@535 199
never@1155 200 DEMO_TARGET = $(TARGET_DIR)/hsdis-demo
jrose@535 201 DEMO_SOURCE = hsdis-demo.c
jrose@535 202
jrose@535 203 .PHONY: all clean demo both
jrose@535 204
never@1155 205 all: $(TARGET)
jrose@535 206
jrose@535 207 both: all all64
jrose@535 208
jrose@535 209 %64:
jrose@535 210 $(MAKE) LP64=1 ${@:%64=%}
jrose@535 211
jrose@535 212 demo: $(TARGET) $(DEMO_TARGET)
jrose@535 213
never@1155 214 $(LIBRARIES): $(TARGET_DIR) $(TARGET_DIR)/Makefile
never@1155 215 if [ ! -f $@ ]; then cd $(TARGET_DIR); make all-opcodes; fi
never@1155 216
never@1155 217 $(TARGET_DIR)/Makefile:
simonis@6456 218 (cd $(TARGET_DIR); CC=$(CC) CFLAGS="$(CFLAGS)" AR="$(AR)" $(BINUTILSDIR)/configure --disable-nls $(CONFIGURE_ARGS))
jrose@535 219
jrose@535 220 $(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)
never@1155 221 $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES)
jrose@535 222
jrose@535 223 $(DEMO_TARGET): $(DEMO_SOURCE) $(TARGET) $(TARGET_DIR)
never@1155 224 $(CC) $(OUTFLAGS) -DTARGET_DIR=\"$(TARGET_DIR)\" $(CPPFLAGS) -g $(CFLAGS/$(ARCH)) $(DEMO_SOURCE) $(LDFLAGS)
jrose@535 225
jrose@535 226 $(TARGET_DIR):
jrose@535 227 [ -d $@ ] || mkdir -p $@
jrose@535 228
jrose@535 229 clean:
jrose@535 230 rm -rf $(TARGET_DIR)

mercurial