Skip to content

Commit

Permalink
Fix android build and add r_core->anal_define api
Browse files Browse the repository at this point in the history
Fix static build (libr.a)
Fix android build farm scripts
Build system is still hacky
  • Loading branch information
radare committed Sep 2, 2012
1 parent a47c577 commit a8757a6
Show file tree
Hide file tree
Showing 31 changed files with 173 additions and 45 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ plugins.cfg:
gitpush:
sh mk/gitpush.sh

.PHONY: todo
todo:
grep -re TODO:0.9.2 libr binr

farm:
./sys/farm/run.sh

Expand All @@ -41,6 +37,14 @@ w32:
./configure --without-ssl --without-gmp --with-compiler=i486-mingw32-gcc --with-ostype=windows --host=i486-unknown-windows
make

.PHONY: depgraph.png
depgraph.png:
cd libr ; perl depgraph.pl | dot -Tpng -odepgraph.png

android:
@if [ -z "$(NDK_ARCH)" ]; then echo "Set NDK_ARCH=[arm|mips|x86]" ; false; fi
sys/android-${NDK_ARCH}.sh

w32dist:
rm -rf radare2-w32-${VERSION} w32dist
mkdir w32dist
Expand Down
7 changes: 7 additions & 0 deletions binr/binr.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
BINR_PROGRAM=1
include ../../libr/config.mk

#.PHONY: all clean
Expand All @@ -13,3 +14,9 @@ BEXE=${BIN}${EXT_EXE}
# ${CC} -o ${BEXE} ${OBJ} ${LIBS} ${LDFLAGS}

include ../../libr/rules.mk

ifeq ($(WITHNONPIC),1)
LDFLAGS+=../../libr/db/sdb/src/libsdb.a
LDFLAGS+=../../libr/fs/p/grub/libgrubfs.a
LDFLAGS+=-lm
endif
5 changes: 4 additions & 1 deletion binr/blob/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ include ../../config-user.mk
CFLAGS=-I ../../libr/include/
CFLAGS+=-DLIBDIR="\"${LIBDIR}\""
CFLAGS+=-DR2_BIRTH=\"`date +%Y-%m-%d`\"
ifeq ($(STATIC_BUILD),1)
CFLAGS+=-DR2_GITTIP=\"$(GIT_TIP)\"

#ifeq ($(STATIC_BUILD),1)
ifeq ($(WITHNONPIC),1)
LDFLAGS+=../../libr/th/libr_th.a
LDFLAGS+=../../libr/io/libr_io.a
LDFLAGS+=../../libr/socket/libr_socket.a
Expand Down
10 changes: 6 additions & 4 deletions libr/anal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ include ../../global.mk

NAME=r_anal
EXTRA_CLEAN=clean2
DEPS=r_util r_db r_lib r_reg r_syscall r_diff # r_core (commented as it would be recursive)
DEPS=r_util r_db r_lib r_reg r_syscall r_diff
# r_core (commented as it would be recursive)
CFLAGS+=-DCORELIB -Iarch -I$(TOP)/shlr

include $(TOP)/libr/config.mk
include $(LTOP)/config.mk

LDFLAGS+=${BN_LIBS}

Expand All @@ -21,13 +22,14 @@ CPARSE_OBJS=cparse/cparse.o cparse/lex.yy.o cparse/tree.o cparse/gen.o cparse/er
OBJ=${STATIC_OBJS} ${OBJLIBS} ${CPARSE_OBJS}

pre:
@cd $(TOP)/shlr && ${MAKE}
@cd cparse && ${MAKE} all
@if [ ! -e libr_anal.${EXT_SO} ]; then rm -f ${STATIC_OBJS} ; fi
#@if [ ! -e libr_anal.${EXT_SO} ]; then rm -f ${STATIC_OBJS} ; fi

clean2:
@cd cparse && ${MAKE} clean

plugins:
@${MAKE} -C p all

include $(TOP)/libr/rules.mk
include $(LTOP)/rules.mk
13 changes: 9 additions & 4 deletions libr/anal/p/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
include ../../config.mk


CFLAGS+=-I../../include -I../arch -Wall -shared -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}..
CFLAGS+=-L../../util -lr_util -L../../anal -lr_anal -L../../reg -lr_reg
LDFLAGS+=${LINK}

foo: all
ifeq ($(WITHPIC),1)
all: ${ALL_TARGETS}
@true

ALL_TARGETS=
# TODO: rename to enabled plugins
ARCHS=x86.mk x86_udis86.mk x86_simple.mk ppc.mk arm.mk avr.mk csr.mk dalvik.mk sh.mk
include $(ARCHS)

all: ${ALL_TARGETS}
@true

clean:
-rm -f *.${EXT_SO} *.o ${STATIC_OBJ}

mrproper: clean
-rm -f *.d ../arch/*/*/*.d

.PHONY: all clean foo mrproper
.PHONY: all clean mrproper
else
all:
.PHONY: all
endif
11 changes: 10 additions & 1 deletion libr/anal/type.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ R_API RAnalType *r_anal_type_find(RAnal *a, const char *name) {
return NULL;
}

static const char *analtype(ushort t) {
static const char *analtype(ut16 t) {
switch (t) {
case R_ANAL_VAR_TYPE_VOID:
return "void";
Expand Down Expand Up @@ -296,3 +296,12 @@ R_API RAnalType *r_anal_type_loadfile(RAnal *a, const char *path) {
}
return tTree;
}

/* if value is null, undefine, if value is "" , defined*/
/* numeric values are parsed from strings */
R_API void r_anal_type_define (RAnal *anal, const char *key, const char *value) {
// TODO: store in RPair
}

R_API void r_anal_type_header (RAnal *anal, const char *hdr) {
}
2 changes: 1 addition & 1 deletion libr/asm/arch/z80/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static UBYTE OpcodeLen(ULONG p, const ut8 *Opcodes) {
return(len);
}

ULONG ParseOpcodes(ULONG adr, ut8 *Opcodes, int len) {
R_API_I ULONG ParseOpcodes(ULONG adr, ut8 *Opcodes, int len) {
int i;
ULONG next;

Expand Down
2 changes: 2 additions & 0 deletions libr/asm/arch/z80/z80.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#define R_API_I static

#include "z80asm.c"
#include "disasm.c"
2 changes: 1 addition & 1 deletion libr/asm/arch/z80/z80asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ return obuflen;
}

// XXX
int z80asm (unsigned char *outbuf, const char *s) {
R_API_I int z80asm (unsigned char *outbuf, const char *s) {
return assemble (s, outbuf);
}

Expand Down
4 changes: 4 additions & 0 deletions libr/bp/p/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include ../../config.mk
ifeq ($(WITHPIC),1)

CFLAGS=-I../../include -I../arch/ -I../arch/include -Wall -fPIC ${LDFLAGS_LIB}
CFLAGS+=-DLIL_ENDIAN=1 -D__UNIX__
Expand All @@ -19,3 +20,6 @@ mrproper: clean
-rm -f *.d

.PHONY: all clean foo mrproper
else
all:
endif
25 changes: 25 additions & 0 deletions libr/core/anal.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,3 +773,28 @@ R_API int r_core_anal_all(RCore *core) {
}
return R_TRUE;
}

R_API void r_core_anal_setup_enviroment (RCore *core) {
char key[128], *str = NULL;
RListIter *iter;
RConfigNode *kv;
r_list_foreach (core->config->nodes, iter, kv) {
strcpy (key, kv->name); // XXX: overflow
r_str_case (key, 1);
r_str_replace_char (key, '.', '_');
#define RANAL_PARSE_STRING_ONLY 1
#if RANAL_PARSE_STRING_ONLY
r_anal_type_define (core->anal, key, kv->value);
#else
if (kv->flags & CN_INT) {
r_anal_type_define_i (core->anal, key, kv->i_value);
} else if (kv->flags & CN_BOOL) {
r_anal_type_define (core->anal, key, kv->i_value? "": NULL);
} else {
r_anal_type_define (core->anal, key, kv->value);
}
#endif
}
r_anal_type_header (core->anal, str);
free (str);
}
5 changes: 5 additions & 0 deletions libr/db/r.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ifeq ($(WITHNONPIC),1)
LDFLAGS+=$(LIBR)/db/sdb/src/libsdb.a
else
LDFLAGS+=-L$(LIBR)/db -lr_db
endif
2 changes: 2 additions & 0 deletions libr/db/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ BINDEPS=r_db r_util
BIN=test
OBJ=test.o
include ../../rules.mk

include ../r.mk
5 changes: 1 addition & 4 deletions libr/debug/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ DEPS=r_reg r_anal r_bp r_util r_io r_parse r_cons
CFLAGS+=-DCORELIB

foo:
@${MAKE} pre
@${MAKE} libs
@${MAKE} tests
@${MAKE} plugins
Expand All @@ -15,9 +14,6 @@ STATIC_OBJS=$(subst ..,p/..,$(subst debug_,p/debug_,$(STATIC_OBJ)))

OBJ=map.o trace.o arg.o debug.o plugin.o pid.o reg.o desc.o ${STATIC_OBJS}

pre:
@if [ ! -e libr_debug.${EXT_SO} ]; then rm -f ${STATIC_OBJS} ; fi

tests:
cd t && ${MAKE} all

Expand All @@ -27,3 +23,4 @@ plugins:
include ../rules.mk

libs: ${LIBSO} ${LIBAR}
.PHONY: foo plugins tests libs
4 changes: 4 additions & 0 deletions libr/debug/p/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include ../../config.mk

ifeq ($(WITHPIC),1)
CFLAGS+=-I../../include -Wall ${PIC_FLAGS} ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}.. -DCORELIB

foo: all
Expand All @@ -21,3 +22,6 @@ mrproper: clean
-rm -f *.d */*.d

.PHONY: all clean foo mrproper
else
all:
endif
16 changes: 9 additions & 7 deletions libr/debug/p/gdb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ ifeq (${OSTYPE},solaris)
LDFLAGS+=-lsocket
endif

LDFLAGS+=-L../../util -lr_util
LDFLAGS+=-L../../cons -lr_cons
LDFLAGS+=-L../../parse -lr_parse
LDFLAGS+=-L../../anal -lr_anal
LDFLAGS+=-L../../reg -lr_reg
LDFLAGS+=-L../../bp -lr_bp
LDFLAGS+=-L../../io -lr_io
-include ../../global.mk
-include ../../../global.mk
LDFLAGS+=-L$(LTOP)/util -lr_util
LDFLAGS+=-L$(LTOP)/cons -lr_cons
LDFLAGS+=-L$(LTOP)/parse -lr_parse
LDFLAGS+=-L$(LTOP)/anal -lr_anal
LDFLAGS+=-L$(LTOP)/reg -lr_reg
LDFLAGS+=-L$(LTOP)/bp -lr_bp
LDFLAGS+=-L$(LTOP)/io -lr_io

OBJ_GDB=debug_gdb.o
#libgdbwrap/gdbwrapper.o
Expand Down
1 change: 1 addition & 0 deletions libr/debug/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ BIN=main
BINDEPS=r_lib r_debug r_bp r_io r_reg r_cons r_anal r_socket r_syscall r_diff r_db r_util

include ../../rules.mk
include ../../db/r.mk
7 changes: 4 additions & 3 deletions libr/egg/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ BINDEPS=r_egg r_asm r_parse r_syscall r_db r_util r_lib
BIN=test
OBJ=test.o

.PHONY: t
.PHONY: t tests myclean

include ../../rules.mk
include ../../db/r.mk

t tests:
@for a in ${TESTS} ; do sh t-$$a.sh ; done

myclean:
rm -f test${EXT_EXE} test.o

include ../../rules.mk
2 changes: 2 additions & 0 deletions libr/include/r_anal.h
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ R_API RAnalType *r_anal_str_to_type(RAnal *a, const char* s);
R_API char *r_anal_type_to_str(RAnal *a, RAnalType *t, const char *sep);
R_API RAnalType *r_anal_type_free(RAnalType *t);
R_API RAnalType *r_anal_type_loadfile(RAnal *a, const char *path);
R_API void r_anal_type_define (RAnal *anal, const char *key, const char *value);
R_API void r_anal_type_header (RAnal *anal, const char *hdr);

/* anal.c */
R_API RAnal *r_anal_new();
Expand Down
7 changes: 7 additions & 0 deletions libr/io/p/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CFLAGS+=-I../../include -Wall -DWORDSIZE=64 ${PIC_CFLAGS} ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}.. -DCORELIB

include ../../config.mk

ifeq ($(WITHPIC),1)
# on solaris only
ifeq (${OSTYPE},solaris)
CFLAGS+=-lsocket
Expand Down Expand Up @@ -34,3 +36,8 @@ mrproper: clean
-rm -f *.d

.PHONY: all clean foo mrproper
else
clean all:

.PHONY: all
endif
2 changes: 1 addition & 1 deletion libr/io/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ all:
EXTRA_CLEAN=myclean
#include ../../rules.mk

myclean:
clean myclean:
rm -f cat read4 map *.o
10 changes: 8 additions & 2 deletions libr/parse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ NAME=r_parse
DEPS=r_lib r_flags r_util r_anal

-include ../config.mk

foo:
for a in pre libr_parse.${EXT_SO} libr_parse.${EXT_AR} plugins bins ; do ${MAKE} $$a ; done

Expand All @@ -14,9 +15,14 @@ bins:
@cd t && ${MAKE} all

pre:
@if [ ! -e libr_parse.${EXT_SO} ]; then rm -f ${STATIC_OBJS} ; fi
ifeq ($(WITHNONPIC),1)
if [ ! -e libr_parse.${EXT_AR} ]; then rm -f ${STATIC_OBJS} ; fi
endif
ifeq ($(WITHPIC),1)
if [ ! -e libr_parse.${EXT_SO} ]; then rm -f ${STATIC_OBJS} ; fi
endif

plugins:
@cd p && ${MAKE} all

include ../rules.mk
include $(LTOP)/rules.mk
6 changes: 4 additions & 2 deletions libr/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ ifeq ($(USE_RPATH),1)
LDFLAGS+=-Wl,-R${PREFIX}/lib
endif


#-------------------------------------#
# Rules for libraries
ifneq ($(NAME),)
Expand Down Expand Up @@ -128,14 +127,17 @@ endif

ifneq ($(BIN)$(BINS),)
BEXE=$(BIN)$(EXT_EXE)
X=$(subst r_,,$(BINDEPS))
LDFLAGS+=$(addprefix -L$(TOP)/libr/,$(X))
LDFLAGS+=$(addprefix -l,$(BINDEPS))

all: ${BEXE} ${BINS}

${BINS}: ${OBJS}
ifneq ($(SILENT),)
@echo CC $@
endif
${CC} ${CFLAGS} [email protected] ${OBJS} -L.. ${LDFLAGS} -o $@
${CC} ${CFLAGS} [email protected] ${OBJS} ${LDFLAGS} -o $@

${BEXE}: ${OBJ} ${SHARED_OBJ}
ifneq ($(SILENT),)
Expand Down
1 change: 1 addition & 0 deletions libr/sign/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ BIN=rasign2
BINDEPS=r_sign r_anal r_reg r_syscall r_diff r_db r_util

include ../../rules.mk
include ../../db/r.mk
1 change: 1 addition & 0 deletions libr/syscall/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ BIN=hello
BINDEPS=r_syscall r_db r_util

include ../../rules.mk
include ../../db/r.mk
Loading

0 comments on commit a8757a6

Please sign in to comment.