[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH]std=c89 not supported

From: <leif.eriksen_at_hpa.com.au>
Date: 2003-07-03 06:48:43 CEST

OK, I have tested this on a Linux RH7 box that has a gcc that does NOT
support -std=c89, and it all works OK, plus I have tested this on a Solaris
2.8 box that does support -std=c89, and it works all OK too. Additionally I
have tested it with --enable-maintainer-mode and without, and all OK.
 
Basically I added one more m4 script to build/ac-macros, called
check-gcc-opt.m4. This defines one function svn_lib_check_gcc_option(), that
takes one possible CFLAG option and tries to compile an empty main() with
it. If it compiles and runs OK, then the option is considered valid.
 
Additionally, in configure.in, I call that function to see if std=c89 should
be appended to the CFLAGS parameter.
 
All fairly simple.
 
I am new to m4 programming (if it can be called that, kind of like calling
snow-boarding skiing), so I am not aware of how much other 'protection' I
need to wrap this implementation up in.
 
Leif Eriksen
Developer
HPA - IT Development
+61 3 9217 5545
leif.eriksen@hpa.com.au <mailto:leif.eriksen@hpa.com.au>
 
<snip>
 
Log:
Added subversion/build/ac-macros/check-gcc-opt.m4, containing one function
SVN_LIB_CHECK_GCC_OPTION. This checks whether the option is supported by the
GCC compiler on the target platform.
Added call to SVN_LIB_CHECK_GCC_OPTION in subversion/configure.in, to see if
std=c89 should be added to CFLAGS.
 
Index: subversion-0.24.2/configure.in
===================================================================
--- subversion-0.24.2/configure.in Thu Jun 19 02:35:41 2003
+++ subversion-0.24.2/configure.in.leif Thu Jul 3 13:27:43 2003
@@ -51,6 +51,7 @@
 
 dnl Grab our own macros
 sinclude(build/ac-macros/berkeley-db.m4)
+sinclude(build/ac-macros/check-gcc-opt.m4)
 sinclude(build/ac-macros/svn-apache.m4)
 sinclude(build/ac-macros/svn-macros.m4)
 sinclude(build/ac-macros/neon.m4)
@@ -378,6 +379,7 @@
 ])
 AC_SUBST(MOD_ACTIVATION)
 
+AC_MSG_NOTICE([Setting CFLAGS])
 
 AC_ARG_ENABLE(maintainer-mode,
 AC_HELP_STRING([--enable-maintainer-mode],
@@ -391,12 +393,20 @@
       if test "$GCC" = "yes"; then
         dnl SVN_DEBUG enables specific features for developer builds
         dnl AP_DEBUG enables specific (Apache) features for developer
builds
- CFLAGS="$CFLAGS -std=c89 -Wpointer-arith -Wwrite-strings -Wshadow
-DSVN_DEBUG -DAP_DEBUG";
+
+ CFLAGS="$CFLAGS -Wpointer-arith -Wwrite-strings -Wshadow -DSVN_DEBUG
-DAP_DEBUG";
+
+ dnl Check the compiler options
+ SVN_LIB_CHECK_GCC_OPTION(["-std=c89"])
+
+ if test "$svn_lib_check_option" = "yes" ; then
+ CFLAGS="$CFLAGS -std=c89"
+ fi
+ AC_MSG_NOTICE([CFLAGS is $CFLAGS])
       fi
     fi
 ])
 
-
 if test "$enable_debugging" = "yes" ; then
   dnl At the moment, we don't want optimization, because we're
   dnl debugging.

Index: subversion-0.24.2/build/ac-macros/check-gcc-opt.m4
===================================================================
dnl SVN_LIB_CHECK_GCC_OPTION(option)
dnl
dnl Compile a little C program with the passed in option
dnl and see if it was successfully compiled.
 
AC_DEFUN(SVN_LIB_CHECK_GCC_OPTION,
[
  option=$1
 
  svn_lib_check_gcc_option_save_flags="$CFLAGS"
 
  CFLAGS="$CFLAGS $option"
 
    AC_TRY_RUN(
      [
#include <stdlib.h>
main ()
{
    exit (0);
}
      ],
      [svn_lib_check_option=yes],
      [svn_lib_check_option=no],
      [svn_lib_check_option=yes]
    )
  CFLAGS="$svn_lib_check_gcc_option_save_flags"
]
)
 
---------------------------------------------------------------------

**********************************************************************
IMPORTANT
The contents of this e-mail and its attachments are confidential and intended
solely for the use of the individual or entity to whom they are
addressed. If you received this e-mail in error, please notify
the HPA Postmaster, postmaster@hpa.com.au, then delete
the e-mail.

This footnote also confirms that this e-mail message has been swept for
the presence of computer viruses by MimeSweeper. Before opening or
using any attachments, check them for viruses and defects.

Our liability is limited to resupplying any affected attachments.

HPA collects personal information to provide and market our services.
For more information about use, disclosure and access see our Privacy
Policy at www.hpa.com.au
**********************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jul 3 06:50:26 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.