diff -burN -x CVS -x uisimulator -x 'build-*' -x tools -x manual rockbox-clean/apps/eq.c rockbox-fmath/apps/eq.c
--- rockbox-clean/apps/eq.c	2006-04-11 23:49:05.000000000 +1000
+++ rockbox-fmath/apps/eq.c	2006-08-09 20:36:15.000000000 +1000
@@ -19,6 +19,7 @@
 
 #include <inttypes.h>
 #include "config.h"
+#include "fmath/fmath.h"
 #include "eq.h"
 
 /* Coef calculation taken from Audio-EQ-Cookbook.txt by Robert Bristow-Johnson.
@@ -32,139 +33,7 @@
    implementations.
  */
 
-#define DIV64(x, y, z) (long)(((long long)(x) << (z))/(y))
-/* This macro requires the EMAC unit to be in fractional mode
-   when the coef generator routines are called. If this can't be guaranteeed,
-   then add "&& 0" below. This will use a slower coef calculation on Coldfire.
- */
-#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
-#define FRACMUL(x, y) \
-({ \
-    long t; \
-    asm volatile ("mac.l    %[a], %[b], %%acc0\n\t" \
-                  "movclr.l %%acc0, %[t]\n\t" \
-                  : [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
-    t; \
-})
-#else
-#define FRACMUL(x, y) ((long)(((((long long) (x)) * ((long long) (y))) >> 31)))
-#endif
-
-/* TODO: replaygain.c has some fixed point routines. perhaps we could reuse
-   them? */
-
-/* Inverse gain of circular cordic rotation in s0.31 format. */
-static const long cordic_circular_gain = 0xb2458939; /* 0.607252929 */
-
-/* Table of values of atan(2^-i) in 0.32 format fractions of pi where pi = 0xffffffff / 2 */
-static const unsigned long atan_table[] = {
-    0x1fffffff, /* +0.785398163 (or pi/4) */
-    0x12e4051d, /* +0.463647609 */
-    0x09fb385b, /* +0.244978663 */
-    0x051111d4, /* +0.124354995 */
-    0x028b0d43, /* +0.062418810 */
-    0x0145d7e1, /* +0.031239833 */
-    0x00a2f61e, /* +0.015623729 */
-    0x00517c55, /* +0.007812341 */
-    0x0028be53, /* +0.003906230 */
-    0x00145f2e, /* +0.001953123 */
-    0x000a2f98, /* +0.000976562 */
-    0x000517cc, /* +0.000488281 */
-    0x00028be6, /* +0.000244141 */
-    0x000145f3, /* +0.000122070 */
-    0x0000a2f9, /* +0.000061035 */
-    0x0000517c, /* +0.000030518 */
-    0x000028be, /* +0.000015259 */
-    0x0000145f, /* +0.000007629 */
-    0x00000a2f, /* +0.000003815 */
-    0x00000517, /* +0.000001907 */
-    0x0000028b, /* +0.000000954 */
-    0x00000145, /* +0.000000477 */
-    0x000000a2, /* +0.000000238 */
-    0x00000051, /* +0.000000119 */
-    0x00000028, /* +0.000000060 */
-    0x00000014, /* +0.000000030 */
-    0x0000000a, /* +0.000000015 */
-    0x00000005, /* +0.000000007 */
-    0x00000002, /* +0.000000004 */
-    0x00000001, /* +0.000000002 */
-    0x00000000, /* +0.000000001 */
-    0x00000000, /* +0.000000000 */
-};
-
-/**
- * Implements sin and cos using CORDIC rotation.
- *
- * @param phase has range from 0 to 0xffffffff, representing 0 and
- *        2*pi respectively.
- * @param cos return address for cos
- * @return sin of phase, value is a signed value from LONG_MIN to LONG_MAX,
- *         representing -1 and 1 respectively. 
- */
-long fsincos(unsigned long phase, long *cos) {
-    int32_t x, x1, y, y1;
-    unsigned long z, z1;
-    int i;
-
-    /* Setup initial vector */
-    x = cordic_circular_gain;
-    y = 0;
-    z = phase;
-
-    /* The phase has to be somewhere between 0..pi for this to work right */
-    if (z < 0xffffffff / 4) {
-        /* z in first quadrant, z += pi/2 to correct */
-        x = -x;
-        z += 0xffffffff / 4;
-    } else if (z < 3 * (0xffffffff / 4)) {
-        /* z in third quadrant, z -= pi/2 to correct */
-        z -= 0xffffffff / 4;
-    } else {
-        /* z in fourth quadrant, z -= 3pi/2 to correct */
-        x = -x;
-        z -= 3 * (0xffffffff / 4);
-    }
-
-    /* Each iteration adds roughly 1-bit of extra precision */
-    for (i = 0; i < 31; i++) {
-        x1 = x >> i;
-        y1 = y >> i;
-        z1 = atan_table[i];
-
-        /* Decided which direction to rotate vector. Pivot point is pi/2 */
-        if (z >= 0xffffffff / 4) {
-            x -= y1;
-            y += x1;
-            z -= z1;
-        } else {
-            x += y1;
-            y -= x1;
-            z += z1;
-        }
-    }
-
-    *cos = x;
-
-    return y;
-}
-
-/* Fixed point square root via Newton-Raphson.
- * Output is in same fixed point format as input. 
- * fracbits specifies number of fractional bits in argument.
- */
-static long fsqrt(long a, unsigned int fracbits)
-{
-    long b = a/2 + (1 << fracbits); /* initial approximation */
-    unsigned n;
-    const unsigned iterations = 4;
-    
-    for (n = 0; n < iterations; ++n)
-        b = (b + DIV64(a, b, fracbits))/2;
-
-    return b;
-}
-
-short dbtoatab[49] = {
+static const short dbtoatab[49] = {
     2058, 2180, 2309, 2446, 2591, 2744, 2907, 3079, 3261, 3455, 3659, 3876,
     4106, 4349, 4607, 4880, 5169, 5475, 5799, 6143, 6507, 6893, 7301, 7734,
     8192, 8677, 9192, 9736, 10313, 10924, 11572, 12257, 12983, 13753, 14568,
diff -burN -x CVS -x uisimulator -x 'build-*' -x tools -x manual rockbox-clean/apps/FILES rockbox-fmath/apps/FILES
--- rockbox-clean/apps/FILES	2006-04-06 10:01:56.000000000 +1000
+++ rockbox-fmath/apps/FILES	2006-08-09 19:49:19.000000000 +1000
@@ -81,3 +81,6 @@
 codecs/lib/*.[ch]
 codecs/lib/Makefile
 codecs/lib/SOURCES
+fmath/SOURCES
+fmath/*.[ch]
+fmath/Makefile
diff -burN -x CVS -x uisimulator -x 'build-*' -x tools -x manual rockbox-clean/apps/fmath/fmath.h rockbox-fmath/apps/fmath/fmath.h
--- rockbox-clean/apps/fmath/fmath.h	1970-01-01 10:00:00.000000000 +1000
+++ rockbox-fmath/apps/fmath/fmath.h	2006-08-09 20:34:04.000000000 +1000
@@ -0,0 +1,46 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2006 Dan Everton
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef _FMATH_H
+#define _FMATH_H
+
+#include "config.h"
+
+#define DIV64(x, y, z) (long)(((long long)(x) << (z))/(y))
+/* This macro requires the EMAC unit to be in fractional mode
+   when the coef generator routines are called. If this can't be guaranteeed,
+   then add "&& 0" below. This will use a slower coef calculation on Coldfire.
+ */
+#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
+#define FRACMUL(x, y) \
+({ \
+    long t; \
+    asm volatile ("mac.l    %[a], %[b], %%acc0\n\t" \
+                  "movclr.l %%acc0, %[t]\n\t" \
+                  : [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
+    t; \
+})
+#else
+#define FRACMUL(x, y) ((long)(((((long long) (x)) * ((long long) (y))) >> 31)))
+#endif
+
+long fsincos(unsigned long phase, long *cos);
+long fsqrt(long a, unsigned int fracbits);
+
+#endif
diff -burN -x CVS -x uisimulator -x 'build-*' -x tools -x manual rockbox-clean/apps/fmath/fsincos.c rockbox-fmath/apps/fmath/fsincos.c
--- rockbox-clean/apps/fmath/fsincos.c	1970-01-01 10:00:00.000000000 +1000
+++ rockbox-fmath/apps/fmath/fsincos.c	2006-08-09 20:36:30.000000000 +1000
@@ -0,0 +1,115 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2006 Dan Everton
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <inttypes.h>
+
+/* Inverse gain of circular cordic rotation in s0.31 format. */
+static const long cordic_circular_gain = 0xb2458939; /* 0.607252929 */
+
+/* Table of values of atan(2^-i) in 0.32 format fractions of pi where pi = 0xffffffff / 2 */
+static const unsigned long atan_table[] = {
+    0x1fffffff, /* +0.785398163 (or pi/4) */
+    0x12e4051d, /* +0.463647609 */
+    0x09fb385b, /* +0.244978663 */
+    0x051111d4, /* +0.124354995 */
+    0x028b0d43, /* +0.062418810 */
+    0x0145d7e1, /* +0.031239833 */
+    0x00a2f61e, /* +0.015623729 */
+    0x00517c55, /* +0.007812341 */
+    0x0028be53, /* +0.003906230 */
+    0x00145f2e, /* +0.001953123 */
+    0x000a2f98, /* +0.000976562 */
+    0x000517cc, /* +0.000488281 */
+    0x00028be6, /* +0.000244141 */
+    0x000145f3, /* +0.000122070 */
+    0x0000a2f9, /* +0.000061035 */
+    0x0000517c, /* +0.000030518 */
+    0x000028be, /* +0.000015259 */
+    0x0000145f, /* +0.000007629 */
+    0x00000a2f, /* +0.000003815 */
+    0x00000517, /* +0.000001907 */
+    0x0000028b, /* +0.000000954 */
+    0x00000145, /* +0.000000477 */
+    0x000000a2, /* +0.000000238 */
+    0x00000051, /* +0.000000119 */
+    0x00000028, /* +0.000000060 */
+    0x00000014, /* +0.000000030 */
+    0x0000000a, /* +0.000000015 */
+    0x00000005, /* +0.000000007 */
+    0x00000002, /* +0.000000004 */
+    0x00000001, /* +0.000000002 */
+    0x00000000, /* +0.000000001 */
+    0x00000000, /* +0.000000000 */
+};
+
+/**
+ * Implements sin and cos using CORDIC rotation.
+ *
+ * @param phase has range from 0 to 0xffffffff, representing 0 and
+ *        2*pi respectively.
+ * @param cos return address for cos
+ * @return sin of phase, value is a signed value from LONG_MIN to LONG_MAX,
+ *         representing -1 and 1 respectively. 
+ */
+long fsincos(unsigned long phase, long *cos) {
+    int32_t x, x1, y, y1;
+    unsigned long z, z1;
+    int i;
+
+    /* Setup initial vector */
+    x = cordic_circular_gain;
+    y = 0;
+    z = phase;
+
+    /* The phase has to be somewhere between 0..pi for this to work right */
+    if (z < 0xffffffff / 4) {
+        /* z in first quadrant, z += pi/2 to correct */
+        x = -x;
+        z += 0xffffffff / 4;
+    } else if (z < 3 * (0xffffffff / 4)) {
+        /* z in third quadrant, z -= pi/2 to correct */
+        z -= 0xffffffff / 4;
+    } else {
+        /* z in fourth quadrant, z -= 3pi/2 to correct */
+        x = -x;
+        z -= 3 * (0xffffffff / 4);
+    }
+
+    /* Each iteration adds roughly 1-bit of extra precision */
+    for (i = 0; i < 31; i++) {
+        x1 = x >> i;
+        y1 = y >> i;
+        z1 = atan_table[i];
+
+        /* Decided which direction to rotate vector. Pivot point is pi/2 */
+        if (z >= 0xffffffff / 4) {
+            x -= y1;
+            y += x1;
+            z -= z1;
+        } else {
+            x += y1;
+            y -= x1;
+            z += z1;
+        }
+    }
+
+    *cos = x;
+
+    return y;
+}
diff -burN -x CVS -x uisimulator -x 'build-*' -x tools -x manual rockbox-clean/apps/fmath/fsqrt.c rockbox-fmath/apps/fmath/fsqrt.c
--- rockbox-clean/apps/fmath/fsqrt.c	1970-01-01 10:00:00.000000000 +1000
+++ rockbox-fmath/apps/fmath/fsqrt.c	2006-08-09 20:40:06.000000000 +1000
@@ -0,0 +1,37 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2006 Thom Johansen
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "fmath.h"
+
+/**
+ * Fixed point square root via Newton-Raphson.
+ * Output is in same fixed point format as input. 
+ * fracbits specifies number of fractional bits in argument.
+ */
+long fsqrt(long a, unsigned int fracbits)
+{
+    long b = a/2 + (1 << fracbits); /* initial approximation */
+    unsigned n;
+    const unsigned iterations = 4;
+    
+    for (n = 0; n < iterations; ++n)
+        b = (b + DIV64(a, b, fracbits))/2;
+
+    return b;
+}
diff -burN -x CVS -x uisimulator -x 'build-*' -x tools -x manual rockbox-clean/apps/fmath/Makefile rockbox-fmath/apps/fmath/Makefile
--- rockbox-clean/apps/fmath/Makefile	1970-01-01 10:00:00.000000000 +1000
+++ rockbox-fmath/apps/fmath/Makefile	2006-08-09 19:45:26.000000000 +1000
@@ -0,0 +1,49 @@
+#             __________               __   ___.
+#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+#                     \/            \/     \/    \/            \/
+# $Id$
+#
+
+# . for stuff in the fmath dir
+INCLUDES=-I$(APPSDIR) -I. $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export	\
+ -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(BUILDDIR)
+
+ifdef APPEXTRA
+   INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
+endif
+
+CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(EXTRA_DEFINES) \
+ -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE}
+
+# Sectioned compilation for target
+ifndef SIMVER
+	CFLAGS += -ffunction-sections -fdata-sections
+endif
+
+# This sets up 'SRC' based on the files mentioned in SOURCES
+include $(TOOLSDIR)/makesrc.inc
+
+SOURCES = $(SRC)
+OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
+DEPFILE = $(OBJDIR)/dep-fmathlib
+DIRS = .
+
+OUTPUT = $(BUILDDIR)/libfmath.a
+
+all: $(OUTPUT)
+
+$(OUTPUT): $(OBJS)
+	@echo "AR+RANLIB $@"
+	@$(AR) ruv $@ $+ >/dev/null 2>&1
+	@$(RANLIB) $@
+
+include $(TOOLSDIR)/make.inc
+
+clean:
+	@echo "cleaning lib"
+	@rm -f $(OBJS) $(OUTPUT) $(DEPFILE)
+
+-include $(DEPFILE)
diff -burN -x CVS -x uisimulator -x 'build-*' -x tools -x manual rockbox-clean/apps/fmath/SOURCES rockbox-fmath/apps/fmath/SOURCES
--- rockbox-clean/apps/fmath/SOURCES	1970-01-01 10:00:00.000000000 +1000
+++ rockbox-fmath/apps/fmath/SOURCES	2006-08-09 20:38:13.000000000 +1000
@@ -0,0 +1,2 @@
+fsincos.c
+fsqrt.c
diff -burN -x CVS -x uisimulator -x 'build-*' -x tools -x manual rockbox-clean/apps/Makefile rockbox-fmath/apps/Makefile
--- rockbox-clean/apps/Makefile	2006-07-27 23:27:17.000000000 +1000
+++ rockbox-fmath/apps/Makefile	2006-08-09 20:18:56.000000000 +1000
@@ -116,15 +116,15 @@
 	@cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
 	@rm $(MAXINFILE)
 
-$(OBJDIR)/rombox.elf : $(OBJS) $(LINKROM) $(DEPFILE) $(LIBROCKBOX) $(BITMAPLIBS)
+$(OBJDIR)/rombox.elf : $(OBJS) $(LINKROM) $(DEPFILE) $(LIBROCKBOX) $(BITMAPLIBS) $(BUILDDIR)/libfmath.a
 	@echo "LD rombox.elf"
-	@$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -lrockbox -lgcc $(LINKBITMAPS) -L$(BUILDDIR)/firmware -T$(LINKROM) -Wl,-Map,$(OBJDIR)/rombox.map
+	@$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -lrockbox -lgcc $(LINKBITMAPS) -lfmath -L$(BUILDDIR)/firmware -T$(LINKROM) -Wl,-Map,$(OBJDIR)/rombox.map
 
 ifndef SIMVER
 
-$(OBJDIR)/rockbox.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(BITMAPLIBS)
+$(OBJDIR)/rockbox.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(BITMAPLIBS) $(BUILDDIR)/libfmath.a
 	@echo "LD rockbox.elf"
-	@$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS)  -L$(BUILDDIR)/firmware -L$(BUILDDIR) -lrockbox $(LINKBITMAPS) -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/rockbox.map
+	@$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS)  -L$(BUILDDIR)/firmware -L$(BUILDDIR) -lrockbox $(LINKBITMAPS) -lfmath -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/rockbox.map
 
 $(OBJDIR)/rockbox.bin : $(OBJDIR)/rockbox.elf
 	@echo "OBJCOPY "`basename $@`
@@ -166,9 +166,9 @@
 
 
 $(BUILDDIR)/$(BINARY) : $(OBJS) $(DEPFILE) $(BUILDDIR)/libsim.a \
-	$(BUILDDIR)/libcomsim.a $(LIBROCKBOX) $(BITMAPLIBS)
+	$(BUILDDIR)/libcomsim.a $(LIBROCKBOX) $(BITMAPLIBS) $(BUILDDIR)/libfmath.a
 	@echo "LD $(BINARY)"
-	$(SILENT)$(CC) $(GCCOPTS) -o $@ $(OBJS) -L$(BUILDDIR) -lrockbox -lsim -lcomsim $(LINKBITMAPS) $(LDOPTS) $(EXTRAOBJ) -Wl,-Map,$(OBJDIR)/rockbox.map
+	$(SILENT)$(CC) $(GCCOPTS) -o $@ $(OBJS) -L$(BUILDDIR) -lrockbox -lsim -lcomsim -lfmath $(LINKBITMAPS) $(LDOPTS) $(EXTRAOBJ) -Wl,-Map,$(OBJDIR)/rockbox.map
 
 endif
 
@@ -194,6 +194,11 @@
 	@echo "CC lang.c"
 	@$(CC) $(CFLAGS) -c $(BUILDDIR)/lang.c -o $@
 
+$(BUILDDIR)/libfmath.a:
+	@echo "MAKE in fmath"
+	$(SILENT)mkdir -p $(OBJDIR)/fmath
+	$(SILENT)$(MAKE) -C fmath OBJDIR=$(OBJDIR)/fmath
+
 clean:
 	@echo "cleaning apps"
 	@-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/rockbox.asm	     \
@@ -206,6 +211,7 @@
 	@$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
 	@$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
 	@$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
+	@$(MAKE) -C fmath clean OBJDIR=$(OBJDIR)/fmath
 	@$(MAKE) -C plugins clean OBJDIR=$(OBJDIR)/plugins
 	@$(MAKE) -C codecs clean OBJDIR=$(OBJDIR)/codecs
 	@rm -rf $(OBJDIR)/recorder $(OBJDIR)/player
diff -burN -x CVS -x uisimulator -x 'build-*' -x tools -x manual rockbox-clean/apps/plugins/Makefile rockbox-fmath/apps/plugins/Makefile
--- rockbox-clean/apps/plugins/Makefile	2006-07-27 23:27:19.000000000 +1000
+++ rockbox-fmath/apps/plugins/Makefile	2006-08-09 20:23:14.000000000 +1000
@@ -83,7 +83,7 @@
 ifndef SIMVER
 $(OBJDIR)/%.elf: $(OBJDIR)/%.o $(LINKFILE) $(BUILDDIR)/libplugin.a $(BITMAPLIBS)
 	@echo "LD $(notdir $@)"
-	$(SILENT)$(CC) $(GCCOPTS) -O -nostdlib -o $@ $< -L$(BUILDDIR) $(CODECLIBS) -lplugin $(LINKBITMAPS) -lgcc -T$(LINKFILE) -Wl,--gc-sections -Wl,-Map,$(OBJDIR)/$*.map
+	$(SILENT)$(CC) $(GCCOPTS) -O -nostdlib -o $@ $< -L$(BUILDDIR) $(CODECLIBS) -lplugin $(LINKBITMAPS) -lfmath -lgcc -T$(LINKFILE) -Wl,--gc-sections -Wl,-Map,$(OBJDIR)/$*.map
 
 $(OBJDIR)/%.rock : $(OBJDIR)/%.elf
 	@echo "OBJCOPY "`basename $@`
@@ -96,7 +96,7 @@
 
 $(OBJDIR)/%.rock : $(OBJDIR)/%.o  $(BUILDDIR)/libplugin.a $(BITMAPLIBS)
 	@echo "LD "`basename $@`
-	$(SILENT)$(CC) $(CFLAGS) -shared $< -L$(BUILDDIR)  $(CODECLIBS) -lplugin $(LINKBITMAPS) -o $@
+	$(SILENT)$(CC) $(CFLAGS) -shared $< -L$(BUILDDIR)  $(CODECLIBS) -lplugin $(LINKBITMAPS) -lfmath -o $@
 ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
 # 'x' must be kept or you'll have "Win32 error 5"
 #     $ fgrep 5 /usr/include/w32api/winerror.h | head -1
@@ -112,7 +112,7 @@
 
 $(OBJDIR)/%.rock : $(OBJDIR)/%.o  $(BUILDDIR)/libplugin.a $(BITMAPLIBS)
 	@echo "LD "`basename $@`
-	$(SILENT)$(CC) $(CFLAGS) -shared $< -L$(BUILDDIR)  $(CODECLIBS) -lplugin $(LINKBITMAPS) -o $@
+	$(SILENT)$(CC) $(CFLAGS) -shared $< -L$(BUILDDIR)  $(CODECLIBS) -lplugin $(LINKBITMAPS) -lfmath -o $@
 ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
 # 'x' must be kept or you'll have "Win32 error 5"
 #     $ fgrep 5 /usr/include/w32api/winerror.h | head -1
@@ -130,7 +130,7 @@
 $(OBJDIR)/%.rock : $(OBJDIR)/%.o  $(BUILDDIR)/libplugin.a $(BITMAPLIBS)
 	@echo "DLL "`basename $@`
 	$(SILENT)$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $<
-	$(SILENT)$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $< $(BUILDDIR)/libplugin.a $(BITMAPLIBS) \
+	$(SILENT)$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $< $(BUILDDIR)/libplugin.a $(BITMAPLIBS) -lfmath \
                 $(patsubst -l%,$(BUILDDIR)/lib%.a,$(CODECLIBS)) -o $@
 ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN)
 # 'x' must be kept or you'll have "Win32 error 5"
