* improve script

git-svn-id: trunk@16453 -
This commit is contained in:
pierre 2010-11-26 23:35:34 +00:00
parent e5e5cfdc2a
commit 110e3a6988

View File

@ -1,7 +1,23 @@
#!/usr/bin/env bash
if [ "$1" != "" ]; then
destdir=$1
if [ "$1" == "--help" ]; then
echo "Script used to easily create collection of libraries needed"
echo "to generate a Free Pascal IDE with debugger support."
echo "Usage: Copy this script to the directory where you just compile"
echo "a specific GNU debugger (for a specific target)"
echo "and run ./$0 in that directory"
echo "After, you will need to run a second script, copy-libs.sh"
echo "with a single parameter specifying to which directory the libraries"
echo "should be copied."
echo "Possible parameters for this script:"
echo "implicitlibs=\"space separated list if system librairies used\""
fi
if [ "${1#implicitlibs=}" != "$1" ]; then
implicitlibs=${1#implicitlibs=}
echo "Also adding implicit libs \"$implicitlibs\""
fi
if [ "${PATHEXT}" != "" ]; then
EXEEXT=.exe
@ -18,7 +34,7 @@ fi
echo "Deleting gdb${EXEEXT} to force recompile"
rm -f gdb${EXEEXT}
echo "Rebuilding gdb${EXEEXT}"
MAKE=`which gmake`
MAKE=`which gmake 2> /dev/null`
if [ "${MAKE}" == "" ]; then
MAKE=make
@ -39,13 +55,6 @@ if [ ${gdb_version2} -lt 10 ]; then
else
gdbversion=${gdb_version1}${gdb_version2}
fi
if [ "${destdir}" == "" ]; then
destdir=./libgdb
fi
if ! [ -d ${destdir} ]; then
mkdir ${destdir}
fi
cat make.log | gawk '
BEGIN {
@ -63,15 +72,29 @@ if ( doprint == 1 ) {
! /\\$/ { doprint=0; }
' | tee comp-cmd.log
gcccompiler=`sed -n "s:\([A-Za-z0-9_-]*gcc\) .*:\1:p" comp-cmd.log`
if [ "$gcccompiler" != "" ]; then
gcclibs=`$gcccompiler -print-search-dirs | sed -n "s#.*libraries: =\(.*\)#\1#p" `
if [ "$gcclibs" != "" ]; then
libdir=${gcclibs//:/ }
echo "gcc libs are \"$libdir\""
fi
fi
# Try to locate all libraries
echo Creating ./copy-libs.sh script
cat comp-cmd.log |gawk -v destdir=${destdir} -v libdir=${libdir} '
cat comp-cmd.log | gawk -v libdir="${libdir}" -v implibs="${implicitlibs}" '
BEGIN {
print "#!/usr/bin/env bash"
print "# copy-libs.sh generated by awk script"
print "INSTALL=`which ginstall 2> /dev/null `"
print "if [ "$INSTALL" == "" ]; then"
print " INSTALL=install"
print "fi"
print "if [ \"$1\" != \"\" ]; then"
print " destdir=$1"
print " ginstall -d ${destdir}"
print " $INSTALL -d ${destdir}"
print "else"
print " echo $0 destdir"
print " echo destdir should be the location where libgdb.a"
@ -86,24 +109,38 @@ BEGIN {
nb = split ($0,list);
for (i=1; i<=nb; i++) {
if ( list[i] ~ /lib[^ ]*\.a/ ) {
staticlib = gensub (/([^ ]*)(lib[^ ]*\.a)/,"\\1\\2 ","g",list[i]);
print "cp " staticlib " ${destdir}";
if ( list[i] ~ /lib[^ ]*\.a/ ) {
staticlib = gensub (/([^ ]*)(lib[^ ]*\.a)/,"\\1\\2 ","g",list[i]);
print "cp " staticlib " ${destdir}";
}
if ( list[i] ~ /lib[^ ]*\.so/ ) {
dynamiclib = gensub (/([^ ]*)(lib[^ ]*\.so)/,"\\1\\2 ","g",list[i]);
print "echo " dynamiclib " found";
}
if ( list[i] ~ /-l/ ) {
systemlib = gensub (/-l([^ ]*)/,"lib\\1.a ","g",list[i]);
print "systemlib=`find " libdir " -name " systemlib " 2> /dev/null `" ;
print "if [ \"${systemlib}\" != \"\" ]; then";
print " echo System lib found: ${systemlib}";
print " cp ${systemlib} ${destdir}";
print "else";
print " echo Library " systemlib " not found, shared library assumed";
print "fi";
}
if ( list[i] ~ /lib[^ ]*\.so/ ) {
dynamiclib = gensub (/([^ ]*)(lib[^ ]*\.so)/,"\\1\\2 ","g",list[i]);
print "echo " dynamiclib " found";
}
if ( list[i] ~ /-l/ ) {
systemlib = gensub (/-l([^ ]*)/,"lib\\1.a ","g",list[i]);
print "systemlib=`find " libdir " -name " systemlib "`" ;
print "if [ \"${systemlib}\" != \"\" ]; then";
print "echo System lib found: ${systemlib}";
print "cp ${systemlib} ${destdir}";
print "else";
print "echo Library " systemlib " not found, shared library assumed";
print "fi";
}
}
END {
nb = split (implibs,list);
for (i=1;i<=nb; i++) {
systemlib = "lib" list[i] ".a";
print "echo Adding system library " systemlib;
print "systemlib=`find " libdir " -name " systemlib " 2> /dev/null `" ;
print "if [ \"${systemlib}\" != \"\" ]; then";
print " echo System lib found: ${systemlib}";
print " cp ${systemlib} ${destdir}";
print "else";
print " echo Library " systemlib " not found, shared library assumed";
print "fi";
}
}
' | tee copy-libs.sh
@ -112,7 +149,8 @@ chmod u+x ./copy-libs.sh
echo Creating ./gdblib.inc file
# Generate gdblib.inc file
cat comp-cmd.log |gawk -v gdbcvs=${gdbcvs} -v destdir=${destdir} -v gdbversion=${gdbversion} '
cat comp-cmd.log |gawk -v gdbcvs=${gdbcvs} -v implibs="${implicitlibs}" \
-v gdbversion=${gdbversion} '
BEGIN {
use_mingw=0;
print "{ libgdb.inc file generated by awk script }"
@ -150,6 +188,10 @@ BEGIN {
}
}
END {
nb = split (implibs,list);
for (i=1;i<=nb; i++) {
print "{$LINKLIB " list[i] "} { implicit library } "
}
print "{$endif COMPILING_GDBINT_UNIT }"
print "{$undef NotImplemented}"
if ( use_mingw == 1 ) {