diff -urN potrace-1.8/Makefile.in potrace-1.8-haiku/Makefile.in
--- potrace-1.8/Makefile.in	2007-04-09 00:28:49.063963136 +0000
+++ potrace-1.8-haiku/Makefile.in	2010-09-22 14:37:46.670564352 +0000
@@ -101,6 +101,7 @@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LIBM = @LIBM@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
 MKBITMAP = @MKBITMAP@
diff -urN potrace-1.8/configure.in potrace-1.8-haiku/configure.in
--- potrace-1.8/configure.in	2007-04-09 00:27:12.063700992 +0000
+++ potrace-1.8-haiku/configure.in	2010-09-22 13:58:47.000000000 +0000
@@ -135,7 +135,8 @@
   ])
 fi
 
-AC_CHECK_LIB(m, floor, true, AC_MSG_ERROR([cannot find the m library (-lm)]))
+AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+AC_CHECK_LIB(m, floor, LIBM="$LIBM -lm")
 
 dnl ----------------------------------------------------------------------
 dnl Check for library functions.
diff -urN potrace-1.8/src/Makefile.am potrace-1.8-haiku/src/Makefile.am
--- potrace-1.8/src/Makefile.am	2007-04-09 00:36:44.066060288 +0000
+++ potrace-1.8-haiku/src/Makefile.am	2010-09-22 14:51:36.089653248 +0000
@@ -16,16 +16,16 @@
  backend_gimp.c backend_gimp.h backend_xfig.c backend_xfig.h		   \
  backend_pdf.c backend_pdf.h lzw.c lzw.h bitops.h auxiliary.h potracelib.h \
  bitmap.h curve.h platform.h progress.h
-potrace_LDADD = libpotrace.a @EXTRA_OBJS@ -lm @EXTRA_LIBS@
+potrace_LDADD = libpotrace.a @EXTRA_OBJS@ $(LIBM) @EXTRA_LIBS@
 potrace_DEPENDENCIES = libpotrace.a @EXTRA_OBJS@
 
 mkbitmap_SOURCES = mkbitmap.c bitmap_io.c bitmap_io.h greymap.c	\
  greymap.h platform.h
-mkbitmap_LDADD = @EXTRA_OBJS@ -lm
+mkbitmap_LDADD = @EXTRA_OBJS@ $(LIBM)
 mkbitmap_DEPENDENCIES = @EXTRA_OBJS@
 
 potracelib_demo_SOURCES = potracelib_demo.c
-potracelib_demo_LDADD = libpotrace.a -lm
+potracelib_demo_LDADD = libpotrace.a $(LIBM)
 potracelib_demo_DEPENDENCIES = libpotrace.a
 
 #----------------------------------------------------------------------
diff -urN potrace-1.8/src/Makefile.in potrace-1.8-haiku/src/Makefile.in
--- potrace-1.8/src/Makefile.in	2007-04-09 00:37:31.066322432 +0000
+++ potrace-1.8-haiku/src/Makefile.in	2010-09-22 14:34:20.208666624 +0000
@@ -117,6 +117,7 @@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LIBM = @LIBM@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
 MKBITMAP = @MKBITMAP@
@@ -172,15 +173,15 @@
  backend_pdf.c backend_pdf.h lzw.c lzw.h bitops.h auxiliary.h potracelib.h \
  bitmap.h curve.h platform.h progress.h
 
-potrace_LDADD = libpotrace.a @EXTRA_OBJS@ -lm @EXTRA_LIBS@
+potrace_LDADD = libpotrace.a @EXTRA_OBJS@ $(LIBM) @EXTRA_LIBS@
 potrace_DEPENDENCIES = libpotrace.a @EXTRA_OBJS@
 mkbitmap_SOURCES = mkbitmap.c bitmap_io.c bitmap_io.h greymap.c	\
  greymap.h platform.h
 
-mkbitmap_LDADD = @EXTRA_OBJS@ -lm
+mkbitmap_LDADD = @EXTRA_OBJS@ $(LIBM)
 mkbitmap_DEPENDENCIES = @EXTRA_OBJS@
 potracelib_demo_SOURCES = potracelib_demo.c
-potracelib_demo_LDADD = libpotrace.a -lm
+potracelib_demo_LDADD = libpotrace.a $(LIBM)
 potracelib_demo_DEPENDENCIES = libpotrace.a
 
 #----------------------------------------------------------------------
