Skip to content

Commit

Permalink
Xtensa: fix make build
Browse files Browse the repository at this point in the history
  • Loading branch information
imbillow committed Jun 8, 2024
1 parent 23e2583 commit c6fff6d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
5 changes: 3 additions & 2 deletions COMPILE_CMAKE.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Get CMake for free from http://www.cmake.org.
- CAPSTONE_WASM_SUPPORT: support Web Assembly. Run cmake with -DCAPSTONE_WASM_SUPPORT=0 to remove WASM.
- CAPSTONE_BPF_SUPPORT: support BPF. Run cmake with -DCAPSTONE_BPF_SUPPORT=0 to remove BPF.
- CAPSTONE_RISCV_SUPPORT: support RISCV. Run cmake with -DCAPSTONE_RISCV_SUPPORT=0 to remove RISCV.
- CAPSTONE_XTENSA_SUPPORT: support XTENSA. Run cmake with -DCAPSTONE_XTENSA_SUPPORT=0 to remove XTENSA.
- CAPSTONE_ARCHITECTURE_DEFAULT: Whether architectures are enabled by default.
Set this of OFF with -DCAPSTONE_ARCHITECTURE_DEFAULT=OFF to disable all architectures by default.
You can then enable them again with one of the CAPSTONE_<ARCH>_SUPPORT options.
Expand Down Expand Up @@ -118,8 +119,8 @@ Get CMake for free from http://www.cmake.org.

Will just target the x86 architecture. The list of available architectures is: ARM,
AARCH64, M68K, MIPS, PowerPC, Sparc, SystemZ, XCore, x86, TMS320C64x, M680x, EVM, MOS65XX,
WASM, BPF, RISCV, Alpha, HPPA.
WASM, BPF, RISCV, Alpha, HPPA, Xtensa.

(4) You can also create an installation image with cmake, by using the 'install' target.
Use:

Expand Down
1 change: 1 addition & 0 deletions HACK.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Capstone source is organized as followings.
│   ├── TMS320C64x <- TMS320C64x engine
│   ├── TriCore <- TriCore engine
│   └── WASM <- WASM engine
│   └── Xtensa <- Xtensa engine
├── bindings <- all bindings are under this dir
│   ├── java <- Java bindings + test code
│   ├── ocaml <- Ocaml bindings + test code
Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,21 @@ ifneq (,$(findstring hppa,$(CAPSTONE_ARCHS)))
LIBOBJ_HPPA += $(LIBSRC_HPPA:%.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

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 += $(LIBOBJ_TRICORE) $(LIBOBJ_ALPHA) $(LIBOBJ_HPPA) $(LIBOBJ_XTENSA)


ifeq ($(PKG_EXTRA),)
Expand Down Expand Up @@ -488,6 +497,7 @@ $(LIBOBJ_BPF): $(DEP_BPF)
$(LIBOBJ_TRICORE): $(DEP_TRICORE)
$(LIBOBJ_ALPHA): $(DEP_ALPHA)
$(LIBOBJ_HPPA): $(DEP_HPPA)
$(LIBOBJ_XTENSA): $(DEP_XTENSA)

ifeq ($(CAPSTONE_STATIC),yes)
$(ARCHIVE): $(LIBOBJ)
Expand Down
2 changes: 1 addition & 1 deletion config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
################################################################################
# Specify which archs you want to compile in. By default, we build all archs.

CAPSTONE_ARCHS ?= arm aarch64 m68k mips powerpc sparc systemz x86 xcore tms320c64x m680x evm riscv mos65xx wasm bpf sh tricore alpha hppa
CAPSTONE_ARCHS ?= arm aarch64 m68k mips powerpc sparc systemz x86 xcore tms320c64x m680x evm riscv mos65xx wasm bpf sh tricore alpha hppa xtensa


################################################################################
Expand Down
1 change: 1 addition & 0 deletions nmake.bat
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if "%1"=="BPF" set %arch%=BPF
if "%1"=="RISCV" set %arch%=RISCV
if "%1"=="ALPHA" set %arch%=ALPHA
if "%1"=="HPPA" set %arch%=HPPA
if "%1"=="XTENSA" set %arch%=XTENSA

if not "%arch%"=="" set flags=%flags% and " -DCAPSTONE_ARCHITECTURE_DEFAULT=OFF -DCAPSTONE_%arch%_SUPPORT=ON"

Expand Down
4 changes: 2 additions & 2 deletions suite/cstest/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
SOURCE = src
INCLUDE = include ../../include
BUILD = build
LIBRARY = -lcmocka -lcapstone -L../..
LIBRARY = -lcapstone -L../..

all:
rm -rf $(BUILD)
mkdir $(BUILD)
$(CC) $(SOURCE)/*.c $(INCLUDE:%=-I %) -g -o $(BUILD)/cstest $(LIBRARY)
$(CC) $(SOURCE)/*.c $(INCLUDE:%=-I %) -g -o $(BUILD)/cstest $(LIBRARY) $(shell pkg-config --libs cmocka) $(shell pkg-config --cflags cmocka)
cstest:
$(BUILD)/cstest -d ../MC
clean:
Expand Down

0 comments on commit c6fff6d

Please sign in to comment.