From ccecf5fc352c2554b8ecaa7ee76780909e81da8e Mon Sep 17 00:00:00 2001 From: Satoshi Asami Date: Thu, 20 Apr 1995 18:03:02 +0000 Subject: Major overhaul. The major targets (fetch, extract, patch, configure, build, install) are now all skeletons and do nothing but (1) Call pre-* target (if exists) (2) Call scripts/pre-* script (if exists) (3) Call do-* target (4) Call post-* target (if exists) (5) Call scripts/post-* script (if exists) The do-* targets do all the work. The pre-* and post-* targets/scripts don't exist by default. The main targets check for the cookies too, so porters shouldn't have to worry about them at all. NOTE: THE MAIN TARGETS IN THE PORTS MAKEFILES SHOULD GO AWAY. We need to fix this before wcarchive comes back up. Change the names to do-*, rip out the cookies, rip out the calls to pre-* etc. and most of them should work. Also, reorganize the whole thing so that similar targets are together and add more comments. Surround section header with 64 #'s (C-u C-u C-u # in emacs :). Hopefully this will be the last major change to bsd.port.mk. Now let the Makefile-hacking begin. --- Mk/bsd.port.mk | 933 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 554 insertions(+), 379 deletions(-) diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk index bd3a36d9b167..cb7757fced37 100644 --- a/Mk/bsd.port.mk +++ b/Mk/bsd.port.mk @@ -3,7 +3,7 @@ # bsd.port.mk - 940820 Jordan K. Hubbard. # This file is in the public domain. # -# $Id: bsd.port.mk,v 1.142 1995/04/18 08:24:18 asami Exp $ +# $Id: bsd.port.mk,v 1.134 1995/04/09 10:24:09 jkh Exp $ # # Please view me with 4 column tabs! @@ -139,7 +139,15 @@ # checksum - Use files/md5 to ensure that your distfiles are valid # makesum - Generate files/md5 (only do this for your own ports!) # -# Default sequence for "all" is: fetch extract patch configure build +# Default sequence for "all" is: fetch checksum extract patch configure build +# +# Please read the comments in the targets section below, you +# should be able to use the pre-* or post-* targets/scripts +# (which are available for every stage except checksum) or +# override the do-* targets to do pretty much anything you want. +# +# NEVER override the "regular" targets unless you want to open +# a major can of worms. .if exists(${.CURDIR}/../Makefile.inc) .include "${.CURDIR}/../Makefile.inc" @@ -179,7 +187,6 @@ EXEC_DEPENDS+= gmake:${PORTSDIR}/devel/gmake .include "${PORTSDIR}/../Makefile.inc" .endif - # Change these if you'd prefer to keep the cookies someplace else. EXTRACT_COOKIE?= ${WRKDIR}/.extract_done CONFIGURE_COOKIE?= ${WRKDIR}/.configure_done @@ -298,30 +305,26 @@ HAS_CONFIGURE= yes .MAIN: all -# If we're in BATCH mode and the port is interactive, or we're in -# interactive mode and the port is non-interactive, skip all the important -# targets. The reason we have two modes is that one might want to leave -# a build in BATCH mode running overnight, then come back in the morning -# and do _only_ the interactive ones that required your intervention. -# This allows you to do both. +################################################################ +# If we're in BATCH mode and the port is interactive, or we're +# in interactive mode and the port is non-interactive, skip all +# the important targets. The reason we have two modes is that +# one might want to leave a build in BATCH mode running +# overnight, then come back in the morning and do _only_ the +# interactive ones that required your intervention. # +# This allows you to do both. +################################################################ + .if (defined(IS_INTERACTIVE) && defined(BATCH)) || (!defined(IS_INTERACTIVE) && defined(INTERACTIVE)) all: @${DO_NADA} -pre-build: - @${DO_NADA} build: @${DO_NADA} -pre-install: - @${DO_NADA} install: @${DO_NADA} -pre-fetch: - @${DO_NADA} fetch: @${DO_NADA} -pre-configure: - @${DO_NADA} configure: @${DO_NADA} package: @@ -333,15 +336,19 @@ all: build .endif .if !target(is_depended) -is_depended: all install +is_depended: install .endif -# The following are used to create easy dummy targets for disabling some -# bit of default target behavior you don't want. They still check to see -# if the target exists, and if so don't do anything, since you might want -# to set this globally for a group of ports in a Makefile.inc, but still -# be able to override from an individual Makefile (since you can't _undefine_ -# a variable in make!). +################################################################ +# The following are used to create easy dummy targets for +# disabling some bit of default target behavior you don't want. +# They still check to see if the target exists, and if so don't +# do anything, since you might want to set this globally for a +# group of ports in a Makefile.inc, but still be able to +# override from an individual Makefile (since you can't _ +# undefine_ a variable in make!). +################################################################ + .if defined(NO_EXTRACT) && !target(extract) extract: @${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE} @@ -375,50 +382,174 @@ patch: @${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE} .endif +################################################################ # More standard targets start here. - -# This target generates an index entry suitable for aggregation into -# a large index. Format is: -# -# distribution-name|port-path|installation-prefix|comment| \ -# description-file|maintainer # -.if !target(describe) -describe: - @echo -n "${PKGNAME}|${.CURDIR}/${PKGNAME}|" - @echo -n "${PREFIX}|" - @if [ -f ${PKGDIR}/COMMENT ]; then \ - echo -n "`cat ${PKGDIR}/COMMENT`"; \ - else \ - echo -n "** No Description"; \ +# These are the body of the build/install framework. If you are +# not happy with the default actions, and you can't solve it by +# adding pre-* or post-* targets/scripts, override these. +################################################################ + +# Fetch + +.if !target(do-fetch) +do-fetch: + @if [ ! -d ${DISTDIR} ]; then mkdir -p ${DISTDIR}; fi + @(cd ${DISTDIR}; \ + for file in ${DISTFILES}; do \ + if [ ! -f $$file -a ! -f `basename $$file` ]; then \ + ${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \ + for site in ${MASTER_SITES}; do \ + ${ECHO_MSG} ">> Attempting to fetch from $${site}"; \ + if ${NCFTP} ${NCFTPFLAGS} $${site}$${file}; then \ + break; \ + fi \ + done; \ + if [ ! -f $$file -a ! -f `basename $$file` ]; then \ + ${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\ + ${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \ + exit 1; \ + fi; \ + fi \ + done) +.if defined(PATCHFILES) + @(cd ${DISTDIR}; \ + for file in ${PATCHFILES}; do \ + if [ ! -f $$file -a ! -f `basename $$file` ]; then \ + ${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \ + for site in ${PATCH_SITES}; do \ + ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \ + if ${NCFTP} ${NCFTPFLAGS} $${site}$${file}; then \ + break; \ + fi \ + done; \ + if [ ! -f $$file -a ! -f `basename $$file` ]; then \ + ${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\ + ${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \ + exit 1; \ + fi; \ + fi \ + done) +.endif +.endif + +# Extract + +.if !target(do-extract) +do-extract: + @rm -rf ${WRKDIR} + @mkdir -p ${WRKDIR} +.if defined(EXTRACT_ONLY) + @for file in ${EXTRACT_ONLY}; do \ + if ! (cd ${WRKDIR};${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\ + then \ + exit 1; \ + fi \ + done +.else + @for file in ${DISTFILES}; do \ + if ! (cd ${WRKDIR};${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\ + then \ + exit 1; \ + fi \ + done +.endif +.endif + +# Patch + +.if !target(do-patch) +do-patch: +.if defined(PATCHFILES) + @${ECHO_MSG} "===> Applying distributed patches for ${PKGNAME}" +.if defined(PATCH_DEBUG) + @(cd ${DISTDIR}; \ + for i in ${PATCHFILES}; do \ + ${ECHO_MSG} "===> Applying distributed patch $$i" ; \ + case $$i in \ + *.Z|*.gz) \ + zcat $$i | ${PATCH} ${PATCH_DIST_ARGS}; \ + ;; \ + *) \ + ${PATCH} ${PATCH_DIST_ARGS} < $$i; \ + ;; \ + esac; \ + done) +.else + @(cd ${DISTDIR}; \ + for i in ${PATCHFILES}; do \ + case $$i in \ + *.Z|*.gz) \ + zcat $$i | ${PATCH} ${PATCH_DIST_ARGS}; \ + ;; \ + *) \ + ${PATCH} ${PATCH_DIST_ARGS} < $$i; \ + ;; \ + esac; \ + done) +.endif +.endif +.if defined(PATCH_DEBUG) + @if [ -d ${PATCHDIR} ]; then \ + ${ECHO_MSG} "===> Applying FreeBSD patches for ${PKGNAME}" ; \ + for i in ${PATCHDIR}/patch-*; do \ + ${ECHO_MSG} "===> Applying FreeBSD patch $$i" ; \ + ${PATCH} ${PATCH_ARGS} < $$i; \ + done; \ fi - @if [ -f ${PKGDIR}/DESCR ]; then \ - echo -n "|${PKGDIR}/DESCR"; \ - else \ - echo -n "|/dev/null"; \ + @${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE} +.else + @if [ -d ${PATCHDIR} ]; then \ + ${ECHO_MSG} "===> Applying FreeBSD patches for ${PKGNAME}" ; \ + for i in ${PATCHDIR}/patch-*; \ + do ${PATCH} ${PATCH_ARGS} < $$i; \ + done;\ fi - @echo -n "|${MAINTAINER}|${CATEGORIES}|${KEYWORDS}" - @echo "" + @${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE} +.endif .endif -.if !target(reinstall) -reinstall: pre-reinstall install +# Configure -pre-reinstall: - @rm -f ${INSTALL_COOKIE} +.if !target(do-configure) +do-configure: + @if [ -f ${SCRIPTDIR}/configure ]; then \ + env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ + WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ + FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ + DEPENDS="${DEPENDS}" \ + sh ${SCRIPTDIR}/configure; \ + fi +.if defined(HAS_CONFIGURE) + @(cd ${WRKSRC}; CC="${CC}" ac_cv_path_CC="${CC}" CFLAGS="${CFLAGS}" \ + INSTALL="/usr/bin/install -c -o ${BINOWN} -g ${BINGRP}" \ + INSTALL_PROGRAM="/usr/bin/install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \ + ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}) +.endif +.if defined(USE_IMAKE) +.if defined(USE_GMAKE) + @(cd ${WRKSRC}; ${XMKMF} && ${GMAKE} Makefiles) +.else + @(cd ${WRKSRC}; ${XMKMF} && ${MAKE} Makefiles) +.endif +.endif .endif -.if !target(pre-install) -pre-install: - @${DO_NADA} +# Build + +.if !target(do-build) +do-build: +.if defined(USE_GMAKE) + @(cd ${WRKSRC}; ${GMAKE} PREFIX=${PREFIX} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET}) +.else defined(USE_GMAKE) + @(cd ${WRKSRC}; ${MAKE} PREFIX=${PREFIX} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET}) +.endif .endif -.if !target(install) -install: build ${INSTALL_COOKIE} +# Install -${INSTALL_COOKIE}: - @${ECHO_MSG} "===> Installing for ${PKGNAME}" - @${MAKE} ${.MAKEFLAGS} pre-install +.if !target(do-install) +do-install: .if defined(USE_GMAKE) @(cd ${WRKSRC}; ${GMAKE} PREFIX=${PREFIX} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET}) .if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES) @@ -430,353 +561,234 @@ ${INSTALL_COOKIE}: @(cd ${WRKSRC}; ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man) .endif .endif -.if !defined(NO_PACKAGE) - @if [ ! -f ${PKGDIR}/PLIST -o ! -f ${PKGDIR}/COMMENT -o ! -f ${PKGDIR}/DESCR ]; then echo "** Missing patch files for ${PKGNAME} - installation not recorded."; exit 1; fi - @if [ ! -d ${PKG_DBDIR} ]; then rm -f ${PKG_DBDIR}; mkdir -p ${PKG_DBDIR}; fi - @if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \ - ${ECHO_MSG} "===> Registering installation for ${PKGNAME}"; \ - mkdir -p ${PKG_DBDIR}/${PKGNAME}; \ - cp ${PKGDIR}/PLIST ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \ - cp ${PKGDIR}/DESCR ${PKG_DBDIR}/${PKGNAME}/+DESC; \ - cp ${PKGDIR}/COMMENT ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \ - else \ - ${ECHO_MSG} "===> ${PKGNAME} is already installed - perhaps an older version?"; \ - ${ECHO_MSG} " If so, you may wish to \`\`pkg_delete ${PKGNAME}'' and install"; \ - ${ECHO_MSG} " this port again to upgrade it properly."; \ + @${MAKE} ${.MAKEFLAGS} fake-pkg +.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. +################################################################ + +# Fetch + +.if !target(fetch) +fetch: depends +.if target(pre-fetch) + @${MAKE} ${.MAKEFLAGS} pre-fetch +.endif + @if [ -f ${SCRIPTDIR}/pre-fetch ]; then \ + env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ + WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ + FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ + DEPENDS="${DEPENDS}" \ + sh ${SCRIPTDIR}/pre-fetch; \ fi + @${MAKE} ${.MAKEFLAGS} do-fetch +.if target(post-fetch) + @${MAKE} ${.MAKEFLAGS} post-fetch .endif - @${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE} + @if [ -f ${SCRIPTDIR}/post-fetch ]; then \ + env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ + WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ + FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ + DEPENDS="${DEPENDS}" \ + sh ${SCRIPTDIR}/post-fetch; \ + fi .endif -# package-name and package-depends are internal targets and really -# shouldn't be touched by anybody but the release engineers. +# Extract -# Nobody should want to override this unless PKGNAME is simply bogus. -.if !target(package-name) -package-name: -.if !defined(NO_PACKAGE) - @echo ${PKGNAME} +.if !target(extract) +extract: checksum ${EXTRACT_COOKIE} + +${EXTRACT_COOKIE}: + @${ECHO_MSG} "===> Extracting for ${PKGNAME}" +.if target(pre-extract) + @${MAKE} ${.MAKEFLAGS} pre-extract .endif + @if [ -f ${SCRIPTDIR}/pre-extract ]; then \ + env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ + WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ + FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ + DEPENDS="${DEPENDS}" \ + sh ${SCRIPTDIR}/pre-extract; \ + fi + @${MAKE} ${.MAKEFLAGS} do-extract +.if target(post-extract) + @${MAKE} ${.MAKEFLAGS} post-extract .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 \ - dir=`echo $$i | sed -e 's/.*://'`; \ - (cd $$dir ; ${MAKE} package-name package-depends); \ - done + @if [ -f ${SCRIPTDIR}/post-extract ]; then \ + env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ + WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ + FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ + DEPENDS="${DEPENDS}" \ + sh ${SCRIPTDIR}/post-extract; \ + fi + @${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE} .endif -.if !target(pre-package) -pre-package: - @${DO_NADA} -.endif +# Patch -.if !target(package) -package: install - @${MAKE} ${.MAKEFLAGS} pre-package - @${MAKE} ${.MAKEFLAGS} do-package -.endif +.if !target(patch) +patch: extract ${PATCH_COOKIE} -.if !target(repackage) -repackage: - @${MAKE} ${.MAKEFLAGS} pre-package - @${MAKE} ${.MAKEFLAGS} do-package +${PATCH_COOKIE}: + @${ECHO_MSG} "===> Patching for ${PKGNAME}" +.if target(pre-patch) + @${MAKE} ${.MAKEFLAGS} pre-patch .endif - -.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 ! mkdir -p ${PKGREPOSITORY}; then \ - ${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \ - exit 1; \ - fi; \ - fi; \ - fi; \ - ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; \ - if [ -d ${PACKAGES} ]; then \ - rm -f ${PACKAGES}/*/${PKGNAME}${PKG_SUFX}; \ - for cat in ${CATEGORIES}; do \ - if [ ! -d ${PACKAGES}/$$cat ]; then \ - if ! 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; \ - fi; \ + @if [ -f ${SCRIPTDIR}/pre-patch ]; then \ + env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ + WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ + FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ + DEPENDS="${DEPENDS}" \ + sh ${SCRIPTDIR}/pre-patch; \ fi + @${MAKE} ${.MAKEFLAGS} do-patch +.if target(post-patch) + @${MAKE} ${.MAKEFLAGS} post-patch .endif - -.if !target(depends) -depends: exec_depends lib_depends misc_depends - -exec_depends: -.if defined(EXEC_DEPENDS) -.if defined(NO_DEPENDS) -# Just print out messages - @for i in ${EXEC_DEPENDS}; do \ - prog=`echo $$i | sed -e 's/:.*//'`; \ - dir=`echo $$i | sed -e 's/.*://'`; \ - ${ECHO_MSG} "===> ${PKGNAME} depends on executable: $$prog ($$dir)"; \ - done -.else - @for i in ${EXEC_DEPENDS}; do \ - prog=`echo $$i | sed -e 's/:.*//'`; \ - dir=`echo $$i | sed -e 's/.*://'`; \ - if which -s "$$prog"; then \ - ${ECHO_MSG} "===> ${PKGNAME} depends on executable: $$prog - found"; \ - else \ - ${ECHO_MSG} "===> ${PKGNAME} depends on executable: $$prog - not found"; \ - ${ECHO_MSG} "===> Verifying build for $$prog in $$dir"; \ - if [ ! -d "$$dir" ]; then \ - ${ECHO_MSG} ">> No directory for $$prog. Skipping.."; \ - else \ - (cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \ - ${ECHO_MSG} "===> Returning to build of ${PKGNAME}"; \ - fi; \ - fi; \ - done -.endif -.else - @${DO_NADA} + @if [ -f ${SCRIPTDIR}/post-patch ]; then \ + env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ + WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ + FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ + DEPENDS="${DEPENDS}" \ + sh ${SCRIPTDIR}/post-patch; \ + fi + @${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE} .endif -lib_depends: -.if defined(LIB_DEPENDS) -.if defined(NO_DEPENDS) -# Just print out messages - @for i in ${LIB_DEPENDS}; do \ - lib=`echo $$i | sed -e 's/:.*//'`; \ - dir=`echo $$i | sed -e 's/.*://'`; \ - ${ECHO_MSG} "===> ${PKGNAME} depends on shared library: $$lib ($$dir)"; \ - done -.else - @for i in ${LIB_DEPENDS}; do \ - lib=`echo $$i | sed -e 's/:.*//'`; \ - dir=`echo $$i | sed -e 's/.*://'`; \ - if ldconfig -r | grep -q -e "-l$$lib"; then \ - ${ECHO_MSG} "===> ${PKGNAME} depends on shared library: $$lib - found"; \ - else \ - ${ECHO_MSG} "===> ${PKGNAME} depends on shared library: $$lib - not found"; \ - ${ECHO_MSG} "===> Verifying build for $$lib in $$dir"; \ - if [ ! -d "$$dir" ]; then \ - ${ECHO_MSG} ">> No directory for $$lib. Skipping.."; \ - else \ - (cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \ - ${ECHO_MSG} "===> Returning to build of ${PKGNAME}"; \ - fi; \ - fi; \ - done -.endif -.else - @${DO_NADA} -.endif +# Configure -misc_depends: -.if defined(DEPENDS) - @${ECHO_MSG} "===> ${PKGNAME} depends on: ${DEPENDS}" -.if !defined(NO_DEPENDS) - @for i in ${DEPENDS}; do \ - ${ECHO_MSG} "===> Verifying build for $$i"; \ - if [ ! -d $$i ]; then \ - ${ECHO_MSG} ">> No directory for $$i. Skipping.."; \ - else \ - (cd $$i; ${MAKE} ${.MAKEFLAGS} is_depended) ; \ - fi \ - done - @${ECHO_MSG} "===> Returning to build of ${PKGNAME}" +.if !target(configure) +configure: patch ${CONFIGURE_COOKIE} + +${CONFIGURE_COOKIE}: + @${ECHO_MSG} "===> Configuring for ${PKGNAME}" +.if target(pre-configure) + @${MAKE} ${.MAKEFLAGS} pre-configure .endif -.else - @${DO_NADA} + @if [ -f ${SCRIPTDIR}/pre-configure ]; then \ + env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ + WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ + FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ + DEPENDS="${DEPENDS}" \ + sh ${SCRIPTDIR}/pre-configure; \ + fi + @${MAKE} ${.MAKEFLAGS} do-configure +.if target(post-configure) + @${MAKE} ${.MAKEFLAGS} post-configure .endif - + @if [ -f ${SCRIPTDIR}/post-configure ]; then \ + env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ + WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ + FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ + DEPENDS="${DEPENDS}" \ + sh ${SCRIPTDIR}/post-configure; \ + fi + @${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE} .endif -.if !target(pre-build) -pre-build: - @${DO_NADA} -.endif +# Build .if !target(build) build: configure ${BUILD_COOKIE} ${BUILD_COOKIE}: @${ECHO_MSG} "===> Building for ${PKGNAME}" +.if target(pre-build) @${MAKE} ${.MAKEFLAGS} pre-build -.if defined(USE_GMAKE) - @(cd ${WRKSRC}; ${GMAKE} PREFIX=${PREFIX} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET}) -.else defined(USE_GMAKE) - @(cd ${WRKSRC}; ${MAKE} PREFIX=${PREFIX} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET}) +.endif + @if [ -f ${SCRIPTDIR}/pre-build ]; then \ + env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ + WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ + FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ + DEPENDS="${DEPENDS}" \ + sh ${SCRIPTDIR}/pre-build; \ + fi + @${MAKE} ${.MAKEFLAGS} do-build +.if target(post-build) + @${MAKE} ${.MAKEFLAGS} post-build .endif @if [ -f ${SCRIPTDIR}/post-build ]; then \ env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ DEPENDS="${DEPENDS}" \ - sh ${SCRIPTDIR}/post-build; \ + sh ${SCRIPTDIR}/post-build; \ fi @${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE} .endif -.if !target(pre-patch) -pre-patch: - @${DO_NADA} -.endif +# Install -.if !target(patch) -patch: extract ${PATCH_COOKIE} - -${PATCH_COOKIE}: - @${MAKE} ${.MAKEFLAGS} pre-patch -.if defined(PATCHFILES) - @${ECHO_MSG} "===> Applying distributed patches for ${PKGNAME}" -.if defined(PATCH_DEBUG) - @(cd ${DISTDIR}; \ - for i in ${PATCHFILES}; do \ - ${ECHO_MSG} "===> Applying distributed patch $$i" ; \ - case $$i in \ - *.Z|*.gz) \ - zcat $$i | ${PATCH} ${PATCH_DIST_ARGS}; \ - ;; \ - *) \ - ${PATCH} ${PATCH_DIST_ARGS} < $$i; \ - ;; \ - esac; \ - done) -.else - @(cd ${DISTDIR}; \ - for i in ${PATCHFILES}; do \ - case $$i in \ - *.Z|*.gz) \ - zcat $$i | ${PATCH} ${PATCH_DIST_ARGS}; \ - ;; \ - *) \ - ${PATCH} ${PATCH_DIST_ARGS} < $$i; \ - ;; \ - esac; \ - done) -.endif -.endif -.if defined(PATCH_DEBUG) - @if [ -d ${PATCHDIR} ]; then \ - ${ECHO_MSG} "===> Applying FreeBSD patches for ${PKGNAME}" ; \ - for i in ${PATCHDIR}/patch-*; do \ - ${ECHO_MSG} "===> Applying FreeBSD patch $$i" ; \ - ${PATCH} ${PATCH_ARGS} < $$i; \ - done; \ - fi - @${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE} -.else - @if [ -d ${PATCHDIR} ]; then \ - ${ECHO_MSG} "===> Applying FreeBSD patches for ${PKGNAME}" ; \ - for i in ${PATCHDIR}/patch-*; \ - do ${PATCH} ${PATCH_ARGS} < $$i; \ - done;\ - fi - @${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE} -.endif -.endif +.if !target(install) +install: build ${INSTALL_COOKIE} -.if !target(pre-configure) -pre-configure: - @${DO_NADA} +${INSTALL_COOKIE}: + @${ECHO_MSG} "===> Installing for ${PKGNAME}" +.if target(pre-install) + @${MAKE} ${.MAKEFLAGS} pre-install .endif - -.if !target(configure) -configure: depends patch ${CONFIGURE_COOKIE} - -${CONFIGURE_COOKIE}: - @${ECHO_MSG} "===> Configuring for ${PKGNAME}" - @${MAKE} ${.MAKEFLAGS} pre-configure - @if [ -f ${SCRIPTDIR}/pre-configure ]; then \ + @if [ -f ${SCRIPTDIR}/pre-install ]; then \ env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ DEPENDS="${DEPENDS}" \ - sh ${SCRIPTDIR}/pre-configure; \ + sh ${SCRIPTDIR}/pre-install; \ fi - @if [ -f ${SCRIPTDIR}/configure ]; then \ - env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ - WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ - FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ - DEPENDS="${DEPENDS}" \ - sh ${SCRIPTDIR}/configure; \ - fi -.if defined(HAS_CONFIGURE) - @(cd ${WRKSRC}; CC="${CC}" ac_cv_path_CC="${CC}" CFLAGS="${CFLAGS}" \ - INSTALL="/usr/bin/install -c -o ${BINOWN} -g ${BINGRP}" \ - INSTALL_PROGRAM="/usr/bin/install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \ - ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}) -.endif -.if defined(USE_IMAKE) -.if defined(USE_GMAKE) - @(cd ${WRKSRC}; ${XMKMF} && ${GMAKE} Makefiles) -.else - @(cd ${WRKSRC}; ${XMKMF} && ${MAKE} Makefiles) + @${MAKE} ${.MAKEFLAGS} do-install +.if target(post-install) + @${MAKE} ${.MAKEFLAGS} post-install .endif -.endif - @if [ -f ${SCRIPTDIR}/post-configure ]; then \ + @if [ -f ${SCRIPTDIR}/post-install ]; then \ env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ DEPENDS="${DEPENDS}" \ - sh ${SCRIPTDIR}/post-configure; \ + sh ${SCRIPTDIR}/post-install; \ fi - @${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE} + @${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE} +.endif + +# Reinstall +# +# This is a special target to re-run install + +.if !target(reinstall) +reinstall: pre-reinstall install + +pre-reinstall: + @rm -f ${INSTALL_COOKIE} .endif -.if !target(pre-fetch) -pre-fetch: +################################################################ +# Some more targets supplied for users' convenience +################################################################ + +# Cleaning up + +.if !target(pre-clean) +pre-clean: @${DO_NADA} .endif -.if !target(fetch) -fetch: pre-fetch - @if [ ! -d ${DISTDIR} ]; then mkdir -p ${DISTDIR}; fi - @(cd ${DISTDIR}; \ - for file in ${DISTFILES}; do \ - if [ ! -f $$file -a ! -f `basename $$file` ]; then \ - ${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \ - for site in ${MASTER_SITES}; do \ - ${ECHO_MSG} ">> Attempting to fetch from $${site}"; \ - if ${NCFTP} ${NCFTPFLAGS} $${site}$${file}; then \ - break; \ - fi \ - done; \ - if [ ! -f $$file -a ! -f `basename $$file` ]; then \ - ${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\ - ${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \ - exit 1; \ - fi; \ - fi \ - done) -.if defined(PATCHFILES) - @(cd ${DISTDIR}; \ - for file in ${PATCHFILES}; do \ - if [ ! -f $$file -a ! -f `basename $$file` ]; then \ - ${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \ - for site in ${PATCH_SITES}; do \ - ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \ - if ${NCFTP} ${NCFTPFLAGS} $${site}$${file}; then \ - break; \ - fi \ - done; \ - if [ ! -f $$file -a ! -f `basename $$file` ]; then \ - ${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\ - ${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \ - exit 1; \ - fi; \ - fi \ - done) +.if !target(clean) +clean: pre-clean + @${ECHO_MSG} "===> Cleaning for ${PKGNAME}" + @rm -f ${EXTRACT_COOKIE} ${CONFIGURE_COOKIE} ${INSTALL_COOKIE} \ + ${BUILD_COOKIE} ${PATCH_COOKIE} +.if !defined(NO_WRKDIR) + @rm -rf ${WRKDIR} .endif .endif +# Prints out a list of files to fetch (useful to do a batch fetch) + .if !target(fetch-list) fetch-list: @if [ ! -d ${DISTDIR} ]; then mkdir -p ${DISTDIR}; fi @@ -804,6 +816,8 @@ fetch-list: .endif .endif +# Checksumming utilities + .if !target(makesum) makesum: fetch @if [ ! -d ${FILESDIR} ]; then mkdir -p ${FILESDIR}; fi @@ -839,57 +853,218 @@ checksum: fetch fi .endif -.if !target(pre-extract) -pre-extract: - @${DO_NADA} +################################################################ +# The 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) + @echo ${PKGNAME} +.endif .endif -.if !target(extract) -# We need to depend on .extract_done rather than the presence of ${WRKDIR} -# because if the user interrupts the extract in the middle (and it's often -# a long procedure), we get tricked into thinking that we've got a good dist -# in ${WRKDIR}. -extract: fetch ${EXTRACT_COOKIE} +# Show (recursively) all the packages this package depends on. +.if !target(package-depends) +package-depends: + @for i in ${EXEC_DEPENDS} ${LIB_DEPENDS} ${DEPENDS}; do \ + dir=`echo $$i | sed -e 's/.*://'`; \ + (cd $$dir ; ${MAKE} package-name package-depends); \ + done +.endif -${EXTRACT_COOKIE}: - @${MAKE} ${.MAKEFLAGS} checksum pre-extract - @${ECHO_MSG} "===> Extracting for ${PKGNAME}" - @rm -rf ${WRKDIR} - @mkdir -p ${WRKDIR} -.if defined(EXTRACT_ONLY) - @for file in ${EXTRACT_ONLY}; do \ - if ! (cd ${WRKDIR};${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\ - then \ - exit 1; \ - fi \ +# Build a package + +.if !target(package) +package: install +.if target(pre-package) + @${MAKE} ${.MAKEFLAGS} pre-package +.endif + @${MAKE} ${.MAKEFLAGS} do-package +.endif + +# Build a package but don't check the cookie for installation + +.if !target(repackage) +repackage: +.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 ! mkdir -p ${PKGREPOSITORY}; then \ + ${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \ + exit 1; \ + fi; \ + fi; \ + fi; \ + ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; \ + if [ -d ${PACKAGES} ]; then \ + rm -f ${PACKAGES}/*/${PKGNAME}${PKG_SUFX}; \ + for cat in ${CATEGORIES}; do \ + if [ ! -d ${PACKAGES}/$$cat ]; then \ + if ! 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; \ + fi; \ + fi +.endif + +################################################################ +# Dependency checking +################################################################ + +.if !target(depends) +depends: exec_depends lib_depends misc_depends + +exec_depends: +.if defined(EXEC_DEPENDS) +.if defined(NO_DEPENDS) +# Just print out messages + @for i in ${EXEC_DEPENDS}; do \ + prog=`echo $$i | sed -e 's/:.*//'`; \ + dir=`echo $$i | sed -e 's/.*://'`; \ + ${ECHO_MSG} "===> ${PKGNAME} depends on executable: $$prog ($$dir)"; \ done .else - @for file in ${DISTFILES}; do \ - if ! (cd ${WRKDIR};${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\ - then \ - exit 1; \ - fi \ + @for i in ${EXEC_DEPENDS}; do \ + prog=`echo $$i | sed -e 's/:.*//'`; \ + dir=`echo $$i | sed -e 's/.*://'`; \ + if which -s "$$prog"; then \ + ${ECHO_MSG} "===> ${PKGNAME} depends on executable: $$prog - found"; \ + else \ + ${ECHO_MSG} "===> ${PKGNAME} depends on executable: $$prog - not found"; \ + ${ECHO_MSG} "===> Verifying build for $$prog in $$dir"; \ + if [ ! -d "$$dir" ]; then \ + ${ECHO_MSG} ">> No directory for $$prog. Skipping.."; \ + else \ + (cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \ + ${ECHO_MSG} "===> Returning to build of ${PKGNAME}"; \ + fi; \ + fi; \ done .endif - @${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE} +.else + @${DO_NADA} .endif -.if !target(pre-clean) -pre-clean: +lib_depends: +.if defined(LIB_DEPENDS) +.if defined(NO_DEPENDS) +# Just print out messages + @for i in ${LIB_DEPENDS}; do \ + lib=`echo $$i | sed -e 's/:.*//'`; \ + dir=`echo $$i | sed -e 's/.*://'`; \ + ${ECHO_MSG} "===> ${PKGNAME} depends on shared library: $$lib ($$dir)"; \ + done +.else + @for i in ${LIB_DEPENDS}; do \ + lib=`echo $$i | sed -e 's/:.*//'`; \ + dir=`echo $$i | sed -e 's/.*://'`; \ + if ldconfig -r | grep -q -e "-l$$lib"; then \ + ${ECHO_MSG} "===> ${PKGNAME} depends on shared library: $$lib - found"; \ + else \ + ${ECHO_MSG} "===> ${PKGNAME} depends on shared library: $$lib - not found"; \ + ${ECHO_MSG} "===> Verifying build for $$lib in $$dir"; \ + if [ ! -d "$$dir" ]; then \ + ${ECHO_MSG} ">> No directory for $$lib. Skipping.."; \ + else \ + (cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \ + ${ECHO_MSG} "===> Returning to build of ${PKGNAME}"; \ + fi; \ + fi; \ + done +.endif +.else @${DO_NADA} .endif -.if !target(clean) -clean: pre-clean - @${ECHO_MSG} "===> Cleaning for ${PKGNAME}" - @rm -f ${EXTRACT_COOKIE} ${CONFIGURE_COOKIE} ${INSTALL_COOKIE} \ - ${BUILD_COOKIE} ${PATCH_COOKIE} -.if !defined(NO_WRKDIR) - @rm -rf ${WRKDIR} +misc_depends: +.if defined(DEPENDS) + @${ECHO_MSG} "===> ${PKGNAME} depends on: ${DEPENDS}" +.if !defined(NO_DEPENDS) + @for i in ${DEPENDS}; do \ + ${ECHO_MSG} "===> Verifying build for $$i"; \ + if [ ! -d $$i ]; then \ + ${ECHO_MSG} ">> No directory for $$i. Skipping.."; \ + else \ + (cd $$i; ${MAKE} ${.MAKEFLAGS} is_depended) ; \ + fi \ + done + @${ECHO_MSG} "===> Returning to build of ${PKGNAME}" .endif +.else + @${DO_NADA} +.endif + .endif -# No pre-targets for depend or tags. It would be silly. +################################################################ +# Everything after here are internal targets and really +# shouldn't be touched by anybody but the release engineers. +################################################################ + +# This target generates an index entry suitable for aggregation into +# a large index. Format is: +# +# distribution-name|port-path|installation-prefix|comment| \ +# description-file|maintainer|categories|keywords +# +.if !target(describe) +describe: + @echo -n "${PKGNAME}|${.CURDIR}/${PKGNAME}|" + @echo -n "${PREFIX}|" + @if [ -f ${PKGDIR}/COMMENT ]; then \ + echo -n "`cat ${PKGDIR}/COMMENT`"; \ + else \ + echo -n "** No Description"; \ + fi + @if [ -f ${PKGDIR}/DESCR ]; then \ + echo -n "|${PKGDIR}/DESCR"; \ + else \ + echo -n "|/dev/null"; \ + fi + @echo -n "|${MAINTAINER}|${CATEGORIES}|${KEYWORDS}" + @echo "" +.endif + +# Fake installation of package so that user can pkg_delete it later. +# Also, make sure that an installed port is recognized correctly in +# accordance to the @pkgdep directive in the packing lists + +.if !target(fake-pkg) +.if !defined(NO_PACKAGE) +fake-pkg: + @if [ ! -f ${PKGDIR}/PLIST -o ! -f ${PKGDIR}/COMMENT -o ! -f ${PKGDIR}/DESCR ]; then echo "** Missing patch files for ${PKGNAME} - installation not recorded."; exit 1; fi + @if [ ! -d ${PKG_DBDIR} ]; then rm -f ${PKG_DBDIR}; mkdir -p ${PKG_DBDIR}; fi + @if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \ + ${ECHO_MSG} "===> Registering installation for ${PKGNAME}"; \ + mkdir -p ${PKG_DBDIR}/${PKGNAME}; \ + cp ${PKGDIR}/PLIST ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \ + cp ${PKGDIR}/DESCR ${PKG_DBDIR}/${PKGNAME}/+DESC; \ + cp ${PKGDIR}/COMMENT ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \ + else \ + ${ECHO_MSG} "===> ${PKGNAME} is already installed - perhaps an older version?"; \ + ${ECHO_MSG} " If so, you may wish to \`\`pkg_delete ${PKGNAME}'' and install"; \ + ${ECHO_MSG} " this port again to upgrade it properly."; \ + fi +.endif +.endif # Depend is generally meaningless for arbitrary ports, but if someone wants # one they can override this. This is just to catch people who've gotten into -- cgit v1.2.3