Compiling Kannel 1.4.3 on Solaris 10

By Alasdair Lumsden on 18 Sep 2009

Compiling kannel 143 on solaris 10

Kannel doesn’t appear to compile with Sun Studio, I couldn’t be bothered to work out why. It compiles with the default Solaris gcc 3.4.3, but fails with:

gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES= -I/usr/include/libxml2 -o wmlscript/wsstream_data.o -c wmlscript/wsstream_data.c
wmlscript/wslexer.c: In function `read_float_from_exp':
wmlscript/wslexer.c:1037: error: syntax error before '||' token
gmake-3.81: *** [wmlscript/wslexer.o] Error 1
gmake-3.81: *** Waiting for unfinished jobs....
No postbuild script
Error: build failed

The issue is that wmlscript/wslexer.c uses “HUGE_VAL”, which has a broken definition on Solaris (or at least gcc doesn’t like it).

The solution is to force it to use GCC’s built in HUGE_VAL definition, which you can do with the following patch:

--- wmlscript/wslexer.c.orig    2009-09-18 12:51:52.218499508 +0100
+++ wmlscript/wslexer.c 2009-09-18 12:54:09.811272795 +0100
@@ -1034,7 +1034,7 @@

     /* Check that the generated floating point number fits to
        `float32'. */
-    if (*result == HUGE_VAL || *result == -HUGE_VAL
+    if (*result == __builtin_huge_val() || *result == -__builtin_huge_val()
         || ws_ieee754_encode_single(*result, buf) != WS_IEEE754_OK)
         ws_src_error(compiler, 0, "floating point literal too large");

Happy compiling!