* Hard simplification of the swig build system

* Add swig dependencies to the default build
* Check for valaswig and swig at configure time
* Some random vapi fixes
* Upgrade to acr 0.8
  - Add --without-valaswig flag to disable the build
    of the python/perl/ruby bindings
This commit is contained in:
pancake 2010-01-12 19:57:33 +01:00
parent 3b35f5329a
commit 28adb73802
11 changed files with 164 additions and 217 deletions

View File

@ -1,9 +1,16 @@
include config-user.mk
include config.mk
all:
all: libr swig
libr:
cd libr && ${MAKE} all
swig:
ifeq (${HAVE_VALASWIG},1)
cd swig && ${MAKE} all
endif
clean:
cd libr && make clean
@ -55,4 +62,4 @@ shot:
include ${MKPLUGINS}
.PHONY: all clean mrproper install uninstall deinstall dist shot pkgcfg vdoc
.PHONY: all clean mrproper install uninstall deinstall dist shot pkgcfg vdoc swig libr

View File

@ -20,6 +20,7 @@ VERSION=@VERSION@
OSTYPE?=@USEROSTYPE@
HAVE_LIB_TCC=@HAVE_LIB_TCC@
HAVE_VALASWIG=@HAVE_VALASWIG@
#-include ../config.mk
#-include ../../config.mk

152
configure vendored
View File

@ -1,5 +1,5 @@
#!/bin/sh
# This script was automatically generated by ACR v0.7.2
# This script was automatically generated by ACR v0.8
# @author: pancake <youterm.com>
# @url: http://news.nopcode.org/pancake/acr.html
@ -20,6 +20,7 @@ DEBUGGER=1
HAVE_EWF=1
[ -z "${USERCC}" ] && USERCC="gcc"
[ -z "${USEROSTYPE}" ] && USEROSTYPE="gnulinux"
WANT_VALASWIG=1
WANT_VALA=1
split_host() {
S="$"
@ -145,6 +146,7 @@ printf "\nOptional Features:
--without-ewf disable EWF dependency
--with-compiler Define compiler to use (see mk/) (USERCC=gcc)
--with-ostype Choose OS type ( gnulinux windows osx ) (USEROSTYPE=gnulinux)
--without-valaswig disables the build of the valaswig bindings for python, perl, ruby
--without-vala disables the build of all the vala-dependant parts \n"
printf "\nSome influential environment variables:
CC C compiler command
@ -167,7 +169,7 @@ take_environ() {
}
show_version() {
echo "radare2-0.3b configuration script done with acr v0.7.2.
echo "radare2-0.3b configuration script done with acr v0.8.
The 'Free Software Foundation' message is only for autodetection.
Originally written by pancake <youterm.com>."
exit 0
@ -189,7 +191,7 @@ echo "VERSION: 0.3b"
echo "LANGS: c"
echo "REQUIRED: lib>=vala-1.0 libvala-1.0>=0.5.0"
echo "OPTIONAL: libewf"
echo "FLAGS: --without-debugger --without-ewf --with-compiler=gcc --with-ostype=gnulinux --without-vala"
echo "FLAGS: --without-debugger --without-ewf --with-compiler=gcc --with-ostype=gnulinux --without-valaswig --without-vala"
exit 0
;;
"--cache-file")
@ -235,6 +237,7 @@ echo "FLAGS: --without-debugger --without-ewf --with-compiler=gcc --with-ost
"--without-ewf") HAVE_EWF="0"; ;;
--with-compiler) if [ -z "${value}" ]; then USERCC="gcc"; else USERCC="${value}" ; fi ;;
--with-ostype) if [ -z "${value}" ]; then USEROSTYPE="gnulinux"; else USEROSTYPE="${value}" ; fi ;;
"--without-valaswig") WANT_VALASWIG="0"; ;;
"--without-vala") WANT_VALA="0"; ;;
*) if [ "$value" ]; then eval "`echo $flag2=$value`" ;
else echo ; echo "WARNING: Unknown flag '$flag'." >&2 ; echo ; fi ;;
@ -253,7 +256,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 LIL_ENDIAN BIG_ENDIAN BYTEORDER 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 LIL_ENDIAN BIG_ENDIAN BYTEORDER HAVE_LIB_EWF HAVE_EWF HAVE_LIB_TCC USERCC USEROSTYPE WANT_VALASWIG HAVE_VALASWIG VALASWIG HAVE_SWIG SWIG WANT_VALA HAVE_VALAC VALAC HAVE_VALA_1_0_VERSION_0_5_0"
create_environ
@ -270,6 +273,7 @@ ACR_RMFILES=" test.c a.out a.exe"
:
COMPILER=CC
printf "checking for c compiler... "
@ -285,45 +289,6 @@ if [ $? = 0 ]; then echo ${CC}; else
do_remove
echo "ERROR: ${CC} cannot create executables" >&2 ;
exit 1 ; fi
check_library() {
VAR=$1
S="$"
_REQUIRED=$3
_CHKLIB_NAME=$2
_CHKLIB_LIBS=$(echo "-l${_CHKLIB_NAME}" | sed 's,\+, -l,g')
printf "checking for lib${_CHKLIB_NAME} ... "
echo "main(){ }" > test.c
eval ${S}${COMPILER} ${CFLAGS} ${LDFLAGS} ${_CHKLIB_LIBS} test.c >/dev/null 2>&1
if [ $? = 0 ]; then
eval ${VAR}=1
echo yes
else
eval ${VAR}=0
echo no ; fi }
check_library HAVE_LIB_EWF ewf 0
if [ "$HAVE_EWF" = "1" ]; then
export HAVE_LIB_EWF="0"; fi
check_library HAVE_LIB_TCC tcc 0
printf "checking for valac... "
if [ -x "${VALAC}" ]; then
FIND=${VALAC}
else
FIND=""
for A in `echo ${PATH} | sed -e 's,:, ,g'`; do
if [ -x "${A}/valac" ]; then
FIND="${A}/valac"
break;
fi
done
fi
if [ -n "${FIND}" ]; then
echo ${FIND};
HAVE_VALAC=1
VALAC=${FIND}
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
@ -344,6 +309,91 @@ else
echo big
fi
check_library() {
VAR=$1
S="$"
_REQUIRED=$3
_CHKLIB_NAME=$2
_CHKLIB_LIBS=$(echo "-l${_CHKLIB_NAME}" | sed 's,\+, -l,g')
printf "checking for lib${_CHKLIB_NAME} ... "
echo "main(){ }" > test.c
eval ${S}${COMPILER} ${CFLAGS} ${LDFLAGS} ${_CHKLIB_LIBS} test.c >/dev/null 2>&1
if [ $? = 0 ]; then
eval ${VAR}=1
echo yes
else
eval ${VAR}=0
echo no ; fi }
check_library HAVE_LIB_EWF ewf 0
if [ "$HAVE_EWF" = "1" ]; then
HAVE_LIB_EWF="0"; fi
check_library HAVE_LIB_TCC tcc 0
printf "checking for valaswig... "
if [ -x "${VALASWIG}" ]; then
FIND=${VALASWIG}
else
FIND=""
for A in `echo ${PATH} | sed -e 's,:, ,g'`; do
if [ -x "${A}/valaswig" ]; then
FIND="${A}/valaswig"
break;
fi
done
fi
if [ -n "${FIND}" ]; then
echo ${FIND};
HAVE_VALASWIG=1
VALASWIG=${FIND}
else
HAVE_VALASWIG=0
VALASWIG=valaswig
echo no ; fi
printf "checking for swig... "
if [ -x "${SWIG}" ]; then
FIND=${SWIG}
else
FIND=""
for A in `echo ${PATH} | sed -e 's,:, ,g'`; do
if [ -x "${A}/swig" ]; then
FIND="${A}/swig"
break;
fi
done
fi
if [ -n "${FIND}" ]; then
echo ${FIND};
HAVE_SWIG=1
SWIG=${FIND}
else
HAVE_SWIG=0
SWIG=swig
echo no ; fi
if [ "$WANT_VALASWIG" = "1" ]; then
if [ "$HAVE_SWIG" = "0" ]; then
echo " valaswig depends on swig" >&2
HAVE_VALASWIG="0"; fi
else
HAVE_VALASWIG="0"; fi
printf "checking for valac... "
if [ -x "${VALAC}" ]; then
FIND=${VALAC}
else
FIND=""
for A in `echo ${PATH} | sed -e 's,:, ,g'`; do
if [ -x "${A}/valac" ]; then
FIND="${A}/valac"
break;
fi
done
fi
if [ -n "${FIND}" ]; then
echo ${FIND};
HAVE_VALAC=1
VALAC=${FIND}
else
HAVE_VALAC=0
VALAC=valac
echo no ; 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... "
@ -352,10 +402,10 @@ if [ $? = 0 ]; then HAVE_VALA_1_0_VERSION_0_5_0=1 ; echo ok; else
echo "no" ; fi
if [ "$HAVE_VALA_1_0_VERSION_0_5_0" = "0" ]; then
echo " Needs vala 0.5.0 at least" >&2
export HAVE_VALAC="0"
export VALAC=""; fi
HAVE_VALAC="0"
VALAC=""; fi
else
export HAVE_VALAC="0"; fi
HAVE_VALAC="0"; fi
SEDFLAGS=" -e '"
COUNT=0
for A in ${ENVWORDS} ; do
@ -369,7 +419,7 @@ for A in ${ENVWORDS} ; do
done
SEDFLAGS="${SEDFLAGS}'"
for A in ./config-user.mk libr/include/r_userconf.h pkgcfg/libr.pc pkgcfg/r_io.pc pkgcfg/r_asm.pc pkgcfg/r_bin.pc pkgcfg/r_cons.pc pkgcfg/r_diff.pc pkgcfg/r_core.pc pkgcfg/r_lang.pc pkgcfg/r_socket.pc pkgcfg/r_debug.pc pkgcfg/r_reg.pc pkgcfg/r_line.pc pkgcfg/r_syscall.pc pkgcfg/r_macro.pc pkgcfg/r_util.pc pkgcfg/r_search.pc pkgcfg/r_vm.pc pkgcfg/r_th.pc pkgcfg/r_bp.pc pkgcfg/r_db.pc ; do # SUBDIRS
if [ -f "${VPATH}/${A}.acr" ]; then
if [ -f "${VPATH}/${A}.acr" ]; then
SD_TARGET=${A}
else
if [ -d "${VPATH}/${A}" ]; then
@ -387,11 +437,13 @@ eval sed -e "s,@VPATH@,${VPATH}/${A},g" ${SEDFLAGS} > ${SD_TARGET}.tmp
for A in ${ENVWORDS}; do
VALUE=`eval echo "$"${A}`
if [ "$VALUE" = "0" ]; then ## FALSE
if [ "$VALUE" = 0 ]; then ## FALSE
MARK="##${A}##"
if [ -n "`grep \"${MARK}\" ${SD_TARGET}.tmp`" ]; then
mv ${SD_TARGET}.tmp ${SD_TARGET}.tmp2
cat ${SD_TARGET}.tmp2 | MARK=$MARK awk 'BEGIN{a=0;}{if($1==ENVIRON["MARK"]){ if(a)a=0;else a=1 }else{if(!a)print;}}' > ${SD_TARGET}.tmp
cat ${SD_TARGET}.tmp2 | MARK=$MARK awk 'BEGIN{a=0;}{if($1==ENVIRON["MARK"]){if(a)a=0;else a=1}else{if(!a)print;}}' > ${SD_TARGET}.tmp
fi
fi
done
mv ${SD_TARGET}.tmp ${SD_TARGET} && rm -f ${SD_TARGET}.tmp2
if [ $? = 1 ]; then echo Cannot write target file ; control_c ; fi
@ -400,7 +452,7 @@ done
do_remove
echo
echo "Final report:"
for A in PREFIX HAVE_LIB_EWF HAVE_LIB_TCC HAVE_VALAC DEBUGGER USERCC USEROSTYPE ; do # REPORT
for A in PREFIX HAVE_VALASWIG HAVE_LIB_EWF HAVE_LIB_TCC HAVE_VALAC DEBUGGER USERCC USEROSTYPE ; do # REPORT
eval VAL="\$${A}"
[ -z "${VAL}" ] && VAL="(null)"
echo " - ${A} = ${VAL}"

View File

@ -6,6 +6,7 @@ LANG_C!
ARG_WITHOUT DEBUGGER debugger disable native debugger features ;
CHECK_ENDIAN
CHKLIB ewf
ARG_WITHOUT HAVE_EWF ewf disable EWF dependency ;
IF HAVE_EWF { HAVE_LIB_EWF = 0 ; }
@ -16,9 +17,21 @@ CHKLIB tcc
ARG_WITH USERCC=gcc compiler Define compiler to use (see mk/) ;
ARG_WITH USEROSTYPE=gnulinux ostype Choose OS type ( gnulinux windows osx ) ;
ARG_WITHOUT WANT_VALASWIG valaswig disables the build of the valaswig bindings for python, perl, ruby ;
CHKPRG VALASWIG valaswig
CHKPRG SWIG swig
IF WANT_VALASWIG {
IFNOT HAVE_SWIG {
ECHO valaswig depends on swig ;
HAVE_VALASWIG = 0 ;
}
}{
HAVE_VALASWIG = 0 ;
}
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 {
@ -32,7 +45,7 @@ IF WANT_VALA {
HAVE_VALAC = 0 ;
}
REPORT PREFIX HAVE_LIB_EWF HAVE_LIB_TCC HAVE_VALAC DEBUGGER USERCC USEROSTYPE ;
REPORT PREFIX HAVE_VALASWIG HAVE_LIB_EWF HAVE_LIB_TCC HAVE_VALAC DEBUGGER USERCC USEROSTYPE ;
(( TODO: Add the rest of .pc files here.. add a rule for acr? ))
SUBDIRS ./config-user.mk libr/include/r_userconf.h

View File

@ -47,6 +47,11 @@ namespace Radare {
public string buf_asm;
}
[CCode (cname="struct r_asm_fastcall_t", destroy_function="" )]
public class Fastcall {
public string arg[16];
}
public int arch;
public int bits;
public bool big_endian;
@ -73,7 +78,7 @@ namespace Radare {
public int assemble(out Aop aop, string buf);
public Code? mdisassemble(uint8 *buf, uint64 length);
public Code? massemble(string buf);
public weak string fastcall(int idx, int num);
public Fastcall fastcall(int idx, int num);
//public int parse();
// This is the destructor
public void free();

View File

@ -4,9 +4,9 @@
namespace Radare {
[Compact]
[CCode (cname="struct r_debug_t", free_function="r_debug_free", cprefix="r_debug_")]
public class Debug {
public class rDebug {
public rBreakpoint bp;
public Debug();
public rDebug();
public bool use(string plugin);
@ -49,6 +49,8 @@ namespace Radare {
//public struct Process *parent;
}
// XXX cname=int must be deprecated by valaswig
[CCode (cprefix="R_DBG_PROC_", cname="int")]
public enum ProcessStatus {
STOP,
RUN,
@ -59,8 +61,8 @@ namespace Radare {
public int pid_del();
public int pid_add_thread();
public int pid_del_thread();
public Debug.Process pid_get(int pid);
public bool pid_set_status(Debug.ProcessStatus status);
//public Process pid_get(int pid); // XXX wrong api syntax 'get' is keyword
public bool pid_set_status(ProcessStatus status);
}
}

View File

@ -2,12 +2,11 @@
[CCode (cheader_filename="r_lib.h", cprefix="r_", lower_case_cprefix="r_")]
namespace Radare {
[Compact]
[CCode (cname="struct r_lib_t", free_function="r_lib_free")]
public class Library {
public Library(string symname);
public Library init(string symname);
public class rLibrary {
public rLibrary(string symname);
public rLibrary init(string symname);
public bool close(void *ptr);
public void* opendir(string path);
public string types_get(int idx);
@ -21,7 +20,7 @@ namespace Radare {
// we need delegates here (function pointerz)
// public bool add_handler(int type, string desc, /* */, void* user);
public bool del_handler(int type);
public Library.Handler get_handler(int type);
public Handler get_handler(int type);
//public struct Struct { }
[Compact]
public struct Handler {

View File

@ -1,12 +1,18 @@
MODS=r_bp r_util r_diff r_hash r_socket r_reg
all: ruby perl python
all: python ruby perl
perl:
cd perl && make
python:
cd python && make
ruby:
cd ruby && make
test:
cd perl && make test
cd python && make test
cd ruby && make test
#sh do-test.sh
oldtest:
sh do-swig.sh r_bp
@ -16,13 +22,4 @@ clean:
rm -rf python/*
rm -rf perl/*
python:
for a in ${MODS} ; do sh do-swig.sh python $$a ; done
perl:
for a in ${MODS} ; do sh do-swig.sh perl $$a ; done
ruby:
for a in ${MODS} ; do sh do-swig.sh ruby $$a ; done
.PHONY: ruby python perl clean oldtest test all

View File

@ -1,48 +1,5 @@
all: r_bp.so r_asm.so r_diff.so r_debug.so r_hash.so r_cons.so r_core.so r_search.so r_db.so r_lib.so
LANG=perl
LANG_EXT=pl
LIBS_PFX=
r_bp.so:
cd .. && sh do-swig.sh perl r_bp
r_diff.so:
cd .. && sh do-swig.sh perl r_diff
r_asm.so:
cd .. && sh do-swig.sh perl r_asm
r_debug.so:
cd .. && sh do-swig.sh perl r_debug
r_hash.so:
cd .. && sh do-swig.sh perl r_hash
r_cons.so:
cd .. && sh do-swig.sh perl r_cons
# XXX r_reg is broken
r_reg.so:
cd .. && sh do-swig.sh perl r_reg
# XXX r_reg is broken
r_bin.so:
cd .. && sh do-swig.sh perl r_bin
r_core.so:
cd .. && sh do-swig.sh perl r_core
r_search.so:
cd .. && sh do-swig.sh perl r_search
r_db.so:
cd .. && sh do-swig.sh perl r_db
r_lib.so:
cd .. && sh do-swig.sh perl r_lib
test:
perl test-r_bp.pl
perl test-r_asm.pl
clean:
rm -f *.so
.PHONY: all test clean
include ../rules.mk

View File

@ -1,48 +1,5 @@
all: r_bp.so r_asm.so r_diff.so r_debug.so r_hash.so r_cons.so r_core.so r_search.so r_db.so r_lib.so
LANG=python
LANG_EXT=py
LIBS_PFX=_
r_bp.so:
cd .. && sh do-swig.sh python r_bp
r_diff.so:
cd .. && sh do-swig.sh python r_diff
r_asm.so:
cd .. && sh do-swig.sh python r_asm
r_debug.so:
cd .. && sh do-swig.sh python r_debug
r_hash.so:
cd .. && sh do-swig.sh python r_hash
r_cons.so:
cd .. && sh do-swig.sh python r_cons
# XXX r_reg is broken
r_reg.so:
cd .. && sh do-swig.sh python r_reg
# XXX r_reg is broken
r_bin.so:
cd .. && sh do-swig.sh python r_bin
r_core.so:
cd .. && sh do-swig.sh python r_core
r_search.so:
cd .. && sh do-swig.sh python r_search
r_db.so:
cd .. && sh do-swig.sh python r_db
r_lib.so:
cd .. && sh do-swig.sh python r_lib
test:
python test-r_bp.py
python test-r_asm.py
clean:
rm -f *.so
.PHONY: all test clean
include ../rules.mk

View File

@ -1,48 +1,5 @@
all: r_bp.so r_asm.so r_diff.so r_debug.so r_hash.so r_cons.so r_core.so r_search.so r_db.so r_lib.so
LANG=ruby
LANG_EXT=rb
LIBS_PFX=
r_bp.so:
cd .. && sh do-swig.sh ruby r_bp
r_diff.so:
cd .. && sh do-swig.sh ruby r_diff
r_asm.so:
cd .. && sh do-swig.sh ruby r_asm
r_debug.so:
cd .. && sh do-swig.sh ruby r_debug
r_hash.so:
cd .. && sh do-swig.sh ruby r_hash
r_cons.so:
cd .. && sh do-swig.sh ruby r_cons
# XXX r_reg is broken
r_reg.so:
cd .. && sh do-swig.sh ruby r_reg
# XXX r_reg is broken
r_bin.so:
cd .. && sh do-swig.sh ruby r_bin
r_core.so:
cd .. && sh do-swig.sh ruby r_core
r_search.so:
cd .. && sh do-swig.sh ruby r_search
r_db.so:
cd .. && sh do-swig.sh ruby r_db
r_lib.so:
cd .. && sh do-swig.sh ruby r_lib
test:
ruby test-r_bp.rb
@#ruby test-r_asm.rb
clean:
rm -f *.so
.PHONY: all test clean
include ../rules.mk