fixes compiler flags

Wed, 31 May 2017 12:51:24 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 31 May 2017 12:51:24 +0200
changeset 51
5acf05940667
parent 50
63477d92411d
child 52
02816cd75edc

fixes compiler flags

config.h.in file | annotate | diff | comparison | revisions
configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
src/Makefile.am file | annotate | diff | comparison | revisions
src/Makefile.in file | annotate | diff | comparison | revisions
     1.1 --- a/config.h.in	Wed May 31 12:32:22 2017 +0200
     1.2 +++ b/config.h.in	Wed May 31 12:51:24 2017 +0200
     1.3 @@ -1,5 +1,8 @@
     1.4  /* config.h.in.  Generated from configure.ac by autoheader.  */
     1.5  
     1.6 +/* Define to 1 if you have the <dirent.h> header file. */
     1.7 +#undef HAVE_DIRENT_H
     1.8 +
     1.9  /* Define to 1 if you have the <inttypes.h> header file. */
    1.10  #undef HAVE_INTTYPES_H
    1.11  
    1.12 @@ -20,6 +23,9 @@
    1.13  /* Define to 1 if you have the `regcomp' function. */
    1.14  #undef HAVE_REGCOMP
    1.15  
    1.16 +/* Define to 1 if you have the <regex.h> header file. */
    1.17 +#undef HAVE_REGEX_H
    1.18 +
    1.19  /* Define to 1 if you have the <stdint.h> header file. */
    1.20  #undef HAVE_STDINT_H
    1.21  
     2.1 --- a/configure	Wed May 31 12:32:22 2017 +0200
     2.2 +++ b/configure	Wed May 31 12:51:24 2017 +0200
     2.3 @@ -1345,7 +1345,7 @@
     2.4    --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
     2.5    --enable-silent-rules   less verbose build output (undo: "make V=1")
     2.6    --disable-silent-rules  verbose build output (undo: "make V=0")
     2.7 -  --enable-debug    Turn on debugging
     2.8 +  --enable-debug          Turn on debugging
     2.9    --enable-dependency-tracking
    2.10                            do not reject slow dependency extractors
    2.11    --disable-dependency-tracking
    2.12 @@ -2789,7 +2789,8 @@
    2.13  fi
    2.14  
    2.15  
    2.16 -# Checks for programs.
    2.17 +# Compiler (empty default options)
    2.18 +${CFLAGS=""}
    2.19  ac_ext=c
    2.20  ac_cpp='$CPP $CPPFLAGS'
    2.21  ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
    2.22 @@ -3770,8 +3771,298 @@
    2.23  fi
    2.24  
    2.25  
    2.26 -
    2.27 -# Checks for libraries.
    2.28 +   case $ac_cv_prog_cc_stdc in #(
    2.29 +  no) :
    2.30 +    ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no ;; #(
    2.31 +  *) :
    2.32 +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
    2.33 +$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
    2.34 +if ${ac_cv_prog_cc_c99+:} false; then :
    2.35 +  $as_echo_n "(cached) " >&6
    2.36 +else
    2.37 +  ac_cv_prog_cc_c99=no
    2.38 +ac_save_CC=$CC
    2.39 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    2.40 +/* end confdefs.h.  */
    2.41 +#include <stdarg.h>
    2.42 +#include <stdbool.h>
    2.43 +#include <stdlib.h>
    2.44 +#include <wchar.h>
    2.45 +#include <stdio.h>
    2.46 +
    2.47 +// Check varargs macros.  These examples are taken from C99 6.10.3.5.
    2.48 +#define debug(...) fprintf (stderr, __VA_ARGS__)
    2.49 +#define showlist(...) puts (#__VA_ARGS__)
    2.50 +#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
    2.51 +static void
    2.52 +test_varargs_macros (void)
    2.53 +{
    2.54 +  int x = 1234;
    2.55 +  int y = 5678;
    2.56 +  debug ("Flag");
    2.57 +  debug ("X = %d\n", x);
    2.58 +  showlist (The first, second, and third items.);
    2.59 +  report (x>y, "x is %d but y is %d", x, y);
    2.60 +}
    2.61 +
    2.62 +// Check long long types.
    2.63 +#define BIG64 18446744073709551615ull
    2.64 +#define BIG32 4294967295ul
    2.65 +#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
    2.66 +#if !BIG_OK
    2.67 +  your preprocessor is broken;
    2.68 +#endif
    2.69 +#if BIG_OK
    2.70 +#else
    2.71 +  your preprocessor is broken;
    2.72 +#endif
    2.73 +static long long int bignum = -9223372036854775807LL;
    2.74 +static unsigned long long int ubignum = BIG64;
    2.75 +
    2.76 +struct incomplete_array
    2.77 +{
    2.78 +  int datasize;
    2.79 +  double data[];
    2.80 +};
    2.81 +
    2.82 +struct named_init {
    2.83 +  int number;
    2.84 +  const wchar_t *name;
    2.85 +  double average;
    2.86 +};
    2.87 +
    2.88 +typedef const char *ccp;
    2.89 +
    2.90 +static inline int
    2.91 +test_restrict (ccp restrict text)
    2.92 +{
    2.93 +  // See if C++-style comments work.
    2.94 +  // Iterate through items via the restricted pointer.
    2.95 +  // Also check for declarations in for loops.
    2.96 +  for (unsigned int i = 0; *(text+i) != '\0'; ++i)
    2.97 +    continue;
    2.98 +  return 0;
    2.99 +}
   2.100 +
   2.101 +// Check varargs and va_copy.
   2.102 +static void
   2.103 +test_varargs (const char *format, ...)
   2.104 +{
   2.105 +  va_list args;
   2.106 +  va_start (args, format);
   2.107 +  va_list args_copy;
   2.108 +  va_copy (args_copy, args);
   2.109 +
   2.110 +  const char *str;
   2.111 +  int number;
   2.112 +  float fnumber;
   2.113 +
   2.114 +  while (*format)
   2.115 +    {
   2.116 +      switch (*format++)
   2.117 +	{
   2.118 +	case 's': // string
   2.119 +	  str = va_arg (args_copy, const char *);
   2.120 +	  break;
   2.121 +	case 'd': // int
   2.122 +	  number = va_arg (args_copy, int);
   2.123 +	  break;
   2.124 +	case 'f': // float
   2.125 +	  fnumber = va_arg (args_copy, double);
   2.126 +	  break;
   2.127 +	default:
   2.128 +	  break;
   2.129 +	}
   2.130 +    }
   2.131 +  va_end (args_copy);
   2.132 +  va_end (args);
   2.133 +}
   2.134 +
   2.135 +int
   2.136 +main ()
   2.137 +{
   2.138 +
   2.139 +  // Check bool.
   2.140 +  _Bool success = false;
   2.141 +
   2.142 +  // Check restrict.
   2.143 +  if (test_restrict ("String literal") == 0)
   2.144 +    success = true;
   2.145 +  char *restrict newvar = "Another string";
   2.146 +
   2.147 +  // Check varargs.
   2.148 +  test_varargs ("s, d' f .", "string", 65, 34.234);
   2.149 +  test_varargs_macros ();
   2.150 +
   2.151 +  // Check flexible array members.
   2.152 +  struct incomplete_array *ia =
   2.153 +    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
   2.154 +  ia->datasize = 10;
   2.155 +  for (int i = 0; i < ia->datasize; ++i)
   2.156 +    ia->data[i] = i * 1.234;
   2.157 +
   2.158 +  // Check named initializers.
   2.159 +  struct named_init ni = {
   2.160 +    .number = 34,
   2.161 +    .name = L"Test wide string",
   2.162 +    .average = 543.34343,
   2.163 +  };
   2.164 +
   2.165 +  ni.number = 58;
   2.166 +
   2.167 +  int dynamic_array[ni.number];
   2.168 +  dynamic_array[ni.number - 1] = 543;
   2.169 +
   2.170 +  // work around unused variable warnings
   2.171 +  return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
   2.172 +	  || dynamic_array[ni.number - 1] != 543);
   2.173 +
   2.174 +  ;
   2.175 +  return 0;
   2.176 +}
   2.177 +_ACEOF
   2.178 +for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99
   2.179 +do
   2.180 +  CC="$ac_save_CC $ac_arg"
   2.181 +  if ac_fn_c_try_compile "$LINENO"; then :
   2.182 +  ac_cv_prog_cc_c99=$ac_arg
   2.183 +fi
   2.184 +rm -f core conftest.err conftest.$ac_objext
   2.185 +  test "x$ac_cv_prog_cc_c99" != "xno" && break
   2.186 +done
   2.187 +rm -f conftest.$ac_ext
   2.188 +CC=$ac_save_CC
   2.189 +
   2.190 +fi
   2.191 +# AC_CACHE_VAL
   2.192 +case "x$ac_cv_prog_cc_c99" in
   2.193 +  x)
   2.194 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
   2.195 +$as_echo "none needed" >&6; } ;;
   2.196 +  xno)
   2.197 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
   2.198 +$as_echo "unsupported" >&6; } ;;
   2.199 +  *)
   2.200 +    CC="$CC $ac_cv_prog_cc_c99"
   2.201 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
   2.202 +$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
   2.203 +esac
   2.204 +if test "x$ac_cv_prog_cc_c99" != xno; then :
   2.205 +  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
   2.206 +else
   2.207 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
   2.208 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
   2.209 +if ${ac_cv_prog_cc_c89+:} false; then :
   2.210 +  $as_echo_n "(cached) " >&6
   2.211 +else
   2.212 +  ac_cv_prog_cc_c89=no
   2.213 +ac_save_CC=$CC
   2.214 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   2.215 +/* end confdefs.h.  */
   2.216 +#include <stdarg.h>
   2.217 +#include <stdio.h>
   2.218 +struct stat;
   2.219 +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
   2.220 +struct buf { int x; };
   2.221 +FILE * (*rcsopen) (struct buf *, struct stat *, int);
   2.222 +static char *e (p, i)
   2.223 +     char **p;
   2.224 +     int i;
   2.225 +{
   2.226 +  return p[i];
   2.227 +}
   2.228 +static char *f (char * (*g) (char **, int), char **p, ...)
   2.229 +{
   2.230 +  char *s;
   2.231 +  va_list v;
   2.232 +  va_start (v,p);
   2.233 +  s = g (p, va_arg (v,int));
   2.234 +  va_end (v);
   2.235 +  return s;
   2.236 +}
   2.237 +
   2.238 +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
   2.239 +   function prototypes and stuff, but not '\xHH' hex character constants.
   2.240 +   These don't provoke an error unfortunately, instead are silently treated
   2.241 +   as 'x'.  The following induces an error, until -std is added to get
   2.242 +   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
   2.243 +   array size at least.  It's necessary to write '\x00'==0 to get something
   2.244 +   that's true only with -std.  */
   2.245 +int osf4_cc_array ['\x00' == 0 ? 1 : -1];
   2.246 +
   2.247 +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
   2.248 +   inside strings and character constants.  */
   2.249 +#define FOO(x) 'x'
   2.250 +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
   2.251 +
   2.252 +int test (int i, double x);
   2.253 +struct s1 {int (*f) (int a);};
   2.254 +struct s2 {int (*f) (double a);};
   2.255 +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
   2.256 +int argc;
   2.257 +char **argv;
   2.258 +int
   2.259 +main ()
   2.260 +{
   2.261 +return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
   2.262 +  ;
   2.263 +  return 0;
   2.264 +}
   2.265 +_ACEOF
   2.266 +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
   2.267 +	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
   2.268 +do
   2.269 +  CC="$ac_save_CC $ac_arg"
   2.270 +  if ac_fn_c_try_compile "$LINENO"; then :
   2.271 +  ac_cv_prog_cc_c89=$ac_arg
   2.272 +fi
   2.273 +rm -f core conftest.err conftest.$ac_objext
   2.274 +  test "x$ac_cv_prog_cc_c89" != "xno" && break
   2.275 +done
   2.276 +rm -f conftest.$ac_ext
   2.277 +CC=$ac_save_CC
   2.278 +
   2.279 +fi
   2.280 +# AC_CACHE_VAL
   2.281 +case "x$ac_cv_prog_cc_c89" in
   2.282 +  x)
   2.283 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
   2.284 +$as_echo "none needed" >&6; } ;;
   2.285 +  xno)
   2.286 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
   2.287 +$as_echo "unsupported" >&6; } ;;
   2.288 +  *)
   2.289 +    CC="$CC $ac_cv_prog_cc_c89"
   2.290 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
   2.291 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
   2.292 +esac
   2.293 +if test "x$ac_cv_prog_cc_c89" != xno; then :
   2.294 +  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
   2.295 +else
   2.296 +  ac_cv_prog_cc_stdc=no
   2.297 +fi
   2.298 +
   2.299 +fi
   2.300 + ;;
   2.301 +esac
   2.302 +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO Standard C" >&5
   2.303 +$as_echo_n "checking for $CC option to accept ISO Standard C... " >&6; }
   2.304 +  if ${ac_cv_prog_cc_stdc+:} false; then :
   2.305 +  $as_echo_n "(cached) " >&6
   2.306 +fi
   2.307 +
   2.308 +  case $ac_cv_prog_cc_stdc in #(
   2.309 +  no) :
   2.310 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
   2.311 +$as_echo "unsupported" >&6; } ;; #(
   2.312 +  '') :
   2.313 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
   2.314 +$as_echo "none needed" >&6; } ;; #(
   2.315 +  *) :
   2.316 +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_stdc" >&5
   2.317 +$as_echo "$ac_cv_prog_cc_stdc" >&6; } ;;
   2.318 +esac
   2.319 +
   2.320  
   2.321  # Checks for header files.
   2.322  
   2.323 @@ -4172,7 +4463,7 @@
   2.324  done
   2.325  
   2.326  
   2.327 -for ac_header in stdlib.h string.h
   2.328 +for ac_header in stdlib.h string.h dirent.h regex.h
   2.329  do :
   2.330    as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
   2.331  ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
     3.1 --- a/configure.ac	Wed May 31 12:32:22 2017 +0200
     3.2 +++ b/configure.ac	Wed May 31 12:51:24 2017 +0200
     3.3 @@ -29,7 +29,7 @@
     3.4  
     3.5  # Conditionals
     3.6  AC_ARG_ENABLE([debug],
     3.7 -[  --enable-debug    Turn on debugging],
     3.8 +[  --enable-debug          Turn on debugging],
     3.9  [case "${enableval}" in
    3.10    yes) debug=true ;;
    3.11    no)  debug=false ;;
    3.12 @@ -37,13 +37,13 @@
    3.13  esac],[debug=false])
    3.14  AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
    3.15  
    3.16 -# Checks for programs.
    3.17 +# Compiler (empty default options)
    3.18 +${CFLAGS=""}
    3.19  AC_PROG_CC
    3.20 -
    3.21 -# Checks for libraries.
    3.22 +AC_PROG_CC_STDC
    3.23  
    3.24  # Checks for header files.
    3.25 -AC_CHECK_HEADERS([stdlib.h string.h])
    3.26 +AC_CHECK_HEADERS([stdlib.h string.h dirent.h regex.h])
    3.27  
    3.28  # Checks for typedefs, structures, and compiler characteristics.
    3.29  AC_CHECK_HEADER_STDBOOL
     4.1 --- a/src/Makefile.am	Wed May 31 12:32:22 2017 +0200
     4.2 +++ b/src/Makefile.am	Wed May 31 12:51:24 2017 +0200
     4.3 @@ -22,9 +22,9 @@
     4.4  # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     4.5  
     4.6  if DEBUG
     4.7 -AM_CFLAGS = -std=gnu99 -O0 -Wall
     4.8 +AM_CFLAGS = -g -O0 -Wall
     4.9  else
    4.10 -AM_CFLAGS = -std=gnu99 -O2
    4.11 +AM_CFLAGS = -O2
    4.12  endif
    4.13  
    4.14  bin_PROGRAMS = cline
     5.1 --- a/src/Makefile.in	Wed May 31 12:32:22 2017 +0200
     5.2 +++ b/src/Makefile.in	Wed May 31 12:51:24 2017 +0200
     5.3 @@ -260,8 +260,8 @@
     5.4  top_build_prefix = @top_build_prefix@
     5.5  top_builddir = @top_builddir@
     5.6  top_srcdir = @top_srcdir@
     5.7 -@DEBUG_FALSE@AM_CFLAGS = -std=gnu99 -O2
     5.8 -@DEBUG_TRUE@AM_CFLAGS = -std=gnu99 -O0 -Wall
     5.9 +@DEBUG_FALSE@AM_CFLAGS = -O2
    5.10 +@DEBUG_TRUE@AM_CFLAGS = -g -O0 -Wall
    5.11  cline_SOURCES = arguments.c bfile_heuristics.c cline.c regex_parser.c \
    5.12  		scanner.c settings.c string_list.c suffix_fnc.c
    5.13  

mercurial