1# bsd.port.mk - 940820 Jordan K. Hubbard. 2# This file is in the public domain. 3# 4# $Id: bsd.port.mk,v 1.15 1994/08/22 13:25:33 jkh Exp $ 5 6# 7# Supported Variables and their behaviors: 8# 9# GMAKE - Set to path of GNU make if not in $PATH. 10# DISTDIR - Where to get gzip'd, tarballed copies of original sources. 11# DISTNAME - Name of package or distribution. 12# WRKDIR - A temporary working directory that gets *clobbered* on clean. 13# WRKSRC - A subdirectory of ${WRKDIR} where the distribution actually 14# unpacks to. Defaults to ${WRKDIR}/${DISTNAME}. 15# PATCHDIR - A directory containing required patches. 16# SCRIPTDIR - A directory containing auxilliary scripts. 17# FILESDIR - A directory containing any miscellaneous additional files. 18# PKGDIR - Package creation files. 19# 20# USE_GMAKE - Says that the package uses gmake. 21# HAS_CONFIGURE - Says that the package has its own configure script. 22# CONFIGURE_ARGS - Pass these args to configure, if $HAS_CONFIGURE. 23# HOME_LOCATION - site/path name (or user's email address) describing 24# where this package came from or can be obtained if the 25# tarball is missing. 26# DEPENDS - A list of other packages this package depends on being 27# made first. 28# 29# 30# Default targets and their behaviors: 31# 32# extract - Unpacks ${DISTDIR}/${DISTNAME}.tar.gz into ${WRKDIR}. 33# configure - Applys patches, if any, and runs either GNU configure, one 34# or more local configure scripts or nothing, depending on 35# what's available. 36# build - Actually compile the sources. 37# install - Install the results of a build. 38# package - Create a package from a build. 39# bundle - From an unextracted source tree, re-create tarballs. 40 41 42.if exists(${.CURDIR}/../Makefile.inc) 43.include "${.CURDIR}/../Makefile.inc" 44.endif 45 46GMAKE?= gmake 47 48# These need to be absolute since we don't know how deep in the ports 49# tree we are and thus can't go relative. It can, of course, be overridden 50# by individual Makefiles. 51PORTSDIR?= /usr/ports 52DISTDIR?= ${PORTSDIR}/distfiles 53PACKAGES?= ${PORTSDIR}/packages 54 55WRKDIR?= ${.CURDIR}/work 56WRKSRC?= ${WRKDIR}/${DISTNAME} 57PATCHDIR?= ${.CURDIR}/patches 58SCRIPTDIR?= ${.CURDIR}/scripts 59FILESDIR?= ${.CURDIR}/files 60PKGDIR?= ${.CURDIR}/pkg 61 62# Change these if you'd prefer to keep the cookies someplace else. 63EXTRACT_COOKIE?= ${.CURDIR}/.extract_done 64CONFIGURE_COOKIE?= ${.CURDIR}/.configure_done 65 66# Miscellaneous overridable commands: 67EXTRACT_CMD?= tar 68EXTRACT_SUFX?= .tar.gz 69EXTRACT_ARGS?= -C ${WRKDIR} -xzf 70 71BUNDLE_CMD?= tar 72BUNDLE_ARGS?= -C ${WRKDIR} -czf 73 74PKG_CMD?= pkg_create 75PKG_ARGS?= -v -c ${PKGDIR}/COMMENT -d ${PKGDIR}/DESCR -f ${PKGDIR}/PLIST 76PKG_SUFX?= .tgz 77 78HOME_LOCATION?= <original site unknown> 79 80.MAIN: all 81all: extract configure build 82 83# Try to make whomever's install target maintain the same semantics. 84install:: pre-install 85 86.if !target(pre-install) 87pre-install: 88 @echo -n 89.endif 90 91.if !target(install) 92install: 93 @echo "===> Installing for ${DISTNAME}" 94.if defined(USE_GMAKE) 95 @(cd ${WRKSRC}; ${GMAKE} install) 96.else defined(USE_GMAKE) 97 @(cd ${WRKSRC}; ${MAKE} install) 98.endif 99.endif 100 101# Try to make whomever's package target maintain the same semantics. 102package:: pre-package 103 104.if !target(pre-package) 105pre-package: 106 @echo -n 107.endif 108 109.if !target(package) 110package: 111# Makes some gross assumptions about a fairly simple package with no 112# install, require or deinstall scripts. Override the arguments with 113# PKG_ARGS if your package is anything but run-of-the-mill. 114 @if [ -d ${PKGDIR} ]; then \ 115 if [ -d ${PACKAGES} ]; then \ 116 echo "===> Building package for ${DISTNAME} in ${PACKAGES}"; \ 117 ${PKG_CMD} ${PKG_ARGS} ${PACKAGES}/${DISTNAME}${PKG_SUFX}; \ 118 else \ 119 echo "===> Building package for ${DISTNAME} in ${.CURDIR}"; \ 120 ${PKG_CMD} ${PKG_ARGS} ${DISTNAME}${PKG_SUFX}; \ 121 fi; \ 122 fi 123.endif 124 125# Try to make whomever's build target maintain the same semantics. 126build:: pre-build 127 128.if !target(pre-build) 129pre-build: 130 @echo -n 131.endif 132 133.if !target(build) 134build: configure 135 @echo "===> Building for ${DISTNAME}" 136.if defined(DEPENDS) 137 @echo "===> ${DISTNAME} depends on: ${DEPENDS}" 138 @for i in $(DEPENDS); do \ 139 echo "===> Verifying build for $$i"; \ 140 if [ ! -d ${PORTSDIR}/$$i ]; then \ 141 echo ">> No directory for ${PORTSDIR}/$$i. Skipping.."; \ 142 else \ 143 (cd ${PORTSDIR}/$$i; ${MAKE}) ; \ 144 fi \ 145 done 146 @echo "===> Returning to build of ${DISTNAME}" 147.endif 148.if defined(USE_GMAKE) 149 @(cd ${WRKSRC}; ${GMAKE} all) 150.else defined(USE_GMAKE) 151 @(cd ${WRKSRC}; ${MAKE} all) 152.endif 153.endif 154 155# No pre-configure stuff since that's handled differently. We wrap 156# pre-configure and post-configure scripts around what is generally 157# an originally-provided script file, and easier to pre/post install for 158# than change. 159 160.if !target(configure) 161# This is done with a .configure because configures are often expensive, 162# and you don't want it done again gratuitously when you're trying to get 163# a make of the whole tree to work. 164configure: extract ${CONFIGURE_COOKIE} 165 166${CONFIGURE_COOKIE}: 167 @echo "===> Configuring for ${DISTNAME}" 168 @if [ -d ${PATCHDIR} ]; then \ 169 echo "===> Applying patches for ${DISTNAME}" ; \ 170 for i in ${PATCHDIR}/patch-*; do \ 171 patch -d ${WRKSRC} --quiet -E -p0 < $$i; \ 172 done; \ 173 fi 174# We have a small convention for our local configure scripts, which 175# is that ${PORTSDIR}, ${.CURDIR} and ${WRKSRC} get passed as 176# command-line arguments since all other methods are a little 177# problematic. 178 @if [ -f ${SCRIPTDIR}/pre-configure ]; then \ 179 sh ${SCRIPTDIR}/pre-configure ${PORTSDIR} ${.CURDIR} ${WRKSRC}; \ 180 fi 181 @if [ -f ${SCRIPTDIR}/configure ]; then \ 182 sh ${SCRIPTDIR}/configure ${PORTSDIR} ${.CURDIR} ${WRKSRC}; \ 183 fi 184.if defined(HAS_CONFIGURE) 185 @(cd ${WRKSRC}; ./configure ${CONFIGURE_ARGS}) 186.endif 187 @if [ -f ${SCRIPTDIR}/post-configure ]; then \ 188 sh ${SCRIPTDIR}/post-configure ${PORTSDIR} ${.CURDIR} ${WRKSRC}; \ 189 fi 190 @touch -f ${CONFIGURE_COOKIE} 191.endif 192 193# Try to make whomever's bundle target maintain the same semantics. 194bundle:: pre-bundle 195 196.if !target(pre-bundle) 197pre-bundle: 198 @echo -n 199.endif 200 201.if !target(bundle) 202bundle: 203 @echo "===> Bundling for ${DISTNAME}" 204 @if [ ! -f ${EXTRACT_COOKIE} ]; then \ 205 echo ">> There doesn't appear to be a properly extracted"; \ 206 echo ">> distribution for ${DISTNAME}. Skipping.."; \ 207 exit 0; \ 208 fi 209 @if [ -f ${CONFIGURE_COOKIE} ]; then \ 210 echo ">> WARNING: This source has been configured and may"; \ 211 echo ">> produce a tainted distfile!"; \ 212 fi 213 ${BUNDLE_CMD} ${BUNDLE_ARGS} ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX} \ 214 ${DISTNAME} 215.endif 216 217# Try to make whomever's extract target maintain the same semantics. 218extract:: pre-extract 219 220.if !target(pre-extract) 221pre-extract: 222 @echo -n 223.endif 224 225.if !target(extract) 226# We need to depend on .extract_done rather than the presence of ${WRKDIR} 227# because if the user interrupts the extract in the middle (and it's often 228# a long procedure), we get tricked into thinking that we've got a good dist 229# in ${WRKDIR}. 230extract: ${EXTRACT_COOKIE} 231 232${EXTRACT_COOKIE}: 233 @echo "===> Extracting for ${DISTNAME}" 234 @rm -rf ${WRKDIR} 235 @mkdir -p ${WRKDIR} 236 @if [ ! -f ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX} ]; then \ 237 echo ">> Sorry, can't find: ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX}"; \ 238 echo ">> Please obtain this file from:"; \ 239 echo ">> ${HOME_LOCATION}"; \ 240 echo ">>before proceeding."; \ 241 exit 1; \ 242 fi 243 @${EXTRACT_CMD} ${EXTRACT_ARGS} ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX} 244 @touch -f ${EXTRACT_COOKIE} 245.endif 246 247# No pre-targets for clean, depend or tags. It would be silly. 248 249.if !target(clean) 250clean: 251 @echo "===> Cleaning for ${DISTNAME}" 252 @rm -f ${EXTRACT_COOKIE} ${CONFIGURE_COOKIE} 253 @rm -rf ${WRKDIR} 254.endif 255 256# Depend is generally meaningless for arbitrary ports, but if someone wants 257# one they can override this. This is just to catch people who've gotten into 258# the habit of typing `make depend all install' as a matter of course. 259# 260.if !target(depend) 261depend: 262.endif 263 264# Same goes for tags 265.if !target(tags) 266tags: 267.endif 268