radare2/configure-plugins
pancake 3bc0212ee6 * Initial import of the 'configure-plugins' script
- accepts --static and --shared to setup which plugins
    you want to build statically in the library or dynamically
  - normalize .mk and plugin file names to adopt a single standard
  - WARNING: huge commit
* Added 'mk/sloc.mk' with 'sloc' target to count
  lines with sloccount everywhere (yeah!)

--HG--
rename : libr/asm/p/x86bea.mk => libr/asm/p/x86_bea.mk
rename : libr/asm/p/x86nasm.mk => libr/asm/p/x86_nasm.mk
rename : libr/asm/p/x86olly.mk => libr/asm/p/x86_olly.mk
rename : libr/config.h => libr/config.h.head
rename : libr/config.mk => libr/config.mk.head
rename : libr/debug/p/dbg_gdb.c => libr/debug/p/debug_gdb.c
rename : libr/debug/p/dbg_ptrace.c => libr/debug/p/debug_ptrace.c
rename : libr/debug/p/dbg_libgdbwrap/Makefile => libr/debug/p/libgdbwrap/Makefile
rename : libr/debug/p/dbg_libgdbwrap/README => libr/debug/p/libgdbwrap/README
rename : libr/debug/p/dbg_libgdbwrap/client.c => libr/debug/p/libgdbwrap/client.c
rename : libr/debug/p/dbg_libgdbwrap/gdbwrapper.c => libr/debug/p/libgdbwrap/gdbwrapper.c
rename : libr/debug/p/dbg_libgdbwrap/include/gdbwrapper-internals.h => libr/debug/p/libgdbwrap/include/gdbwrapper-internals.h
rename : libr/debug/p/dbg_libgdbwrap/include/gdbwrapper-stddef.h => libr/debug/p/libgdbwrap/include/gdbwrapper-stddef.h
rename : libr/debug/p/dbg_libgdbwrap/include/gdbwrapper.h => libr/debug/p/libgdbwrap/include/gdbwrapper.h
rename : libr/debug/p/dbg_libgdbwrap/include/libaspect.h => libr/debug/p/libgdbwrap/include/libaspect.h
rename : libr/debug/p/dbg_libgdbwrap/include/libe2dbg.h => libr/debug/p/libgdbwrap/include/libe2dbg.h
rename : libr/debug/p/dbg_libgdbwrap/include/revm.h => libr/debug/p/libgdbwrap/include/revm.h
rename : libr/debug/p/dbg_libgdbwrap/interface.c => libr/debug/p/libgdbwrap/interface.c
rename : libr/io/p/dbg.mk => libr/io/p/debug.mk
rename : libr/io/p/io_dbg.c => libr/io/p/io_debug.c
2010-01-13 23:42:49 +01:00

147 lines
3.4 KiB
Bash
Executable File

#!/bin/sh
#
# Script to configure "staticability" of plugins
# author: pancake // nopcode
#
# default configuration
STATIC_ASM="asm.x86_olly asm.x86_nasm asm.mips asm.java"
STATIC_PAR="parse.dummy parse.x86_pseudo parse.mreplace"
STATIC_BIN="bin.elf bin.elf64 bin.pe bin.pe64 bin.java bin.dummy"
STATIC_BP="bp.x86 bp.arm"
STATIC_IO="io.ptrace io.dbg io.shm io.malloc"
STATIC_BININFO="bininfo.addr2line"
STATIC_DEBUG="debug.ptrace"
STATIC_CRYPTO="crypto.aes"
STATIC="${STATIC_ASM} ${STATIC_PAR} ${STATIC_BIN} ${STATIC_BP} ${STATIC_IO}"
STATIC="${STATIC} ${STATIC_BININFO} ${STATIC_DEBUG} ${STATIC_CRYPTO}"
# TODO: fill it with love
SHARED=""
function list {
for a in $STATIC ; do echo "static $a" ; done
for a in $SHARED ; do echo "shared $a" ; done
exit 0
}
function help {
echo "Usage: ./configure-plugins [options]"
echo " -n do nothing.. do not generate any file"
echo " --list list all static and shared plugins"
echo " --static [name ..] define named plugin as static"
echo " --shared [name ..] define named plugin as shared"
echo " --help, -h display this helpful message"
echo "NOTE: static plugins are compiled inside the owner library"
exit 0
}
cfg=./plugins.cfg
function load {
[ -e $cfg ] && . $cfg
}
function save {
echo "STATIC=\"$STATIC\"" > $cfg
echo "SHARED=\"$SHARED\"" >>$cfg
}
function generate_configh {
oldlib=""
for a in ${STATIC} ; do
lib=$(echo $a | cut -d . -f 1) # library
plg=$(echo $a | cut -d . -f 2) # plugin name
if [ ! "$oldlib" = "$lib" ]; then
[ -n "$oldlib" ] && echo " 0"
oldlib=$lib
uclib=$(echo $lib | tr '[:lower:]' '[:upper:]')
echo
echo "#define R_${uclib}_STATIC_PLUGINS \\"
fi
echo " &r_${lib}_plugin_${plg}, \\"
done
echo " 0"
}
function generate_configmk {
oldlib=""
for a in ${STATIC} ; do
lib=$(echo $a | cut -d . -f 1) # library
plg=$(echo $a | cut -d . -f 2) # plugin name
if [ ! "$oldlib" = "$lib" ]; then
[ -n "$oldlib" ] && printf "\n"
oldlib=$lib
uclib=$(echo $lib | tr '[:lower:]' '[:upper:]')
printf "STATIC_${uclib}_PLUGINS= "
fi
printf "p/${plg}.mk "
done
}
function generate {
echo "configure-plugins: Generating libr/config.h .."
cat libr/config.h.head > libr/config.h
generate_configh >> libr/config.h
cat libr/config.h.tail >> libr/config.h
echo "configure-plugins: Generating libr/config.mk .."
cat libr/config.mk.head > libr/config.mk
generate_configmk >> libr/config.mk
cat libr/config.mk.tail >> libr/config.mk
return
}
function add {
for a in $1 ; do [ $a = $2 ] && return ; done ; echo $1 $2
}
function sub {
n="" ; for a in $1 ; do [ $a = $2 ] && continue ; n="$n $a" ; done ; echo $n
}
function dosort {
( for a in $1 ; do echo $a ; done ) | sort
}
function sort_vars {
STATIC=$(dosort "$STATIC")
SHARED=$(dosort "$SHARED")
}
function make_static {
STATIC=$(add "$STATIC" $1)
SHARED=$(sub "$SHARED" $1)
}
function make_shared {
SHARED=$(add "$SHARED" $1)
STATIC=$(sub "$STATIC" $1)
}
function make_ { : ; }
load
MODE=""
DONOTHING=0
while : ; do
[ -z "$1" ] && break
case "$1" in
"--static") MODE=static ; ;;
"--shared") MODE=shared ; ;;
"--list") sort_vars ; list ; ;;
"-n") DONOTHING=1 ; ;;
"-h"|"--help") help ; ;;
*) eval make_$MODE $1 ; ;;
esac
shift
done
sort_vars
[ ${DONOTHING} = 0 ] && generate
save