From owner-freebsd-ports Sun Nov 8 03:22:09 1998 Return-Path: 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 ; 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 ; 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 Precedence: bulk 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 .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 === 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 .undef BEFOREPORTMK === and here's bsd.port.post.mk: === AFTERPORTMK= yes .include .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 : (everything else) : .include === 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