[Debburn-devel] [PATCH] Building on FreeBSD

Lorenz Minder lminder at gmx.net
Sat Sep 23 14:16:56 UTC 2006


Hi,

As I said yesterday, I'm trying to build cdrkit on FreeBSD.  I'm now at
a point where I can get the executables built.  I have not come to the
point to check whether wodim actually correctly burns CDR.  I did some
quick testing with mkisofs however, and I can mount the images it
creates.

There are two patches attached:

(1) fixes to libschily. Correctly build replacement ecvt, fcvt, gcvt,
__dtoa and strtod if they are not there. I have moved the various
prototype declarations to a common file, cvt.h.

Before that change it would complain that ecvt is defined twice in
libschily.a:

Linking C executable cdda2wav
../libschily/libschily.a(fconv.o)(.text+0xf58): In function `strtod':
: multiple definition of `strtod'
../libschily/libschily.a(cvt.o)(.text+0xf58): first defined here
../libschily/libschily.a(fconv.o)(.text+0x219c): In function `__dtoa':
: multiple definition of `__dtoa'
../libschily/libschily.a(cvt.o)(.text+0x219c): first defined here
../libschily/libschily.a(fconv.o)(.text+0x33e0): In function `ecvt':
: multiple definition of `ecvt'
../libschily/libschily.a(cvt.o)(.text+0x33e0): first defined here
../libschily/libschily.a(fconv.o)(.text+0x3498): In function `fcvt':
: multiple definition of `fcvt'
../libschily/libschily.a(cvt.o)(.text+0x3498): first defined here
../libschily/libschily.a(fconv.o)(.text+0x3560): In function `gcvt':
: multiple definition of `gcvt'
../libschily/libschily.a(cvt.o)(.text+0x3560): first defined here
*** Error code 1

That is the case because "cvt.c" was #included in fconv.c, but was
"cvt.o" was linked in seperately as well.  An alternative would thus
be to not link in cvt.o and leave the code as is. (I think though, that
we should move away from #including .c files in other .c files.)

(2) Fixes to makeisofs, so it also builds without iconv.  Previously it
would complain about incompatible prototypes for joliet_strlen().


BTW, it still does not work out of the box for me. For example, after
running cmake I have to patch xconfig.h, because it has HAVE_ECVT and
friends defined, although they are clearly not available on this system.
(?!) Here's the relevant excerpt from FreeBSD's /usr/include/stdlib.h

/*
 * The only changes to the XSI namespace in revision 6 were the deletion
 * of the ttyslot() and valloc() functions, which FreeBSD never declared
 * in this header.  For revision 7, ecvt(), fcvt(), and gcvt(), which
 * FreeBSD also does not have, and mktemp(), are to be deleted.
 */
// ...
/* char	*ecvt(double, int, int * __restrict, int * __restrict); */
// ...
/* char	*fcvt(double, int, int * __restrict, int * __restrict); */
/* char	*gcvt(double, int, int * __restrict, int * __restrict); */

Note that ecvt, fcvt and gcvt are commented out. This is FreeBSD 6, btw.

Also, I still need some help with the USE_ICONV issue. Besides the fact
that cmake looks in the wrong directories to see if it is there, I'm
unclear of how I could cause it to not use it, even if it were
available.  Anyway, it seems that probably no-one has tempted to build
either cdrutils or cdrkit without USE_ICONV in a long time, since it
currently causes the build to fail without my attached patch.  (To work
around this, I just patched the CMakeList.txt files on my local box to
not look for iconv.)

I tried to double-check that my changes cause no breakage on Debian, but
unfortunately, I can't get it to build on sarge either, because cmake
complains. I suspect the cmake version in sarge is too old. Let me know
if you need more details.

Best,
--Lorenz
-------------- next part --------------
Index: libschily/fconv.c
===================================================================
--- libschily/fconv.c	(revision 329)
+++ libschily/fconv.c	(working copy)
@@ -40,10 +40,7 @@
 #include <strdefs.h>
 #include <schily.h>
 
-#if	!defined(HAVE_STDLIB_H) || defined(HAVE_DTOA)
-extern	char	*ecvt __PR((double, int, int *, int *));
-extern	char	*fcvt __PR((double, int, int *, int *));
-#endif
+#include "cvt.h"
 
 #if	defined(HAVE_ISNAN) && defined(HAVE_ISINF)
 /*
@@ -109,10 +106,6 @@
 #define	isinf(val)	(0)
 #endif
 
-#if !defined(HAVE_ECVT) || !defined(HAVE_FCVT) || !defined(HAVE_GCVT)
-#include "cvt.c"
-#endif
-
 static	char	_js_nan[] = "(NaN)";
 static	char	_js_inf[] = "(Infinity)";
 
@@ -125,7 +118,7 @@
 
 EXPORT int
 ftoes(s, val, fieldwidth, ndigits)
-	register	char 	*s;
+	register	char	*s;
 			double	val;
 	register	int	fieldwidth;
 	register	int	ndigits;
@@ -134,7 +127,7 @@
 	register	char	*rs;
 	register	int	len;
 	register	int	rdecpt;
-			int 	decpt;
+			int	decpt;
 			int	sign;
 
 	if ((len = _ferr(s, val)) > 0)
Index: libschily/cvt.c
===================================================================
--- libschily/cvt.c	(revision 329)
+++ libschily/cvt.c	(working copy)
@@ -41,15 +41,9 @@
 #include <utypes.h>
 #include <standard.h>
 
-#ifdef	HAVE_DTOA	/* 4.4BSD floating point implementation */
-#ifdef	HAVE_DTOA_R
-extern	char *__dtoa	__PR((double value, int mode, int ndigit, int *decpt, int *sign, char **ep, char **resultp));
-#else
-extern	char *__dtoa	__PR((double value, int mode, int ndigit, int *decpt, int *sign, char **ep));
-#endif
-#else
+#include "cvt.h"
 
-#if	!defined(HAVE_ECVT)
+#ifndef	HAVE_DTOA	/* 4.4BSD floating point implementation */
 /*
  * As a hint from Thomas Langer <Langer.Thomas at gmx.net>, we use strtod.c in
  * hope that we then will be able to print floating point numbers on all
@@ -66,23 +60,10 @@
  * If at least ecvt() is present, we don't need __dtoa() from strtod.c
  */
 #include "strtod.c"
-#define	HAVE_DTOA
-#endif	/* !defined(HAVE_ECVT) */
+//#define	HAVE_DTOA
+#endif	/* !defined(HAVE_DTOA) */
 
-#endif	/* HAVE_DTOA */
-
-#ifndef	HAVE_ECVT
-EXPORT	char *ecvt	__PR((double value, int ndigit, int *decpt, int *sign));
-#endif
-#ifndef	HAVE_FCVT
-EXPORT	char *fcvt	__PR((double value, int ndigit, int *decpt, int *sign));
-#endif
-#ifndef	HAVE_GCVT
-EXPORT	char *gcvt	__PR((double value, int ndigit, char *buf));
-#endif
-
-#if	!defined(HAVE_ECVT) && defined(HAVE_DTOA)
-#define	HAVE_ECVT
+#if !defined(HAVE_ECVT)
 char *
 ecvt(value, ndigit, decpt, sign)
 	double	value;
@@ -139,8 +120,7 @@
 }
 #endif
 
-#if	!defined(HAVE_FCVT) && defined(HAVE_DTOA)
-#define	HAVE_FCVT
+#if !defined(HAVE_FCVT)
 char *
 fcvt(value, ndigit, decpt, sign)
 	double	value;
@@ -199,7 +179,6 @@
 #endif
 
 #ifndef	HAVE_GCVT
-#define	HAVE_GCVT
 char *
 gcvt(number, ndigit, buf)
 	double	number;
Index: libschily/strtod.c
===================================================================
--- libschily/strtod.c	(revision 329)
+++ libschily/strtod.c	(working copy)
@@ -400,12 +400,6 @@
 
 #define Kmax 15
 
-#ifdef __cplusplus
-extern "C" double strtod(const char *s00, char **se);
-extern "C" char *__dtoa(double d, int mode, int ndigits,
-			int *decpt, int *sign, char **rve);
-#endif
-
  struct
 Bigint {
 	struct Bigint *next;
@@ -1787,7 +1781,7 @@
 	if (se)
 		*se = (char *)s;
 	return sign ? -rv : rv;
-	}
+}
 
  static int
 quorem
@@ -1893,7 +1887,7 @@
 			}
 		}
 	return q;
-	}
+}
 
 /* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
  *
Index: libschily/format.c
===================================================================
--- libschily/format.c	(revision 329)
+++ libschily/format.c	(working copy)
@@ -42,13 +42,13 @@
 #ifdef	DEBUG
 #include <unixstd.h>
 #endif
-#if	!defined(HAVE_STDLIB_H) || !defined(HAVE_GCVT)
-extern	char	*gcvt __PR((double, int, char *));
-#endif
+
 #include <standard.h>
 #include <utypes.h>
 #include <schily.h>
 
+#include "cvt.h"
+
 /*
  * As Llong is currently a 'best effort' long long, we usually need to
  * include long long print formats.
--- /dev/null	Sat Sep 23 15:15:47 2006
+++ libschily/cvt.h	Sat Sep 23 15:12:44 2006
@@ -0,0 +1,51 @@
+/*
+	cvt
+
+	Numeric conversion routines. libshily provides replacements for
+	ecvt, fcvt, gcvt, __dtoa and strtod if those are not available
+	in the standard C library.  #include "cvt.h" to use them.
+
+	This file is part of the cdrkit suite.
+
+	(C) 2006, the cdrkit project. License: GPL.
+
+ */
+
+#ifndef CVT_H
+#define CVT_H
+
+#include <stdlib.h>
+
+#include "prototyp.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef HAVE_ECVT
+char	*ecvt __PR((double, int, int *, int *));
+#endif
+#ifndef HAVE_FCVT
+char	*fcvt __PR((double, int, int *, int *));
+#endif
+#ifndef	HAVE_GCVT
+char	*gcvt __PR((double value, int ndigit, char *buf));
+#endif
+
+#ifdef	HAVE_DTOA	/* 4.4BSD floating point implementation */
+#ifdef	HAVE_DTOA_R
+char *__dtoa __PR((double value, int mode, int ndigit, int *decpt,
+				int *sign, char **ep, char **resultp));
+#else
+char *__dtoa __PR((double value, int mode, int ndigit, int *decpt, int *sign,
+							char **ep));
+#endif
+#endif
+
+double strtod(const char *s00, char **se);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CVT_H */
-------------- next part --------------
Index: mkisofs/mkisofs.h
===================================================================
--- mkisofs/mkisofs.h	(revision 329)
+++ mkisofs/mkisofs.h	(working copy)
@@ -548,12 +548,11 @@
 #   ifdef USE_ICONV
 extern	size_t	convert_to_unicode	__PR((unsigned char *buffer,
 			int size, char *source, struct unls_table *inls));
-extern	int	joliet_strlen		__PR((const char *string, struct unls_table *inls));
 #   else
 extern	void	convert_to_unicode	__PR((unsigned char *buffer,
 			int size, char *source, struct unls_table *inls));
-extern	int	joliet_strlen		__PR((const char *string));
 #   endif
+extern	int	joliet_strlen		__PR((const char *string, struct unls_table *inls));
 #endif
 extern unsigned char conv_charset __PR((unsigned char, struct unls_table *,
 				struct unls_table *));


More information about the Debburn-devel mailing list