Subject: pkg/23856: pkgsrc doesn't distinguish between FreeBSD versions; this is bad; trival fix
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <dotz@irc.pl>
List: netbsd-bugs
Date: 12/23/2003 13:12:54
>Number:         23856
>Category:       pkg
>Synopsis:       pkgsrc doesn't distinguish between FreeBSD versions; this is bad; trival fix
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 23 13:13:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Michal Pasternak
>Release:        N/A
>Organization:
>Environment:
FreeBSD mainframe.w.lub.pl 4.9-RELEASE FreeBSD 4.9-RELEASE #0: Mon Oct 27 17:51:09 GMT 2003     root@freebsd-stable.sentex.ca:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
Every i386 FreeBSD machine will have MACHINE_GNU_PLATFORM defined as "i386-pc-freebsd". As LOWER_OPSYS set to "freebsd" seems sufficient for pkgsrc (and trying to change it results in much bad things), MACHINE_GNU_PLATFORM should be _definetley_ different for 4.x and 5.x . 

Because:
- FreeBSD Ports use "i386-pc-freebsd4.9" as the GNU platform name
- many important GNU programs (like GCC) want to distinguish FreeBSD 
  versions
- other GNU programs use *-*-freebsd*) in their scripts, so they won't 
  be affected

>How-To-Repeat:
Try buildling wip/mingw-gcc; it will fail at configure stage badly:
checking if mkdir takes one argument... (cached) no
Please update *-*-freebsd* in gcc/config.gcc
Configure in /usr/pkgsrc/wip/mingw-gcc/work/gcc-3.3.1-20030804-1/gcc failed, exiting.
*** Error code 1

Stop.
bmake: stopped in /usr/pkgsrc/wip/mingw-gcc
*** Error code 1

Looking at the configure script: everything is _FINE_, it is just pkgsrc doesn't setting proper --host on FreeBSD machinery:
$ grep freebsd work/gcc-3.3.1-20030804-1/gcc/config.gcc
*-*-freebsd[12] | *-*-freebsd[12].* | *-*-freebsd*aout*)
*-*-freebsd*)
        # freebsd<version_number>.h [freebsd-<conf_option>.h ...] freebsd-spec.h freebsd.h
        *-*-freebsd3 | *-*-freebsd[3].*) fbsd_tm_file="freebsd3.h";;
        *-*-freebsd4 | *-*-freebsd[4].*) fbsd_tm_file="freebsd4.h";;
        *-*-freebsd5 | *-*-freebsd[5].*) fbsd_tm_file="freebsd5.h";;
        *-*-freebsd6 | *-*-freebsd[6].*) fbsd_tm_file="freebsd6.h";;
        *) echo 'Please update *-*-freebsd* in gcc/config.gcc'; exit 1;;

Do you see? There is _NO_ such thing like "i386-pc-freebsd", there are "*-*-freebsd[123456]*", but no just "freebsd"

I haven't tried gcc-3.3, but I bet $50 it is the same there.
>Fix:
Please apply those patches; as FreeBSD Ports use the same value to --host and nothing bad happens, I think we could also use it:

Index: bsd.prefs.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.prefs.mk,v
retrieving revision 1.135
diff -u -r1.135 bsd.prefs.mk
--- bsd.prefs.mk        11 Dec 2003 22:35:50 -0000      1.135
+++ bsd.prefs.mk        23 Dec 2003 13:11:20 -0000
@@ -65,6 +65,8 @@
 LOWER_OPSYS?=          freebsd
 LOWER_ARCH!=           ${UNAME} -p
 MACHINE_ARCH=          ${LOWER_ARCH}
+# ${SED} is not defined at this point:
+LOWER_OPSYS_VERSUFFIX!= ${UNAME} -r | /usr/bin/sed -e 's/[-(].*//'
 MAKEFLAGS+=            LOWER_ARCH=${LOWER_ARCH}
 .  if ${LOWER_ARCH} == "i386"
 LOWER_VENDOR?=         pc

>Release-Note:
>Audit-Trail:
>Unformatted: