Sfoglia il codice sorgente

Merge branch 'symbol-generating' into next

* symbol-generating:
  * Check for valid sed at configure
  * Delete tmpfile when bailing out
  * Place -I in INCLUDES var
  * Use gsed if available
Bryan Drewery 14 anni fa
parent
commit
fdc8dee6ca
3 ha cambiato i file con 83 aggiunte e 7 eliminazioni
  1. 2 1
      autotools/configure.ac
  2. 71 1
      configure
  3. 10 5
      src/generate_defs.sh

+ 2 - 1
autotools/configure.ac

@@ -38,6 +38,7 @@ AC_CACHE_SAVE
 
 # Checks for programs
 AC_PROG_MAKE_SET
+AC_PROG_SED
 EGG_PROG_HEAD_1
 EGG_PROG_AWK
 EGG_PROG_BASENAME
@@ -277,7 +278,7 @@ if [ "$GIT_REQUIRED" = "1" ]; then
 fi
 ]
 
-CXX="$CXX" TCLINC="$TCLINC" SSL_INCLUDES="$SSL_INCLUDES" src/generate_defs.sh
+CXX="$CXX" TCLINC="$TCLINC" SSL_INCLUDES="$SSL_INCLUDES" SED="$SED" src/generate_defs.sh
 [
 if [ $? -ne 0 ]; then
   exit 1

+ 71 - 1
configure

@@ -633,6 +633,7 @@ OBJCOPY
 BASENAME
 AWK
 HEAD_1
+SED
 SET_MAKE
 GCC4DEB
 GCC3DEB
@@ -3789,6 +3790,75 @@ $as_echo "no" >&6; }
   SET_MAKE="MAKE=${MAKE-make}"
 fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if ${ac_cv_path_SED+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+     for ac_i in 1 2 3 4 5 6 7; do
+       ac_script="$ac_script$as_nl$ac_script"
+     done
+     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+     { ac_script=; unset ac_script;}
+     if test -z "$SED"; then
+  ac_path_SED_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
+# Check for GNU ac_path_SED and select it if it is found.
+  # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo '' >> "conftest.nl"
+    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_SED_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_SED="$ac_path_SED"
+      ac_path_SED_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_SED_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_SED"; then
+    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+  fi
+else
+  ac_cv_path_SED=$SED
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+$as_echo "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+  rm -f conftest.sed
+
 
 cat << 'EOF' > conftest.head
 a
@@ -9804,7 +9874,7 @@ if [ "$GIT_REQUIRED" = "1" ]; then
 fi
 
 
-CXX="$CXX" TCLINC="$TCLINC" SSL_INCLUDES="$SSL_INCLUDES" src/generate_defs.sh
+CXX="$CXX" TCLINC="$TCLINC" SSL_INCLUDES="$SSL_INCLUDES" SED="$SED" src/generate_defs.sh
 
 if [ $? -ne 0 ]; then
   exit 1

+ 10 - 5
src/generate_defs.sh

@@ -1,7 +1,11 @@
 #! /bin/bash
 
+if [ -z "$SED" -o -z "$CXX" ]; then
+  echo "This must be ran by configure" >&2
+  exit 1
+fi
 echo "Generating lib symbols"
-INCLUDES="${TCLINC} ${SSL_INCLUDES}"
+INCLUDES="-I${TCLINC} ${SSL_INCLUDES}"
 
 mkdir -p src/.defs > /dev/null 2>&1
 TMPFILE=$(mktemp "/tmp/pre.XXXXXX")
@@ -23,12 +27,12 @@ for file in $(grep -l DLSYM_GLOBAL src/*.c|grep -v "src/_"); do
   echo "extern \"C\" {" > $defsFile_post
   touch $defsFile_pre
   pushd src >/dev/null 2>&1
-  $CXX -E -I. -I.. -I../lib -I${INCLUDES} -DHAVE_CONFIG_H ../${file} > $TMPFILE
+  $CXX -E -I. -I.. -I../lib ${INCLUDES} -DHAVE_CONFIG_H ../${file} > $TMPFILE
   # Fix wrapped prototypes
-  sed -i -e ':a;N;$!ba;s/,\n/,/g' $TMPFILE
+  $SED -i -e ':a;N;$!ba;s/,\n/,/g' $TMPFILE
   popd >/dev/null 2>&1
 
-  for symbol in $(sed -n -e 's/.*DLSYM_GLOBAL(.*, \([^)]*\).*/\1/p' $file|sort -u); do
+  for symbol in $($SED -n -e 's/.*DLSYM_GLOBAL(.*, \([^)]*\).*/\1/p' $file|sort -u); do
     echo "#define ${symbol} ORIGINAL_SYMBOL_${symbol}" >> $defsFile_pre
     echo "#undef ${symbol}" >> $defsFile_post
     # Check if the typedef is already defined ...
@@ -36,13 +40,14 @@ for file in $(grep -l DLSYM_GLOBAL src/*.c|grep -v "src/_"); do
     # ... if not, generate it
     if [ -z "$typedef" ]; then
       # Trim off any extern "C", trim out the variable names, cleanup whitespace issues
-      typedef=$(sed -n -e "/\<${symbol}\>/p" $TMPFILE | head -n 1 | sed -e 's/extern "C" *//' -e "s/\(.*\) *${symbol} *(\(.*\));/typedef \1 (*${symbol}_t)(\2);/" -e 's/[_0-9A-Za-z]*\(,\)/\1/g' -e 's/[_0-9A-Za-z]*\();\)/\1/g' -e 's/  */ /g' -e 's/ \([,)]\)/\1/g' -e 's/ *()/(void)/g')
+      typedef=$($SED -n -e "/\<${symbol}\>/p" $TMPFILE | head -n 1 | $SED -e 's/extern "C" *//' -e "s/\(.*\) *${symbol} *(\(.*\));/typedef \1 (*${symbol}_t)(\2);/" -e 's/[_0-9A-Za-z]*\(,\)/\1/g' -e 's/[_0-9A-Za-z]*\();\)/\1/g' -e 's/  */ /g' -e 's/ \([,)]\)/\1/g' -e 's/ *()/(void)/g')
       echo "$typedef" >> $defsFile_post
     fi
 
     if [ "${typedef%;}" = "${typedef}" ]; then
       echo "Error: Unable to generate typedef for: ${symbol}" >&2
       echo "$typedef"
+      rm -rf $TMPFILE
       exit 1
     fi