Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jul 1995 03:37:00 -0700
From:      asami@cs.berkeley.edu (Satoshi Asami)
To:        ports@freebsd.org
Subject:   Merging skeleton targets
Message-ID:  <199507241037.DAA11522@silvia.HIP.Berkeley.EDU>

next in thread | raw e-mail | index | archive | help
As part of the great bsd.port.mk cleanup, I merged all the "skeleton"
targets (fetch, extract, patch, configure, build, install) into one by
using a macro.  A patch is attached at the end of this mail.

The result is also now running on thud, please report any problems.
You shouldn't notice any changes.

Well, except for one.  Anyone know how I can capitalize the first
letter of a variable?  It now prints "extracting for ..." instead of
"Extracting for ...", and I can't do anything about it because the
target name contains the string "extract" but not "Extract". ;)

Do I need to use a shell substitution with tr or something?  Of course
I can also do what I did with configure (see below, if I didn't use a
special target it would have blurted "configureing ..." ;) for all the
other targets too, but that's gross....

Satoshi
-------
Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/src/share/mk/bsd.port.mk,v
retrieving revision 1.174
diff -u -r1.174 bsd.port.mk
--- 1.174	1995/07/24 08:02:07
+++ bsd.port.mk	1995/07/24 10:19:59
@@ -209,7 +209,8 @@
 .include "${PORTSDIR}/../Makefile.inc"
 .endif
 
-# Change these if you'd prefer to keep the cookies someplace else.
+# Don't change these!!!  These names are built into the _TARGET_USE macro,
+# there is no way to refer to them cleanly from within the macro AFAIK.
 EXTRACT_COOKIE?=	${WRKDIR}/.extract_done
 CONFIGURE_COOKIE?=	${WRKDIR}/.configure_done
 INSTALL_COOKIE?=	${WRKDIR}/.install_done
@@ -609,219 +610,120 @@
 .endif
 
 ################################################################
-# Skeleton targets start here
-# 
-# You shouldn't have to change these.  Either add the pre-* or
-# post-* targets/scripts or redefine the do-* targets.  These
-# targets don't do anything other than checking for cookies and
-# call the necessary targets/scripts.
+# This is the "generic" port target, actually a macro used from the
+# six main targets.  See below for more.
 ################################################################
 
-# Fetch
-
-.if !target(fetch)
-fetch: depends
-.if target(pre-fetch)
-	@${MAKE} ${.MAKEFLAGS} pre-fetch
+_PORT_USE: .USE
+.if make(real-configure)
+	@${ECHO_MSG} "===>  configuring for ${PKGNAME}"
+.elif !make(real-fetch)
+	@${ECHO_MSG} "===>  ${.TARGET:S/^real-//}ing for ${PKGNAME}"
 .endif
-	@if [ -f ${SCRIPTDIR}/pre-fetch ]; then \
-		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
-		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
-		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
-		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/pre-fetch; \
+.if make(real-install)
+.if !defined(NO_MTREE)
+	@if [ `id -u` = 0 ]; then \
+		${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
+	else \
+		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
+		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
 	fi
-	@${MAKE} ${.MAKEFLAGS} do-fetch
-.if target(post-fetch)
-	@${MAKE} ${.MAKEFLAGS} post-fetch
 .endif
-	@if [ -f ${SCRIPTDIR}/post-fetch ]; then \
-		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
-		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
-		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
-		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/post-fetch; \
-	fi
 .endif
-
-# Extract
-
-.if !target(extract)
-extract: checksum ${EXTRACT_COOKIE}
-
-${EXTRACT_COOKIE}:
-	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
-.if target(pre-extract)
-	@${MAKE} ${.MAKEFLAGS} pre-extract
+.if target(${.TARGET:S/^real-/pre-/})
+	@${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/pre-/}
 .endif
-	@if [ -f ${SCRIPTDIR}/pre-extract ]; then \
+	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
 		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
 		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
 		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
 		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/pre-extract; \
+			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \
 	fi
-	@${MAKE} ${.MAKEFLAGS} do-extract
-.if target(post-extract)
-	@${MAKE} ${.MAKEFLAGS} post-extract
+	@${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/do-/}
+.if target(${.TARGET:S/^real-/post-/})
+	@${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/post-/}
 .endif
-	@if [ -f ${SCRIPTDIR}/post-extract ]; then \
+	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/post-/} ]; then \
 		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
 		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
 		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
 		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/post-extract; \
+			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \
 	fi
-	@${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE}
+.if make(real-install)
+	@${MAKE} ${.MAKEFLAGS} fake-pkg
+.endif
+.if !make(real-fetch) && (!make(real-patch) || !defined(PATCH_CHECK_ONLY))
+	@${TOUCH} ${TOUCH_FLAGS} ${WRKDIR}/.${.TARGET:S/^real-//}_done
 .endif
 
-# Patch
-
-.if !target(patch)
-patch: extract ${PATCH_COOKIE}
+################################################################
+# Skeleton targets start here
+# 
+# You shouldn't have to change these.  Either add the pre-* or
+# post-* targets/scripts or redefine the do-* targets.  These
+# targets don't do anything other than checking for cookies and
+# call the necessary targets/scripts.
+################################################################
 
-${PATCH_COOKIE}:
-	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
-.if target(pre-patch)
-	@${MAKE} ${.MAKEFLAGS} pre-patch
-.endif
-	@if [ -f ${SCRIPTDIR}/pre-patch ]; then \
-		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
-		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
-		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
-		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/pre-patch; \
-	fi
-	@${MAKE} ${.MAKEFLAGS} do-patch
-.if target(post-patch)
-	@${MAKE} ${.MAKEFLAGS} post-patch
-.endif
-	@if [ -f ${SCRIPTDIR}/post-patch ]; then \
-		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
-		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
-		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
-		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/post-patch; \
-	fi
-.if !defined(PATCH_CHECK_ONLY)
-	@${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE}
-.endif
+.if !target(fetch)
+fetch: depends
+	@${MAKE} ${.MAKEFLAGS} real-fetch
 .endif
 
-# Checkpatch
-#
-# Special target to verify patches
-
-.if !target(checkpatch)
-checkpatch:
-	@${MAKE} PATCH_CHECK_ONLY=yes ${.MAKEFLAGS} patch
+.if !target(extract)
+extract: checksum ${EXTRACT_COOKIE}
 .endif
 
-# Configure
+.if !target(patch)
+patch: extract ${PATCH_COOKIE}
+.endif
 
 .if !target(configure)
 configure: patch ${CONFIGURE_COOKIE}
-
-${CONFIGURE_COOKIE}:
-	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
-.if target(pre-configure)
-	@${MAKE} ${.MAKEFLAGS} pre-configure
-.endif
-	@if [ -f ${SCRIPTDIR}/pre-configure ]; then \
-		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
-		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
-		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
-		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/pre-configure; \
-	fi
-	@${MAKE} ${.MAKEFLAGS} do-configure
-.if target(post-configure)
-	@${MAKE} ${.MAKEFLAGS} post-configure
-.endif
-	@if [ -f ${SCRIPTDIR}/post-configure ]; then \
-		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
-		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
-		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
-		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/post-configure; \
-	fi
-	@${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE}
 .endif
 
-# Build
-
 .if !target(build)
 build: configure ${BUILD_COOKIE}
-
-${BUILD_COOKIE}:
-	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
-.if target(pre-build)
-	@${MAKE} ${.MAKEFLAGS} pre-build
-.endif
-	@if [ -f ${SCRIPTDIR}/pre-build ]; then \
-		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
-		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
-		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
-		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/pre-build; \
-	fi
-	@${MAKE} ${.MAKEFLAGS} do-build
-.if target(post-build)
-	@${MAKE} ${.MAKEFLAGS} post-build
 .endif
-	@if [ -f ${SCRIPTDIR}/post-build ]; then \
-		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
-		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
-		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
-		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/post-build; \
-	fi
-	@${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
-.endif
-
-# Install
 
 .if !target(install)
 install: build ${INSTALL_COOKIE}
+.endif
 
+${EXTRACT_COOKIE}:
+	@${MAKE} ${.MAKEFLAGS} real-extract
+${PATCH_COOKIE}:
+	@${MAKE} ${.MAKEFLAGS} real-patch
+${CONFIGURE_COOKIE}:
+	@${MAKE} ${.MAKEFLAGS} real-configure
+${BUILD_COOKIE}:
+	@${MAKE} ${.MAKEFLAGS} real-build
 ${INSTALL_COOKIE}:
-	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
-.if !defined(NO_MTREE)
-	@if [ `id -u` = 0 ]; then \
-		${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
-	else \
-		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
-		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
-	fi
-.endif
-.if target(pre-install)
-	@${MAKE} ${.MAKEFLAGS} pre-install
-.endif
-	@if [ -f ${SCRIPTDIR}/pre-install ]; then \
-		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
-		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
-		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
-		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/pre-install; \
-	fi
-	@${MAKE} ${.MAKEFLAGS} do-install
-.if target(post-install)
-	@${MAKE} ${.MAKEFLAGS} post-install
-.endif
-	@if [ -f ${SCRIPTDIR}/post-install ]; then \
-		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
-		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
-		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
-		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
-			/bin/sh ${SCRIPTDIR}/post-install; \
-	fi
-	@${MAKE} ${.MAKEFLAGS} fake-pkg
-	@${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
+	@${MAKE} ${.MAKEFLAGS} real-install
+
+# And call the macros
+
+real-fetch: _PORT_USE
+real-extract: _PORT_USE
+real-patch: _PORT_USE
+real-configure: _PORT_USE
+real-build: _PORT_USE
+real-install: _PORT_USE
+
+# Checkpatch
+#
+# Special target to verify patches
+
+.if !target(checkpatch)
+checkpatch:
+	@${MAKE} PATCH_CHECK_ONLY=yes ${.MAKEFLAGS} patch
 .endif
 
 # Reinstall
 #
-# This is a special target to re-run install
+# Special target to re-run install
 
 .if !target(reinstall)
 reinstall: pre-reinstall install




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