Subject: pkg/35413: goffice 0.2.2 fails to build on darwin due to math.h conflict
To: None <,,>
From: None <>
List: pkgsrc-bugs
Date: 01/12/2007 19:25:00
>Number:         35413
>Category:       pkg
>Synopsis:       goffice 0.2.2 fails to build on darwin due to math.h conflict
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 12 19:25:00 +0000 2007
>Originator:     Jussi Liukkonen
>Release:        none
Headache, Inc
Darwin 8.8.0 Darwin Kernel Version 8.8.0: Fri Sep  8 17:18:57 PDT 2006; root:xnu-792.12.6.obj~1/RELEASE_PPC Power Macintosh powerpc

goffice from pkgsrc-2006Q4 build fails on darwin (macosx 10.4.8 ppc) with error "static declaration follows a non-static one" regarding function fmin() in plugins/plot_radar/gog-radar.c. 

C99 defines fmin() in <math.h>, and the overlapping definition in gog-radar.c is in error in a C99 compliant build system.

The issue was discussed in #gnumeric at at 10 Jan 2007, where the authors said having eliminated all use of fmin() in gnumeric and goffice in the later (1.7/0.3 development branch) releases. goffice 0.3.5 + gnumeric 1.7.5 do indeed build and work without any patches via pkgsrc (verified in macosx 10.4.8 ppc and netbsd 3.1_STABLE i386). The proposed patch makes also the stable branch (0.2/1.6) build and work on darwin (although the __APPLE__ check is technically incorrect, as fmin() is c99 and not specific to Apple).
cd misc/goffice; bmake

--- plugins/plot_radar/gog-radar.c.orig 2007-01-12 21:17:33.000000000 +0200
+++ plugins/plot_radar/gog-radar.c      2007-01-12 21:17:50.000000000 +0200
@@ -386,11 +386,13 @@
 typedef GogPlotView            GogRTView;
 typedef GogPlotViewClass       GogRTViewClass;
+#ifndef __APPLE__
 static double
 fmin (double a, double b)
        return (a < b) ? a : b;
 static void
 gog_rt_view_render (GogView *view, GogViewAllocation const *bbox)