mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-01 00:51:19 +00:00
08d5afd5c5
* Now r_bin is only using r_buf/r_file for file handling
140 lines
2.9 KiB
Bash
Executable File
140 lines
2.9 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Script to configure "staticability" of plugins
|
|
# author: pancake // nopcode
|
|
# date: 2010-01-14
|
|
#
|
|
|
|
list () {
|
|
for a in $STATIC ; do echo "static $a" ; done
|
|
for a in $SHARED ; do echo "shared $a" ; done
|
|
exit 0
|
|
}
|
|
|
|
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
|
|
|
|
load () {
|
|
if [ -e $cfg ]; then
|
|
echo "configure-plugins: Loading $cfg .."
|
|
. $cfg
|
|
else
|
|
echo "configure-plugins: Loading plugins.def.cfg .."
|
|
. ./plugins.def.cfg
|
|
fi
|
|
}
|
|
|
|
save () {
|
|
echo "STATIC=\"$STATIC\"" > $cfg
|
|
echo "SHARED=\"$SHARED\"" >>$cfg
|
|
}
|
|
|
|
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"
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
add () {
|
|
for a in $1 ; do [ $a = $2 ] && return ; done ; echo $1 $2
|
|
}
|
|
|
|
sub () {
|
|
n="" ; for a in $1 ; do [ $a = $2 ] && continue ; n="$n $a" ; done ; echo $n
|
|
}
|
|
|
|
dosort () {
|
|
( for a in $1 ; do echo $a ; done ) | sort -t. --key=1,1d
|
|
}
|
|
|
|
sort_vars () {
|
|
STATIC=$(dosort "$STATIC")
|
|
SHARED=$(dosort "$SHARED")
|
|
}
|
|
|
|
make_static () {
|
|
STATIC=$(add "$STATIC" $1)
|
|
SHARED=$(sub "$SHARED" $1)
|
|
}
|
|
|
|
make_shared () {
|
|
SHARED=$(add "$SHARED" $1)
|
|
STATIC=$(sub "$STATIC" $1)
|
|
}
|
|
|
|
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
|
|
|
|
exit 0
|