Makefile revision 1472
1N/A#
1N/A# Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
1N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1N/A#
1N/A# This code is free software; you can redistribute it and/or modify it
1N/A# under the terms of the GNU General Public License version 2 only, as
1N/A# published by the Free Software Foundation.
1N/A#
1N/A# This code is distributed in the hope that it will be useful, but WITHOUT
1N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1N/A# version 2 for more details (a copy is included in the LICENSE file that
1N/A# accompanied this code).
1N/A#
1N/A# You should have received a copy of the GNU General Public License version
1N/A# 2 along with this work; if not, write to the Free Software Foundation,
1N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1N/A#
1N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1N/A# or visit www.oracle.com if you need additional information or have any
1N/A# questions.
1N/A#
2N/A#
1N/A
1N/A# Single gnu makefile for solaris, linux and windows (windows requires cygwin and mingw)
1N/A
1N/A# Default arch; it is changed below as needed.
1N/AARCH = i386
1N/AOS = $(shell uname)
1N/A
1N/A## OS = SunOS ##
1N/Aifeq ($(OS),SunOS)
1N/ACPU = $(shell uname -p)
1N/AARCH1=$(CPU:i586=i386)
1N/AARCH=$(ARCH1:i686=i386)
1N/AOS = solaris
1N/ACC = cc
1N/ACFLAGS += -KPIC
1N/Aifdef LP64
1N/Aifeq ($(ARCH),sparc)
1N/AARCH = sparcv9
1N/Aendif
1N/Aifeq ($(ARCH),i386)
1N/AARCH = amd64
1N/Aendif
1N/Aendif
1N/ACFLAGS/sparcv9 += -xarch=v9
1N/ACFLAGS/amd64 += -m64
1N/ACFLAGS += $(CFLAGS/$(ARCH))
1N/ADLDFLAGS += -G
1N/ALDFLAGS += -ldl
1N/AOUTFLAGS += -o $@
1N/ALIB_EXT = .so
1N/Aelse
1N/A## OS = Linux ##
1N/Aifeq ($(OS),Linux)
1N/Aifneq ($(MINGW),)
1N/ALIB_EXT = .dll
1N/ACPPFLAGS += -I$(TARGET_DIR)/include
1N/ALDFLAGS += -L$(TARGET_DIR)/lib
1N/AOS=windows
1N/Aifneq ($(findstring x86_64-,$(MINGW)),)
1N/AARCH=amd64
1N/Aelse
1N/AARCH=i386
1N/Aendif
1N/ACC = $(MINGW)-gcc
1N/ACONFIGURE_ARGS= --host=$(MINGW) --target=$(MINGW)
1N/Aelse
1N/ACPU = $(shell uname -m)
1N/AARCH1=$(CPU:x86_64=amd64)
1N/AARCH=$(ARCH1:i686=i386)
1N/ACFLAGS/i386 += -m32
1N/ACFLAGS/sparc += -m32
1N/ACFLAGS/sparcv9 += -m64
1N/ACFLAGS/amd64 += -m64
1N/ACFLAGS += $(CFLAGS/$(ARCH))
1N/ACFLAGS += -fPIC
1N/AOS = linux
1N/ALIB_EXT = .so
1N/ACC = gcc
1N/Aendif
1N/ACFLAGS += -O
1N/ADLDFLAGS += -shared
1N/ALDFLAGS += -ldl
1N/AOUTFLAGS += -o $@
1N/A## OS = Windows ##
1N/Aelse # !SunOS, !Linux => Windows
1N/AOS = windows
1N/ACC = gcc
1N/A#CPPFLAGS += /D"WIN32" /D"_WINDOWS" /D"DEBUG" /D"NDEBUG"
1N/ACFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi-
1N/ACFLAGS += LIBARCH=\"$(LIBARCH)\""
1N/ADLDFLAGS += /dll /subsystem:windows /incremental:no \
1N/A /export:decode_instruction
1N/AOUTFLAGS += /link /out:$@
1N/ALIB_EXT = .dll
1N/Aendif # Linux
1N/Aendif # SunOS
1N/A
1N/ALIBARCH = $(ARCH)
1N/Aifdef LP64
1N/ALIBARCH64/sparc = sparcv9
1N/ALIBARCH64/i386 = amd64
1N/ALIBARCH64 = $(LIBARCH64/$(ARCH))
1N/Aifneq ($(LIBARCH64),)
1N/ALIBARCH = $(LIBARCH64)
1N/Aendif # LIBARCH64/$(ARCH)
1N/Aendif # LP64
1N/A
1N/AJDKARCH=$(LIBARCH:i386=i586)
1N/A
1N/Aifeq ($(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 = $(TARGET_DIR)/bfd/libbfd.a \
$(TARGET_DIR)/opcodes/libopcodes.a \
$(TARGET_DIR)/libiberty/libiberty.a
DEMO_TARGET = $(TARGET_DIR)/hsdis-demo
DEMO_SOURCE = hsdis-demo.c
.PHONY: all clean demo both
all: $(TARGET)
both: all all64
%64:
$(MAKE) LP64=1 ${@:%64=%}
demo: $(TARGET) $(DEMO_TARGET)
$(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) $(CFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES)
$(DEMO_TARGET): $(DEMO_SOURCE) $(TARGET) $(TARGET_DIR)
$(CC) $(OUTFLAGS) -DTARGET_DIR=\"$(TARGET_DIR)\" $(CPPFLAGS) -g $(CFLAGS/$(ARCH)) $(DEMO_SOURCE) $(LDFLAGS)
$(TARGET_DIR):
[ -d $@ ] || mkdir -p $@
clean:
rm -rf $(TARGET_DIR)