Browse Source

+ Use MAKE and AWK variables to try to find GNU make and GNU awk
if available.
+ Add dexplicit building rule for libgdb.a
This library is not generated automatically anymore after 7.4 release.
+ Only handle '-l' if it is at start of argument.

git-svn-id: trunk@20168 -

pierre 13 years ago
parent
commit
b3c246e9f6
1 changed files with 26 additions and 10 deletions
  1. 26 10
      packages/gdbint/gen-gdblib-inc.sh

+ 26 - 10
packages/gdbint/gen-gdblib-inc.sh

@@ -15,6 +15,19 @@ usage ()
   echo "implicitlibs=\"space separated list if system librairies used\""
 }
 
+# Try to find GNU make and GNU awk
+MAKE=`which gmake 2> /dev/null`
+AWK=`which gawk 2> /dev/null`
+# Assume make is OK if gmake is not found
+if [ "${MAKE}" == "" ]; then
+  MAKE=make
+fi
+# Assume awk is OK if gawk is not found
+if [ "${AWK}" == "" ]; then
+  AWK=awk
+fi
+# Possible extra option to pass when rebuilding gdb executable below
+MAKEOPT=
 
 if [ "$1" == "--help" ]; then
   usage
@@ -24,6 +37,7 @@ fi
 if [ "$1" == "--forcestatic" ]; then
   echo "Using only static libraries in gdblib.inc"
   forcestatic=1
+  MAKEOPT="LDFLAGS=-static"
   shift
 else
   forcestatic=0
@@ -60,14 +74,16 @@ fi
 echo "Deleting gdb${EXEEXT} to force recompile"
 rm -f gdb${EXEEXT}
 echo "Rebuilding gdb${EXEEXT}"
-MAKE=`which gmake 2> /dev/null`
 
-if [ "${MAKE}" == "" ]; then
-  MAKE=make
-fi
+${MAKE} gdb${EXEEXT} ${MAKEOPT} | tee make.log
 
-${MAKE} gdb${EXEEXT} | tee make.log
+# libgdb.a will not be built automatically anymore after
+# GDB release 7.4, so we need to explicitly make it.
+echo "Rebuilding GDB library if needed"
+${MAKE} libgdb.a ${MAKEOPT}
 
+# version.c is an automatically generated file from gdb/version.in
+# We extract GDB version from that file.
 gdb_full_version=`sed -n "s:.*version.*\"\(.*\)\".*:\1:p" version.c`
 gdbcvs=`sed -n "s:.*version.*\"\(.*\)cvs\(.*\)\".*:\1cvs\2:p" version.c`
 gdb_version1=`sed -n "s:.*version.*\"\([0-9]*\)\.\([0-9]*\).*:\1:p" version.c`
@@ -82,7 +98,7 @@ else
   gdbversion=${gdb_version1}${gdb_version2}
 fi
 
-cat make.log | gawk '
+cat make.log | ${AWK} '
 BEGIN {
 doprint=0
 }
@@ -105,7 +121,7 @@ if [ "$gcccompiler" != "" ]; then
   if [ "$gcclibs" != "" ]; then
     if [ $in_msys -eq 1 ]; then
       # If we are on msys, gcc is mingw, so that it uses c:/dir
-      # while find is an msys utility that needs /c/dir path 
+      # while find is an msys utility that needs /c/dir path
       # we do this conversion below
       for let in a b c d e f g h i j k l m n o p q r s t u v w x y z; do
         gcclibs=${gcclibs//$let:/\/$let}
@@ -132,7 +148,7 @@ fi
 
 # Try to locate all libraries
 echo Creating ./copy-libs.sh script
-cat comp-cmd.log | gawk -v libdir="${libdir}" -v implibs="${implicitlibs}" '
+cat comp-cmd.log | ${AWK} -v libdir="${libdir}" -v implibs="${implicitlibs}" '
 BEGIN {
   print "#!/usr/bin/env bash"
   print "# copy-libs.sh generated by awk script"
@@ -166,7 +182,7 @@ BEGIN {
       dynamiclib = gensub (/([^ ]*)(lib[^ ]*\.so)/,"\\1\\2 ","g",list[i]);
       print "echo " dynamiclib " found";
     }
-    if ( list[i] ~ /-l/ ) {
+    if ( list[i] ~ /^-l/ ) {
       print "#Looking for shared libs"
       systemlib = gensub (/-l([^ ]*)/,"lib\\1.a ","g",list[i]);
       print "systemlib=`find " libdir " -name " systemlib " -print -quit 2> /dev/null `" ;
@@ -199,7 +215,7 @@ chmod u+x ./copy-libs.sh
 
 echo Creating ./gdblib.inc file
 # Generate gdblib.inc file
-cat comp-cmd.log |gawk -v gdbcvs=${gdbcvs} -v implibs="${implicitlibs}" \
+cat comp-cmd.log |${AWK} -v gdbcvs=${gdbcvs} -v implibs="${implicitlibs}" \
   -v gdbversion=${gdbversion} -v forcestatic=${forcestatic} '
 BEGIN {
   use_mingw=0;