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

Here's a patch to 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 
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:

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>
#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.

Content-Type: text/plain; charset=iso-8859-1; name=""
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=""; size=645

---	Tue Jun  6 11:28:52 2006
+++	Tue Jun  6 11:28:52 2006
@@ -129,6 +129,8 @@
 .elif ${OPSYS} =3D=3D "FreeBSD"
+# See =
+OS_VERSION!=3D		/sbin/sysctl -n kern.osreldate
 LOWER_OPSYS?=3D		freebsd
@@ -265,6 +267,12 @@
 .  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
 .  endif
 .elif ${OPSYS} =3D=3D "DragonFly"