Subject: xsrc/15443: XFree86 3.3.6 does not compile
To: None <gnats-bugs@gnats.netbsd.org>
From: None <bpstark@pacbell.net>
List: netbsd-bugs
Date: 01/30/2002 22:04:30
>Number:         15443
>Category:       xsrc
>Synopsis:       XFree86 3.3.6 does not compile
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    xsrc-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 31 02:53:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Brian Stark
>Release:        NetBSD 1.5ZA
>Organization:

Brian Stark
bpstark@pacbell.net
>Environment:
	
	
System: NetBSD callisto.niangua.net 1.5ZA NetBSD 1.5ZA (CALLISTO) #2: Thu Jan 10 17:24:14 PST 2002 bstark@callisto.niangua.net:/usr/src/sys/arch/i386/compile/CALLISTO i386
Architecture: i386
Machine: i386
>Description:

Attempting to compile XFree86 3.3.6 using the source contained in 
xsrc.tar.gz from ftp.netbsd.org will fail on NetBSD-current versions
when the version number contains two letters, as is the case currently
with NetBSD 1.5ZA. 

(This problem was first reported to the NetBSD current-users mailing list
on January 10, 2002.)

	
>How-To-Repeat:

With a NetBSD-current version with two letters in the version (e.g. 1.5ZA)
try to compile XFree86 3.3.6. The build will fail with the following 
messages:

  making all in programs/Xserver/hw/xfree86/common...
  rm -f xf86USBtablet.so
  gcc -nostdlib -o xf86USBtablet.so -Wl,-Bshareable -R/usr/X11R6/lib xf86USBtabl
et.o /usr/lib/libusb_pic.a
  gcc: /usr/lib/libusb_pic.a: No such file or directory
  *** Error code 1

  Stop.
  make: stopped in /usr/xsrc/xc/programs/Xserver/hw/xfree86/common
  *** Error code 1


>Fix:

There is a fix available for this problem. 

The problem is in one of the defines used by xsrc/xc/config/imake/imake.c 
(DEFAULT_OS_TEENY_REV_FROB).  The define is in:

  xsrc/xc/config/imake/imakemdep.h

The problem occurs when the version string returned by "uname -r"
includes two or more letters.  The macro DEFAULT_OS_TEENY_REV_FROB
only looks at the first such letter to determine a "teeny revision
number", and hence this number never gets incremented past 26.  (The
numbering starts with "A" = 1.)

One easy way to check this is to look at xsrc/xc/xmakefile which is
created by imake.  There you find:

--------------------

callisto:bstark$  make -f /usr/xsrc/xc/xmakefile VerifyOS

Building on NetBSD/i386 1.5ZA [ELF] (1.5.26).

callisto:bstark$ 

--------------------

The Imakefile in programs/Xserver/hw/xfree86/common contains the following
check which fails because the OSTeenyVersion is not greater than 26:

#     if (OSMajorVersion == 1 && OSMinorVersion > 5) || (OSMajorVersion == 1 &&
OSMinorVersion == 5 && OSTeenyVersion > 26)
         ARCH_USB = /usr/lib/libusbhid_pic.a
#     else
         ARCH_USB = /usr/lib/libusb_pic.a
#     endif


Since libusbhid_pic became available in NetBSD-1.5ZA imake should realize
set the value for OSTeenyVersion to 27 but does not. The following is
a patch for XFree86 3.3.6 that solves this problem:

Index: imakemdep.h
===================================================================
RCS file: /cvsroot/xsrc/xc/config/imake/imakemdep.h,v
retrieving revision 1.10
diff -u -r1.10 imakemdep.h
--- imakemdep.h 2001/10/08 23:24:59     1.10
+++ imakemdep.h 2002/01/24 13:51:54
@@ -719,10 +719,15 @@
 # define DEFAULT_OS_TEENY_REV   "r %*d.%*d%[A-Z]"
 # define DEFAULT_OS_TEENY_REV_FROB(buf, size)                          \
     do {                                                               \
-       if (*(buf) >= 'A' && *(buf) <= 'Z') /* sanity check */          \
-               snprintf((buf), (size), "%d", *(buf) - 'A' + 1);        \
+       char *p;                                                        \
+       int i;                                                          \
+       i = 0;                                                          \
+       for (p=(buf); *p && *p >= 'A' && *p <= 'Z' ; p++)               \
+         i += *p - 'A' + 1;                                            \
+       if (*p)                                                         \
+         *(buf) = '\0';                                                \
        else                                                            \
-           *(buf) = '\0';                                              \
+         snprintf((buf), (size), "%d", i);                             \
     } while (0)
 # define DEFAULT_OS_NAME        "smr %[^\n]"
 # define DEFAULT_OS_NAME_FROB(buf, size)                               \


This fix in this patch needs to be implemented in the same file for
XFree86 4.2 as well. The file for XFree86 4.2 is newer than the one 
for XFree86 3.3.6 so the above fix will have to be manually added.

On a final note, the code changes for imakemdep.h probably should
be passed back to the XFree86 project. Perhaps one of the NetBSD 
developers who have contributed fixes to XFree86 could handle 
getting this fix into the XFree86 CVS repository.
>Release-Note:
>Audit-Trail:
>Unformatted: