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