diff --git a/src/plugins/dev-asm.md b/src/plugins/dev-asm.md index 3e7dc389..773ddeb0 100644 --- a/src/plugins/dev-asm.md +++ b/src/plugins/dev-asm.md @@ -2,7 +2,7 @@ Rizin has modular architecture, thus adding support for a new architecture is very easy, if you are fluent in C. For various reasons it might be easier to implement it out of the tree. For this we -will need to create single C file, called `asm_mycpu.c` and makefile for it. +will need to create single C file, called `asm_mycpu.c` and a meson file for it. The key thing of RzAsm plugin is a structure ```c @@ -24,30 +24,21 @@ and length: static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) ``` -**Makefile** +**Meson** -```makefile -NAME=asm_mycpu -RZ_PLUGIN_PATH=$(shell rizin -H RZ_USER_PLUGINS) -LIBEXT=$(shell rizin -H LIBEXT) -CFLAGS=-g -fPIC $(shell pkg-config --cflags rz_analyss) -LDFLAGS=-shared $(shell pkg-config --libs rz_analysis) -OBJS=$(NAME).o -LIB=$(NAME).$(LIBEXT) +```bash +project('asm_mycpu', 'c') -all: $(LIB) +rz_asm_dep = dependency('rz_asm') +plugins_dir = get_option('prefix') / rz_asm_dep.get_variable(pkgconfig: 'plugindir', cmake: 'rz_asm_PLUGINDIR') +message('Plugins install directory: ' + plugins_dir) -clean: - rm -f $(LIB) $(OBJS) - -$(LIB): $(OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(LIB) - -install: - cp -f asm_mycpu.$(SO_EXT) $(RZ_PLUGIN_PATH) - -uninstall: - rm -f $(RZ_PLUGIN_PATH)/asm_mycpu.$(SO_EXT) +library('asm_mycpu', + ['asm_mycpu.c'], + dependencies: [rz_asm_dep], + install: true, + install_dir: plugins_dir, +) ``` **asm_mycpu.c** @@ -112,7 +103,7 @@ That's where most of our code will be, the key part is to declare a `RzAsmPlugin * `librz/asm/meson.build` The build is handled by meson, we have to add our plugin to the list of things to be compiled : ```diff -@@ -49,6 +49,7 @@ asm_plugins = [ +@@ -49,6 +49,7 @@ asm_plugins_list = [ 'x86_nz', 'xap', 'xcore_cs', @@ -127,6 +118,12 @@ The build is handled by meson, we have to add our plugin to the list of things t #'arch/6502/6502dis.c', 'arch/amd29k/amd29k.c', #'arch/8051/8051_disas.c', ++ 'arch/mycpu/mycpu_disas.c', + 'arch/arm/armass.c', + +@@ -129,6 +130,7 @@ rz_asm_inc = [ ++ 'arch/mycpu', +] ``` * `librz/include/rz_asm.h`