2010-01-13 22:42:49 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Script to configure "staticability" of plugins
|
|
|
|
# author: pancake // nopcode
|
2011-05-20 17:49:50 +00:00
|
|
|
# update: 2010-01-14
|
2010-01-13 22:42:49 +00:00
|
|
|
#
|
|
|
|
|
2015-04-09 22:17:30 +00:00
|
|
|
LOADLIBS=1
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
list () {
|
2010-01-13 22:42:49 +00:00
|
|
|
for a in $STATIC ; do echo "static $a" ; done
|
|
|
|
for a in $SHARED ; do echo "shared $a" ; done
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
help () {
|
2010-01-13 22:42:49 +00:00
|
|
|
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
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
load () {
|
2010-01-13 23:12:41 +00:00
|
|
|
if [ -e $cfg ]; then
|
|
|
|
echo "configure-plugins: Loading $cfg .."
|
|
|
|
. $cfg
|
|
|
|
else
|
2015-02-07 00:41:54 +00:00
|
|
|
echo "configure-plugins: Loading $1 .."
|
|
|
|
. "$1" #plugins.def.cfg
|
2010-01-13 23:12:41 +00:00
|
|
|
fi
|
2010-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
save () {
|
2010-01-13 22:42:49 +00:00
|
|
|
echo "STATIC=\"$STATIC\"" > $cfg
|
|
|
|
echo "SHARED=\"$SHARED\"" >>$cfg
|
|
|
|
}
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
generate_configh () {
|
2010-02-25 23:37:49 +00:00
|
|
|
plugins=""
|
2010-01-13 22:42:49 +00:00
|
|
|
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
|
2010-03-05 01:03:54 +00:00
|
|
|
uclib=$(echo $lib | tr '[a-z]' '[A-Z]')
|
2010-01-13 22:42:49 +00:00
|
|
|
echo
|
|
|
|
echo "#define R_${uclib}_STATIC_PLUGINS \\"
|
2010-02-25 23:37:49 +00:00
|
|
|
plugins="${plugins} __${uclib}"
|
2010-01-13 22:42:49 +00:00
|
|
|
fi
|
|
|
|
echo " &r_${lib}_plugin_${plg}, \\"
|
|
|
|
done
|
2010-02-21 19:21:36 +00:00
|
|
|
[ -n "$oldlib" ] && echo " 0"
|
2010-02-25 23:37:49 +00:00
|
|
|
|
|
|
|
# FILL EMPTY PLUGIN ARRAYS WITH LOVE
|
|
|
|
for a in ${SHARED} ; do
|
|
|
|
lib=$(echo $a | cut -d . -f 1) # library
|
|
|
|
plg=$(echo $a | cut -d . -f 2) # plugin name
|
|
|
|
if [ ! "$oldlib" = "$lib" ]; then
|
|
|
|
oldlib=$lib
|
2010-03-04 21:01:15 +00:00
|
|
|
uclib=$(echo $lib | tr '[a-z]' '[A-Z]')
|
2010-02-25 23:37:49 +00:00
|
|
|
if [ -z "`echo ${plugins} | grep __${uclib}`" ]; then
|
|
|
|
plugins="${plugins} __${uclib}"
|
|
|
|
echo
|
|
|
|
echo "#define R_${uclib}_STATIC_PLUGINS 0"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2010-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
generate_configmk () {
|
2010-02-25 23:37:49 +00:00
|
|
|
plugins=""
|
2010-01-13 22:42:49 +00:00
|
|
|
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
|
2010-03-04 21:01:15 +00:00
|
|
|
uclib=$(echo $lib | tr '[a-z]' '[A-Z]')
|
2010-01-13 22:42:49 +00:00
|
|
|
printf "STATIC_${uclib}_PLUGINS= "
|
2010-02-25 23:37:49 +00:00
|
|
|
plugins="${plugins} __${uclib}"
|
2010-01-13 22:42:49 +00:00
|
|
|
fi
|
|
|
|
printf "p/${plg}.mk "
|
|
|
|
done
|
2010-02-25 23:37:49 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
# fill the holes with love
|
|
|
|
for a in ${SHARED} ; do
|
|
|
|
lib=$(echo $a | cut -d . -f 1) # library
|
2010-03-04 21:01:15 +00:00
|
|
|
uclib=$(echo $lib | tr '[a-z]' '[A-Z]')
|
2010-02-25 23:37:49 +00:00
|
|
|
if [ -z "`echo ${plugins} | grep __${uclib}`" ]; then
|
|
|
|
plugins="${plugins} __${uclib}"
|
|
|
|
echo "STATIC_${uclib}_PLUGINS="
|
|
|
|
fi
|
|
|
|
done
|
2010-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
generate () {
|
2010-01-13 22:42:49 +00:00
|
|
|
echo "configure-plugins: Generating libr/config.h .."
|
|
|
|
cat libr/config.h.head > libr/config.h
|
2015-04-09 22:17:30 +00:00
|
|
|
echo "#define R2_LOADLIBS ${LOADLIBS}" >> libr/config.h
|
2010-01-13 22:42:49 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
add () {
|
2010-01-13 22:42:49 +00:00
|
|
|
for a in $1 ; do [ $a = $2 ] && return ; done ; echo $1 $2
|
|
|
|
}
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
sub () {
|
2010-01-13 22:42:49 +00:00
|
|
|
n="" ; for a in $1 ; do [ $a = $2 ] && continue ; n="$n $a" ; done ; echo $n
|
|
|
|
}
|
|
|
|
|
2014-09-01 13:25:32 +00:00
|
|
|
|
|
|
|
echo | sort -t. > /dev/null 2>&1
|
|
|
|
if [ $? = 0 ]; then
|
|
|
|
SORT="sort -t."
|
|
|
|
else
|
|
|
|
SORT="sort"
|
|
|
|
fi
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
dosort () {
|
2014-09-01 13:25:32 +00:00
|
|
|
|
|
|
|
( for a in $1 ; do echo $a ; done ) | ${SORT}
|
2010-02-21 19:21:36 +00:00
|
|
|
#( for a in $1 ; do echo $a ; done ) | sort -t. --key=1,1d
|
2010-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
sort_vars () {
|
2010-01-13 22:42:49 +00:00
|
|
|
STATIC=$(dosort "$STATIC")
|
|
|
|
SHARED=$(dosort "$SHARED")
|
|
|
|
}
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
make_static () {
|
2010-01-13 22:42:49 +00:00
|
|
|
STATIC=$(add "$STATIC" $1)
|
|
|
|
SHARED=$(sub "$SHARED" $1)
|
|
|
|
}
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
make_shared () {
|
2010-01-13 22:42:49 +00:00
|
|
|
SHARED=$(add "$SHARED" $1)
|
|
|
|
STATIC=$(sub "$STATIC" $1)
|
|
|
|
}
|
|
|
|
|
2010-01-14 18:15:36 +00:00
|
|
|
make_ () { : ; }
|
2010-01-13 22:42:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
MODE=""
|
|
|
|
DONOTHING=0
|
2015-02-07 00:41:54 +00:00
|
|
|
DEFCFG=./plugins.def.cfg
|
|
|
|
|
2010-01-13 22:42:49 +00:00
|
|
|
while : ; do
|
|
|
|
[ -z "$1" ] && break
|
|
|
|
case "$1" in
|
|
|
|
"--static") MODE=static ; ;;
|
|
|
|
"--shared") MODE=shared ; ;;
|
2015-02-07 00:41:54 +00:00
|
|
|
"--without-gpl") DEFCFG=./plugins.nogpl.cfg ;;
|
2015-04-09 22:17:30 +00:00
|
|
|
"--disable-loadlibs") LOADLIBS=0 ;;
|
2010-01-13 22:42:49 +00:00
|
|
|
"--list") sort_vars ; list ; ;;
|
|
|
|
"-n") DONOTHING=1 ; ;;
|
|
|
|
"-h"|"--help") help ; ;;
|
|
|
|
*) eval make_$MODE $1 ; ;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2015-02-07 00:41:54 +00:00
|
|
|
load ${DEFCFG}
|
2010-01-13 22:42:49 +00:00
|
|
|
sort_vars
|
|
|
|
|
|
|
|
[ ${DONOTHING} = 0 ] && generate
|
|
|
|
|
2015-03-16 00:19:25 +00:00
|
|
|
echo SHARED: ${SHARED}
|
|
|
|
echo STATIC: ${STATIC}
|
2014-09-01 13:25:32 +00:00
|
|
|
|
2010-01-13 22:42:49 +00:00
|
|
|
save
|
2010-01-13 23:12:41 +00:00
|
|
|
|
|
|
|
exit 0
|