Discussion:
[bug-gnu-utils] sharutils-4.14 compilation issue
(too old to reply)
Nelson H. F. Beebe
2014-04-25 14:30:38 UTC
Permalink
On several platforms, compilation of sharutils-4.14 fails like this:

/usr/local/bin/gcc-4.5 -std=c99 \
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I.. \
-I../libopts -I. -I.. -I../lib -I../lib -I../intl -D_REENTRANT \
-I/usr/local/include -Wno-format-contains-nul -g -O2 \
-Wno-format-contains-nul -MT scribble.o -MD -MP -MF .deps/scribble.Tpo \
-c -o scribble.o scribble.c
In file included from ../lib/stdlib.h:96:0,
from scribble.c:3:
../lib/unistd.h:121:3: error: #error "Please include config.h first."
../lib/unistd.h:553:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'extern'
In file included from scribble.c:3:0:
../lib/stdlib.h:607:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'extern'

The 4.13.x versions of sharutils did not have that problem.

The above build problem for 4.14 appears on at least these systems:

DragonflyBSD 3.2 x86-64
FreeBSD 9.1 x86
Mac OS X (PowerPC & x86-64)
MirBSD 10 x86
NetBSD 5.0.2 x86
OpenBSD 4.9 x86
OpenBSD 5.1 x86
SGI IRIX 6 MIPS
Solaris 10 (SPARC, x86, x86-64)
Solaris 11 (x86-64)

-------------------------------------------------------------------------------
- Nelson H. F. Beebe Tel: +1 801 581 5254 -
- University of Utah FAX: +1 801 581 4148 -
- Department of Mathematics, 110 LCB Internet e-mail: ***@math.utah.edu -
- 155 S 1400 E RM 233 ***@acm.org ***@computer.org -
- Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------
Eric Blake
2014-04-25 14:36:53 UTC
Permalink
Post by Nelson H. F. Beebe
/usr/local/bin/gcc-4.5 -std=c99 \
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I.. \
-I../libopts -I. -I.. -I../lib -I../lib -I../intl -D_REENTRANT \
-I/usr/local/include -Wno-format-contains-nul -g -O2 \
-Wno-format-contains-nul -MT scribble.o -MD -MP -MF .deps/scribble.Tpo \
-c -o scribble.o scribble.c
In file included from ../lib/stdlib.h:96:0,
../lib/unistd.h:121:3: error: #error "Please include config.h first."
Here's the patch I had to apply to package sharutils for cygwin:

--- origsrc/sharutils-4.14/src/scribble.c 2013-05-19 08:49:05.000000000
-0600
+++ src/sharutils-4.14/src/scribble.c 2014-04-16 09:08:54.492563800 -0600
@@ -1,4 +1,4 @@
-
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include "scribble.h"
--- origsrc/sharutils-4.14/src/shar.c 2013-10-12 16:18:28.000000000 -0600
+++ src/sharutils-4.14/src/shar.c 2014-04-16 09:03:17.826856400 -0600
@@ -1107,7 +1107,7 @@ emit_char_ct_validation (
sprintf (command, cct_cmd, quoted_name);

{
- FILE * pfp = popen (command, "r");
+ FILE * pfp = popen (command, "rb");
if (pfp == NULL)
die (SHAR_EXIT_FAILED, _("Could not popen command"), command);
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Eric Blake
2014-04-25 18:43:27 UTC
Permalink
Post by Eric Blake
--- origsrc/sharutils-4.14/src/scribble.c 2013-05-19 08:49:05.000000000
-0600
+++ src/sharutils-4.14/src/scribble.c 2014-04-16 09:08:54.492563800 -0600
@@ -1,4 +1,4 @@
-
+#include <config.h>
#include <stdio.h>
While this patch is required for ALL platforms,
Post by Eric Blake
#include <stdlib.h>
#include "scribble.h"
--- origsrc/sharutils-4.14/src/shar.c 2013-10-12 16:18:28.000000000 -0600
+++ src/sharutils-4.14/src/shar.c 2014-04-16 09:03:17.826856400 -0600
@@ -1107,7 +1107,7 @@ emit_char_ct_validation (
sprintf (command, cct_cmd, quoted_name);
{
- FILE * pfp = popen (command, "r");
+ FILE * pfp = popen (command, "rb");
you'll probably want this one to be gated by conditional compilation.
While "rb" is required for fopen() to force binary mode, it is a
non-POSIX extension supported by Cygwin but not all other platforms when
dealing with popen(). Something like this is sufficient (all known
platforms where O_BINARY is non-zero support the extension):

popen (command, O_BINARY ? "rb" : "r")
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Loading...