diff -r 041a415cdea9 -r 85c3ae53ca1c hotspot/src/share/tools/hsdis/Makefile --- a/hotspot/src/share/tools/hsdis/Makefile Tue Apr 14 12:25:54 2009 -0700 +++ b/hotspot/src/share/tools/hsdis/Makefile Wed Apr 15 09:53:54 2009 -0700 @@ -22,61 +22,75 @@ # # -# Single gnu makefile for solaris, linux and windows (windows requires mks or -# cygwin). - -ifeq ($(BINUTILS),) -# Pop all the way out of the workspace to look for binutils. -# ...You probably want to override this setting. -BINUTILS = $(shell cd ../../../../..;pwd)/binutils-2.17-$(LIBARCH) -endif +# Single gnu makefile for solaris, linux and windows (windows requires cygwin and mingw) # Default arch; it is changed below as needed. ARCH = i386 OS = $(shell uname) -CPPFLAGS += -I$(BINUTILS)/include -I$(BINUTILS)/bfd -CPPFLAGS += -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -DLIBARCH_$(LIBARCH) -CPPFLAGS += -DHOTSPOT_OS=\"$(OS)\" -DOS_$(OS) - ## OS = SunOS ## ifeq ($(OS),SunOS) -ARCH = $(shell uname -p) +CPU = $(shell uname -p) +ARCH1=$(CPU:i586=i386) +ARCH=$(ARCH1:i686=i386) OS = solaris CC = cc -CCFLAGS += -Kpic -g -CCFLAGS/amd64 += -xarch=amd64 -CCFLAGS/sparcv9 += -xarch=v9 -CCFLAGS += $(CCFLAGS/$(LIBARCH)) +CFLAGS += -KPIC +ifdef LP64 +ifeq ($(ARCH),sparc) +ARCH = sparcv9 +endif +ifeq ($(ARCH),i386) +ARCH = amd64 +endif +endif +CFLAGS/sparcv9 += -xarch=v9 +CFLAGS/amd64 += -m64 +CFLAGS += $(CFLAGS/$(ARCH)) DLDFLAGS += -G +LDFLAGS += -ldl OUTFLAGS += -o $@ LIB_EXT = .so else ## OS = Linux ## ifeq ($(OS),Linux) -CPU = $(shell uname -m) -ifeq ($(CPU),ia64) -ARCH = ia64 +ifneq ($(MINGW),) +LIB_EXT = .dll +CPPFLAGS += -I$(TARGET_DIR)/include +LDFLAGS += -L$(TARGET_DIR)/lib +OS=windows +ifneq ($(findstring x86_64-,$(MINGW)),) +ARCH=amd64 +else +ARCH=i386 +endif +CC = $(MINGW)-gcc +CONFIGURE_ARGS= --host=$(MINGW) --target=$(MINGW) else -ifeq ($(CPU),x86_64) -CCFLAGS += -fPIC -endif # x86_64 -endif # ia64 +CPU = $(shell uname -m) +ARCH1=$(CPU:x86_64=amd64) +ARCH=$(ARCH1:i686=i386) +CFLAGS/i386 += -m32 +CFLAGS/sparc += -m32 +CFLAGS/sparcv9 += -m64 +CFLAGS/amd64 += -m64 +CFLAGS += $(CFLAGS/$(ARCH)) +CFLAGS += -fPIC OS = linux +LIB_EXT = .so CC = gcc -CCFLAGS += -O +endif +CFLAGS += -O DLDFLAGS += -shared +LDFLAGS += -ldl OUTFLAGS += -o $@ -LIB_EXT = .so -CPPFLAGS += -Iinclude -Iinclude/$(OS)_$(ARCH)/ ## OS = Windows ## else # !SunOS, !Linux => Windows -OS = win -CC = cl +OS = windows +CC = gcc #CPPFLAGS += /D"WIN32" /D"_WINDOWS" /D"DEBUG" /D"NDEBUG" -CCFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi- -CCFLAGS += -Iinclude -Iinclude/gnu -Iinclude/$(OS)_$(ARCH) -CCFLAGS += /D"HOTSPOT_LIB_ARCH=\"$(LIBARCH)\"" +CFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi- +CFLAGS += LIBARCH=\"$(LIBARCH)\"" DLDFLAGS += /dll /subsystem:windows /incremental:no \ /export:decode_instruction OUTFLAGS += /link /out:$@ @@ -94,21 +108,34 @@ endif # LIBARCH64/$(ARCH) endif # LP64 -TARGET_DIR = bin/$(OS) +JDKARCH=$(LIBARCH:i386=i586) + +ifeq ($(BINUTILS),) +# Pop all the way out of the workspace to look for binutils. +# ...You probably want to override this setting. +BINUTILSDIR = $(shell cd build/binutils;pwd) +else +BINUTILSDIR = $(shell cd $(BINUTILS);pwd) +endif + +CPPFLAGS += -I$(BINUTILSDIR)/include -I$(BINUTILS)/bfd -I$(TARGET_DIR)/bfd +CPPFLAGS += -DLIBARCH_$(LIBARCH) -DLIBARCH=\"$(LIBARCH)\" -DLIB_EXT=\"$(LIB_EXT)\" + +TARGET_DIR = build/$(OS)-$(JDKARCH) TARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT) SOURCE = hsdis.c -LIBRARIES = $(BINUTILS)/bfd/libbfd.a \ - $(BINUTILS)/opcodes/libopcodes.a \ - $(BINUTILS)/libiberty/libiberty.a +LIBRARIES = $(TARGET_DIR)/bfd/libbfd.a \ + $(TARGET_DIR)/opcodes/libopcodes.a \ + $(TARGET_DIR)/libiberty/libiberty.a -DEMO_TARGET = $(TARGET_DIR)/hsdis-demo-$(LIBARCH) +DEMO_TARGET = $(TARGET_DIR)/hsdis-demo DEMO_SOURCE = hsdis-demo.c .PHONY: all clean demo both -all: $(TARGET) demo +all: $(TARGET) both: all all64 @@ -117,16 +144,17 @@ demo: $(TARGET) $(DEMO_TARGET) -$(LIBRARIES): - @echo "*** Please build binutils first; see ./README: ***" - @sed < ./README '1,/__________/d' | head -20 - @echo "..."; exit 1 +$(LIBRARIES): $(TARGET_DIR) $(TARGET_DIR)/Makefile + if [ ! -f $@ ]; then cd $(TARGET_DIR); make all-opcodes; fi + +$(TARGET_DIR)/Makefile: + (cd $(TARGET_DIR); CC=$(CC) CFLAGS="$(CFLAGS)" $(BINUTILSDIR)/configure --disable-nls $(CONFIGURE_ARGS)) $(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR) - $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CCFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES) + $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES) $(DEMO_TARGET): $(DEMO_SOURCE) $(TARGET) $(TARGET_DIR) - $(CC) $(OUTFLAGS) $(CPPFLAGS) $(CCFLAGS) $(DEMO_SOURCE) $(LDFLAGS) + $(CC) $(OUTFLAGS) -DTARGET_DIR=\"$(TARGET_DIR)\" $(CPPFLAGS) -g $(CFLAGS/$(ARCH)) $(DEMO_SOURCE) $(LDFLAGS) $(TARGET_DIR): [ -d $@ ] || mkdir -p $@