On 16 Jun 2000, Akim Demaille wrote:

> >>>>> "Mo" == Mo DeJong <[EMAIL PROTECTED]> writes:
> 
> Mo> That might not be a bad idea. I don't like to depend on od just to
> Mo> get the size of a file. Am I just missing something? Is there an
> Mo> easy way to figure out the size of a binary file in bytes?
> 
> Autoconf 2.13 says:
> 
>   ac_lines=`grep -c . conftest.vals`
>   # grep -c gives empty output for an empty file on some AIX systems.
>   if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
> 
> so I guess this means you can rely on grep -c.  But really, don't fear
> using wc -c, just write your test in such a way that it is pessimistic
> is wc fails.
> 
>         Akim


I like that wc -c a lot better, we can just do this. Of course
this depends on the output format of wc, is it going to
be the same everywhere? We just need the first word
to be the size.


for ac_cv_prog_cc_g_smaller in `wc -c conftest_smaller.o` ; do
  break
done


Mo DeJong
Red Hat Inc


Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.34
diff -u -r1.34 aclang.m4
--- aclang.m4   2000/06/09 11:14:05     1.34
+++ aclang.m4   2000/06/16 18:18:04
@@ -604,10 +609,34 @@
 
 # _AC_PROG_CC_G
 # ------------
+# There is no dependable way to check to see if a compiler
+# supports a given flag. In the case of the -g flag, we can
+# test to see if -g adds debug info the the object file by
+# seeing if the produced object file get bigger when the
+# -g option is passed in to the compiler.
 define([_AC_PROG_CC_G],
 [AC_CACHE_CHECK(whether ${CC-cc} accepts -g, ac_cv_prog_cc_g,
 [echo 'void f(){}' >conftest.c
-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+# First, make sure an object file is generated
+AC_TRY_COMMAND(${CC-cc} -c conftest.c)
+if test ! -s conftest.${ac_objext} ; then
+    AC_MSG_ERROR([Compiler did not produce an object file with -c flag])
+fi
+mv conftest.${ac_objext} conftest_smaller.${ac_objext}
+# Run the compiler with the -g flag
+AC_TRY_COMMAND(${CC-cc} -c -g conftest.c)
+mv conftest.${ac_objext} conftest_bigger.${ac_objext}
+# Now figure out how big each file is
+for ac_cv_prog_cc_g_smaller in `wc -c conftest_smaller.o` ; do
+  break
+done
+for ac_cv_prog_cc_g_bigger in `wc -c conftest_bigger.o` ; do
+  break
+done
+dnl echo "ac_cv_prog_cc_g_smaller = $ac_cv_prog_cc_g_smaller" >&AC_FD_LOG
+dnl echo "ac_cv_prog_cc_g_bigger = $ac_cv_prog_cc_g_bigger" >&AC_FD_LOG
+# If the object file generated with -g is bigger, then -g works
+if test "${ac_cv_prog_cc_g_bigger}0" -gt "${ac_cv_prog_cc_g_smaller}0" ; 
then
   ac_cv_prog_cc_g=yes
 else
   ac_cv_prog_cc_g=no

Reply via email to