Skip to content

Commit

Permalink
* Added 'pkgcfg' directory with autogenerated .pc files
Browse files Browse the repository at this point in the history
  - 'make pkgcfg' does that automagically :)
* Implement r_mem_mem function in r_util
  • Loading branch information
radare committed Jul 16, 2009
1 parent a8a6619 commit 1c3a319
Show file tree
Hide file tree
Showing 45 changed files with 438 additions and 17 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ include config-user.mk
include config.mk

all:
cd libr && make
cd libr && ${MAKE} all

clean:
cd libr && make 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
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config-user.mk.acr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DESTDIR=
PREFIX=@PREFIX@
HAVE_LIB_EWF=@HAVE_LIB_EWF@
LIL_ENDIAN=@LIL_ENDIAN@

COMPILER=@USERCC@
STATIC_DEBUG=0
Expand Down
35 changes: 30 additions & 5 deletions configure
Original file line number Diff line number Diff line change
@@ -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 <youterm.com>
# @url: http://news.nopcode.org/pancake/acr.html

Expand Down Expand Up @@ -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 <youterm.com>."
exit 0
Expand Down Expand Up @@ -243,14 +243,17 @@ esac

# MAIN #
take_environ
split_host BUILD HOST TARGET
[ -z "$ACRHOOK" ] && ACRHOOK=./configure.hook
[ -e "$ACRHOOK" ] && . ${ACRHOOK}

while : ; do
[ -z "$1" ] && break
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

Expand All @@ -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... "
Expand Down Expand Up @@ -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... "
Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion configure.acr
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
;
Empty file modified env.sh
100755 → 100644
Empty file.
9 changes: 7 additions & 2 deletions libr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down Expand Up @@ -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; }'`"; \
Expand Down
Binary file modified libr/bin/format/elf/elf.h
Binary file not shown.
Binary file modified libr/hash/crca.c
Binary file not shown.
1 change: 1 addition & 0 deletions libr/include/r_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions libr/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 18 additions & 6 deletions libr/util/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
#include <r_util.h>
#include <stdlib.h>

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<dsize)
for(j=0;j<osize && i<dsize;j++)
dest[i++] = orig[j];
}

int r_mem_cmp_mask(const ut8 *dest, const ut8 *orig, const ut8 *mask, int len)
R_API int r_mem_cmp_mask(const ut8 *dest, const ut8 *orig, const ut8 *mask, int len)
{
int i, ret = 0;
for(i=0;i<len;i++)
ret += (orig[i]&mask[i])&dest[i];
return ret;
}

/* TODO check and use system endian */
void r_mem_copyendian (ut8 *dest, const ut8 *orig, int size, int endian)
/* XXX TODO check and use system endian */
R_API void r_mem_copyendian (ut8 *dest, const ut8 *orig, int size, int endian)
{
if (endian) {
if (dest != orig)
memcpy(dest, orig, size);
if (dest != orig)
memcpy(dest, orig, size);
} else {
unsigned char buffer[8];
switch(size) {
Expand Down Expand Up @@ -56,3 +56,15 @@ void r_mem_copyendian (ut8 *dest, const ut8 *orig, int size, int endian)
}
}
}

//R_DOC r_mem_mem: Finds the needle of nlen size into the haystack of hlen size
//R_UNIT printf("%s\n", r_mem_mem("food is pure lame", 20, "is", 2));
R_API const ut8 *r_mem_mem(const ut8 *haystack, int hlen, const ut8 *needle, int nlen)
{
int i, until = hlen-nlen;
for(i=0;i<until;i++) {
if (!memcmp(haystack+i, needle, nlen))
return haystack+i;
}
return NULL;
}
7 changes: 6 additions & 1 deletion libr/vapi/r_util.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ namespace Radare {
[Compact]
[CCode (cprefix="r_")]
public static class Util {
public static int hex_str2bin(string in, uint8 *buf);
public static int hex_str2bin (string in, uint8 *buf);
/* mem */
public uint8 *mem_mem (uint8 *a, int al, uint8 *b, int bl);
public void mem_copyendian (uint8 *dest, uint8 *orig, int size, int endian);
public void mem_copyloop (uint8 *dest, uint8 *orig, int dsize, int osize);
public void mem_cmp_mask (uint8 *dest, uint8 *orig, uint8 *mask, int len);
}
}

2 changes: 2 additions & 0 deletions pkgcfg/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all:
cd ../libr && ${MAKE} pkgcfg
11 changes: 11 additions & 0 deletions pkgcfg/libr.pc.acr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: libr
Description: radare framework libraries
Version: 0.1
Requires:
Libs: -L${libdir} -lr_core -lr_lang -lr_search -lr_cmd -lr_meta -lr_asm -lr_util
Cflags: -I${includedir}/libr
11 changes: 11 additions & 0 deletions pkgcfg/r_anal.pc.acr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include

Name: r_anal
Description: radare foundation libraries
Version:
Requires:
Libs: -L${libdir} -lr_anal -lr_util -lr_lib
Cflags: -I${includedir}/libr
11 changes: 11 additions & 0 deletions pkgcfg/r_asm.pc.acr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include

Name: r_asm
Description: radare foundation libraries
Version: 0.2
Requires:
Libs: -L${libdir} -lr_asm -lr_lib -lr_util
Cflags: -I${includedir}/libr
11 changes: 11 additions & 0 deletions pkgcfg/r_bin.pc.acr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include

Name: r_bin
Description: radare foundation libraries
Version: 0.2
Requires:
Libs: -L${libdir} -lr_bin -lr_lib -lr_util
Cflags: -I${includedir}/libr
11 changes: 11 additions & 0 deletions pkgcfg/r_bininfo.pc.acr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include

Name: r_bininfo
Description: radare foundation libraries
Version: 0.2
Requires:
Libs: -L${libdir} -lr_bininfo -lr_lib -lr_util
Cflags: -I${includedir}/libr
11 changes: 11 additions & 0 deletions pkgcfg/r_cmd.pc.acr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include

Name: r_cmd
Description: radare foundation libraries
Version:
Requires:
Libs: -L${libdir} -lr_cmd -lr_util
Cflags: -I${includedir}/libr
11 changes: 11 additions & 0 deletions pkgcfg/r_config.pc.acr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include

Name: r_config
Description: radare foundation libraries
Version:
Requires:
Libs: -L${libdir} -lr_config -lr_util
Cflags: -I${includedir}/libr
11 changes: 11 additions & 0 deletions pkgcfg/r_cons.pc.acr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include

Name: r_cons
Description: radare foundation libraries
Version:
Requires:
Libs: -L${libdir} -lr_cons -lr_util
Cflags: -I${includedir}/libr
11 changes: 11 additions & 0 deletions pkgcfg/r_core.pc.acr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include

Name: r_core
Description: radare foundation libraries
Version:
Requires:
Libs: -L${libdir} -lr_core -lr_config -lr_cons -lr_line -lr_io -lr_cmd -lr_util -lr_print -lr_flags -lr_asm -lr_lib -lr_macro -lr_debug -lr_hash -lr_bin -lr_lang -lr_io -lr_asm -lr_anal -lr_parse -lr_config -lr_macro -lr_print -lr_bininfo -lr_bp
Cflags: -I${includedir}/libr
Loading

0 comments on commit 1c3a319

Please sign in to comment.