From ed7e9f8be56844e1f1294badef960d21eb5e01f7 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 30 Sep 2009 18:28:55 -0700 Subject: [PATCH] Check if the compiler supports C99 and better check for some math functions. Add a configuration check that says we would like to use C99 if the compiler supports it. Also change the lround(), nan(), fmin() and fmax() checks to look in the default libraries as well as the math library. Update the iverilog-vpi sh script to correctly quote CC since it may now have two words (gcc -std=gnu99). Add a missing int for main in draw_tt.c. --- configure.in | 11 ++++++++++- iverilog-vpi.sh | 2 +- vvp/draw_tt.c | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index 44536cb05..04c70c207 100644 --- a/configure.in +++ b/configure.in @@ -11,6 +11,7 @@ AC_CONFIG_HEADER(tgt-vhdl/vhdl_config.h) AC_CANONICAL_HOST dnl Checks for programs. AC_PROG_CC +AC_PROG_CC_C99 AC_PROG_CXX AC_PROG_RANLIB AC_CHECK_TOOL(STRIP, strip, true) @@ -156,7 +157,15 @@ AC_SUBST(file64_support) # Check that these functions exist. They are mostly C99 # functions that older compilers may not yet support. -AC_CHECK_FUNCS(lround nan fmin fmax fopen64) +AC_CHECK_FUNCS(fopen64) +# The following math functions may be defined in the math library so look +# in the default libraries first and then look in -lm for them. On some +# systems we may need to use the compiler in C99 mode to get a definition. +# We requested C99 mode earlier with AC_PROG_CC_C99. +AC_SEARCH_LIBS([lround], [m], [AC_DEFINE([HAVE_LROUND], [1])]) +AC_SEARCH_LIBS([nan], [m], [AC_DEFINE([HAVE_NAN], [1])]) +AC_SEARCH_LIBS([fmin], [m], [AC_DEFINE([HAVE_FMIN], [1])]) +AC_SEARCH_LIBS([fmax], [m], [AC_DEFINE([HAVE_FMAX], [1])]) # Linker option used when compiling the target AX_LD_RDYNAMIC diff --git a/iverilog-vpi.sh b/iverilog-vpi.sh index 29c9a880c..d2cdfb440 100644 --- a/iverilog-vpi.sh +++ b/iverilog-vpi.sh @@ -19,7 +19,7 @@ # # These are the variables used for compiling files -CC=@IVCC@ +CC="@IVCC@" CXX=@IVCXX@ CFLAGS="@PIC@ @IVCFLAGS@ -I@INCLUDEDIR@" diff --git a/vvp/draw_tt.c b/vvp/draw_tt.c index 85e3b6237..1a0491652 100644 --- a/vvp/draw_tt.c +++ b/vvp/draw_tt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -117,7 +117,7 @@ static void draw_oct_table() printf("};\n"); } -main() +int main() { draw_hex_table(); draw_oct_table();