Makefile revision 100
829N/A#
2362N/A# Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
829N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
829N/A#
829N/A# This code is free software; you can redistribute it and/or modify it
829N/A# under the terms of the GNU General Public License version 2 only, as
2362N/A# published by the Free Software Foundation.
829N/A#
2362N/A# This code is distributed in the hope that it will be useful, but WITHOUT
829N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
829N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
829N/A# version 2 for more details (a copy is included in the LICENSE file that
829N/A# accompanied this code).
829N/A#
829N/A# You should have received a copy of the GNU General Public License version
829N/A# 2 along with this work; if not, write to the Free Software Foundation,
829N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
829N/A#
829N/A# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
829N/A# CA 95054 USA or visit www.sun.com if you need additional information or
2362N/A# have any questions.
2362N/A#
2362N/A#
829N/A
829N/A# Single gnu makefile for solaris, linux and windows (windows requires mks or
829N/A# cygwin).
829N/A
829N/Aifeq ($(BINUTILS),)
829N/A# Pop all the way out of the workspace to look for binutils.
829N/A# ...You probably want to override this setting.
829N/ABINUTILS = $(shell cd ../../../../..;pwd)/binutils-2.17-$(LIBARCH)
829N/Aendif
829N/A
829N/A# Default arch; it is changed below as needed.
829N/AARCH = i386
829N/AOS = $(shell uname)
829N/A
829N/ACPPFLAGS += -I$(BINUTILS)/include -I$(BINUTILS)/bfd
829N/ACPPFLAGS += -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -DLIBARCH_$(LIBARCH)
829N/ACPPFLAGS += -DHOTSPOT_OS=\"$(OS)\" -DOS_$(OS)
829N/A
829N/A## OS = SunOS ##
829N/Aifeq ($(OS),SunOS)
829N/AARCH = $(shell uname -p)
829N/AOS = solaris
829N/ACC = cc
829N/ACCFLAGS += -Kpic -g
829N/ACCFLAGS/amd64 += -xarch=amd64
829N/ACCFLAGS/sparcv9 += -xarch=v9
829N/ACCFLAGS += $(CCFLAGS/$(LIBARCH))
829N/ADLDFLAGS += -G
829N/AOUTFLAGS += -o $@
829N/ALIB_EXT = .so
829N/Aelse
829N/A## OS = Linux ##
829N/Aifeq ($(OS),Linux)
829N/ACPU = $(shell uname -m)
829N/Aifeq ($(CPU),ia64)
829N/AARCH = ia64
829N/Aelse
829N/Aifeq ($(CPU),x86_64)
829N/ACCFLAGS += -fPIC
829N/Aendif # x86_64
829N/Aendif # ia64
829N/AOS = linux
829N/ACC = gcc
829N/ACCFLAGS += -O
829N/ADLDFLAGS += -shared
829N/AOUTFLAGS += -o $@
829N/ALIB_EXT = .so
829N/ACPPFLAGS += -Iinclude -Iinclude/$(OS)_$(ARCH)/
829N/A## OS = Windows ##
829N/Aelse # !SunOS, !Linux => Windows
829N/AOS = win
829N/ACC = cl
829N/A#CPPFLAGS += /D"WIN32" /D"_WINDOWS" /D"DEBUG" /D"NDEBUG"
829N/ACCFLAGS += /nologo /MD /W3 /WX /O2 /Fo$(@:.dll=.obj) /Gi-
829N/ACCFLAGS += -Iinclude -Iinclude/gnu -Iinclude/$(OS)_$(ARCH)
829N/ACCFLAGS += /D"HOTSPOT_LIB_ARCH=\"$(LIBARCH)\""
829N/ADLDFLAGS += /dll /subsystem:windows /incremental:no \
829N/A /export:decode_instruction
829N/AOUTFLAGS += /link /out:$@
829N/ALIB_EXT = .dll
829N/Aendif # Linux
829N/Aendif # SunOS
829N/A
829N/ALIBARCH = $(ARCH)
829N/Aifdef LP64
829N/ALIBARCH64/sparc = sparcv9
829N/ALIBARCH64/i386 = amd64
829N/ALIBARCH64 = $(LIBARCH64/$(ARCH))
829N/Aifneq ($(LIBARCH64),)
829N/ALIBARCH = $(LIBARCH64)
829N/Aendif # LIBARCH64/$(ARCH)
829N/Aendif # LP64
829N/A
829N/ATARGET_DIR = bin/$(OS)
829N/ATARGET = $(TARGET_DIR)/hsdis-$(LIBARCH)$(LIB_EXT)
829N/A
829N/ASOURCE = hsdis.c
829N/A
829N/ALIBRARIES = $(BINUTILS)/bfd/libbfd.a \
829N/A $(BINUTILS)/opcodes/libopcodes.a \
829N/A $(BINUTILS)/libiberty/libiberty.a
829N/A
829N/ADEMO_TARGET = $(TARGET_DIR)/hsdis-demo-$(LIBARCH)
DEMO_SOURCE = hsdis-demo.c
.PHONY: all clean demo both
all: $(TARGET) demo
both: all all64
%64:
$(MAKE) LP64=1 ${@:%64=%}
demo: $(TARGET) $(DEMO_TARGET)
$(LIBRARIES):
@echo "*** Please build binutils first; see ./README: ***"
@sed < ./README '1,/__________/d' | head -20
@echo "..."; exit 1
$(TARGET): $(SOURCE) $(LIBS) $(LIBRARIES) $(TARGET_DIR)
$(CC) $(OUTFLAGS) $(CPPFLAGS) $(CCFLAGS) $(SOURCE) $(DLDFLAGS) $(LIBRARIES)
$(DEMO_TARGET): $(DEMO_SOURCE) $(TARGET) $(TARGET_DIR)
$(CC) $(OUTFLAGS) $(CPPFLAGS) $(CCFLAGS) $(DEMO_SOURCE) $(LDFLAGS)
$(TARGET_DIR):
[ -d $@ ] || mkdir -p $@
clean:
rm -rf $(TARGET_DIR)