src/share/tools/hsdis/Makefile

Thu, 31 Aug 2017 13:58:45 +0800

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

mercurial