1 #
2 # Copyright (c) 2008, 2017, 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
109 endif
110 CFLAGS += $(CFLAGS/$(ARCH))
111 CFLAGS += -fPIC
112 OS = linux
113 LIB_EXT = .so
114 CC = gcc
115 endif
116 CFLAGS += -O
117 DLDFLAGS += -shared
118 LDFLAGS += -ldl
119 OUTFLAGS += -o $@
120 else
121 ## OS = AIX ##
122 ifeq ($(OS),AIX)
123 OS = aix
124 ARCH = ppc64
125 CC = xlc_r
126 CFLAGS += -DAIX -g -qpic=large -q64
127 CFLAGS/ppc64 += -q64
128 AR = ar -X64
129 DLDFLAGS += -qmkshrobj -lz
130 OUTFLAGS += -o $@
131 LIB_EXT = .so
132 else
133 ## OS = Darwin ##
134 ifeq ($(OS),Darwin)
135 CPU = $(shell uname -m)
136 ARCH1=$(CPU:x86_64=amd64)
137 ARCH=$(ARCH1:i686=i386)
138 ifdef LP64
139 CFLAGS/sparcv9 += -m64
140 CFLAGS/amd64 += -m64
141 else
142 ARCH=$(ARCH1:amd64=i386)
143 CFLAGS/i386 += -m32
144 CFLAGS/sparc += -m32
145 endif # LP64
146 CFLAGS += $(CFLAGS/$(ARCH))
147 CFLAGS += -fPIC
148 OS = macosx
149 LIB_EXT = .dylib
150 CC = gcc
151 CFLAGS += -O
152 # CFLAGS += -DZ_PREFIX
153 DLDFLAGS += -shared
154 DLDFLAGS += -lz
155 LDFLAGS += -ldl
156 OUTFLAGS += -o $@
157 else
158 ## OS = Windows ##
159 OS = windows
160 CC = gcc
161 CFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi-
162 CFLAGS += LIBARCH=\"$(LIBARCH)\"
163 DLDFLAGS += /dll /subsystem:windows /incremental:no \
164 /export:decode_instruction
165 OUTFLAGS += /link /out:$@
166 LIB_EXT = .dll
167 endif # Darwin
168 endif # AIX
169 endif # Linux
170 endif # SunOS
171
172 LIBARCH = $(ARCH)
173 ifdef LP64
174 LIBARCH64/sparc = sparcv9
182 JDKARCH=$(LIBARCH:i386=i586)
183
184 ifeq ($(BINUTILS),)
185 # Pop all the way out of the workspace to look for binutils.
186 # ...You probably want to override this setting.
187 BINUTILSDIR = $(shell cd build/binutils;pwd)
188 else
189 BINUTILSDIR = $(shell cd $(BINUTILS);pwd)
190 endif
191
192 CPPFLAGS += -I$(BINUTILSDIR)/include -I$(BINUTILSDIR)/bfd -I$(TARGET_DIR)/bfd
193 CPPFLAGS += -DLIBARCH_$(LIBARCH) -DLIBARCH=\"$(LIBARCH)\" -DLIB_EXT=\"$(LIB_EXT)\"
194
195 TARGET_DIR = build/$(OS)-$(JDKARCH)
196 TARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT)
197
198 SOURCE = hsdis.c
199
200 LIBRARIES = $(TARGET_DIR)/bfd/libbfd.a \
201 $(TARGET_DIR)/opcodes/libopcodes.a \
202 $(TARGET_DIR)/libiberty/libiberty.a
203
204 DEMO_TARGET = $(TARGET_DIR)/hsdis-demo
205 DEMO_SOURCE = hsdis-demo.c
206
207 .PHONY: all clean demo both
208
209 all: $(TARGET)
210
211 both: all all64
212
213 %64:
214 $(MAKE) LP64=1 ${@:%64=%}
215
216 demo: $(TARGET) $(DEMO_TARGET)
217
218 $(LIBRARIES): $(TARGET_DIR) $(TARGET_DIR)/Makefile
219 if [ ! -f $@ ]; then cd $(TARGET_DIR); make all-opcodes; fi
220
221 $(TARGET_DIR)/Makefile:
222 (cd $(TARGET_DIR); CC=$(CC) CFLAGS="$(CFLAGS)" AR="$(AR)" $(BINUTILSDIR)/configure --disable-nls $(CONFIGURE_ARGS))
|
1 #
2 # Copyright (c) 2008, 2019, 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
109 endif
110 CFLAGS += $(CFLAGS/$(ARCH))
111 CFLAGS += -fPIC
112 OS = linux
113 LIB_EXT = .so
114 CC = gcc
115 endif
116 CFLAGS += -O
117 DLDFLAGS += -shared
118 LDFLAGS += -ldl
119 OUTFLAGS += -o $@
120 else
121 ## OS = AIX ##
122 ifeq ($(OS),AIX)
123 OS = aix
124 ARCH = ppc64
125 CC = xlc_r
126 CFLAGS += -DAIX -g -qpic=large -q64
127 CFLAGS/ppc64 += -q64
128 AR = ar -X64
129 DLDFLAGS += -qmkshrobj
130 OUTFLAGS += -o $@
131 LIB_EXT = .so
132 else
133 ## OS = Darwin ##
134 ifeq ($(OS),Darwin)
135 CPU = $(shell uname -m)
136 ARCH1=$(CPU:x86_64=amd64)
137 ARCH=$(ARCH1:i686=i386)
138 ifdef LP64
139 CFLAGS/sparcv9 += -m64
140 CFLAGS/amd64 += -m64
141 else
142 ARCH=$(ARCH1:amd64=i386)
143 CFLAGS/i386 += -m32
144 CFLAGS/sparc += -m32
145 endif # LP64
146 CFLAGS += $(CFLAGS/$(ARCH))
147 CFLAGS += -fPIC
148 OS = macosx
149 LIB_EXT = .dylib
150 CC = gcc
151 CFLAGS += -O
152 # CFLAGS += -DZ_PREFIX
153 DLDFLAGS += -shared
154 LDFLAGS += -ldl
155 OUTFLAGS += -o $@
156 else
157 ## OS = Windows ##
158 OS = windows
159 CC = gcc
160 CFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi-
161 CFLAGS += LIBARCH=\"$(LIBARCH)\"
162 DLDFLAGS += /dll /subsystem:windows /incremental:no \
163 /export:decode_instruction
164 OUTFLAGS += /link /out:$@
165 LIB_EXT = .dll
166 endif # Darwin
167 endif # AIX
168 endif # Linux
169 endif # SunOS
170
171 LIBARCH = $(ARCH)
172 ifdef LP64
173 LIBARCH64/sparc = sparcv9
181 JDKARCH=$(LIBARCH:i386=i586)
182
183 ifeq ($(BINUTILS),)
184 # Pop all the way out of the workspace to look for binutils.
185 # ...You probably want to override this setting.
186 BINUTILSDIR = $(shell cd build/binutils;pwd)
187 else
188 BINUTILSDIR = $(shell cd $(BINUTILS);pwd)
189 endif
190
191 CPPFLAGS += -I$(BINUTILSDIR)/include -I$(BINUTILSDIR)/bfd -I$(TARGET_DIR)/bfd
192 CPPFLAGS += -DLIBARCH_$(LIBARCH) -DLIBARCH=\"$(LIBARCH)\" -DLIB_EXT=\"$(LIB_EXT)\"
193
194 TARGET_DIR = build/$(OS)-$(JDKARCH)
195 TARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT)
196
197 SOURCE = hsdis.c
198
199 LIBRARIES = $(TARGET_DIR)/bfd/libbfd.a \
200 $(TARGET_DIR)/opcodes/libopcodes.a \
201 $(TARGET_DIR)/libiberty/libiberty.a \
202 $(TARGET_DIR)/zlib/libz.a
203
204 DEMO_TARGET = $(TARGET_DIR)/hsdis-demo
205 DEMO_SOURCE = hsdis-demo.c
206
207 .PHONY: all clean demo both
208
209 all: $(TARGET)
210
211 both: all all64
212
213 %64:
214 $(MAKE) LP64=1 ${@:%64=%}
215
216 demo: $(TARGET) $(DEMO_TARGET)
217
218 $(LIBRARIES): $(TARGET_DIR) $(TARGET_DIR)/Makefile
219 if [ ! -f $@ ]; then cd $(TARGET_DIR); make all-opcodes; fi
220
221 $(TARGET_DIR)/Makefile:
222 (cd $(TARGET_DIR); CC=$(CC) CFLAGS="$(CFLAGS)" AR="$(AR)" $(BINUTILSDIR)/configure --disable-nls $(CONFIGURE_ARGS))
|