Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Oct 1998 17:55:46 -0700 (PDT)
From:      asami@cs.berkeley.edu (Satoshi Asami)
To:        ports@FreeBSD.ORG
Subject:   package-loop
Message-ID:  <199810200055.RAA15405@vader.cs.berkeley.edu>

next in thread | raw e-mail | index | archive | help
What do people think about this one?  Use it like this (from a2ps43):

===
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/print/a2ps43/Makefile,v
retrieving revision 1.16
diff -u -r1.16 Makefile
--- Makefile	1998/04/04 07:36:44	1.16
+++ Makefile	1998/10/19 23:59:49
@@ -15,7 +15,8 @@
 MAINTAINER=	obrien@FreeBSD.org
 
 NO_LATEST_LINK=	yes
-MANUAL_PACKAGE_BUILD=	PAPERSIZE has to be set to Letter A4
+LOOP_VARIABLE=	PAPERSIZE
+LOOP_OPTIONS=	letter a4
 MAKE_FLAGS?=	WIDTH=${WIDTH} HEIGHT=${HEIGHT} A4_PAPERSIZE=${A4_PAPERSIZE} -f
 NO_WRKSUBDIR=	yes
 MAN1=		a2ps.1
===

By the way, credit goes to Justin S. for insisting that it's really
easy to do. :)

Satoshi
-------
Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/src/share/mk/bsd.port.mk,v
retrieving revision 1.227.2.57
diff -u -r1.227.2.57 bsd.port.mk
--- bsd.port.mk	1998/10/09 01:27:55	1.227.2.57
+++ bsd.port.mk	1998/10/20 00:24:24
@@ -246,6 +246,20 @@
 #				  is set and NO_INSTALL_MANPAGES is not set, and
 #				  "no" otherwise.
 #
+# If your port wants the package to be built with several options,
+# set the following variables.
+#
+# LOOP_VARIABLE	- The name of the variable.
+# LOOP_OPTIONS	- The value of the options.
+#
+# If they are set, there will be a target "package-loop" which will
+# iterate several times, each time cleaning up afterwards, with the
+# value of ${LOOP_VARIABLE} set to one of ${LOOP_OPTIONS}.  In addition,
+# the "describe" target will print out multiple lines with the variable
+# set accordingly.  Also, if PACKAGE_BUILDING is defined, "package"
+# will essentially become "package-loop" (to make it easy to build all
+# packages from the upper level).
+#
 # Default targets and their behaviors:
 #
 # fetch			- Retrieves ${DISTFILES} (and ${PATCHFILES} if defined)
@@ -1490,9 +1504,16 @@
 install: ${INSTALL_COOKIE}
 .endif
 
+# If LOOP_VARIABLE and PACKAGE_BUILDING is set, "package"
+# essentially turns into "package-loop".
 .if !target(package)
+.if defined(LOOP_VARIABLE) && defined(PACKAGE_BUILDING)
+package: package-loop
+do-package-loop: ${PACKAGE_COOKIE}
+.else
 package: ${PACKAGE_COOKIE}
 .endif
+.endif
 
 ${EXTRACT_COOKIE}:
 	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch
@@ -1761,6 +1782,23 @@
 	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package
 .endif
 
+# Loop through several options for package building
+
+#LOOP_VARIABLE?=	dummy
+#LOOP_OPTIONS?=	dummy
+.if !target(package-loop)
+package-loop:
+.if defined(LOOP_VARIABLE)
+	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} LOOP=yes clean
+.for option in ${LOOP_OPTIONS}
+	@cd ${.CURDIR} && ${SETENV} ${LOOP_VARIABLE}=${option} LOOP=yes \
+		${MAKE} ${.MAKEFLAGS} do-package-loop clean
+.endfor
+.else
+	@${DO_NADA}
+.endif
+.endif
+
 ################################################################
 # Dependency checking
 ################################################################
@@ -1934,8 +1972,22 @@
 # distribution-name|port-path|installation-prefix|comment| \
 #  description-file|maintainer|categories|build deps|run deps
 #
+# If LOOP_VARIABLE is set, multiple lines will be printed with the
+# variable set to each value of LOOP_OPTIONS.
+
 .if !target(describe)
 describe:
+.if !defined(LOOP_VARIABLE)
+	@cd ${.CURDIR} && ${MAKE} do-describe
+.else
+.for option in ${LOOP_OPTIONS}
+	@cd ${.CURDIR} && ${SETENV} ${LOOP_VARIABLE}=${option} ${MAKE} do-describe
+.endfor
+.endif
+.endif
+
+.if !target(do-describe)
+do-describe:
 	@${ECHO} -n "${PKGNAME}|${.CURDIR}|"; \
 	${ECHO} -n "${PREFIX}|"; \
 	if [ -f ${COMMENT} ]; then \

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810200055.RAA15405>