src/share/tools/hsdis/Makefile

Wed, 02 Apr 2008 12:09:59 -0700

author
jrose
date
Wed, 02 Apr 2008 12:09:59 -0700
changeset 535
c7c777385a15
child 1155
67a2f5ba5582
permissions
-rw-r--r--

6667042: PrintAssembly option does not work without special plugin
Summary: remove old private plugin interface, simplify, rework old plugin to use unchanged Gnu sources
Reviewed-by: kvn, rasbold

jrose@535 1 #
jrose@535 2 # Copyright 2008 Sun Microsystems, Inc. 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 #
jrose@535 19 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
jrose@535 20 # CA 95054 USA or visit www.sun.com if you need additional information or
jrose@535 21 # have any questions.
jrose@535 22 #
jrose@535 23 #
jrose@535 24
jrose@535 25 # Single gnu makefile for solaris, linux and windows (windows requires mks or
jrose@535 26 # cygwin).
jrose@535 27
jrose@535 28 ifeq ($(BINUTILS),)
jrose@535 29 # Pop all the way out of the workspace to look for binutils.
jrose@535 30 # ...You probably want to override this setting.
jrose@535 31 BINUTILS = $(shell cd ../../../../..;pwd)/binutils-2.17-$(LIBARCH)
jrose@535 32 endif
jrose@535 33
jrose@535 34 # Default arch; it is changed below as needed.
jrose@535 35 ARCH = i386
jrose@535 36 OS = $(shell uname)
jrose@535 37
jrose@535 38 CPPFLAGS += -I$(BINUTILS)/include -I$(BINUTILS)/bfd
jrose@535 39 CPPFLAGS += -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -DLIBARCH_$(LIBARCH)
jrose@535 40 CPPFLAGS += -DHOTSPOT_OS=\"$(OS)\" -DOS_$(OS)
jrose@535 41
jrose@535 42 ## OS = SunOS ##
jrose@535 43 ifeq ($(OS),SunOS)
jrose@535 44 ARCH = $(shell uname -p)
jrose@535 45 OS = solaris
jrose@535 46 CC = cc
jrose@535 47 CCFLAGS += -Kpic -g
jrose@535 48 CCFLAGS/amd64 += -xarch=amd64
jrose@535 49 CCFLAGS/sparcv9 += -xarch=v9
jrose@535 50 CCFLAGS += $(CCFLAGS/$(LIBARCH))
jrose@535 51 DLDFLAGS += -G
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)
jrose@535 57 CPU = $(shell uname -m)
jrose@535 58 ifeq ($(CPU),ia64)
jrose@535 59 ARCH = ia64
jrose@535 60 else
jrose@535 61 ifeq ($(CPU),x86_64)
jrose@535 62 CCFLAGS += -fPIC
jrose@535 63 endif # x86_64
jrose@535 64 endif # ia64
jrose@535 65 OS = linux
jrose@535 66 CC = gcc
jrose@535 67 CCFLAGS += -O
jrose@535 68 DLDFLAGS += -shared
jrose@535 69 OUTFLAGS += -o $@
jrose@535 70 LIB_EXT = .so
jrose@535 71 CPPFLAGS += -Iinclude -Iinclude/$(OS)_$(ARCH)/
jrose@535 72 ## OS = Windows ##
jrose@535 73 else # !SunOS, !Linux => Windows
jrose@535 74 OS = win
jrose@535 75 CC = cl
jrose@535 76 #CPPFLAGS += /D"WIN32" /D"_WINDOWS" /D"DEBUG" /D"NDEBUG"
jrose@535 77 CCFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi-
jrose@535 78 CCFLAGS += -Iinclude -Iinclude/gnu -Iinclude/$(OS)_$(ARCH)
jrose@535 79 CCFLAGS += /D"HOTSPOT_LIB_ARCH=\"$(LIBARCH)\""
jrose@535 80 DLDFLAGS += /dll /subsystem:windows /incremental:no \
jrose@535 81 /export:decode_instruction
jrose@535 82 OUTFLAGS += /link /out:$@
jrose@535 83 LIB_EXT = .dll
jrose@535 84 endif # Linux
jrose@535 85 endif # SunOS
jrose@535 86
jrose@535 87 LIBARCH = $(ARCH)
jrose@535 88 ifdef LP64
jrose@535 89 LIBARCH64/sparc = sparcv9
jrose@535 90 LIBARCH64/i386 = amd64
jrose@535 91 LIBARCH64 = $(LIBARCH64/$(ARCH))
jrose@535 92 ifneq ($(LIBARCH64),)
jrose@535 93 LIBARCH = $(LIBARCH64)
jrose@535 94 endif # LIBARCH64/$(ARCH)
jrose@535 95 endif # LP64
jrose@535 96
jrose@535 97 TARGET_DIR = bin/$(OS)
jrose@535 98 TARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT)
jrose@535 99
jrose@535 100 SOURCE = hsdis.c
jrose@535 101
jrose@535 102 LIBRARIES = $(BINUTILS)/bfd/libbfd.a \
jrose@535 103 $(BINUTILS)/opcodes/libopcodes.a \
jrose@535 104 $(BINUTILS)/libiberty/libiberty.a
jrose@535 105
jrose@535 106 DEMO_TARGET = $(TARGET_DIR)/hsdis-demo-$(LIBARCH)
jrose@535 107 DEMO_SOURCE = hsdis-demo.c
jrose@535 108
jrose@535 109 .PHONY: all clean demo both
jrose@535 110
jrose@535 111 all: $(TARGET) demo
jrose@535 112
jrose@535 113 both: all all64
jrose@535 114
jrose@535 115 %64:
jrose@535 116 $(MAKE) LP64=1 ${@:%64=%}
jrose@535 117
jrose@535 118 demo: $(TARGET) $(DEMO_TARGET)
jrose@535 119
jrose@535 120 $(LIBRARIES):
jrose@535 121 @echo "*** Please build binutils first; see ./README: ***"
jrose@535 122 @sed < ./README '1,/__________/d' | head -20
jrose@535 123 @echo "..."; exit 1
jrose@535 124
jrose@535 125 $(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)
jrose@535 126 $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CCFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES)
jrose@535 127
jrose@535 128 $(DEMO_TARGET): $(DEMO_SOURCE) $(TARGET) $(TARGET_DIR)
jrose@535 129 $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CCFLAGS) $(DEMO_SOURCE) $(LDFLAGS)
jrose@535 130
jrose@535 131 $(TARGET_DIR):
jrose@535 132 [ -d $@ ] || mkdir -p $@
jrose@535 133
jrose@535 134 clean:
jrose@535 135 rm -rf $(TARGET_DIR)

mercurial