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

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

mercurial