comparison src/share/tools/hsdis/Makefile @ 100:c7c777385a15

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