Subject: FreeBSD/ports ${OSVERSION} vs. pkgsrc ${OS_VERSION}
To: None <tech-pkg@NetBSD.org>
From: Yarema <yds@CoolRat.org>
List: tech-pkg
Date: 06/26/2006 03:54:51
--==========3482B0D74CBB15B86C85==========
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Here's a patch to mk/bsd.prefs.mk to set OBJECT_FMT=ELF for FreeBSD.  At 
this point the value could be hardcoded as it is for DragonFly since I 
doubt anyone is likely to be running FreeBSD 2.2.x.  And if they are, I 
really doubt those poor lost souls would care that pkgsrc correctly 
determines the OBJECT_FMT.

I figured that populating pkgsrc ${OS_VERSION} with the value of 
__FreeBSD_version as defined in sys/param.h and published via "sysctl 
kern.osreldate" should not break anything.  At the same time it would allow 
fine tuning pkgsrc to various incremental revisions of FreeBSD.  See 
<http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/porters-handbook/freebsd-versions.html> 
and 
<http://www.FreeBSD.org/cgi/cvsweb.cgi/ports/databases/mysql50-server/Makefile> 
for examples of its use.

FreeBSD/ports ${OSVERSION} is not the same as pkgsrc ${OS_VERSION}.  In 
FreeBSD/ports ${OSREL} is roughly analogous to pkgsrc ${OS_VERSION}:

in pkgsrc:
OS_VERSION!=	${UNAME} -r

while FreeBSD/ports:
OSREL!=	${UNAME} -r | ${SED} -e 's/[-(].*//'
OSVERSION!=	/sbin/sysctl -n kern.osreldate

I notice that some pkgsrc patches use the following idiom:

/* defines __NetBSD_Version__ */
#if defined(__NetBSD__)
#include <sys/param.h>
#endif
...
#if defined (__NetBSD__) && (__NetBSD_Version__ < 106130000)
...

but the Makefiles use:
.if !empty(MACHINE_PLATFORM:MNetBSD-1.*)
...

I was thinking that it might be a Good Thing(TM) for NetBSD and perhaps 
some other OSes to also have pkgsrc define both an OS_RELEASE var to hold 
the ${UNAME} -r value and an OS_VERSION to hold the <sys/param.h> value. 
I'm certain if the latter was readily available  <sys/param.h> it could 
eventually replace the !empty(MACHINE_PLATFORM:MNetBSD-1.*) idiom with 
finer grained tuning ability.

As for pkgsrc on FreeBSD having the <sys/param.h> *_version value available 
in the Makefile might prove to be indispensable.

-- 
Yarema
http://yds.CoolRat.org
--==========3482B0D74CBB15B86C85==========
Content-Type: text/plain; charset=iso-8859-1; name="bsd.prefs.mk.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="bsd.prefs.mk.diff"; size=645

--- bsd.prefs.mk.orig	Tue Jun  6 11:28:52 2006
+++ bsd.prefs.mk	Tue Jun  6 11:28:52 2006
@@ -129,6 +129,8 @@
 LOWER_VENDOR?=3D		pc
=20
 .elif ${OPSYS} =3D=3D "FreeBSD"
+# See =
http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/porters-handbook/freebsd-ve=
rsions.html
+OS_VERSION!=3D		/sbin/sysctl -n kern.osreldate
 LOWER_OPSYS?=3D		freebsd
 LOWER_ARCH!=3D		${UNAME} -p
 MACHINE_ARCH=3D		${LOWER_ARCH}
@@ -265,6 +267,12 @@
 OBJECT_FMT?=3D	ELF
 .  else
 OBJECT_FMT?=3D	a.out
+.  endif
+.elif ${OPSYS} =3D=3D "FreeBSD"
+.  if defined(OS_VERSION) && ${OS_VERSION} < 300004
+OBJECT_FMT=3D	a.out
+.  else
+OBJECT_FMT=3D	ELF
 .  endif
 .elif ${OPSYS} =3D=3D "DragonFly"
 OBJECT_FMT=3D	ELF

--==========3482B0D74CBB15B86C85==========--