bsd.port.mk revision 2451
1# bsd.port.mk - 940820 Jordan K. Hubbard. 2# This file is in the public domain. 3# 4# $Id: bsd.port.mk,v 1.24 1994/09/01 18:03:37 jkh Exp $ 5 6# 7# Supported Variables and their behaviors: 8# 9# Variables that typically apply to all ports: 10# 11# PORTSDIR - The root of the ports tree (default: /usr/ports). 12# DISTDIR - Where to get gzip'd, tarballed copies of original sources 13# - (default: ${PORTSDIR}/distfiles. 14# PACKAGES - A top level directory where all packages go (rather than 15# - going someplace locally). (default: ${PORTSDIR}/packages). 16# GMAKE - Set to path of GNU make if not in $PATH (default: gmake). 17# XMKMF - Set to path of `xmkmf' if not in $PATH (default: xmkmf). 18# 19# Variables that typically apply to an individual port: 20# 21# WRKDIR - A temporary working directory that gets *clobbered* on clean. 22# WRKSRC - A subdirectory of ${WRKDIR} where the distribution actually 23# unpacks to. Defaults to ${WRKDIR}/${DISTNAME}. 24# DISTNAME - Name of port or distribution. 25# PATCHDIR - A directory containing required patches. 26# SCRIPTDIR - A directory containing auxilliary scripts. 27# FILESDIR - A directory containing any miscellaneous additional files. 28# PKGDIR - Package creation files. 29# 30# NO_EXTRACT - Use a dummy (do-nothing) extract target. 31# NO_CONFIGURE - Use a dummy (do-nothing) configure target. 32# NO_BUILD - Use a dummy (do-nothing) build target. 33# NO_PACKAGE - Use a dummy (do-nothing) package target. 34# NO_INSTALL - Use a dummy (do-nothing) install target. 35# USE_GMAKE - Says that the port uses gmake. 36# USE_IMAKE - Says that the port uses imake. 37# HAS_CONFIGURE - Says that the port has its own configure script. 38# CONFIGURE_ARGS - Pass these args to configure, if $HAS_CONFIGURE. 39# HOME_LOCATION - site/path name (or user's email address) describing 40# where this port came from or can be obtained if the 41# tarball is missing. 42# DEPENDS - A list of other ports this package depends on being 43# made first, relative to ${PORTSDIR} (e.g. x11/tk, lang/tcl, 44# etc). 45# 46# 47# Default targets and their behaviors: 48# 49# extract - Unpacks ${DISTDIR}/${DISTNAME}.tar.gz into ${WRKDIR}. 50# configure - Applys patches, if any, and runs either GNU configure, one 51# or more local configure scripts or nothing, depending on 52# what's available. 53# build - Actually compile the sources. 54# install - Install the results of a build. 55# package - Create a package from a build. 56# bundle - From an unextracted source tree, re-create tarballs. 57 58 59.if exists(${.CURDIR}/../Makefile.inc) 60.include "${.CURDIR}/../Makefile.inc" 61.endif 62 63GMAKE?= gmake 64NCFTP?= /usr/local/bin/ncftp 65 66# These need to be absolute since we don't know how deep in the ports 67# tree we are and thus can't go relative. They can, of course, be overridden 68# by individual Makefiles. 69PORTSDIR?= /usr/ports 70DISTDIR?= ${PORTSDIR}/distfiles 71PACKAGES?= ${PORTSDIR}/packages 72 73WRKDIR?= ${.CURDIR}/work 74WRKSRC?= ${WRKDIR}/${DISTNAME} 75PATCHDIR?= ${.CURDIR}/patches 76SCRIPTDIR?= ${.CURDIR}/scripts 77FILESDIR?= ${.CURDIR}/files 78PKGDIR?= ${.CURDIR}/pkg 79 80# Change these if you'd prefer to keep the cookies someplace else. 81EXTRACT_COOKIE?= ${.CURDIR}/.extract_done 82CONFIGURE_COOKIE?= ${.CURDIR}/.configure_done 83 84# How to do nothing. Override if you, for some strange reason, would rather 85# do something. 86DO_NADA?= echo -n 87 88# Miscellaneous overridable commands: 89EXTRACT_CMD?= tar 90EXTRACT_SUFX?= .tar.gz 91EXTRACT_ARGS?= -C ${WRKDIR} -xzf 92 93BUNDLE_CMD?= tar 94BUNDLE_ARGS?= -C ${WRKDIR} -czf 95 96PKG_CMD?= pkg_create 97PKG_ARGS?= -v -c ${PKGDIR}/COMMENT -d ${PKGDIR}/DESCR -f ${PKGDIR}/PLIST 98PKG_SUFX?= .tgz 99 100# Set no default value for this so we can easily detect its absence. 101#HOME_LOCATION?= <original site unknown> 102 103# Derived names so that they're easily overridable. 104DISTFILE?= ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX} 105PKGFILE?= ${PACKAGES}/${DISTNAME}${PKG_SUFX} 106 107.MAIN: all 108all: extract configure build 109 110# The following are used to create easy dummy targets for disabling some 111# bit of default target behavior you don't want. They still check to see 112# if the target exists, and if so don't do anything, since you might want 113# to set this globally for a group of ports in a Makefile.inc, but still 114# be able to override from an individual Makefile (since you can't _undefine_ 115# a variable in make!). 116.if defined(NO_EXTRACT) && !target(extract) 117extract: 118 @touch -f ${EXTRACT_COOKIE} 119.endif 120.if defined(NO_CONFIGURE) && !target(configure) 121configure: 122 @touch -f ${CONFIGURE_COOKIE} 123.endif 124.if defined(NO_BUILD) && !target(build) 125build: 126 @${DO_NADA} 127.endif 128.if defined(NO_PACKAGE) && !target(package) 129package: 130 @${DO_NADA} 131.endif 132.if defined(NO_INSTALL) && !target(install) 133install: 134 @${DO_NADA} 135.endif 136 137# More standard targets start here. 138 139.if !target(pre-install) 140pre-install: 141 @${DO_NADA} 142.endif 143 144.if !target(install) 145install: pre-install 146 @echo "===> Installing for ${DISTNAME}" 147.if defined(USE_GMAKE) 148 @(cd ${WRKSRC}; ${GMAKE} install) 149.else defined(USE_GMAKE) 150 @(cd ${WRKSRC}; ${MAKE} install) 151.endif 152.endif 153 154.if !target(pre-package) 155pre-package: 156 @${DO_NADA} 157.endif 158 159.if !target(package) 160package: pre-package 161# Makes some gross assumptions about a fairly simple package with no 162# install, require or deinstall scripts. Override the arguments with 163# PKG_ARGS if your package is anything but run-of-the-mill. 164 @if [ -d ${PKGDIR} ]; then \ 165 if [ -d ${PACKAGES} ]; then \ 166 echo "===> Building package for ${DISTNAME} in ${PACKAGES}"; \ 167 ${PKG_CMD} ${PKG_ARGS} ${PACKAGES}/${DISTNAME}${PKG_SUFX}; \ 168 else \ 169 echo "===> Building package for ${DISTNAME} in ${.CURDIR}"; \ 170 ${PKG_CMD} ${PKG_ARGS} ${DISTNAME}${PKG_SUFX}; \ 171 fi; \ 172 fi 173.endif 174 175.if !target(pre-build) 176pre-build: 177 @${DO_NADA} 178.endif 179 180.if !target(build) 181build: configure pre-build 182 @echo "===> Building for ${DISTNAME}" 183.if defined(DEPENDS) 184 @echo "===> ${DISTNAME} depends on: ${DEPENDS}" 185 @for i in $(DEPENDS); do \ 186 echo "===> Verifying build for $$i"; \ 187 if [ ! -d ${PORTSDIR}/$$i ]; then \ 188 echo ">> No directory for ${PORTSDIR}/$$i. Skipping.."; \ 189 else \ 190 (cd ${PORTSDIR}/$$i; ${MAKE}) ; \ 191 fi \ 192 done 193 @echo "===> Returning to build of ${DISTNAME}" 194.endif 195.if defined(USE_GMAKE) 196 @(cd ${WRKSRC}; ${GMAKE} all) 197.else defined(USE_GMAKE) 198 @(cd ${WRKSRC}; ${MAKE} all) 199.endif 200 @if [ -f ${SCRIPTDIR}/post-build ]; then \ 201 sh ${SCRIPTDIR}/post-build ${PORTSDIR} ${.CURDIR} ${WRKSRC}; \ 202 fi 203.endif 204 205.if !target(pre-configure) 206pre-configure: 207 @${DO_NADA} 208.endif 209 210.if !target(configure) 211# This is done with a .configure because configures are often expensive, 212# and you don't want it done again gratuitously when you're trying to get 213# a make of the whole tree to work. 214configure: pre-configure extract ${CONFIGURE_COOKIE} 215 216${CONFIGURE_COOKIE}: 217 @echo "===> Configuring for ${DISTNAME}" 218 @if [ -d ${PATCHDIR} ]; then \ 219 echo "===> Applying patches for ${DISTNAME}" ; \ 220 for i in ${PATCHDIR}/patch-*; do \ 221 patch -d ${WRKSRC} --quiet -E -p0 < $$i; \ 222 done; \ 223 fi 224# We have a small convention for our local configure scripts, which 225# is that ${PORTSDIR}, ${.CURDIR} and ${WRKSRC} get passed as 226# command-line arguments since all other methods are a little 227# problematic. 228 @if [ -f ${SCRIPTDIR}/pre-configure ]; then \ 229 sh ${SCRIPTDIR}/pre-configure ${PORTSDIR} ${.CURDIR} ${WRKSRC}; \ 230 fi 231 @if [ -f ${SCRIPTDIR}/configure ]; then \ 232 sh ${SCRIPTDIR}/configure ${PORTSDIR} ${.CURDIR} ${WRKSRC}; \ 233 fi 234.if defined(HAS_CONFIGURE) 235 @(cd ${WRKSRC}; ./configure ${CONFIGURE_ARGS}) 236.endif 237.if defined(USE_IMAKE) 238 @(cd ${WRKSRC}; ${XMKMF} && make Makefiles) 239.endif 240 @if [ -f ${SCRIPTDIR}/post-configure ]; then \ 241 sh ${SCRIPTDIR}/post-configure ${PORTSDIR} ${.CURDIR} ${WRKSRC}; \ 242 fi 243 @touch -f ${CONFIGURE_COOKIE} 244.endif 245 246.if !target(pre-bundle) 247pre-bundle: 248 @${DO_NADA} 249.endif 250 251.if !target(bundle) 252bundle: pre-bundle 253 @echo "===> Bundling for ${DISTNAME}" 254 @if [ ! -f ${EXTRACT_COOKIE} ]; then \ 255 echo ">> There doesn't appear to be a properly extracted"; \ 256 echo ">> distribution for ${DISTNAME}. Skipping.."; \ 257 exit 0; \ 258 fi 259 @if [ -f ${CONFIGURE_COOKIE} ]; then \ 260 echo ">> WARNING: This source has been configured and may"; \ 261 echo ">> produce a tainted distfile!"; \ 262 fi 263 ${BUNDLE_CMD} ${BUNDLE_ARGS} ${DISTFILE} ${DISTNAME} 264.endif 265 266.if !target(pre-extract) 267pre-extract: 268 @${DO_NADA} 269.endif 270 271.if !target(extract) 272# We need to depend on .extract_done rather than the presence of ${WRKDIR} 273# because if the user interrupts the extract in the middle (and it's often 274# a long procedure), we get tricked into thinking that we've got a good dist 275# in ${WRKDIR}. 276extract: pre-extract ${EXTRACT_COOKIE} 277 278${EXTRACT_COOKIE}: 279 @echo "===> Extracting for ${DISTNAME}" 280 @rm -rf ${WRKDIR} 281 @mkdir -p ${WRKDIR} 282 @if [ ! -f ${DISTFILE} ]; then \ 283 echo ">> Sorry, I can't seem to find: ${DISTFILE}"; \ 284 echo ">> on this system."; \ 285.if defined(HOME_LOCATION) 286 if [ -f ${NCFTP} ]; then \ 287 echo ">> Would you like me to fetch it from: ${HOME_LOCATION}";\ 288 echo -n ">> with ncftp? [y/n] "; \ 289 read ans; \ 290 if [ "$ans" = "y" ]; then \ 291 mkdir -p `dirname ${DISTFILE}`; \ 292 if cd `dirname ${DISTFILE}`; then \ 293 if ${NCFTP} ${HOME_LOCATION}; then \ 294 ${EXTRACT_CMD} ${EXTRACT_ARGS}; \ 295 else \ 296 echo ">> Couldn't fetch it - please retreive ${DISTFILE} manually and try again."; \ 297 exit 1; \ 298 fi \ 299 else \ 300 echo ">> Couldn't cd to `dirname ${DISTFILE}`. Please correct and try again."; \ 301 exit 1; \ 302 fi \ 303 else \ 304 echo ">> Please ensure ${DISTFILE} exists before trying again."; \ 305 exit 1; \ 306 fi \ 307 else \ 308 echo ">> Please fetch it from ${HOME_LOCATION} and try again.";\ 309 echo ">> Installing ${NCFTP} can also make this easier in the future."; \ 310 fi \ 311.else 312 echo ">> <original site unknown>"; \ 313 exit 1; \ 314.endif 315 fi 316 @${EXTRACT_CMD} ${EXTRACT_ARGS} ${DISTFILE} 317 @touch -f ${EXTRACT_COOKIE} 318.endif 319 320.if !target(pre-clean) 321pre-clean: 322 @${DO_NADA} 323.endif 324 325.if !target(clean) 326clean: pre-clean 327 @echo "===> Cleaning for ${DISTNAME}" 328 @rm -f ${EXTRACT_COOKIE} ${CONFIGURE_COOKIE} 329 @rm -rf ${WRKDIR} 330.endif 331 332# No pre-targets for depend or tags. It would be silly. 333 334# Depend is generally meaningless for arbitrary ports, but if someone wants 335# one they can override this. This is just to catch people who've gotten into 336# the habit of typing `make depend all install' as a matter of course. 337# 338.if !target(depend) 339depend: 340.endif 341 342# Same goes for tags 343.if !target(tags) 344tags: 345.endif 346