5af28808 Update Auto-Sync to Python 3.13 and tree-sitter-py 24.0 (#2705) 99f018ac Python binding: (#2742) a07baf83 Auto-Sync update Sparc LLVM-18 (#2704) 81c5c93d Enable to generate legacy MC tests for the fuzzer. (#2733) a25d4980 Add warning about naive search and replace to patch reg names. (#2728) 7ac87d17 Print immediate only memory operands for AArch64. (#2732) c34034c8 Add x30 implicit read to the RET alias. (#2739) 95a4ca3e Update source list before installing valgrind. (#2730) 6909724e Make assertion hit warnings optional in release builds. (#2729) fe6bdc6e Make SStream respect the CS_OPT_UNSIGNED flag. (#2723) 21ce3624 Use cs_ac_type for operand access mode in all arches and use cs_xtensa_op_type for Xtensa operand type (#2721) df26583f clang-format: change license to BSD-3-Clause (#2724) 280b749e Remove unused files. (#2709) 87908ece Add flag for the SoftFail case of the LLVM disassembler. (#2707) efc0ba44 Fix missing operand for smstart, due to space replaced by tab (#2720) 2ae64133 Fix missing sp register read in ret instruction (#2719) 8df252a6 Fix arm pop reg access (#2718) 14612272 ARM: fix typo, cspr -> cpsr (#2716) f2f0a3c3 Fix LoongArch ld/st instructions register info (#2701) 829be2bf LoongArch: Compute absolute address for address operand (#2699) 42fbce6c Add jump group for generic jirl (#2698) fc525c73 Apple AArch64 proprietary (#2692) 895f2f2e Build PDB for debugging on Windows (#2685) 5c3aef03 Version: Update to v6.0.0-alpha4 (#2682) 106f7d3b Update read/written registers for x87 comparison instructions (#2680) ebe3ef2a Add workflow for building on Windows (#2675) 72f7d305 Revert "Add a script to compare the inc file content with the latest generate…" (#2678) 5b5c5ed8 Fix nanomips decoding of jalrc (#2672) ae03cca4 Mips32r6_64r632 is for both mips32r6 and mips64r6 (#2673) 21178aea Add a script to compare the inc file content with the latest generated ones. (#2667) 81a6ba03 MIPS: Fix MIPS16 decoding, wrong flags and ghost registers (#2665) 98a393e3 Stringify BH fields when printing ppc details (#2663) 2607d0f3 Remove undefined constants in riscv_const.py (#2660) (#2661) 5058c634 Decode BH field in print_insn_detail_ppc (#2662) 6461ed08 Add Call group to svc, smc and hvc. (#2651) e2f1dc8d Tms32c64x Little Endian (#2648) 5464c91d Fix build for compilers requiring explicit static for inline functions.. (#2645) bb2f6579 Enhance shift value and types of shift instructions. (#2638) cd282ef5 Update operand type enums of all arch modules to the one in `capstone.h` (#2633) dc0c0909 cmake: Fix building capstone as sub-project (#2629) cd8dd20c - Added missing files for sdist archive (#2624) 9affd99b Give the user some guidance where to add missing enumeration values. (#2639) 1bea3fab Add checks for MIPS details on cstest_py (#2640) ace8056c Add aliases mapping for MIPS & test for id, alias_id (#2635) 1abe1868 Build Tarball before DEB/RPM package. (#2627) 0a012190 Switch to ubuntu-24.04-arm runner image (#2625) 4e0b8c48 Fix wrong version requirement of tricore instructions: (#2620) 8ac2843b chore(version): Update Version to 6.0.0-Alpha3 (#2616) d7ef910b Rebased #2570 (#2614) c831cd5e Fix SystemZ macro in Makefile (#2603) 30601176 Apply new EVM opcode updates (#2602) 3c4d7fc8 Add tricore tc1.8 instructions (#2595) 5f290cad Create debian and rpm package on releases (#2590) 0f09210a delete travis (#2600) 5c5f756f Downgrade labeler to v4 due to https://github.com/actions/labeler/issues/710. (#2598) git-subtree-dir: external/capstone git-subtree-split: 5af288083e9f03e32723f9708c305692f866b666
672 lines
17 KiB
Makefile
672 lines
17 KiB
Makefile
# Capstone Disassembly Engine
|
|
# By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014
|
|
|
|
include config.mk
|
|
include pkgconfig.mk # package version
|
|
include functions.mk
|
|
|
|
# Verbose output?
|
|
V ?= 0
|
|
|
|
OS := $(shell uname)
|
|
ifeq ($(OS),Darwin)
|
|
LIBARCHS ?= x86_64 arm64
|
|
PREFIX ?= /usr/local
|
|
endif
|
|
|
|
ifeq ($(PKG_EXTRA),)
|
|
PKG_VERSION = $(PKG_MAJOR).$(PKG_MINOR)
|
|
else
|
|
PKG_VERSION = $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA)
|
|
endif
|
|
|
|
ifeq ($(CROSS),)
|
|
RANLIB ?= ranlib
|
|
else ifeq ($(ANDROID), 1)
|
|
CC = $(CROSS)/../../bin/clang
|
|
AR = $(CROSS)/ar
|
|
RANLIB = $(CROSS)/ranlib
|
|
STRIP = $(CROSS)/strip
|
|
else
|
|
CC = $(CROSS)gcc
|
|
AR = $(CROSS)ar
|
|
RANLIB = $(CROSS)ranlib
|
|
STRIP = $(CROSS)strip
|
|
endif
|
|
|
|
ifeq ($(OS),OS/390)
|
|
RANLIB = touch
|
|
endif
|
|
|
|
ifneq (,$(findstring yes,$(CAPSTONE_DIET)))
|
|
CFLAGS ?= -Os
|
|
CFLAGS += -DCAPSTONE_DIET
|
|
else
|
|
CFLAGS ?= -O3
|
|
endif
|
|
|
|
# C99 has been enforced elsewhere like xcode
|
|
CFLAGS += -std=gnu99
|
|
|
|
ifneq (,$(findstring yes,$(CAPSTONE_X86_ATT_DISABLE)))
|
|
CFLAGS += -DCAPSTONE_X86_ATT_DISABLE
|
|
endif
|
|
|
|
ifeq ($(CC),xlc)
|
|
CFLAGS += -qcpluscmt -qkeyword=inline -qlanglvl=extc1x -Iinclude
|
|
ifneq ($(OS),OS/390)
|
|
CFLAGS += -fPIC
|
|
endif
|
|
else
|
|
CFLAGS += -fPIC -Wall -Wwrite-strings -Wmissing-prototypes -Iinclude
|
|
endif
|
|
|
|
ifeq ($(CAPSTONE_USE_SYS_DYN_MEM),yes)
|
|
CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
|
|
endif
|
|
|
|
ifeq ($(CAPSTONE_HAS_OSXKERNEL), yes)
|
|
CFLAGS += -DCAPSTONE_HAS_OSXKERNEL
|
|
SDKROOT ?= $(shell xcodebuild -version -sdk macosx Path)
|
|
CFLAGS += -mmacosx-version-min=10.5 \
|
|
-isysroot$(SDKROOT) \
|
|
-I$(SDKROOT)/System/Library/Frameworks/Kernel.framework/Headers \
|
|
-mkernel \
|
|
-fno-builtin
|
|
endif
|
|
|
|
PREFIX ?= /usr
|
|
DESTDIR ?=
|
|
ifndef BUILDDIR
|
|
BLDIR = .
|
|
OBJDIR = .
|
|
else
|
|
BLDIR = $(abspath $(BUILDDIR))
|
|
OBJDIR = $(BLDIR)/obj
|
|
endif
|
|
INCDIR ?= $(PREFIX)/include
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
LIBDIRARCH ?= lib
|
|
# Uncomment the below line to installs x86_64 libs to lib64/ directory.
|
|
# Or better, pass 'LIBDIRARCH=lib64' to 'make install/uninstall' via 'make.sh'.
|
|
#LIBDIRARCH ?= lib64
|
|
LIBDIR = $(DESTDIR)$(PREFIX)/$(LIBDIRARCH)
|
|
BINDIR = $(DESTDIR)$(PREFIX)/bin
|
|
|
|
LIBDATADIR = $(LIBDIR)
|
|
|
|
# Don't redefine $LIBDATADIR when global environment variable
|
|
# USE_GENERIC_LIBDATADIR is set. This is used by the pkgsrc framework.
|
|
|
|
ifndef USE_GENERIC_LIBDATADIR
|
|
ifeq ($(UNAME_S), FreeBSD)
|
|
LIBDATADIR = $(DESTDIR)$(PREFIX)/libdata
|
|
endif
|
|
ifeq ($(UNAME_S), DragonFly)
|
|
LIBDATADIR = $(DESTDIR)$(PREFIX)/libdata
|
|
endif
|
|
endif
|
|
|
|
INSTALL_BIN ?= install
|
|
INSTALL_DATA ?= $(INSTALL_BIN) -m0644
|
|
INSTALL_LIB ?= $(INSTALL_BIN) -m0755
|
|
|
|
LIBNAME = capstone
|
|
|
|
|
|
DEP_ARM =
|
|
DEP_ARM += $(wildcard arch/ARM/ARM*.inc)
|
|
|
|
LIBOBJ_ARM =
|
|
ifneq (,$(findstring arm,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_ARM
|
|
LIBSRC_ARM += $(wildcard arch/ARM/ARM*.c)
|
|
LIBOBJ_ARM += $(LIBSRC_ARM:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_AARCH64 =
|
|
DEP_AARCH64 += $(wildcard arch/AArch64/AArch64*.inc)
|
|
|
|
LIBOBJ_AARCH64 =
|
|
ifneq (,$(findstring aarch64,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_ARM64
|
|
CFLAGS += -DCAPSTONE_HAS_AARCH64
|
|
LIBSRC_AARCH64 += $(wildcard arch/AArch64/AArch64*.c)
|
|
LIBOBJ_AARCH64 += $(LIBSRC_AARCH64:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
|
|
DEP_M68K =
|
|
DEP_M68K += $(wildcard arch/M68K/M68K*.inc)
|
|
DEP_M68K += $(wildcard arch/M68K/M68K*.h)
|
|
|
|
LIBOBJ_M68K =
|
|
ifneq (,$(findstring m68k,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_M68K
|
|
LIBSRC_M68K += $(wildcard arch/M68K/M68K*.c)
|
|
LIBOBJ_M68K += $(LIBSRC_M68K:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_MIPS =
|
|
DEP_MIPS += $(wildcard arch/Mips/Mips*.inc)
|
|
|
|
LIBOBJ_MIPS =
|
|
ifneq (,$(findstring mips,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_MIPS
|
|
LIBSRC_MIPS += $(wildcard arch/Mips/Mips*.c)
|
|
LIBOBJ_MIPS += $(LIBSRC_MIPS:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_SH = $(wildcard arch/SH/SH*.inc)
|
|
|
|
LIBOBJ_SH =
|
|
ifneq (,$(findstring sh,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_SH
|
|
LIBSRC_SH += $(wildcard arch/SH/SH*.c)
|
|
LIBOBJ_SH += $(LIBSRC_SH:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_PPC =
|
|
DEP_PPC += $(wildcard arch/PowerPC/PPC*.inc)
|
|
|
|
LIBOBJ_PPC =
|
|
ifneq (,$(findstring powerpc,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_POWERPC
|
|
LIBSRC_PPC += $(wildcard arch/PowerPC/PPC*.c)
|
|
LIBOBJ_PPC += $(LIBSRC_PPC:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
|
|
DEP_SPARC =
|
|
DEP_SPARC += $(wildcard arch/Sparc/Sparc*.inc)
|
|
|
|
LIBOBJ_SPARC =
|
|
ifneq (,$(findstring sparc,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_SPARC
|
|
LIBSRC_SPARC += $(wildcard arch/Sparc/Sparc*.c)
|
|
LIBOBJ_SPARC += $(LIBSRC_SPARC:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
|
|
DEP_SYSZ =
|
|
DEP_SYSZ += $(wildcard arch/SystemZ/SystemZ*.inc)
|
|
|
|
LIBOBJ_SYSZ =
|
|
ifneq (,$(findstring systemz,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_SYSTEMZ
|
|
LIBSRC_SYSZ += $(wildcard arch/SystemZ/SystemZ*.c)
|
|
LIBOBJ_SYSZ += $(LIBSRC_SYSZ:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
|
|
# by default, we compile full X86 instruction sets
|
|
X86_REDUCE =
|
|
ifneq (,$(findstring yes,$(CAPSTONE_X86_REDUCE)))
|
|
X86_REDUCE = _reduce
|
|
CFLAGS += -DCAPSTONE_X86_REDUCE -Os
|
|
endif
|
|
|
|
|
|
DEP_X86 =
|
|
DEP_X86 += $(wildcard arch/X86/X86*.inc)
|
|
|
|
LIBOBJ_X86 =
|
|
ifneq (,$(findstring x86,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_X86
|
|
LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86DisassemblerDecoder.o
|
|
LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Disassembler.o
|
|
LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86InstPrinterCommon.o
|
|
LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86IntelInstPrinter.o
|
|
# assembly syntax is irrelevant in Diet mode, when this info is suppressed
|
|
ifeq (,$(findstring yes,$(CAPSTONE_DIET)))
|
|
ifeq (,$(findstring yes,$(CAPSTONE_X86_ATT_DISABLE)))
|
|
LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86ATTInstPrinter.o
|
|
endif
|
|
endif
|
|
LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Mapping.o
|
|
LIBOBJ_X86 += $(OBJDIR)/arch/X86/X86Module.o
|
|
endif
|
|
|
|
|
|
DEP_XCORE =
|
|
DEP_XCORE += $(wildcard arch/XCore/XCore*.inc)
|
|
|
|
LIBOBJ_XCORE =
|
|
ifneq (,$(findstring xcore,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_XCORE
|
|
LIBSRC_XCORE += $(wildcard arch/XCore/XCore*.c)
|
|
LIBOBJ_XCORE += $(LIBSRC_XCORE:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
|
|
DEP_TMS320C64X =
|
|
DEP_TMS320C64X += $(wildcard arch/TMS320C64x/TMS320C64x*.inc)
|
|
|
|
LIBOBJ_TMS320C64X =
|
|
ifneq (,$(findstring tms320c64x,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_TMS320C64X
|
|
LIBSRC_TMS320C64X += $(wildcard arch/TMS320C64x/TMS320C64x*.c)
|
|
LIBOBJ_TMS320C64X += $(LIBSRC_TMS320C64X:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_M680X =
|
|
DEP_M680X += $(wildcard arch/M680X/*.inc)
|
|
DEP_M680X += $(wildcard arch/M680X/M680X*.h)
|
|
|
|
LIBOBJ_M680X =
|
|
ifneq (,$(findstring m680x,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_M680X
|
|
LIBSRC_M680X += $(wildcard arch/M680X/*.c)
|
|
LIBOBJ_M680X += $(LIBSRC_M680X:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
|
|
DEP_EVM =
|
|
DEP_EVM += $(wildcard arch/EVM/EVM*.inc)
|
|
|
|
LIBOBJ_EVM =
|
|
ifneq (,$(findstring evm,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_EVM
|
|
LIBSRC_EVM += $(wildcard arch/EVM/EVM*.c)
|
|
LIBOBJ_EVM += $(LIBSRC_EVM:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_RISCV =
|
|
DEP_RISCV += $(wildcard arch/RISCV/RISCV*.inc)
|
|
|
|
LIBOBJ_RISCV =
|
|
ifneq (,$(findstring riscv,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_RISCV
|
|
LIBSRC_RISCV += $(wildcard arch/RISCV/RISCV*.c)
|
|
LIBOBJ_RISCV += $(LIBSRC_RISCV:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_WASM =
|
|
DEP_WASM += $(wildcard arch/WASM/WASM*.inc)
|
|
|
|
LIBOBJ_WASM =
|
|
ifneq (,$(findstring wasm,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_WASM
|
|
LIBSRC_WASM += $(wildcard arch/WASM/WASM*.c)
|
|
LIBOBJ_WASM += $(LIBSRC_WASM:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
|
|
DEP_MOS65XX =
|
|
DEP_MOS65XX += $(wildcard arch/MOS65XX/MOS65XX*.inc)
|
|
|
|
LIBOBJ_MOS65XX =
|
|
ifneq (,$(findstring mos65xx,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_MOS65XX
|
|
LIBSRC_MOS65XX += $(wildcard arch/MOS65XX/MOS65XX*.c)
|
|
LIBOBJ_MOS65XX += $(LIBSRC_MOS65XX:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
|
|
DEP_BPF =
|
|
DEP_BPF += $(wildcard arch/BPF/BPF*.inc)
|
|
|
|
LIBOBJ_BPF =
|
|
ifneq (,$(findstring bpf,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_BPF
|
|
LIBSRC_BPF += $(wildcard arch/BPF/BPF*.c)
|
|
LIBOBJ_BPF += $(LIBSRC_BPF:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_TRICORE =
|
|
DEP_TRICORE +=$(wildcard arch/TriCore/TriCore*.inc)
|
|
|
|
LIBOBJ_TRICORE =
|
|
ifneq (,$(findstring tricore,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_TRICORE
|
|
LIBSRC_TRICORE += $(wildcard arch/TriCore/TriCore*.c)
|
|
LIBOBJ_TRICORE += $(LIBSRC_TRICORE:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_ALPHA =
|
|
DEP_ALPHA +=$(wildcard arch/Alpha/Alpha*.inc)
|
|
|
|
LIBOBJ_ALPHA =
|
|
ifneq (,$(findstring alpha,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_ALPHA
|
|
LIBSRC_ALPHA += $(wildcard arch/Alpha/Alpha*.c)
|
|
LIBOBJ_ALPHA += $(LIBSRC_ALPHA:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_HPPA =
|
|
DEP_HPPA += $(wildcard arch/HPPA/HPPA*.inc)
|
|
|
|
LIBOBJ_HPPA =
|
|
ifneq (,$(findstring hppa,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_HPPA
|
|
LIBSRC_HPPA += $(wildcard arch/HPPA/HPPA*.c)
|
|
LIBOBJ_HPPA += $(LIBSRC_HPPA:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_LOONGARCH =
|
|
DEP_LOONGARCH += $(wildcard arch/LoongArch/LoongArch*.inc)
|
|
|
|
LIBOBJ_LOONGARCH =
|
|
ifneq (,$(findstring loongarch,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_LOONGARCH
|
|
LIBSRC_LOONGARCH += $(wildcard arch/LoongArch/LoongArch*.c)
|
|
LIBOBJ_LOONGARCH += $(LIBSRC_LOONGARCH:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_XTENSA =
|
|
DEP_XTENSA += $(wildcard arch/Xtensa/Xtensa*.inc)
|
|
|
|
LIBOBJ_XTENSA =
|
|
ifneq (,$(findstring xtensa,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_XTENSA
|
|
LIBSRC_XTENSA += $(wildcard arch/Xtensa/Xtensa*.c)
|
|
LIBOBJ_XTENSA += $(LIBSRC_XTENSA:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
DEP_ARC =
|
|
DEP_ARC += $(wildcard arch/ARC/ARC*.inc)
|
|
|
|
LIBOBJ_ARC =
|
|
ifneq (,$(findstring arc,$(CAPSTONE_ARCHS)))
|
|
CFLAGS += -DCAPSTONE_HAS_ARC
|
|
LIBSRC_ARC += $(wildcard arch/ARC/ARC*.c)
|
|
LIBOBJ_ARC += $(LIBSRC_ARC:%.c=$(OBJDIR)/%.o)
|
|
endif
|
|
|
|
LIBOBJ =
|
|
LIBOBJ += $(OBJDIR)/cs.o $(OBJDIR)/utils.o $(OBJDIR)/SStream.o $(OBJDIR)/MCInstrDesc.o $(OBJDIR)/MCRegisterInfo.o $(OBJDIR)/MCInst.o $(OBJDIR)/MCInstPrinter.o $(OBJDIR)/Mapping.o
|
|
LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_AARCH64) $(LIBOBJ_M68K) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_RISCV) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ) $(LIBOBJ_SH)
|
|
LIBOBJ += $(LIBOBJ_X86) $(LIBOBJ_XCORE) $(LIBOBJ_TMS320C64X) $(LIBOBJ_M680X) $(LIBOBJ_EVM) $(LIBOBJ_MOS65XX) $(LIBOBJ_WASM) $(LIBOBJ_BPF)
|
|
LIBOBJ += $(LIBOBJ_TRICORE) $(LIBOBJ_ALPHA) $(LIBOBJ_HPPA) $(LIBOBJ_LOONGARCH) $(LIBOBJ_XTENSA) $(LIBOBJ_ARC)
|
|
|
|
|
|
ifeq ($(PKG_EXTRA),)
|
|
PKGCFGDIR = $(LIBDATADIR)/pkgconfig
|
|
else
|
|
PKGCFGDIR ?= $(LIBDATADIR)/pkgconfig
|
|
ifeq ($(PKGCFGDIR),)
|
|
PKGCFGDIR = $(LIBDATADIR)/pkgconfig
|
|
endif
|
|
endif
|
|
|
|
API_MAJOR=$(shell echo `grep -e CS_API_MAJOR include/capstone/capstone.h | grep -v = | awk '{print $$3}'` | awk '{print $$1}')
|
|
VERSION_EXT =
|
|
|
|
IS_APPLE := $(shell $(CC) -dM -E - < /dev/null 2> /dev/null | grep __APPLE__ | wc -l | tr -d " ")
|
|
ifeq ($(IS_APPLE),1)
|
|
# on MacOS, do not build in Universal format by default
|
|
MACOS_UNIVERSAL ?= no
|
|
ifeq ($(MACOS_UNIVERSAL),yes)
|
|
CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
|
|
LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
|
|
endif
|
|
EXT = dylib
|
|
VERSION_EXT = $(API_MAJOR).$(EXT)
|
|
$(LIBNAME)_LDFLAGS += -dynamiclib -install_name lib$(LIBNAME).$(VERSION_EXT) -current_version $(PKG_MAJOR).$(PKG_MINOR).$(PKG_EXTRA) -compatibility_version $(PKG_MAJOR).$(PKG_MINOR)
|
|
AR_EXT = a
|
|
# Homebrew wants to make sure its formula does not disable FORTIFY_SOURCE
|
|
# However, this is not really necessary because 'CAPSTONE_USE_SYS_DYN_MEM=yes' by default
|
|
ifneq ($(HOMEBREW_CAPSTONE),1)
|
|
ifneq ($(CAPSTONE_USE_SYS_DYN_MEM),yes)
|
|
# remove string check because OSX kernel complains about missing symbols
|
|
CFLAGS += -D_FORTIFY_SOURCE=0
|
|
endif
|
|
endif
|
|
else
|
|
CFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
|
|
LDFLAGS += $(foreach arch,$(LIBARCHS),-arch $(arch))
|
|
ifeq ($(OS), AIX)
|
|
$(LIBNAME)_LDFLAGS += -qmkshrobj
|
|
else
|
|
$(LIBNAME)_LDFLAGS += -shared
|
|
endif
|
|
# Cygwin?
|
|
IS_CYGWIN := $(shell $(CC) -dumpmachine 2>/dev/null | grep -i cygwin | wc -l)
|
|
ifeq ($(IS_CYGWIN),1)
|
|
EXT = dll
|
|
AR_EXT = lib
|
|
# 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 2>/dev/null | grep -i "\(mingw\|MSYS\)" | wc -l)
|
|
ifeq ($(IS_MINGW),1)
|
|
EXT = dll
|
|
AR_EXT = lib
|
|
# mingw doesn't like -fPIC either
|
|
CFLAGS := $(CFLAGS:-fPIC=)
|
|
# On Windows we need the shared library to be executable
|
|
else
|
|
# Linux, *BSD
|
|
EXT = so
|
|
VERSION_EXT = $(EXT).$(API_MAJOR)
|
|
AR_EXT = a
|
|
$(LIBNAME)_LDFLAGS += -Wl,-soname,lib$(LIBNAME).$(VERSION_EXT)
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
ifeq ($(CAPSTONE_SHARED),yes)
|
|
ifeq ($(IS_MINGW),1)
|
|
LIBRARY = $(BLDIR)/$(LIBNAME).$(VERSION_EXT)
|
|
else ifeq ($(IS_CYGWIN),1)
|
|
LIBRARY = $(BLDIR)/$(LIBNAME).$(EXT)
|
|
else # *nix
|
|
LIBRARY = $(BLDIR)/lib$(LIBNAME).$(VERSION_EXT)
|
|
CFLAGS += -fvisibility=hidden
|
|
endif
|
|
endif
|
|
|
|
ifeq ($(CAPSTONE_STATIC),yes)
|
|
ifeq ($(IS_MINGW),1)
|
|
ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT)
|
|
else ifeq ($(IS_CYGWIN),1)
|
|
ARCHIVE = $(BLDIR)/$(LIBNAME).$(AR_EXT)
|
|
else
|
|
ARCHIVE = $(BLDIR)/lib$(LIBNAME).$(AR_EXT)
|
|
endif
|
|
endif
|
|
|
|
PKGCFGF = $(BLDIR)/$(LIBNAME).pc
|
|
|
|
.PHONY: all clean install uninstall dist
|
|
|
|
all: $(LIBRARY) $(ARCHIVE) $(PKGCFGF)
|
|
ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
|
|
@V=$(V) CC=$(CC) $(MAKE) -C cstool
|
|
endif
|
|
|
|
ifeq ($(CAPSTONE_SHARED),yes)
|
|
$(LIBRARY): $(LIBOBJ)
|
|
ifeq ($(V),0)
|
|
$(call log,LINK,$(@:$(BLDIR)/%=%))
|
|
@$(create-library)
|
|
else
|
|
$(create-library)
|
|
endif
|
|
endif
|
|
|
|
$(LIBOBJ): config.mk
|
|
|
|
$(LIBOBJ_ARM): $(DEP_ARM)
|
|
$(LIBOBJ_AARCH64): $(DEP_AARCH64)
|
|
$(LIBOBJ_M68K): $(DEP_M68K)
|
|
$(LIBOBJ_MIPS): $(DEP_MIPS)
|
|
$(LIBOBJ_PPC): $(DEP_PPC)
|
|
$(LIBOBJ_SH): $(DEP_SH)
|
|
$(LIBOBJ_SPARC): $(DEP_SPARC)
|
|
$(LIBOBJ_SYSZ): $(DEP_SYSZ)
|
|
$(LIBOBJ_X86): $(DEP_X86)
|
|
$(LIBOBJ_XCORE): $(DEP_XCORE)
|
|
$(LIBOBJ_TMS320C64X): $(DEP_TMS320C64X)
|
|
$(LIBOBJ_M680X): $(DEP_M680X)
|
|
$(LIBOBJ_EVM): $(DEP_EVM)
|
|
$(LIBOBJ_RISCV): $(DEP_RISCV)
|
|
$(LIBOBJ_WASM): $(DEP_WASM)
|
|
$(LIBOBJ_MOS65XX): $(DEP_MOS65XX)
|
|
$(LIBOBJ_BPF): $(DEP_BPF)
|
|
$(LIBOBJ_TRICORE): $(DEP_TRICORE)
|
|
$(LIBOBJ_ALPHA): $(DEP_ALPHA)
|
|
$(LIBOBJ_HPPA): $(DEP_HPPA)
|
|
$(LIBOBJ_LOONGARCH): $(DEP_LOONGARCH)
|
|
$(LIBOBJ_XTENSA): $(DEP_XTENSA)
|
|
$(LIBOBJ_ARC): $(DEP_ARC)
|
|
|
|
ifeq ($(CAPSTONE_STATIC),yes)
|
|
$(ARCHIVE): $(LIBOBJ)
|
|
@rm -f $(ARCHIVE)
|
|
ifeq ($(V),0)
|
|
$(call log,AR,$(@:$(BLDIR)/%=%))
|
|
@$(create-archive)
|
|
else
|
|
$(create-archive)
|
|
endif
|
|
endif
|
|
|
|
$(PKGCFGF):
|
|
ifeq ($(V),0)
|
|
$(call log,GEN,$(@:$(BLDIR)/%=%))
|
|
@$(generate-pkgcfg)
|
|
else
|
|
$(generate-pkgcfg)
|
|
endif
|
|
|
|
# create a list of auto dependencies
|
|
AUTODEPS:= $(patsubst %.o,%.d, $(LIBOBJ))
|
|
|
|
# include by auto dependencies
|
|
-include $(AUTODEPS)
|
|
|
|
install: $(PKGCFGF) $(ARCHIVE) $(LIBRARY)
|
|
mkdir -p $(LIBDIR)
|
|
$(call install-library,$(LIBDIR))
|
|
ifeq ($(CAPSTONE_STATIC),yes)
|
|
$(INSTALL_DATA) $(ARCHIVE) $(LIBDIR)
|
|
endif
|
|
mkdir -p $(DESTDIR)$(INCDIR)/$(LIBNAME)
|
|
$(INSTALL_DATA) include/capstone/*.h $(DESTDIR)$(INCDIR)/$(LIBNAME)
|
|
mkdir -p $(PKGCFGDIR)
|
|
$(INSTALL_DATA) $(PKGCFGF) $(PKGCFGDIR)
|
|
ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
|
|
mkdir -p $(BINDIR)
|
|
$(INSTALL_LIB) cstool/cstool $(BINDIR)
|
|
endif
|
|
|
|
uninstall:
|
|
rm -rf $(DESTDIR)$(INCDIR)/$(LIBNAME)
|
|
rm -f $(LIBDIR)/lib$(LIBNAME).*
|
|
rm -f $(PKGCFGDIR)/$(LIBNAME).pc
|
|
ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
|
|
rm -f $(BINDIR)/cstool
|
|
endif
|
|
|
|
clean:
|
|
rm -f $(LIBOBJ)
|
|
rm -f $(BLDIR)/lib$(LIBNAME).* $(BLDIR)/$(LIBNAME).pc
|
|
rm -f $(PKGCFGF)
|
|
rm -f $(AUTODEPS)
|
|
[ "${ANDROID}" = "1" ] && rm -rf android-ndk-* || true
|
|
|
|
ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
|
|
$(MAKE) -C cstool clean
|
|
$(MAKE) -C suite/fuzz clean
|
|
endif
|
|
|
|
ifdef BUILDDIR
|
|
rm -rf $(BUILDDIR)
|
|
endif
|
|
|
|
ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
|
|
$(MAKE) -C bindings/python clean
|
|
$(MAKE) -C bindings/java clean
|
|
$(MAKE) -C bindings/ocaml clean
|
|
endif
|
|
|
|
|
|
TAG ?= HEAD
|
|
ifeq ($(TAG), HEAD)
|
|
DIST_VERSION = latest
|
|
else
|
|
DIST_VERSION = $(TAG)
|
|
endif
|
|
|
|
dist:
|
|
git archive --format=tar.gz --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).tgz
|
|
git archive --format=zip --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).zip
|
|
|
|
checkfuzz: fuzztest fuzzallcorp
|
|
|
|
FUZZ_INPUTS = $(shell find suite/MC -type f -name '*.cs')
|
|
|
|
buildfuzz:
|
|
ifndef BUILDDIR
|
|
$(MAKE) -C suite/fuzz
|
|
else
|
|
$(MAKE) -C suite/fuzz BUILDDIR=$(BLDIR)
|
|
endif
|
|
|
|
fuzztest:
|
|
./suite/fuzz/fuzz_disasm $(FUZZ_INPUTS)
|
|
|
|
fuzzallcorp:
|
|
ifneq ($(wildcard suite/fuzz/corpus-libFuzzer-capstone_fuzz_disasmnext-latest),)
|
|
./suite/fuzz/fuzz_bindisasm suite/fuzz/corpus-libFuzzer-capstone_fuzz_disasmnext-latest/ > fuzz_bindisasm.log || (tail -1 fuzz_bindisasm.log; false)
|
|
else
|
|
@echo "Skipping tests on whole corpus"
|
|
endif
|
|
|
|
$(OBJDIR)/%.o: %.c
|
|
@mkdir -p $(@D)
|
|
ifeq ($(V),0)
|
|
$(call log,CC,$(@:$(OBJDIR)/%=%))
|
|
@$(compile)
|
|
else
|
|
$(compile)
|
|
endif
|
|
|
|
|
|
ifeq ($(CAPSTONE_SHARED),yes)
|
|
define install-library
|
|
$(INSTALL_LIB) $(LIBRARY) $1
|
|
$(if $(VERSION_EXT),
|
|
cd $1 && \
|
|
rm -f lib$(LIBNAME).$(EXT) && \
|
|
ln -s lib$(LIBNAME).$(VERSION_EXT) lib$(LIBNAME).$(EXT))
|
|
endef
|
|
else
|
|
define install-library
|
|
endef
|
|
endif
|
|
|
|
ifeq ($(AR_FLAGS),)
|
|
AR_FLAGS := q
|
|
endif
|
|
|
|
define create-archive
|
|
$(AR) $(AR_FLAGS) $(ARCHIVE) $(LIBOBJ)
|
|
$(RANLIB) $(ARCHIVE)
|
|
endef
|
|
|
|
|
|
define create-library
|
|
$(CC) $(LDFLAGS) $($(LIBNAME)_LDFLAGS) $(LIBOBJ) -o $(LIBRARY)
|
|
endef
|
|
|
|
|
|
define generate-pkgcfg
|
|
mkdir -p $(BLDIR)
|
|
echo 'Name: capstone' > $(PKGCFGF)
|
|
echo 'Description: Capstone disassembly engine' >> $(PKGCFGF)
|
|
echo 'Version: $(PKG_VERSION)' >> $(PKGCFGF)
|
|
echo 'libdir=$(LIBDIR)' >> $(PKGCFGF)
|
|
echo 'includedir=$(INCDIR)/capstone' >> $(PKGCFGF)
|
|
echo 'archive=$${libdir}/libcapstone.a' >> $(PKGCFGF)
|
|
echo 'Libs: -L$${libdir} -lcapstone' >> $(PKGCFGF)
|
|
echo 'Libs.private: -L$${libdir} -l:libcapstone.a' >> $(PKGCFGF)
|
|
echo 'Cflags: -I$${includedir}' >> $(PKGCFGF)
|
|
echo 'archs=${CAPSTONE_ARCHS}' >> $(PKGCFGF)
|
|
endef
|