diff --git a/Makefile b/Makefile index 5c32cacc54616..a8fbecaf124e3 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ include config-user.mk include config.mk all: - cd libr && make + cd libr && ${MAKE} all clean: cd libr && make clean @@ -10,6 +10,9 @@ clean: mrproper: cd libr && make mrproper +pkgcfg: + cd libr && make pkgcfg + install: ${INSTALL_DIR} ${DESTDIR}${PREFIX}/share/doc/radare2 for a in doc/* ; do ${INSTALL_DATA} $$a ${DESTDIR}/${PREFIX}/share/doc/radare2 ; done @@ -40,4 +43,4 @@ shot: scp radare2-$${DATE}.tar.gz news.nopcode.org:/home/www/radarenopcode/get/shot -.PHONY: all clean mrproper install uninstall deinstall dist shot +.PHONY: all clean mrproper install uninstall deinstall dist shot pkgcfg diff --git a/TODO b/TODO index 8e4d4efe43005..eec844d0763ce 100644 --- a/TODO +++ b/TODO @@ -9,7 +9,11 @@ <{include libr/TODO}> * Add R_TRUFAE -> correct result, but with warnings (implement r_errno and r_errstr in r_util?) + - Quantic computation ftw \o/ +* Add r_th for threading help for w32/osx/linux/bsd/... .. use gthread? :P + - provide simple IPC comunication * r_cmd must provide a nesting char table indexing for commands + - this is pretty similar to r_db - every module can register their own commands - commands can be listed like in a tree * 'Vc' cursor mode makes color toggle diff --git a/config-user.mk.acr b/config-user.mk.acr index cfb2b24b20844..a10d3881c30c2 100644 --- a/config-user.mk.acr +++ b/config-user.mk.acr @@ -3,6 +3,7 @@ DESTDIR= PREFIX=@PREFIX@ HAVE_LIB_EWF=@HAVE_LIB_EWF@ +LIL_ENDIAN=@LIL_ENDIAN@ COMPILER=@USERCC@ STATIC_DEBUG=0 diff --git a/configure b/configure index a0d60e37cfe12..adbf9cd2f8c96 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #!/bin/sh -# This script was automatically generated by ACR v0.7.1 +# This script was automatically generated by ACR v0.7.2 # @author: pancake # @url: http://news.nopcode.org/pancake/acr.html @@ -167,7 +167,7 @@ take_environ() { } show_version() { -echo "radare2-0.2b configuration script done with acr v0.7.1. +echo "radare2-0.2b configuration script done with acr v0.7.2. The 'Free Software Foundation' message is only for autodetection. Originally written by pancake ." exit 0 @@ -243,6 +243,9 @@ esac # MAIN # take_environ +split_host BUILD HOST TARGET +[ -z "$ACRHOOK" ] && ACRHOOK=./configure.hook +[ -e "$ACRHOOK" ] && . ${ACRHOOK} while : ; do [ -z "$1" ] && break @@ -250,7 +253,7 @@ parse_options $1 shift done -ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_EWF HAVE_EWF HAVE_LIB_TCC USERCC USEROSTYPE WANT_VALA HAVE_VALAC VALAC HAVE_VALA_1_0_VERSION_0_5_0" +ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_EWF HAVE_EWF HAVE_LIB_TCC USERCC USEROSTYPE WANT_VALA HAVE_VALAC VALAC LIL_ENDIAN BIG_ENDIAN BYTEORDER HAVE_VALA_1_0_VERSION_0_5_0" create_environ @@ -259,13 +262,14 @@ echo "checking host system type... ${HOST}" echo "checking target system type... ${TARGET}" [ "${CROSSBUILD}" = 1 ] && echo "using crosscompilation mode." -split_host BUILD HOST TARGET +#split_host BUILD HOST TARGET [ -n "${prefix}" ] && PREFIX=${prefix} echo "checking for working directories... ${WODIS}" echo "using prefix '${PREFIX}'" ACR_RMFILES=" test.c a.out a.exe" + : COMPILER=CC printf "checking for c compiler... " @@ -320,6 +324,26 @@ else HAVE_VALAC=0 VALAC=valac echo no ; fi +printf "checking host endianness... " +echo 'main(){int a=1;char *b=(char*)&a;printf("%d",b[0]);}' > test.c +${CC} ${CFLAGS} ${LDFLAGS} -o a.out test.c >/dev/null 2>&1 +if [ ! $? = 0 ]; then + echo unexpected error + do_remove + exit 1 +fi +LIL_ENDIAN=$(./a.out) +if [ "${LIL_ENDIAN}" = 1 ]; then + BYTEORDER=1234 + BIG_ENDIAN=0 + echo little +else + BYTEORDER=4321 + BIG_ENDIAN=1 + LIL_ENDIAN=0 + echo big +fi + if [ "$WANT_VALA" = "1" ]; then HAVE_VALA_1_0_VERSION_0_5_0=0 printf "checking version of library vala-1.0 >= 0.5.0... " @@ -340,10 +364,11 @@ for A in ${ENVWORDS} ; do eval "VAR=\$${A}" VAR="`echo ${VAR} | sed -e 's/\,/\\\,/g'`" [ $COUNT = 10 ] && COUNT=0 && SEDFLAGS="${SEDFLAGS}' -e '" + COUNT=$(($COUNT+1)) SEDFLAGS="${SEDFLAGS}s,@${A}@,${VAR},g;" done SEDFLAGS="${SEDFLAGS}'" -for A in ./config-user.mk libr/libr.pc libr/include/r_userconf.h ; do # SUBDIRS +for A in ./config-user.mk libr/include/r_userconf.h pkgcfg/libr.pc pkgcfg/r_asm.pc pkgcfg/r_bin.pc pkgcfg/r_util.pc pkgcfg/r_search.pc ; do # SUBDIRS if [ -f "${VPATH}/${A}.acr" ]; then SD_TARGET=${A} else diff --git a/configure.acr b/configure.acr index 5e16a989d04e1..61bdb0c220adb 100644 --- a/configure.acr +++ b/configure.acr @@ -18,6 +18,7 @@ ARG_WITH USEROSTYPE=gnulinux ostype Choose OS type ( gnulinux windows osx ) ; ARG_WITHOUT WANT_VALA vala disables the build of all the vala-dependant parts ; CHKPRG VALAC valac +CHECK_ENDIAN (( temporary fix to avoid vala )) IF WANT_VALA { @@ -33,4 +34,11 @@ IF WANT_VALA { REPORT PREFIX HAVE_LIB_EWF HAVE_LIB_TCC HAVE_VALAC DEBUGGER USERCC USEROSTYPE ; -SUBDIRS ./config-user.mk libr/libr.pc libr/include/r_userconf.h ; +(( TODO: Add the rest of .pc files here.. add a rule for acr? )) +SUBDIRS ./config-user.mk libr/include/r_userconf.h + pkgcfg/libr.pc + pkgcfg/r_asm.pc + pkgcfg/r_bin.pc + pkgcfg/r_util.pc + pkgcfg/r_search.pc +; diff --git a/env.sh b/env.sh old mode 100755 new mode 100644 diff --git a/libr/Makefile b/libr/Makefile index fb74ef0ded67f..61428e32b5413 100644 --- a/libr/Makefile +++ b/libr/Makefile @@ -18,10 +18,13 @@ LIBLIST=io util lib meta lang flags bin bininfo macro hash line cons print confi all: echo PREFIX=${PREFIX} - #exit 1 for lib in ${LIBLIST}; do ( cd $${lib} && ${MAKE} all ); done @echo Build done for: ${LIBLIST} +pkgcfg: + for lib in ${LIBLIST}; do ( cd $${lib} && ${MAKE} pkgcfg ); done + # TODO: Magically generate libr.pc.acr here using LIBLIST and so :) + install: # TODO :Use INSTALL_DATA_DIR instead of mkdir echo Using prefix: ${PFX} @@ -41,7 +44,8 @@ install: do echo " $$a"; ${INSTALL_PROGRAM} $$a ${PFX}/bin ; done # plugins @${INSTALL_DIR} ${PFX}/lib/pkgconfig - ${INSTALL_DATA} libr.pc ${PFX}/lib/pkgconfig + for a in ../pkgcfg/*.pc ; do ${INSTALL_DATA} $$a ${PFX}/lib/pkgconfig ; done + #${INSTALL_DATA} libr.pc ${PFX}/lib/pkgconfig @${INSTALL_DIR} ${PFX}/share/vala/vapi ${INSTALL_DATA} vapi/*.vapi vapi/*.deps ${PFX}/share/vala/vapi @${INSTALL_DIR} ${PFX}/lib/radare2 @@ -78,6 +82,7 @@ deinstall uninstall: echo $$a ; rm -f $$a ; done rm -rf ${PREFIX}/lib/radare2 rm -f ${PREFIX}/lib/pkgconfig/libr.pc + rm -f ${PREFIX}/lib/pkgconfig/r_*.pc # test programs -@for a in `find */t -perm /u+x -type f | grep -v 2`; do \ a="${PREFIX}/bin-test/`echo $$a|awk -F / '{ print $$NF; }'`"; \ diff --git a/libr/bin/format/elf/elf.h b/libr/bin/format/elf/elf.h index a63dbadf992aa..dd1e02aa4f109 100644 Binary files a/libr/bin/format/elf/elf.h and b/libr/bin/format/elf/elf.h differ diff --git a/libr/hash/crca.c b/libr/hash/crca.c index 2c22eb0154906..0e8be5936d5e0 100644 Binary files a/libr/hash/crca.c and b/libr/hash/crca.c differ diff --git a/libr/include/r_util.h b/libr/include/r_util.h index a287d97390cf9..f084ed11bb798 100644 --- a/libr/include/r_util.h +++ b/libr/include/r_util.h @@ -40,6 +40,7 @@ double r_prof_end(struct r_prof_t *p); void r_mem_copyloop (ut8 *dest, const ut8 *orig, int dsize, int osize); void r_mem_copyendian (ut8 *dest, const ut8 *orig, int size, int endian); int r_mem_cmp_mask(const ut8 *dest, const ut8 *orig, const ut8 *mask, int len); +R_API const ut8 *r_mem_mem(const ut8 *haystack, int hlen, const ut8 *needle, int nlen); /* numbers */ struct r_num_t { diff --git a/libr/rules.mk b/libr/rules.mk index dc4c7bc4364c8..02c5690651747 100644 --- a/libr/rules.mk +++ b/libr/rules.mk @@ -73,6 +73,20 @@ ${LIBSO}: ${OBJ} ${LIBAR}: ${OBJ} ${CC_AR} ${OBJ} +pkgcfg: + @echo Generating pkgconfig stub for ${NAME} + @echo 'prefix=@PREFIX@' > ../../pkgcfg/${NAME}.pc.acr + @echo 'exec_prefix=$${prefix}' >> ../../pkgcfg/${NAME}.pc.acr + @echo 'libdir=$${exec_prefix}/lib' >> ../../pkgcfg/${NAME}.pc.acr + @echo 'includedir=$${exec_prefix}/include' >> ../../pkgcfg/${NAME}.pc.acr + @echo >> ../../pkgcfg/${NAME}.pc.acr + @echo 'Name: ${NAME}' >> ../../pkgcfg/${NAME}.pc.acr + @echo 'Description: radare foundation libraries' >> ../../pkgcfg/${NAME}.pc.acr + @echo 'Version: ${VERSION}' >> ../../pkgcfg/${NAME}.pc.acr + @echo 'Requires:' >> ../../pkgcfg/${NAME}.pc.acr + @echo 'Libs: -L$${libdir} '`echo ${NAME} ${DEPS}|sed -e s,r_,-lr_,g` >> ../../pkgcfg/${NAME}.pc.acr + @echo 'Cflags: -I$${includedir}/libr' >> ../../pkgcfg/${NAME}.pc.acr + install: cd .. && ${MAKE} install diff --git a/libr/util/mem.c b/libr/util/mem.c index 40aeb7a47fe3a..d824c12d65caf 100644 --- a/libr/util/mem.c +++ b/libr/util/mem.c @@ -3,7 +3,7 @@ #include #include -void r_mem_copyloop (ut8 *dest, const ut8 *orig, int dsize, int osize) +R_API void r_mem_copyloop (ut8 *dest, const ut8 *orig, int dsize, int osize) { int i=0,j; while(i