Capstone disassembly/disassembler framework: Core (Arm, Arm64, BPF, EVM, M68K, M680X, MOS65xx, Mips, PPC, RISCV, Sparc, SystemZ, TMS320C64x, Web Assembly, X86, X86_64, XCore) + bindings. (bloaty 依赖)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.2 KiB

11 years ago
# Capstone Disassembler Engine
# By Nguyen Anh Quynh <aquynh@gmail.com>, 2013>
CC = $(CROSS)gcc
AR ?= $(CROSS)ar
RANLIB ?= $(CROSS)ranlib
STRIP ?= $(CROSS)strip
11 years ago
CFLAGS += -fPIC -O3 -Wall -Iinclude
LDFLAGS += -shared
PREFIX ?= /usr
DESTDIR ?=
INCDIR = $(DESTDIR)$(PREFIX)/include
LIBDIR = $(DESTDIR)$(PREFIX)/lib
INSTALL_DATA ?= install -m0644
INSTALL_LIBRARY ?= install -m0755
11 years ago
LIBNAME = capstone
LIBOBJ =
LIBOBJ += cs.o utils.o SStream.o MCInstrDesc.o MCRegisterInfo.o
LIBOBJ += arch/AArch64/AArch64BaseInfo.o arch/AArch64/AArch64Disassembler.o arch/AArch64/AArch64InstPrinter.o arch/AArch64/mapping.o
LIBOBJ += arch/ARM/ARMDisassembler.o arch/ARM/ARMInstPrinter.o arch/ARM/mapping.o
11 years ago
LIBOBJ += arch/X86/X86DisassemblerDecoder.o arch/X86/X86Disassembler.o arch/X86/X86IntelInstPrinter.o arch/X86/X86ATTInstPrinter.o arch/X86/mapping.o
LIBOBJ += arch/Mips/MipsDisassembler.o arch/Mips/MipsInstPrinter.o arch/Mips/mapping.o
11 years ago
LIBOBJ += MCInst.o
EXT = so
AR_EXT = a
# OSX?
11 years ago
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
EXT = dylib
else
# Cygwin?
IS_CYGWIN := $(shell $(CC) -dumpmachine | grep -i cygwin | wc -l)
ifeq ($(IS_CYGWIN),1)
EXT = dll
AR_EXT = dll.a
# Cygwin doesn't like -fPIC
CFLAGS := $(CFLAGS:-fPIC=)
# On Windows we need the shared library to be executable
else
# mingw?
IS_MINGW := $(shell $(CC) --version | grep -i mingw | wc -l)
ifeq ($(IS_MINGW),1)
EXT = dll
AR_EXT = dll.a
# mingw doesn't like -fPIC either
CFLAGS := $(CFLAGS:-fPIC=)
# On Windows we need the shared library to be executable
endif
endif
11 years ago
endif
.PHONY: all clean lib archive install uninstall
11 years ago
all: lib archive
$(MAKE) -C tests
$(INSTALL_DATA) lib$(LIBNAME).$(EXT) tests
11 years ago
lib: $(LIBOBJ)
$(CC) $(LDFLAGS) $(LIBOBJ) -o lib$(LIBNAME).$(EXT)
# MacOS doesn't like strip
#strip lib$(LIBNAME).$(EXT)
archive: $(LIBOBJ)
rm -f lib$(LIBNAME).$(AR_EXT)
$(AR) q lib$(LIBNAME).$(AR_EXT) $(LIBOBJ)
$(RANLIB) lib$(LIBNAME).$(AR_EXT)
PC=capstone.pc
VERSION=$(shell echo `grep -e PKG_MAJOR -e PKG_MINOR cs.c|grep -v =| awk '{print $$3}'` | awk '{print $$1"."$$2}')
capstone.pc: lib$(LIBNAME).$(AR_EXT)
echo Name: capstone > $(PC)
echo Description: Capstone disassembler engine >> $(PC)
echo Version: $(VERSION) >> $(PC)
echo Libs: -L$(LIBDIR) -lcapstone >> $(PC)
echo Cflags: -I$(PREFIX)/include/capstone >> $(PC)
install: capstone.pc archive lib
mkdir -p $(LIBDIR)
$(INSTALL_LIBRARY) lib$(LIBNAME).$(EXT) $(LIBDIR)
$(INSTALL_DATA) lib$(LIBNAME).$(AR_EXT) $(LIBDIR)
mkdir -p $(INCDIR)/$(LIBNAME)
$(INSTALL_DATA) include/capstone.h $(INCDIR)/$(LIBNAME)
$(INSTALL_DATA) include/x86.h $(INCDIR)/$(LIBNAME)
$(INSTALL_DATA) include/arm.h $(INCDIR)/$(LIBNAME)
$(INSTALL_DATA) include/arm64.h $(INCDIR)/$(LIBNAME)
$(INSTALL_DATA) include/mips.h $(INCDIR)/$(LIBNAME)
mkdir -p $(LIBDIR)/pkgconfig
$(INSTALL_DATA) $(LIBNAME).pc $(LIBDIR)/pkgconfig/
11 years ago
uninstall:
rm -rf $(INCDIR)/$(LIBNAME)
rm -f $(LIBDIR)/lib$(LIBNAME).$(EXT)
rm -f $(LIBDIR)/lib$(LIBNAME).$(AR_EXT)
rm -f $(LIBDIR)/pkgconfig/$(LIBNAME).pc
11 years ago
clean:
rm -f $(LIBOBJ) lib$(LIBNAME).*
#cd bindings/ruby; $(MAKE) clean; rm -rf Makefile
$(MAKE) -C bindings/python clean
$(MAKE) -C bindings/csharp clean
$(MAKE) -C bindings/java clean
$(MAKE) -C bindings/ocaml clean
$(MAKE) -C tests clean
11 years ago
.c.o:
${CC} ${CFLAGS} -c $< -o $@