bsd.port.mk revision 5024
1# -*- mode: Fundamental; tab-width: 4; -*- 2# 3# bsd.port.mk - 940820 Jordan K. Hubbard. 4# This file is in the public domain. 5# 6# $Id: bsd.port.mk,v 1.74 1994/11/25 17:04:02 ache Exp $ 7# 8# Please view me with 4 column tabs! 9 10 11# Supported Variables and their behaviors: 12# 13# Variables that typically apply to all ports: 14# 15# PORTSDIR - The root of the ports tree (default: /usr/ports). 16# DISTDIR - Where to get gzip'd, tarballed copies of original sources 17# (default: ${PORTSDIR}/distfiles). 18# PREFIX - Where to install things in general (default: /usr/local). 19# MASTER_SITES - Primary location(s) for distribution files if not found 20# locally. 21# MASTER_SITE_OVERRIDE - If set, override the MASTER_SITES setting with this 22# value. 23# MASTER_SITE_FREEBSD - If set, only use the FreeBSD master repository for 24# MASTER_SITES. 25# PACKAGES - A top level directory where all packages go (rather than 26# going locally to each port). (default: ${PORTSDIR}/packages). 27# GMAKE - Set to path of GNU make if not in $PATH (default: gmake). 28# XMKMF - Set to path of `xmkmf' if not in $PATH (default: xmkmf). 29# 30# Variables that typically apply to an individual port: 31# 32# WRKDIR - A temporary working directory that gets *clobbered* on clean. 33# WRKSRC - A subdirectory of ${WRKDIR} where the distribution actually 34# unpacks to. (Default: ${WRKDIR}/${DISTNAME} unless 35# NO_WRKSUBDIR is set, in which case simply ${WRKDIR}). 36# DISTNAME - Name of port or distribution. 37# DISTFILES - Name(s) of archive file(s) containing distribution 38# (default: ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX}). 39# PKGNAME - Name of the package file to create if the DISTNAME 40# isn't really relevant for the port/package 41# EXTRACT_ONLY - If defined, a subset of ${DISTFILES} you want to 42# actually extract. 43# PATCHDIR - A directory containing any required patches. 44# SCRIPTDIR - A directory containing any auxilliary scripts. 45# FILESDIR - A directory containing any miscellaneous additional files. 46# PKGDIR - A direction containing any package creation files. 47# 48# NO_EXTRACT - Use a dummy (do-nothing) extract target. 49# NO_CONFIGURE - Use a dummy (do-nothing) configure target. 50# NO_BUILD - Use a dummy (do-nothing) build target. 51# NO_PACKAGE - Use a dummy (do-nothing) package target. 52# NO_INSTALL - Use a dummy (do-nothing) install target. 53# NO_WRKSUBDIR - Assume port unpacks directly into ${WRKDIR}. 54# NO_WRKDIR - There's no work directory at all; port does this someplace 55# else. 56# NO_DEPENDS - Don't verify build of dependencies. 57# USE_GMAKE - Says that the port uses gmake. 58# USE_IMAKE - Says that the port uses imake. 59# NO_INSTALL_MANPAGES - For imake ports that don't like the install.man 60 target. 61# HAS_CONFIGURE - Says that the port has its own configure script. 62# GNU_CONFIGURE - Set if you are using GNU configure (optional). 63# CONFIGURE_ARGS - Pass these args to configure, if $HAS_CONFIGURE. 64# IS_INTERACTIVE - Set this if your port needs to interact with the user 65# during a build. User can then decide to skip this port by 66# setting BATCH, or compile ONLY interactive ports by setting 67# INTERACTIVE. 68# DEPENDS - A list of other ports this package depends on being 69# made first, relative to ${PORTSDIR} (e.g. x11/tk, lang/tcl, 70# etc). 71# EXTRACT_CMD - Command for extracting archive (default: tar). 72# EXTRACT_SUFX - Suffix for archive names (default: .tar.gz). 73# EXTRACT_ARGS - Arguments to ${EXTRACT_CMD} (default: -C ${WRKDIR} -xzf). 74# 75# NCFTP - Full path to ncftp command if not in $PATH (default: ncftp). 76# NCFTPFLAGS - Arguments to ${NCFTP} (default: -N). 77# 78# 79# Default targets and their behaviors: 80# 81# fetch - Retrieves ${DISTFILES} into ${DISTDIR} as necessary. 82# extract - Unpacks ${DISTFILES} into ${WRKDIR}. 83# configure - Applies patches, if any, and runs either GNU configure, one 84# or more local configure scripts or nothing, depending on 85# what's available. 86# patch - Apply any provided patches to the source. 87# build - Actually compile the sources. 88# install - Install the results of a build. 89# reinstall - Install the results of a build, ignoring "already installed" 90# flag. 91# package - Create a package from a build. 92# 93# Default sequence for "all" is: fetch extract configure build 94 95.if exists(${.CURDIR}/../Makefile.inc) 96.include "${.CURDIR}/../Makefile.inc" 97.endif 98 99# These need to be absolute since we don't know how deep in the ports 100# tree we are and thus can't go relative. They can, of course, be overridden 101# by individual Makefiles. 102PORTSDIR?= ${DESTDIR}/usr/ports 103X11BASE?= /usr/X11R6 104DISTDIR?= ${PORTSDIR}/distfiles 105PACKAGES?= ${PORTSDIR}/packages 106.if !defined(NO_WRKDIR) 107WRKDIR?= ${.CURDIR}/work 108.else 109WRKDIR?= ${.CURDIR} 110.endif 111.if defined(NO_WRKSUBDIR) 112WRKSRC?= ${WRKDIR} 113.else 114WRKSRC?= ${WRKDIR}/${DISTNAME} 115.endif 116PATCHDIR?= ${.CURDIR}/patches 117SCRIPTDIR?= ${.CURDIR}/scripts 118FILESDIR?= ${.CURDIR}/files 119PKGDIR?= ${.CURDIR}/pkg 120.if defined(USE_IMAKE) 121PREFIX?= ${X11BASE} 122.else 123PREFIX?= /usr/local 124.endif 125 126.if exists(${PORTSDIR}/../Makefile.inc) 127.include "${PORTSDIR}/../Makefile.inc" 128.endif 129 130 131# Change these if you'd prefer to keep the cookies someplace else. 132EXTRACT_COOKIE?= ${WRKDIR}/.extract_done 133CONFIGURE_COOKIE?= ${WRKDIR}/.configure_done 134INSTALL_COOKIE?= ${WRKDIR}/.install_done 135BUILD_COOKIE?= ${WRKDIR}/.build_done 136PATCH_COOKIE?= ${WRKDIR}/.patch_done 137 138# How to do nothing. Override if you, for some strange reason, would rather 139# do something. 140DO_NADA?= echo -n 141 142# Miscellaneous overridable commands: 143GMAKE?= gmake 144XMKMF?= xmkmf 145MAKE_FLAGS?= -f 146MAKEFILE?= Makefile 147 148NCFTP?= ncftp 149NCFTPFLAGS?= -N 150 151TOUCH?= touch 152TOUCH_FLAGS?= -f 153 154PATCH?= patch 155PATCH_STRIP?= -p0 156.if defined(PATCH_DEBUG) 157PATCH_ARGS?= -d ${WRKSRC} -E ${PATCH_STRIP} 158.else 159PATCH_ARGS?= -d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP} 160.endif 161 162EXTRACT_CMD?= tar 163EXTRACT_SUFX?= .tar.gz 164EXTRACT_ARGS?= -C ${WRKDIR} -xzf 165 166PKG_CMD?= pkg_create 167PKG_ARGS?= -v -c ${PKGDIR}/COMMENT -d ${PKGDIR}/DESCR -f ${PKGDIR}/PLIST -p ${PREFIX} 168PKG_SUFX?= .tgz 169 170ALL_TARGET?= all 171INSTALL_TARGET?= install 172 173.if defined(MASTER_SITE_FREEBSD) 174MASTER_SITE_OVERRIDE= ftp://freebsd.cdrom.com/pub/FreeBSD/FreeBSD-current/ports/distfiles/ 175.endif 176 177# I guess we're in the master distribution business! :) As we gain mirror 178# sites for distfiles, add them to this list. 179.if !defined(MASTER_SITE_OVERRIDE) 180MASTER_SITES+= ftp://freebsd.cdrom.com/pub/FreeBSD/FreeBSD-current/ports/distfiles/ 181.else 182MASTER_SITES= ${MASTER_SITE_OVERRIDE} 183.endif 184 185# Derived names so that they're easily overridable. 186DISTFILES?= ${DISTNAME}${EXTRACT_SUFX} 187PKGNAME?= ${DISTNAME} 188 189.if exists(${PACKAGES}) 190PKGFILE?= ${PACKAGES}/${PKGNAME}${PKG_SUFX} 191.else 192PKGFILE?= ${PKGNAME}${PKG_SUFX} 193.endif 194 195.if defined(GNU_CONFIGURE) 196CONFIGURE_ARGS?= --prefix=${PREFIX} 197HAS_CONFIGURE= yes 198.endif 199 200.MAIN: all 201 202# If we're in BATCH mode and the port is interactive, or we're in 203# interactive mode and the port is non-interactive, skip all the important 204# targets. The reason we have two modes is that one might want to leave 205# a build in BATCH mode running overnight, then come back in the morning 206# and do _only_ the interactive ones that required your intervention. 207# This allows you to do both. 208# 209.if (defined(IS_INTERACTIVE) && defined(BATCH)) || (!defined(IS_INTERACTIVE) && defined(INTERACTIVE)) 210all: 211 @${DO_NADA} 212pre-build: 213 @${DO_NADA} 214build: 215 @${DO_NADA} 216pre-install: 217 @${DO_NADA} 218install: 219 @${DO_NADA} 220pre-fetch: 221 @${DO_NADA} 222fetch: 223 @${DO_NADA} 224pre-configure: 225 @${DO_NADA} 226configure: 227 @${DO_NADA} 228.endif 229 230.if !target(all) 231all: extract configure build 232.endif 233 234.if !target(is_depended) 235is_depended: all install 236.endif 237 238# The following are used to create easy dummy targets for disabling some 239# bit of default target behavior you don't want. They still check to see 240# if the target exists, and if so don't do anything, since you might want 241# to set this globally for a group of ports in a Makefile.inc, but still 242# be able to override from an individual Makefile (since you can't _undefine_ 243# a variable in make!). 244.if defined(NO_EXTRACT) && !target(extract) 245extract: 246 @${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE} 247.endif 248.if defined(NO_CONFIGURE) && !target(configure) 249configure: 250 @${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE} 251.endif 252.if defined(NO_BUILD) && !target(build) 253build: 254 @${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE} 255.endif 256.if defined(NO_PACKAGE) && !target(package) 257package: 258 @${DO_NADA} 259.endif 260.if defined(NO_INSTALL) && !target(install) 261install: 262 @${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE} 263.endif 264.if defined(NO_PATCH) && !target(patch) 265patch: 266 @${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE} 267.endif 268 269# More standard targets start here. 270 271.if !target(reinstall) 272reinstall: pre-reinstall install 273 274pre-reinstall: 275 @rm -f ${INSTALL_COOKIE} 276.endif 277 278.if !target(pre-install) 279pre-install: 280 @${DO_NADA} 281.endif 282 283.if !target(install) 284install: ${INSTALL_COOKIE} 285 286${INSTALL_COOKIE}: 287 @echo "===> Installing for ${DISTNAME}" 288 @${MAKE} ${.MAKEFLAGS} pre-install 289.if defined(USE_GMAKE) 290 @(cd ${WRKSRC}; ${GMAKE} PREFIX=${PREFIX} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET}) 291.else defined(USE_GMAKE) 292 @(cd ${WRKSRC}; ${MAKE} PREFIX=${PREFIX} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET}) 293.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES) 294 @(cd ${WRKSRC}; ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man) 295.endif 296.endif 297 @${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE} 298.endif 299 300.if !target(pre-package) 301pre-package: 302 @${DO_NADA} 303.endif 304 305.if !target(package) 306package: pre-package 307# Makes some gross assumptions about a fairly simple package with no 308# install, require or deinstall scripts. Override the arguments with 309# PKG_ARGS if your package is anything but run-of-the-mill. 310 @if [ -d ${PKGDIR} ]; then \ 311 echo "===> Building package for ${DISTNAME}"; \ 312 ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; \ 313 fi 314.endif 315 316.if !target(depends) 317depends: 318.if defined(DEPENDS) 319 @echo "===> ${DISTNAME} depends on: ${DEPENDS}" 320.if !defined(NO_DEPENDS) 321 @for i in ${DEPENDS}; do \ 322 echo "===> Verifying build for $$i"; \ 323 if [ ! -d $$i ]; then \ 324 echo ">> No directory for $$i. Skipping.."; \ 325 else \ 326 (cd $$i; ${MAKE} ${.MAKEFLAGS} is_depended) ; \ 327 fi \ 328 done 329 @echo "===> Returning to build of ${DISTNAME}" 330.endif 331.endif 332.endif 333 334.if !target(pre-build) 335pre-build: 336 @${DO_NADA} 337.endif 338 339.if !target(build) 340build: configure pre-build depends ${BUILD_COOKIE} 341 342${BUILD_COOKIE}: 343 @echo "===> Building for ${DISTNAME}" 344.if defined(USE_GMAKE) 345 @(cd ${WRKSRC}; ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET}) 346.else defined(USE_GMAKE) 347 @(cd ${WRKSRC}; ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET}) 348.endif 349 @if [ -f ${SCRIPTDIR}/post-build ]; then \ 350 env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ 351 WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ 352 FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ 353 DEPENDS="${DEPENDS}" \ 354 sh ${SCRIPTDIR}/post-build; \ 355 fi 356 @${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE} 357.endif 358 359.if !target(pre-patch) 360pre-patch: 361 @${DO_NADA} 362.endif 363 364.if !target(patch) 365patch: pre-patch ${PATCH_COOKIE} 366 367${PATCH_COOKIE}: 368 @if [ -d ${PATCHDIR} ]; then \ 369.if defined(PATCH_DEBUG) 370 echo "===> Applying patches for ${DISTNAME}" ; \ 371 for i in ${PATCHDIR}/patch-*; \ 372 echo "===> Applying patch $$i" ; \ 373 do ${PATCH} ${PATCH_ARGS} < $$i; \ 374 done; \ 375 fi 376.else 377 echo "===> Applying patches for ${DISTNAME}" ; \ 378 for i in ${PATCHDIR}/patch-*; \ 379 do ${PATCH} {$PATCH_ARGS} < $$i; \ 380 done;\ 381 fi 382 @${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE} 383.endif 384 385.if !target(pre-configure) 386pre-configure: 387 @${DO_NADA} 388.endif 389 390.if !target(configure) 391configure: extract patch ${CONFIGURE_COOKIE} 392 393${CONFIGURE_COOKIE}: 394 @echo "===> Configuring for ${DISTNAME}" 395 @${MAKE} ${.MAKEFLAGS} pre-configure 396 @if [ -f ${SCRIPTDIR}/pre-configure ]; then \ 397 env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ 398 WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ 399 FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ 400 DEPENDS="${DEPENDS}" \ 401 sh ${SCRIPTDIR}/pre-configure; \ 402 fi 403 @if [ -f ${SCRIPTDIR}/configure ]; then \ 404 env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ 405 WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ 406 FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ 407 DEPENDS="${DEPENDS}" \ 408 sh ${SCRIPTDIR}/configure; \ 409 fi 410.if defined(HAS_CONFIGURE) 411 @(cd ${WRKSRC}; ./configure ${CONFIGURE_ARGS}) 412.endif 413.if defined(USE_IMAKE) 414.if defined(USE_GMAKE) 415 @(cd ${WRKSRC}; ${XMKMF} && ${GMAKE} Makefiles) 416.else 417 @(cd ${WRKSRC}; ${XMKMF} && ${MAKE} Makefiles) 418.endif 419.endif 420 @if [ -f ${SCRIPTDIR}/post-configure ]; then \ 421 env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \ 422 WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \ 423 FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \ 424 DEPENDS="${DEPENDS}" \ 425 sh ${SCRIPTDIR}/post-configure; \ 426 fi 427 @${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE} 428.endif 429 430.if !target(pre-fetch) 431pre-fetch: 432 @${DO_NADA} 433.endif 434 435.if !target(fetch) 436fetch: pre-fetch 437 @if [ ! -d ${DISTDIR} ]; then mkdir -p ${DISTDIR}; fi 438 @(cd ${DISTDIR}; \ 439 for file in ${DISTFILES}; do \ 440 if [ ! -f $$file ]; then \ 441 echo ">> $$file doesn't seem to exist on this system."; \ 442 echo ">> Attempting to fetch it from a master site."; \ 443 for site in ${MASTER_SITES}; do \ 444 if ${NCFTP} ${NCFTPFLAGS} $${site}$${file}; then \ 445 break; \ 446 fi \ 447 done; \ 448 if [ ! -f $$file ]; then \ 449 echo ">> Couldn't fetch it - please try to retreive this";\ 450 echo ">> port manually into ${DISTDIR} and try again."; \ 451 exit 1; \ 452 fi; \ 453 fi \ 454 done) 455.endif 456 457.if !target(pre-extract) 458pre-extract: 459 @${DO_NADA} 460.endif 461 462.if !target(extract) 463# We need to depend on .extract_done rather than the presence of ${WRKDIR} 464# because if the user interrupts the extract in the middle (and it's often 465# a long procedure), we get tricked into thinking that we've got a good dist 466# in ${WRKDIR}. 467extract: fetch pre-extract ${EXTRACT_COOKIE} 468 469${EXTRACT_COOKIE}: 470 @echo "===> Extracting for ${DISTNAME}" 471 @rm -rf ${WRKDIR} 472 @mkdir -p ${WRKDIR} 473.if defined(EXTRACT_ONLY) 474 @for file in ${EXTRACT_ONLY}; do \ 475 ${EXTRACT_CMD} ${EXTRACT_ARGS} ${DISTDIR}/$$file ; \ 476 done 477.else 478 @for file in ${DISTFILES}; do \ 479 ${EXTRACT_CMD} ${EXTRACT_ARGS} ${DISTDIR}/$$file ; \ 480 done 481.endif 482 @${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE} 483.endif 484 485.if !target(pre-clean) 486pre-clean: 487 @${DO_NADA} 488.endif 489 490.if !target(clean) 491clean: pre-clean 492 @echo "===> Cleaning for ${DISTNAME}" 493 @rm -f ${EXTRACT_COOKIE} ${CONFIGURE_COOKIE} ${INSTALL_COOKIE} \ 494 ${BUILD_COOKIE} ${PATCH_COOKIE} 495.if !defined(NO_WRKDIR) 496 @rm -rf ${WRKDIR} 497.endif 498.endif 499 500# No pre-targets for depend or tags. It would be silly. 501 502# Depend is generally meaningless for arbitrary ports, but if someone wants 503# one they can override this. This is just to catch people who've gotten into 504# the habit of typing `make depend all install' as a matter of course. 505# 506.if !target(depend) 507depend: 508.endif 509 510# Same goes for tags 511.if !target(tags) 512tags: 513.endif 514