From owner-ports-jp@jp.freebsd.org  Thu Nov 12 17:18:22 1998
Received: (from daemon@localhost)
	by jaz.jp.freebsd.org (8.9.1+3.1W/8.7.3) id RAA27344;
	Thu, 12 Nov 1998 17:18:22 +0900 (JST)
	(envelope-from owner-ports-jp@jp.FreeBSD.org)
Received: from spa.kuis.kyoto-u.ac.jp (root@lab4imgw.kuis.kyoto-u.ac.jp [130.54.23.230])
	by jaz.jp.freebsd.org (8.9.1+3.1W/8.7.3) with ESMTP id RAA27335
	for <ports-jp@jp.freebsd.org>; Thu, 12 Nov 1998 17:18:20 +0900 (JST)
	(envelope-from shige@kuis.kyoto-u.ac.jp)
Received: from localhost (sirahama.kuis.kyoto-u.ac.jp [130.54.22.177])
	by spa.kuis.kyoto-u.ac.jp (8.8.8/3.6Wspa) with ESMTP id RAA19160;
	Thu, 12 Nov 1998 17:16:44 +0900 (JST)
To: ports-jp@jp.freebsd.org
Cc: shige@kuis.kyoto-u.ac.jp
In-Reply-To: Your message of "Thu, 12 Nov 1998 17:04:19 +0900"
	<19981112170419B.taguchi@tohoku.iij.ad.jp>
References: <19981112170419B.taguchi@tohoku.iij.ad.jp>
X-Mailer: Mew version 1.93 on Emacs 20.3 / Mule 4.0
 =?iso-2022-jp?B?KBskQjJWMWMbKEIp?=
X-Prom-Mew: Prom-Mew 1.93 (procmail reader for Mew)
X-URL: http://www.yuasa.kuis.kyoto-u.ac.jp/~shige/
X-fingerprint: C8 BD 6A A7 CF FF 74 88  A4 B2 CC 5F C7 61 5C 9A
X-Pgp-Public-Key-URL: http://pgp5.ai.mit.edu:11371/pks/lookup?op=get&search=0x56B99BF9
X-Face-Version: X-Face utility v1.3.2 - "The Fool On The Hill"
                with Select X-Face v0.09 - "Figure Of Eight"
X-Face: 34/1@t8]M!wP}sAw$~XQMzl5'O=lCIM]8=_8CE,|S)Vs4Wy@tU~A'wRi\lgWh-o&'|:zg<S
 g%%4BRt%M~>>Gc?0?{^jo8(|5'Tg`yBH81.:!N9tSq*Sp6>C0q@{|&+FaM;R;KkoW1jA?QIWQ3:gNq
 {O%`:ww
Mime-Version: 1.0
Content-Type: Multipart/Mixed;
	boundary="--Next_Part(Thu_Nov_12_17:16:05_1998_949)--"
Content-Transfer-Encoding: 7bit
Message-Id: <19981112171817E.shige@kuis.kyoto-u.ac.jp>
Date: Thu, 12 Nov 1998 17:18:17 +0900 (JST)
From: Shigeyuki FUKUSHIMA <shige@kuis.kyoto-u.ac.jp>
X-Dispatcher: imput version 980905(IM100)
Lines: 303
Reply-To: ports-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+980914
X-Sequence: ports-jp 5028
Subject: [ports-jp 5028] Re: bsd.port.{pre|post}.mk ?
Errors-To: owner-ports-jp@jp.freebsd.org
Sender: owner-ports-jp@jp.freebsd.org
X-Originator: shige@kuis.kyoto-u.ac.jp

----Next_Part(Thu_Nov_12_17:16:05_1998_949)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

 From: Taguchi Takeshi <taguchi@tohoku.iij.ad.jp>
 Date: Thu, 12 Nov 1998 17:04:19 +0900
 Title: [ports-jp 5026] bsd.port.{pre|post}.mk ?
 Message-ID: <19981112170419B.taguchi@tohoku.iij.ad.jp>

$BJ!Eg!w5~Bg>pJs(B $B$G$9!#(B

> pre $B$G$O!$4D6-$r$"$i$o$9JQ?t$N$_$,Dj5A$5$l$k$N$_$_$?$$$J(B
> $B$N$G!$4D6-$K$h$C$F?6$kIq$$$rJQ$($k(B ports $B$G;HMQ$G$-$k!$$H(B
> $B9M$($l$P$$$$$N$G$7$g$&$+!)(B

port $B$N(B Makefile $B$G(B

.if (${PORTOBJFORMAT} == "elf")
   ELF $B$J$i$3$&$7$?$$(B
.endif

$B$_$?$$$J$3$H$,$G$-$^$9!#(B
$B$o$?$7$O!"0JA0$3$l$r$9$k$?$a$K!"(B

PORTOBJFORMAT!= test -x /usr/bin/objformat ...($BN,(B)
.if (${PORTOBJFORMAT} == "elf")

$B$_$?$$$K$7$F%+%C%3$o$k$$$J!A$H;W$C$F$^$7$?!#(B

freebsd-ports $B$KN.$l$F$$$?(B $B$"$5$_$5$s(B $B$N(B mail $B$r(B $BE:IU$7$F$*$-$^$9$M!#(B
$B>\:Y$O$3$A$i$r!#(B
---------
$BJ!Eg(B $BLPG7(B (Shigeyuki FUKUSHIMA) <shige@kuis.kyoto-u.ac.jp>
  $B5~ETBg3XBg3X1!9)3X8&5f2J>pJs9)3X@l96(B $BEr^I8&5f<<(B
PGP Public Key:
http://pgp5.ai.mit.edu:11371/pks/lookup?op=get&search=0x56B99BF9


----Next_Part(Thu_Nov_12_17:16:05_1998_949)--
Content-Type: Message/Rfc822
Content-Transfer-Encoding: 7bit

From owner-freebsd-ports@FreeBSD.ORG  Sun Nov  8 20:29:50 1998
Return-Path: <owner-freebsd-ports@FreeBSD.ORG>
Received: from isfs.kuis.kyoto-u.ac.jp (isfs.kuis.kyoto-u.ac.jp [130.54.23.2])
	by spa.kuis.kyoto-u.ac.jp (8.8.8/3.6Wspa) with ESMTP id UAA26545
	for <shige@yuasa.kuis.kyoto-u.ac.jp>; Sun, 8 Nov 1998 20:29:49 +0900 (JST)
Received: from jaz.jp.freebsd.org (jaz.jp.freebsd.org [133.11.156.38])
	by isfs.kuis.kyoto-u.ac.jp (8.8.8/3.6W-kuisMX) with ESMTP id UAA09027
	for <shige@kuis.kyoto-u.ac.jp>; Sun, 8 Nov 1998 20:30:58 +0900 (JST)
Received: from hub.freebsd.org (hub.FreeBSD.ORG [204.216.27.18])
	by jaz.jp.freebsd.org (8.9.1+3.1W/8.7.3/smtpfeed 0.87) with ESMTP id UAA27787;
	Sun, 8 Nov 1998 20:30:55 +0900 (JST)
	(envelope-from owner-freebsd-ports@FreeBSD.ORG)
Received: from localhost (daemon@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) with SMTP id DAA28516;
          Sun, 8 Nov 1998 03:25:12 -0800 (PST)
          (envelope-from owner-freebsd-ports)
Received: by hub.freebsd.org (bulk_mailer v1.6); Sun, 8 Nov 1998 03:22:17 -0800
Received: (from majordom@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) id DAA27972
          for freebsd-ports-outgoing; Sun, 8 Nov 1998 03:22:09 -0800 (PST)
          (envelope-from owner-freebsd-ports@FreeBSD.ORG)
Received: from vader.cs.berkeley.edu (vader.CS.Berkeley.EDU [128.32.38.234])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id DAA27945
          for <ports@freebsd.org>; Sun, 8 Nov 1998 03:21:57 -0800 (PST)
          (envelope-from asami@vader.cs.berkeley.edu)
Received: from silvia.hip.berkeley.edu (sji-ca6-19.ix.netcom.com [205.186.213.19]) by vader.cs.berkeley.edu (8.8.7/8.7.3) with ESMTP id DAA21009 for <ports@freebsd.org>; Sun, 8 Nov 1998 03:21:23 -0800 (PST)
Received: (from asami@localhost) by silvia.hip.berkeley.edu (8.8.8/8.6.9) id DAA04535; Sun, 8 Nov 1998 03:21:20 -0800 (PST)
Date: Sun, 8 Nov 1998 03:21:20 -0800 (PST)
Message-Id: <199811081121.DAA04535@silvia.hip.berkeley.edu>
To: ports@FreeBSD.ORG
Subject: bsd.port.{pre,post}.mk
From: asami@cs.berkeley.edu (Satoshi Asami)
Sender: owner-freebsd-ports@FreeBSD.ORG
X-Loop: FreeBSD.org

Folks,

I'm working on splitting up bsd.port.mk to two parts, one to be
included before the port Makefile (to define stuff like PREFIX and
PORTOBJFORMAT) and one to be included after it.  I think adding two
new files, bsd.port.{pre,post}.mk, which define a dummy variable and
include bsd.port.mk is the easiest way for people, since it will allow 
them to track only one file (bsd.port.mk) most of the time.  It is
also easier for me to maintain the file too.

One thing to note that it bsd.port.pre.mk actually has to be included
after some variable definitions (most notably, USE_X_PREFIX and
friends) for it to be useful, otherwise things like PREFIX will come
out wrong.  So we can't just add the file right after the leading
comments.  (Too bad, that would have been nice.)

So, your Makefile will look like this:

===
# New ports collection makefile for:	oneko
 :
MAN6=		oneko.6

.include <bsd.port.pre.mk>

.if ("${PORTOBJFORMAT}" == "elf")
OBJS=		elf.o
.else
OBJS=		aout.o
.endif

.if exists(${PREFIX}/lib/X11/config/FreeBSD.cf.orig)
laugh:
	@echo "Tee hee, you forgot to delete an .orig file!"
.endif

pre-configure:
	@echo "MANSUFFIX=6" >>${WRKSRC}/Imakefile

.include <bsd.port.post.mk>
===

The general rule is, if you need the pre.mk and post.mk separation,
put pre.mk after variable definitions (except for those that need
variables defined in pre.mk).  Then comes the rules, then post.mk.  If
you only need one, then bsd.port.mk can be used just like before,
included at the end.

Here's bsd.port.pre.mk:

===
BEFOREPORTMK=	yes
.include <bsd.port.mk>
.undef BEFOREPORTMK
===

and here's bsd.port.post.mk:

===
AFTERPORTMK=	yes
.include <bsd.port.mk>
.undef AFTERPORTMK
===

Here's a patch to bsd.port.mk itself and Makefile.  I had to move some
stuff around, but basically all it does is to surround the first part
with ".if !defined(AFTERPORTMK)" and the rest with ".if !defined(BEFOREPORTMK)".

===
Index: Makefile
===================================================================
RCS file: /usr/cvs/src/share/mk/Makefile,v
retrieving revision 1.13.2.3
diff -u -r1.13.2.3 Makefile
--- Makefile	1998/05/30 22:40:58	1.13.2.3
+++ Makefile	1998/11/08 10:54:35
@@ -4,7 +4,8 @@
 FILES=	bsd.README
 FILES+=	bsd.dep.mk bsd.doc.mk bsd.info.mk bsd.kern.mk bsd.kmod.mk
 FILES+=	bsd.lib.mk bsd.libnames.mk bsd.man.mk bsd.obj.mk bsd.own.mk
-FILES+=	bsd.port.mk bsd.port.subdir.mk bsd.prog.mk bsd.sgml.mk bsd.subdir.mk
+FILES+=	bsd.port.mk bsd.port.post.mk  bsd.port.pre.mk bsd.port.subdir.mk
+FILES+=	bsd.prog.mk bsd.sgml.mk bsd.subdir.mk
 FILES+=	sys.mk
 NOOBJ=	noobj
 
Index: bsd.port.mk
===================================================================
RCS file: /usr/cvs/src/share/mk/bsd.port.mk,v
retrieving revision 1.227.2.59
diff -u -r1.227.2.59 bsd.port.mk
--- bsd.port.mk	1998/11/08 10:30:53	1.227.2.59
+++ bsd.port.mk	1998/11/08 11:14:03
@@ -36,6 +36,7 @@
 #				  makefile is being used on.  Automatically set to
 #				  "FreeBSD," "NetBSD," or "OpenBSD" as appropriate.
 # OSREL			- The release version (numeric) of the operating system.
+# OSVER			- __FreeBSD_version.
 # PORTOBJFORMAT	- The object format ("aout" or "elf").
 #
 # These variables are used to identify your port.
@@ -393,6 +394,9 @@
 #				  a different checksum and you intend to verify if
 #				  the port still works with it.
 
+# Start of pre-makefile section.
+.if !defined(AFTERPORTMK)
+
 # Get the architecture
 ARCH!=	uname -m
 
@@ -401,14 +405,12 @@
 
 # Get the operating system revision
 OSREL!=	uname -r | sed -e 's/[-(].*//'
-PLIST_SUB+=	OSREL=${OSREL}
+
+# Get __FreeBSD_version
+OSVER!=	sysctl -n kern.osreldate
 
 # Get the object format.
 PORTOBJFORMAT!=	test -x /usr/bin/objformat && /usr/bin/objformat || echo aout
-CONFIGURE_ENV+=	PORTOBJFORMAT=${PORTOBJFORMAT}
-SCRIPTS_ENV+=	PORTOBJFORMAT=${PORTOBJFORMAT}
-MAKE_ENV+=		PORTOBJFORMAT=${PORTOBJFORMAT}
-PLIST_SUB+=		PORTOBJFORMAT=${PORTOBJFORMAT}
 
 # If they exist, include Makefile.inc, then architecture/operating
 # system specific Makefiles, then local Makefile.local.
@@ -494,6 +496,25 @@
 PKGDIR?=		${.CURDIR}/pkg
 .endif
 
+.if defined(USE_X_PREFIX)
+PREFIX?=		${X11BASE}
+.else
+PREFIX?=		${LOCALBASE}
+.endif
+
+.endif
+# End of pre-makefile section.
+
+# Start of post-makefile section.
+.if !defined(BEFOREPORTMK)
+
+PLIST_SUB+=	OSREL=${OSREL}
+
+CONFIGURE_ENV+=	PORTOBJFORMAT=${PORTOBJFORMAT}
+SCRIPTS_ENV+=	PORTOBJFORMAT=${PORTOBJFORMAT}
+MAKE_ENV+=		PORTOBJFORMAT=${PORTOBJFORMAT}
+PLIST_SUB+=		PORTOBJFORMAT=${PORTOBJFORMAT}
+
 .if defined(MANCOMPRESSED)
 .if ${MANCOMPRESSED} != yes && ${MANCOMPRESSED} != no && \
 	${MANCOMPRESSED} != maybe
@@ -515,11 +536,6 @@
 .if defined(USE_X_PREFIX)
 USE_XLIB=		yes
 .endif
-.if defined(USE_X_PREFIX)
-PREFIX?=		${X11BASE}
-.else
-PREFIX?=		${LOCALBASE}
-.endif
 
 .if defined(USE_GMAKE)
 BUILD_DEPENDS+=		gmake:${PORTSDIR}/devel/gmake
@@ -2189,3 +2210,6 @@
 .if !target(tags)
 tags:
 .endif
+
+.endif
+# End of post-makefile section.
===

I left most of the pathname definitions in pre.mk, as I thought
exists() check is what they are needed for, although I'm not sure if
PKGDIR and stuff are that useful that early.  As for non-pathname
stuff, only these five are defined in pre.mk:

===
ARCH!=	uname -m
OPSYS!=	uname -s
OSREL!=	uname -r | sed -e 's/[-(].*//'
OSVER!=	sysctl -n kern.osreldate
PORTOBJFORMAT!=	test -x /usr/bin/objformat && /usr/bin/objformat || echo aout
===

OSVER is new, and can be used for numeric comparisons.

I'm not so sure about putting pre.mk right in the middle.  Since it
only needs USE_IMAKE and USE_X_PREFIX, maybe we can ask people to put
it right at the top after those.  Something like:

===
# New ports collection makefile for:	oneko
# Version required:	1.2
# Date created:		5 December 1994
# Whom:			asami
#
# $Id: Makefile,v 1.11 1998/10/04 18:11:54 jseger Exp $
#
USE_IMAKE=	yes
.include <bsd.port.pre.mk>
 :
(everything else)
 :
.include <bsd.port.post.mk>
===

This looks pretty ugly though.  Also it means USE_IMAKE/USE_X_PREFIX
could appear in two different places, depending on whether the port
needs pre/post.mk or just bsd.port.mk.  I think putting it in the
middle is fine, as there really aren't that many ports that need the
split.

Any ideas?

Satoshi

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message


----Next_Part(Thu_Nov_12_17:16:05_1998_949)----
