Date: Fri, 28 Jul 1995 17:43:24 -0700 From: asami@cs.berkeley.edu (Satoshi Asami) To: ports@freebsd.org Subject: New version of updated bsd.port.mk Message-ID: <199507290043.RAA21300@silvia.HIP.Berkeley.EDU>
next in thread | raw e-mail | index | archive | help
Well, I found a HUGE bogosity in my original modification I sent out, i.e., the pre-* and post-* targets in ports Makefiles were completely ignored. That nobody reported it probably means nobody tried to test it. :< Hey guys, please test this! I'm using them to build ports on my own machine and on thud, but there is only so much I can do. This is an enormous change, and I don't want to commit it without extensive testing. So here's the updated version. The pre-* and post-* targets now work, package is integrated into the _PORT_USE macro, the use of .for cleaned the generations of empty pre-* and post-* targets up a little, etc. Also, the echo commands are now directly invoked from the real-* targets, so the messages are capitalized again. :) You shouldn't see any functionality changes, except the package target now understands the post-package target and pre- and post-package scripts. I don't think anybody would want to do such complicated things with packages, but it was easier to integrate it and these come with orthogonality. :) Thanks! Satoshi ======= --- /usr/src/share/mk/bsd.port.mk Mon Jul 24 02:06:44 1995 +++ bsd.port.mk Fri Jul 28 17:23:58 1995 @@ -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 @@ -608,220 +609,195 @@ .endif .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. -################################################################ +# Package -# Fetch - -.if !target(fetch) -fetch: depends -.if target(pre-fetch) - @${MAKE} ${.MAKEFLAGS} pre-fetch -.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; \ - 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; \ +.if !target(do-package) +do-package: + @if [ -e ${PKGDIR}/PLIST ]; then \ + ${ECHO_MSG} "===> Building package for ${PKGNAME}"; \ + if [ -d ${PACKAGES} ]; then \ + if [ ! -d ${PKGREPOSITORY} ]; then \ + if ! /bin/mkdir -p ${PKGREPOSITORY}; then \ + ${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \ + exit 1; \ + fi; \ + fi; \ + fi; \ + if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \ + if [ -d ${PACKAGES} ]; then \ + ${MAKE} ${.MAKEFLAGS} package-links; \ + fi; \ + else \ + ${MAKE} ${.MAKEFLAGS} delete-package; \ + exit 1; \ + fi; \ fi .endif -# Extract - -.if !target(extract) -extract: checksum ${EXTRACT_COOKIE} +# Some support rules for do-package -${EXTRACT_COOKIE}: - @${ECHO_MSG} "===> Extracting for ${PKGNAME}" -.if target(pre-extract) - @${MAKE} ${.MAKEFLAGS} pre-extract -.endif - @if [ -f ${SCRIPTDIR}/pre-extract ]; 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; \ - fi - @${MAKE} ${.MAKEFLAGS} do-extract -.if target(post-extract) - @${MAKE} ${.MAKEFLAGS} post-extract +.if !target(package-links) +package-links: + @${MAKE} ${.MAKEFLAGS} delete-package-links + @for cat in ${CATEGORIES}; do \ + if [ ! -d ${PACKAGES}/$$cat ]; then \ + if ! /bin/mkdir -p ${PACKAGES}/$$cat; then \ + ${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \ + exit 1; \ + fi; \ + fi; \ + ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \ + done; .endif - @if [ -f ${SCRIPTDIR}/post-extract ]; 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; \ - fi - @${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE} + +.if !target(delete-package-links) +delete-package-links: + @/bin/rm -f ${PACKAGES}/[a-z]*/${PKGNAME}${PKG_SUFX}; .endif -# Patch +.if !target(delete-package) +delete-package: + @${MAKE} ${.MAKEFLAGS} delete-package-links + @/bin/rm -f ${PKGFILE} +.endif -.if !target(patch) -patch: extract ${PATCH_COOKIE} +################################################################ +# This is the "generic" port target, actually a macro used from the +# six main targets. See below for more. +################################################################ -${PATCH_COOKIE}: - @${ECHO_MSG} "===> Patching for ${PKGNAME}" -.if target(pre-patch) - @${MAKE} ${.MAKEFLAGS} pre-patch +_PORT_USE: .USE +.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 .endif - @if [ -f ${SCRIPTDIR}/pre-patch ]; then \ +.endif + @${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/pre-/} + @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-patch; \ + /bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \ fi - @${MAKE} ${.MAKEFLAGS} do-patch -.if target(post-patch) - @${MAKE} ${.MAKEFLAGS} post-patch -.endif - @if [ -f ${SCRIPTDIR}/post-patch ]; then \ + @${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/do-/} + @${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/post-/} + @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-patch; \ + /bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \ fi -.if !defined(PATCH_CHECK_ONLY) - @${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE} +.if make(real-install) + @${MAKE} ${.MAKEFLAGS} fake-pkg .endif +.if !make(real-fetch) \ + && (!make(real-patch) || !defined(PATCH_CHECK_ONLY)) \ + && (!make(real-package) || !defined(PACKAGE_NOINSTALL)) + @${TOUCH} ${TOUCH_FLAGS} ${WRKDIR}/.${.TARGET:S/^real-//}_done .endif -# Checkpatch -# -# Special target to verify patches +################################################################ +# 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. +################################################################ -.if !target(checkpatch) -checkpatch: - @${MAKE} PATCH_CHECK_ONLY=yes ${.MAKEFLAGS} patch +.if !target(fetch) +fetch: depends + @${MAKE} ${.MAKEFLAGS} real-fetch .endif -# Configure +.if !target(extract) +extract: checksum ${EXTRACT_COOKIE} +.endif + +.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 +.if !target(package) +package: install ${PACKAGE_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}: + @${MAKE} ${.MAKEFLAGS} real-install +${PACKAGE_COOKIE}: + @${MAKE} ${.MAKEFLAGS} real-package + +# And call the macros + +real-fetch: _PORT_USE +real-extract: _PORT_USE + @${ECHO_MSG} "===> Extracting for ${PKGNAME}" +real-patch: _PORT_USE + @${ECHO_MSG} "===> Patching for ${PKGNAME}" +real-configure: _PORT_USE + @${ECHO_MSG} "===> Configuring for ${PKGNAME}" +real-build: _PORT_USE + @${ECHO_MSG} "===> Building for ${PKGNAME}" +real-install: _PORT_USE @${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 +real-package: _PORT_USE + +# Empty pre-* and post-* targets, note we can't use .if !target() +# in the _PORT_USE macro + +.for name in fetch extract patch configure build install package + +.if !target(pre-${name}) +pre-${name}: + @${DO_NADA} .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 + +.if !target(post-${name}) +post-${name}: + @${DO_NADA} .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} + +.endfor + +# 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 @@ -921,11 +897,12 @@ .endif ################################################################ -# The package-building targets +# The special package-building targets # You probably won't need to touch these ################################################################ # Nobody should want to override this unless PKGNAME is simply bogus. + .if !target(package-name) package-name: .if !defined(NO_PACKAGE) @@ -934,6 +911,7 @@ .endif # Show (recursively) all the packages this package depends on. + .if !target(package-depends) package-depends: @for i in ${EXEC_DEPENDS} ${LIB_DEPENDS} ${DEPENDS}; do \ @@ -942,19 +920,6 @@ done .endif -# Build a package - -.if !target(package) -package: install ${PACKAGE_COOKIE} - -${PACKAGE_COOKIE}: -.if target(pre-package) - @${MAKE} ${.MAKEFLAGS} pre-package -.endif - @${MAKE} ${.MAKEFLAGS} do-package - @${TOUCH} ${TOUCH_FLAGS} ${PACKAGE_COOKIE} -.endif - # Build a package but don't check the package cookie .if !target(repackage) @@ -969,60 +934,7 @@ .if !target(package-noinstall) package-noinstall: -.if target(pre-package) - @${MAKE} ${.MAKEFLAGS} pre-package -.endif - @${MAKE} ${.MAKEFLAGS} do-package -.endif - -# The body of the package-building target - -.if !target(do-package) -do-package: - @if [ -e ${PKGDIR}/PLIST ]; then \ - ${ECHO_MSG} "===> Building package for ${PKGNAME}"; \ - if [ -d ${PACKAGES} ]; then \ - if [ ! -d ${PKGREPOSITORY} ]; then \ - if ! /bin/mkdir -p ${PKGREPOSITORY}; then \ - ${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \ - exit 1; \ - fi; \ - fi; \ - fi; \ - if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \ - if [ -d ${PACKAGES} ]; then \ - ${MAKE} ${.MAKEFLAGS} package-links; \ - fi; \ - else \ - ${MAKE} ${.MAKEFLAGS} delete-package; \ - exit 1; \ - fi; \ - fi -.endif - -.if !target(package-links) -package-links: - @${MAKE} ${.MAKEFLAGS} delete-package-links - @for cat in ${CATEGORIES}; do \ - if [ ! -d ${PACKAGES}/$$cat ]; then \ - if ! /bin/mkdir -p ${PACKAGES}/$$cat; then \ - ${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \ - exit 1; \ - fi; \ - fi; \ - ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \ - done; -.endif - -.if !target(delete-package-links) -delete-package-links: - @/bin/rm -f ${PACKAGES}/[a-z]*/${PKGNAME}${PKG_SUFX}; -.endif - -.if !target(delete-package) -delete-package: - @${MAKE} ${.MAKEFLAGS} delete-package-links - @/bin/rm -f ${PKGFILE} + @${MAKE} ${.MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package .endif ################################################################
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199507290043.RAA21300>