jrose@535: # drchase@4942: # Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. jrose@535: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jrose@535: # dbuck@9473: # The Universal Permissive License (UPL), Version 1.0 jrose@535: # dbuck@9473: # Subject to the condition set forth below, permission is hereby granted to dbuck@9473: # any person obtaining a copy of this software, associated documentation dbuck@9473: # and/or data (collectively the "Software"), free of charge and under any dbuck@9473: # and all copyright rights in the Software, and any and all patent rights dbuck@9473: # owned or freely licensable by each licensor hereunder covering either (i) dbuck@9473: # the unmodified Software as contributed to or provided by such licensor, dbuck@9473: # or (ii) the Larger Works (as defined below), to deal in both jrose@535: # dbuck@9473: # (a) the Software, and dbuck@9473: # dbuck@9473: # (b) any piece of software and/or hardware listed in the lrgrwrks.txt file dbuck@9476: # if one is included with the Software (each a "Larger Work" to which the dbuck@9473: # Software is contributed by such licensors), dbuck@9473: # dbuck@9473: # without restriction, including without limitation the rights to copy, dbuck@9473: # create derivative works of, display, perform, and distribute the Software dbuck@9473: # and make, use, sell, offer for sale, import, export, have made, and have dbuck@9473: # sold the Software and the Larger Work(s), and to sublicense the foregoing dbuck@9473: # rights on either these or other terms. dbuck@9473: # dbuck@9473: # This license is subject to the following condition: dbuck@9473: # dbuck@9473: # The above copyright notice and either this complete permission notice or dbuck@9473: # at a minimum a reference to the UPL must be included in all copies or dbuck@9473: # substantial portions of the Software. dbuck@9473: # dbuck@9473: # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS dbuck@9473: # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF dbuck@9473: # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN dbuck@9473: # NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, dbuck@9473: # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR dbuck@9473: # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE dbuck@9473: # USE OR OTHER DEALINGS IN THE SOFTWARE. jrose@535: # trims@1907: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: # or visit www.oracle.com if you need additional information or have any trims@1907: # questions. drchase@4942: # jrose@535: # jrose@535: never@1155: # Single gnu makefile for solaris, linux and windows (windows requires cygwin and mingw) jrose@535: jrose@535: # Default arch; it is changed below as needed. jrose@535: ARCH = i386 jrose@535: OS = $(shell uname) simonis@6456: AR = ar jrose@535: jrose@535: ## OS = SunOS ## jrose@535: ifeq ($(OS),SunOS) never@1155: CPU = $(shell uname -p) never@1155: ARCH1=$(CPU:i586=i386) never@1155: ARCH=$(ARCH1:i686=i386) jrose@535: OS = solaris jrose@535: CC = cc never@1155: CFLAGS += -KPIC never@1155: ifdef LP64 never@1155: ifeq ($(ARCH),sparc) never@1155: ARCH = sparcv9 never@1155: endif never@1155: ifeq ($(ARCH),i386) never@1155: ARCH = amd64 never@1155: endif never@1155: endif never@1155: CFLAGS/sparcv9 += -xarch=v9 never@1155: CFLAGS/amd64 += -m64 never@1155: CFLAGS += $(CFLAGS/$(ARCH)) jrose@535: DLDFLAGS += -G never@1155: LDFLAGS += -ldl jrose@535: OUTFLAGS += -o $@ jrose@535: LIB_EXT = .so jrose@535: else jrose@535: ## OS = Linux ## jrose@535: ifeq ($(OS),Linux) never@1155: ifneq ($(MINGW),) never@1155: LIB_EXT = .dll never@1155: CPPFLAGS += -I$(TARGET_DIR)/include never@1155: LDFLAGS += -L$(TARGET_DIR)/lib never@1155: OS=windows never@1155: ifneq ($(findstring x86_64-,$(MINGW)),) never@1155: ARCH=amd64 never@1155: else never@1155: ARCH=i386 never@1155: endif never@1155: CC = $(MINGW)-gcc never@1155: CONFIGURE_ARGS= --host=$(MINGW) --target=$(MINGW) drchase@4942: else #linux jrose@535: CPU = $(shell uname -m) never@1155: ARCH1=$(CPU:x86_64=amd64) never@1155: ARCH=$(ARCH1:i686=i386) minqi@4093: ifdef LP64 minqi@4093: CFLAGS/sparcv9 += -m64 minqi@4093: CFLAGS/amd64 += -m64 simonis@6456: CFLAGS/ppc64 += -m64 sgehwolf@9493: CFLAGS/ppc64le += -m64 -DABI_ELFv2 minqi@4093: else minqi@4093: ARCH=$(ARCH1:amd64=i386) never@1155: CFLAGS/i386 += -m32 never@1155: CFLAGS/sparc += -m32 minqi@4093: endif never@1155: CFLAGS += $(CFLAGS/$(ARCH)) never@1155: CFLAGS += -fPIC jrose@535: OS = linux never@1155: LIB_EXT = .so jrose@535: CC = gcc never@1155: endif never@1155: CFLAGS += -O jrose@535: DLDFLAGS += -shared never@1155: LDFLAGS += -ldl jrose@535: OUTFLAGS += -o $@ simonis@6456: else simonis@6456: ## OS = AIX ## simonis@6456: ifeq ($(OS),AIX) simonis@6456: OS = aix simonis@6456: ARCH = ppc64 simonis@6456: CC = xlc_r simonis@6456: CFLAGS += -DAIX -g -qpic=large -q64 simonis@6456: CFLAGS/ppc64 += -q64 simonis@6456: AR = ar -X64 simonis@6456: DLDFLAGS += -qmkshrobj -lz simonis@6456: OUTFLAGS += -o $@ simonis@6456: LIB_EXT = .so simonis@6456: else simonis@6456: ## OS = Darwin ## minqi@4093: ifeq ($(OS),Darwin) minqi@4093: CPU = $(shell uname -m) minqi@4093: ARCH1=$(CPU:x86_64=amd64) minqi@4093: ARCH=$(ARCH1:i686=i386) minqi@4093: ifdef LP64 minqi@4093: CFLAGS/sparcv9 += -m64 minqi@4093: CFLAGS/amd64 += -m64 minqi@4093: else minqi@4093: ARCH=$(ARCH1:amd64=i386) minqi@4093: CFLAGS/i386 += -m32 minqi@4093: CFLAGS/sparc += -m32 minqi@4093: endif # LP64 minqi@4093: CFLAGS += $(CFLAGS/$(ARCH)) minqi@4093: CFLAGS += -fPIC minqi@4093: OS = macosx minqi@4093: LIB_EXT = .dylib minqi@4093: CC = gcc minqi@4093: CFLAGS += -O minqi@4093: # CFLAGS += -DZ_PREFIX minqi@4093: DLDFLAGS += -shared minqi@4093: DLDFLAGS += -lz minqi@4093: LDFLAGS += -ldl minqi@4093: OUTFLAGS += -o $@ simonis@6456: else simonis@6456: ## OS = Windows ## never@1155: OS = windows never@1155: CC = gcc never@1155: CFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi- minqi@4093: CFLAGS += LIBARCH=\"$(LIBARCH)\" jrose@535: DLDFLAGS += /dll /subsystem:windows /incremental:no \ jrose@535: /export:decode_instruction jrose@535: OUTFLAGS += /link /out:$@ jrose@535: LIB_EXT = .dll minqi@4093: endif # Darwin simonis@6456: endif # AIX jrose@535: endif # Linux jrose@535: endif # SunOS jrose@535: jrose@535: LIBARCH = $(ARCH) jrose@535: ifdef LP64 jrose@535: LIBARCH64/sparc = sparcv9 jrose@535: LIBARCH64/i386 = amd64 jrose@535: LIBARCH64 = $(LIBARCH64/$(ARCH)) jrose@535: ifneq ($(LIBARCH64),) jrose@535: LIBARCH = $(LIBARCH64) jrose@535: endif # LIBARCH64/$(ARCH) jrose@535: endif # LP64 jrose@535: never@1155: JDKARCH=$(LIBARCH:i386=i586) never@1155: never@1155: ifeq ($(BINUTILS),) never@1155: # Pop all the way out of the workspace to look for binutils. never@1155: # ...You probably want to override this setting. never@1155: BINUTILSDIR = $(shell cd build/binutils;pwd) never@1155: else never@1155: BINUTILSDIR = $(shell cd $(BINUTILS);pwd) never@1155: endif never@1155: minqi@4093: CPPFLAGS += -I$(BINUTILSDIR)/include -I$(BINUTILSDIR)/bfd -I$(TARGET_DIR)/bfd never@1155: CPPFLAGS += -DLIBARCH_$(LIBARCH) -DLIBARCH=\"$(LIBARCH)\" -DLIB_EXT=\"$(LIB_EXT)\" never@1155: never@1155: TARGET_DIR = build/$(OS)-$(JDKARCH) jrose@535: TARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT) jrose@535: jrose@535: SOURCE = hsdis.c jrose@535: never@1155: LIBRARIES = $(TARGET_DIR)/bfd/libbfd.a \ never@1155: $(TARGET_DIR)/opcodes/libopcodes.a \ never@1155: $(TARGET_DIR)/libiberty/libiberty.a jrose@535: never@1155: DEMO_TARGET = $(TARGET_DIR)/hsdis-demo jrose@535: DEMO_SOURCE = hsdis-demo.c jrose@535: jrose@535: .PHONY: all clean demo both jrose@535: never@1155: all: $(TARGET) jrose@535: jrose@535: both: all all64 jrose@535: jrose@535: %64: jrose@535: $(MAKE) LP64=1 ${@:%64=%} jrose@535: jrose@535: demo: $(TARGET) $(DEMO_TARGET) jrose@535: never@1155: $(LIBRARIES): $(TARGET_DIR) $(TARGET_DIR)/Makefile never@1155: if [ ! -f $@ ]; then cd $(TARGET_DIR); make all-opcodes; fi never@1155: never@1155: $(TARGET_DIR)/Makefile: simonis@6456: (cd $(TARGET_DIR); CC=$(CC) CFLAGS="$(CFLAGS)" AR="$(AR)" $(BINUTILSDIR)/configure --disable-nls $(CONFIGURE_ARGS)) jrose@535: jrose@535: $(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR) never@1155: $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES) jrose@535: jrose@535: $(DEMO_TARGET): $(DEMO_SOURCE) $(TARGET) $(TARGET_DIR) never@1155: $(CC) $(OUTFLAGS) -DTARGET_DIR=\"$(TARGET_DIR)\" $(CPPFLAGS) -g $(CFLAGS/$(ARCH)) $(DEMO_SOURCE) $(LDFLAGS) jrose@535: jrose@535: $(TARGET_DIR): jrose@535: [ -d $@ ] || mkdir -p $@ jrose@535: jrose@535: clean: jrose@535: rm -rf $(TARGET_DIR)