diff --git a/Makefile b/Makefile index e5cdbb4737..99258b45dc 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,9 @@ gitpush: todo: grep -re TODO:0.9.2 libr binr +farm: + ./sys/farm/run.sh + libr: cd libr && ${MAKE} all @@ -87,6 +90,7 @@ clean: mrproper: cd libr && ${MAKE} mrproper cd binr && ${MAKE} mrproper + cd shlr && ${MAKE} mrproper rm -f config-user.mk plugins.cfg libr/config.h libr/include/r_userconf.h libr/config.mk rm -f pkgcfg/*.pc diff --git a/libr/Makefile b/libr/Makefile index 0a44a52a4a..476858023f 100644 --- a/libr/Makefile +++ b/libr/Makefile @@ -17,7 +17,7 @@ all: libs libs: @for lib in ${LIBLIST}; do \ - cd $${lib} && ${MAKE} all || exit 1 ; cd .. ; done + cd $${lib} && ${MAKE} || exit 1 ; cd .. ; done @echo Build done for: ${LIBLIST} pkgcfg: diff --git a/libr/anal/cparse/Makefile b/libr/anal/cparse/Makefile index cc6a673385..f056387e43 100644 --- a/libr/anal/cparse/Makefile +++ b/libr/anal/cparse/Makefile @@ -8,13 +8,16 @@ all: tree.o tree.o: lex.yy.o +cparse.o: lemon + ./lemon cparse.y + ${CC} ${CFLAGS} -c cparse.c + lex.yy.o: cparse.o flex cparse.l ${CC} ${CFLAGS} -c lex.yy.c -cparse.o: lemon - ./lemon cparse.y - ${CC} ${CFLAGS} -c cparse.c +lemon.o: + ${HOST_CC} ${CFLAGS} -c lemon.c lemon: lemon.o ${HOST_CC} lemon.o -o lemon diff --git a/libr/asm/p/asm_z80.c b/libr/asm/p/asm_z80.c index 505b7a5f4f..ec0aeb647d 100644 --- a/libr/asm/p/asm_z80.c +++ b/libr/asm/p/asm_z80.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2012 pancake */ +/* radare - LGPL - Copyright 2012 - pancake */ #include #include @@ -8,14 +8,12 @@ #include "../arch/z80/z80.c" static int do_assemble(RAsm *a, RAsmOp *op, const char *buf) { - return op->inst_len = z80asm (obuf, op->buf); + return op->inst_len = z80asm (op->buf, buf); } static int do_disassemble(struct r_asm_t *a, struct r_asm_op_t *op, const ut8 *buf, ut64 len) { int dlen = z80dis (0, buf, op->buf_asm, len); - if (dlen>0) { - // printf ("LEN IS OK\n"); - } else dlen = 0; + if (dlen<0) dlen = 0; op->inst_len = dlen; return op->inst_len; } diff --git a/libr/asm/p/x86.mk b/libr/asm/p/x86.mk index 8aa88f33bc..cdfc3bac10 100644 --- a/libr/asm/p/x86.mk +++ b/libr/asm/p/x86.mk @@ -8,6 +8,8 @@ SHARED_X86+=../../shlr/udis86/syn-intel.o SHARED_X86+=../../shlr/udis86/syn.o SHARED_X86+=../../shlr/udis86/udis86.o +SHARED2_X86=$(addprefix ../,${SHARED_X86}) + STATIC_OBJ+=${OBJ_X86} SHARED_OBJ+=${SHARED_X86} TARGET_X86=asm_x86.${EXT_SO} @@ -15,4 +17,4 @@ TARGET_X86=asm_x86.${EXT_SO} ALL_TARGETS+=${TARGET_X86} ${TARGET_X86}: ${OBJ_X86} - ${CC} $(call libname,asm_x86) ${LDFLAGS} ${CFLAGS} -o ${TARGET_X86} ${OBJ_X86} + ${CC} $(call libname,asm_x86) ${LDFLAGS} ${CFLAGS} -o ${TARGET_X86} ${OBJ_X86} ${SHARED2_X86} diff --git a/libr/core/cmd_magic.c b/libr/core/cmd_magic.c index 804011bf0b..65993a4a43 100644 --- a/libr/core/cmd_magic.c +++ b/libr/core/cmd_magic.c @@ -1,6 +1,6 @@ /* radare - LGPL - Copyright 2009-2012 // pancake */ -static int magicdepth = 99; //XXX: do not use global var here +static int magicdepth = 99; //XXX: do not use global var here static void r_core_magic_at(RCore *core, const char *file, ut64 addr, int depth, int v) { const char *fmt; diff --git a/libr/core/io.c b/libr/core/io.c index 71f7efb691..e22ce6d9cf 100644 --- a/libr/core/io.c +++ b/libr/core/io.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2009-2012 pancake */ +/* radare - LGPL - Copyright 2009-2012 - pancake */ #include "r_core.h" @@ -7,7 +7,7 @@ R_API int r_core_dump(RCore *core, const char *file, ut64 addr, ut64 size) { ut8 *buf; int bs = core->blocksize; FILE *fd; - truncate (file, 0); + r_sys_truncate (file, 0); fd = fopen (file, "wb"); if (!fd) { eprintf ("Cannot open '%s' for writing\n", file); diff --git a/libr/include/r_util.h b/libr/include/r_util.h index b726b57cfb..e5919e9b1f 100644 --- a/libr/include/r_util.h +++ b/libr/include/r_util.h @@ -460,6 +460,7 @@ R_API int r_sys_cmd_str_full(const char *cmd, const char *input, char **output, #if __WINDOWS__ R_API char *r_sys_cmd_str_w32(const char *cmd); #endif +R_API int r_sys_truncate(const char *file, int sz); R_API int r_sys_cmd(const char *cmd); R_API int r_sys_cmdf (const char *fmt, ...); R_API char *r_sys_cmd_str(const char *cmd, const char *input, int *len); diff --git a/libr/io/io.c b/libr/io/io.c index ea17db0486..4c6a27d201 100644 --- a/libr/io/io.c +++ b/libr/io/io.c @@ -447,6 +447,6 @@ R_API int r_io_create (RIO *io, const char *file, int mode, int type) { if (io->plugin && io->plugin->create) return io->plugin->create (io, file, mode, type); if (type == 'd'|| type == 1) - return mkdir (file, mode); + return r_sys_mkdir (file); return creat (file, mode)? R_FALSE: R_TRUE; } diff --git a/libr/lib/t/Makefile b/libr/lib/t/Makefile index 01dd0177dc..594f380165 100644 --- a/libr/lib/t/Makefile +++ b/libr/lib/t/Makefile @@ -1,4 +1,5 @@ BINDEPS=r_lib r_util +LDFLAGS=-L.. include ../../config.mk diff --git a/libr/print/t/Makefile b/libr/print/t/Makefile index 3aa7ded9ed..816eaaa39c 100644 --- a/libr/print/t/Makefile +++ b/libr/print/t/Makefile @@ -2,12 +2,11 @@ include ../../config.mk all: hex fmt +BINS=fmt${EXT_EXE} BIN=hex OBJ=hex.o BINDEPS=r_cons r_print r_util -fmt${EXT_EXE}: fmt.o - myclean: rm -f fmt fmt.o diff --git a/libr/rules.mk b/libr/rules.mk index b4c83cf7c3..2247a5fa89 100644 --- a/libr/rules.mk +++ b/libr/rules.mk @@ -12,7 +12,11 @@ all: $(PRE) $(ALL) @$(MAKE) real_all real_all: ${EXTRA_TARGETS} ${LIBSO} ${LIBAR} +ifeq (${OSTYPE},windows) @-if [ -e t/Makefile ]; then (cd t && ${MAKE} all) ; fi +else + @if [ -e t/Makefile ]; then (cd t && ${MAKE} all) ; fi +endif @-if [ -e p/Makefile ]; then (cd p && ${MAKE} all) ; fi @true @@ -103,10 +107,12 @@ all: ${BIN}${EXT_EXE} ${BINS} ${BINS}: echo ${LIBR} - ${CC} ${CFLAGS} $@.c -L.. ${LDFLAGS} ${LDLIBS} -o $@${EXT_EXE} + ${CC} ${CFLAGS} $@.c -L.. ${LDFLAGS} -o $@${EXT_EXE} +# ${CC} ${CFLAGS} $@.c -L.. ${LDFLAGS} ${LDLIBS} -o $@${EXT_EXE} ${BIN}${EXT_EXE}: ${OBJ} ${SHARED_OBJ} - ${CC} $+ -L.. ${LDFLAGS} ${LDLIBS} -o ${BIN}${EXT_EXE} + ${CC} $+ -L.. -o ${BIN}${EXT_EXE} ${LDFLAGS} +# ${CC} $+ -L.. -o ${BIN}${EXT_EXE} ${LDLIBS} ${LDFLAGS} endif # Dummy myclean rule that can be overriden by the t/ Makefile diff --git a/libr/search/t/Makefile b/libr/search/t/Makefile index 47f6dc842c..6ef293e3f2 100644 --- a/libr/search/t/Makefile +++ b/libr/search/t/Makefile @@ -1,6 +1,6 @@ BINDEPS=r_search r_util -all: test${EXT_EXE} test-str${EXT_EXE} test-regexp${EXT_EXE} +BINS=test${EXT_EXE} test-str${EXT_EXE} test-regexp${EXT_EXE} include ../../rules.mk diff --git a/libr/util/sys.c b/libr/util/sys.c index ee5a170a8f..79f667f6b2 100644 --- a/libr/util/sys.c +++ b/libr/util/sys.c @@ -29,6 +29,18 @@ R_API ut64 r_sys_now(void) { return ret; } +R_API int r_sys_truncate(const char *file, int sz) { +#if __WINDOWS__ + int fd = open (file, O_RDWR); + if (!fd) return R_FALSE; + ftruncate (fd, sz); + close (fd); + return R_TRUE; +#else + return truncate (file, sz)? R_FALSE: R_TRUE; +#endif +} + R_API RList *r_sys_dir(const char *path) { struct dirent *entry; DIR *dir; diff --git a/libr/util/t/Makefile b/libr/util/t/Makefile index ab9bc9f285..9680c4e825 100644 --- a/libr/util/t/Makefile +++ b/libr/util/t/Makefile @@ -1,3 +1,5 @@ +include ../../config.mk + BINDEPS=r_util BINS=test${EXT_EXE} diff --git a/mk/i386-mingw32-gcc.mk b/mk/i386-mingw32-gcc.mk index e66b3f559f..60cc0faf3b 100644 --- a/mk/i386-mingw32-gcc.mk +++ b/mk/i386-mingw32-gcc.mk @@ -1,3 +1,5 @@ +ifeq (${_INCLUDE_MK_GCC_},) +_INCLUDE_MK_GCC_=1 # osx port install mingw32-gcc CC=i386-mingw32-gcc RANLIB=i386-mingw32-ranlib @@ -16,3 +18,4 @@ CFLAGS_OPT1=-O1 CFLAGS_OPT2=-O2 CFLAGS_OPT3=-O3 CFLAGS_DEBUG=-g +endif diff --git a/mk/i486-mingw32-gcc.mk b/mk/i486-mingw32-gcc.mk index 7d93c8ba77..e1f6da6aef 100644 --- a/mk/i486-mingw32-gcc.mk +++ b/mk/i486-mingw32-gcc.mk @@ -1,3 +1,5 @@ +ifeq (${_INCLUDE_MK_GCC_},) +_INCLUDE_MK_GCC_=1 CC=i486-mingw32-gcc RANLIB=i486-mingw32-ranlib OSTYPE=windows @@ -15,3 +17,4 @@ CFLAGS_OPT1=-O1 CFLAGS_OPT2=-O2 CFLAGS_OPT3=-O3 CFLAGS_DEBUG=-g +endif diff --git a/mk/i586-mingw32msvc-gcc.mk b/mk/i586-mingw32msvc-gcc.mk index 9aa090b4af..ed6b3119a4 100644 --- a/mk/i586-mingw32msvc-gcc.mk +++ b/mk/i586-mingw32msvc-gcc.mk @@ -1,3 +1,5 @@ +ifeq (${_INCLUDE_MK_GCC_},) +_INCLUDE_MK_GCC_=1 CC=i586-mingw32msvc-gcc RANLIB=i586-mingw32msvc-ranlib ONELIB=0 @@ -15,3 +17,4 @@ CFLAGS_OPT1=-O1 CFLAGS_OPT2=-O2 CFLAGS_OPT3=-O3 CFLAGS_DEBUG=-g +endif diff --git a/r2-bindings/cxx/Makefile b/r2-bindings/cxx/Makefile index 4ac3eb9d41..1e72396fbf 100644 --- a/r2-bindings/cxx/Makefile +++ b/r2-bindings/cxx/Makefile @@ -13,6 +13,9 @@ LIBS=r_core.so r_asm.so #LIBS=r_util.so mkcxx: + @echo c++ bindings has been disabled + +mkcxx_real: for a in ${LIBS} ; do \ mod=`echo $$a|cut -d . -f 1` ; \ valabind --cxx -N Radare -m $$mod --vapidir=../vapi $$mod && \ diff --git a/shlr/Makefile b/shlr/Makefile index 33b598d51b..bd137b6a50 100644 --- a/shlr/Makefile +++ b/shlr/Makefile @@ -1,2 +1,2 @@ -clean: +clean mrproper: rm -f udis86/*.o udis86/*.d diff --git a/sys/build.sh b/sys/build.sh index c0d35afceb..a00e94826a 100755 --- a/sys/build.sh +++ b/sys/build.sh @@ -1,5 +1,7 @@ #!/bin/sh +MAKE_JOBS=1 + MAKE=make gmake --help >/dev/null 2>&1 [ $? = 0 ] && MAKE=gmake @@ -15,8 +17,7 @@ if [ $? = 0 ]; then fi # build -if [ -f config-user.mk ]; then - ${MAKE} mrproper > /dev/null 2>&1 -fi -./configure --prefix=/usr && \ -${MAKE} -j 4 +${MAKE} mrproper > /dev/null 2>&1 +[ "`uname`" = Linux ] && export LDFLAGS="-Wl,--as-needed" +./configure --prefix=/usr || exit 1 +exec ${MAKE} -j ${MAKE_JOBS} diff --git a/sys/farm/run.sh b/sys/farm/run.sh index c870760311..48c804031a 100755 --- a/sys/farm/run.sh +++ b/sys/farm/run.sh @@ -4,7 +4,9 @@ cd `dirname $PWD/$0` ; cd .. . ./farm/CONFIG revision() { - echo `hg tip|head -n 1|cut -d : -f 2` + R=`hg tip 2>/dev/null|head -n 1|cut -d : -f 2` + [ -z "$R" ] && R=`git log|head -n1 |cut -d ' ' -f 2` + [ -n "$R" ] && echo $R } tstamp() { diff --git a/sys/mingw32.sh b/sys/mingw32.sh index bab638e8be..b02e0c2cb9 100755 --- a/sys/mingw32.sh +++ b/sys/mingw32.sh @@ -3,20 +3,26 @@ cd `dirname $PWD/$0` ; cd .. #TODO: add support for ccache +# XXX. fails with >1 +MAKE_JOBS=1 + +OLD_LDFLAGS="${LDFLAGS}" +unset LDFLAGS + if [ -x /usr/bin/pacman ]; then make clean ./configure --without-gmp --with-compiler=i486-mingw32-gcc --with-ostype=windows --host=i486-unknown-windows --without-ssl && \ - make -j 4 && \ + make -j ${MAKE_JOBS} && \ make w32dist elif [ `uname` = Darwin ]; then make clean ./configure --without-gmp --with-compiler=i386-mingw32-gcc --with-ostype=windows --host=i386-unknown-windows --without-ssl && \ - make -j 4 && \ + make -j ${MAKE_JOBS} && \ make w32dist elif [ -x /usr/bin/apt-get ]; then make clean ./configure --without-gmp --with-compiler=i586-mingw32msvc-gcc --with-ostype=windows --host=i586-unknown-windows && \ - make -j 4 && \ + make -j ${MAKE_JOBS} && \ make w32dist else echo "ubuntu/debian or archlinux required."