Skip to content

Commit

Permalink
Add meson-symstall/uninstall/clean and update README and doc Termux
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed May 14, 2017
1 parent 5f51d46 commit 62b13b9
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 6 deletions.
52 changes: 46 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include global.mk

PREVIOUS_RELEASE=1.4.0

MESON?=meson
R2R=radare2-regressions
R2R_URL=$(shell doc/repo REGRESSIONS)
R2BINS=$(shell cd binr ; echo r*2 r2agent r2pm r2-indent)
Expand Down Expand Up @@ -385,19 +386,19 @@ pie:
sys/pie.sh ${PREVIOUS_RELEASE}

build:
meson --prefix=${PREFIX} build
$(MESON) --prefix="${PREFIX}" build

meson-windows:
cp -f libr/config.mk.meson libr/config.mk
cp -f libr/config.h.meson libr/config.h

meson-config:
meson-config meson-cfg meson-conf:
# TODO: this is wrong for each platform different plugins must be compiled
cp -f plugins.meson.cfg plugins.cfg
./configure --prefix=/usr
$(MAKE) libr/include/r_version.h
cp -f libr/config.mk libr/config.mk.meson
cp -f libr/config.h libr/config.h.meson
# cp -f libr/config.mk libr/config.mk.meson
# cp -f libr/config.h libr/config.h.meson
cp -f shlr/spp/config.def.h shlr/spp/config.h

meson: build
Expand All @@ -407,9 +408,48 @@ meson: build
meson-install:
cd build && DESTDIR="$(DESTDIR)" ninja install

MESON_FILES=$(shell find build/libr build/binr -type f| grep -v @)
B=$(DESTDIR)$(BINDIR)
L=$(DESTDIR)$(LIBDIR)

meson-symstall:
for a in $(MESON_FILES) ; do echo cp -f $$a $$(echo $$a|sed -e s,build/,,) ; done
ln -fs $(PWD)/binr/r2pm/r2pm ${B}/r2pm
ln -fs $(PWD)/build/binr/rasm2/rasm2 ${B}/rasm2
ln -fs $(PWD)/build/binr/rarun2/rarun2 ${B}/rarun2
ln -fs $(PWD)/build/binr/radare2/radare2 ${B}/radare2
ln -fs $(PWD)/build/binr/rahash2/rahash2 ${B}/rahash2
ln -fs $(PWD)/build/binr/rabin2/rabin2 ${B}/rabin2
ln -fs $(PWD)/build/binr/radare2/radare2 ${B}/radare2
ln -fs $(PWD)/build/binr/ragg2/ragg2 ${B}/ragg2
cd $(B) && ln -fs radare2 r2
ln -fs $(PWD)/build/libr/util/libr_util.$(SO_EXT) ${L}/libr_util.$(SO_EXT)
ln -fs $(PWD)/build/libr/bp/libr_bp.$(SO_EXT) ${L}/libr_bp.$(SO_EXT)
ln -fs $(PWD)/build/libr/syscall/libr_syscall.$(SO_EXT) ${L}/libr_syscall.$(SO_EXT)
ln -fs $(PWD)/build/libr/cons/libr_cons.$(SO_EXT) ${L}/libr_cons.$(SO_EXT)
ln -fs $(PWD)/build/libr/search/libr_search.$(SO_EXT) ${L}/libr_search.$(SO_EXT)
ln -fs $(PWD)/build/libr/magic/libr_magic.$(SO_EXT) ${L}/libr_magic.$(SO_EXT)
ln -fs $(PWD)/build/libr/flag/libr_flag.$(SO_EXT) ${L}/libr_flag.$(SO_EXT)
ln -fs $(PWD)/build/libr/reg/libr_reg.$(SO_EXT) ${L}/libr_reg.$(SO_EXT)
ln -fs $(PWD)/build/libr/bin/libr_bin.$(SO_EXT) ${L}/libr_bin.$(SO_EXT)
ln -fs $(PWD)/build/libr/config/libr_config.$(SO_EXT) ${L}/libr_config.$(SO_EXT)
ln -fs $(PWD)/build/libr/parse/libr_parse.$(SO_EXT) ${L}/libr_parse.$(SO_EXT)
ln -fs $(PWD)/build/libr/lang/libr_lang.$(SO_EXT) ${L}/libr_lang.$(SO_EXT)
ln -fs $(PWD)/build/libr/asm/libr_asm.$(SO_EXT) ${L}/libr_asm.$(SO_EXT)
ln -fs $(PWD)/build/libr/anal/libr_anal.$(SO_EXT) ${L}/libr_anal.$(SO_EXT)
ln -fs $(PWD)/build/libr/egg/libr_egg.$(SO_EXT) ${L}/libr_egg.$(SO_EXT)
ln -fs $(PWD)/build/libr/fs/libr_fs.$(SO_EXT) ${L}/libr_fs.$(SO_EXT)
ln -fs $(PWD)/build/libr/debug/libr_debug.$(SO_EXT) ${L}/libr_debug.$(SO_EXT)
ln -fs $(PWD)/build/libr/core/libr_core.$(SO_EXT) ${L}/libr_core.$(SO_EXT)
# TODO: missing libr/*/d .. no sdb binary is compiled to precompile those files

meson-uninstall:
$(MAKE) uninstall

meson-clean:
rm -rf build

MESON_FILES=$(shell find build/libr build/binr -type f| grep -v @)
meson-symstall-experimental:
for a in $(MESON_FILES) ; do echo ln -fs $(PWD)/$$a $(PWD)/$$(echo $$a|sed -e s,build/,,) ; done
$(MAKE) symstall

.PHONY: meson meson-install
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ using root privileges and sudo, simply run:

$ sys/user.sh

# Building with meson + ninja

The sys/install.sh method uses acr+make to build r2 from sources, which is the default
and recommended way, but there's also a work-in-progress support for Meson. Here's how
to build r2 with meson and ninja (supports linux, mac and windows)

$ make meson # will run make meson-config automatically
$ make meson-symstall # symstall the meson build into PREFIX (/usr)
$ make meson-uninstall # uninstall the meson installation

At the moment, the meson build system doesnt supports much configuration options and it
is not able to build all the plugins, it has been tested to work on the following hosts:

* Rpi3-arm32
* macOS-x86-64
* Termux/Android-arm64
* VoidLinux-x86-64
* Windows-x86-64

# Uninstall

In case of a polluted filesystem you can uninstall the current
Expand Down
58 changes: 58 additions & 0 deletions doc/termux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Termux
======

Termux is a terminal emulator that ships a base linux environment using the Debian package system
but compiling everything to run on native Android. The result is a fully functional shell on
Android devices for x86, arm and arm64.

Installation
------------

The Termux maintainer of the radare2 package updates the package really fast after every release
which happens every 6 weeks. So in this case, as long as it's suposed to run on embedded devices
it is ok to just install the package from Termux unless you really want to track git master or
develop for this platform.

$ apt install radare2

Building from git
-----------------

The packages required to build are:

$ apt install git make patch clang

Now you can clone the repo and build:

$ git clone --depth 1 https://github.com/radare/radare2
$ cd radare2
$ sys/termux.sh

Building with meson
-------------------

If you want to build with meson:

$ apt install python
$ pip install meson
$ r2pm -i ninja

And then you can run the build:

$ make meson

To install:

$ make meson-symstall PREFIX=/data/data/com.termux/files/usr

Updating
--------

To update the repo and rebuild you can do a full and clean rebuild by just running sys/termux.sh
or opt for typing `make` or `make meson` and it will just build what has changed, is something
fails please do a clean build like this:

$ git reset --hard
$ git clean -xdf
$ sys/termux.sh

0 comments on commit 62b13b9

Please sign in to comment.