[BACK]Return to bsd.pkg.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / mk

Annotation of pkgsrc/mk/bsd.pkg.mk, Revision 1.1540.2.8

1.1540.2.8! tv          1: #      $NetBSD$
1.1       agc         2: #
1.95      mrg         3: # This file is in the public domain.
1.1       agc         4: #
1.95      mrg         5: # This file is derived from bsd.port.mk - 940820 Jordan K. Hubbard.
1.1       agc         6: #
1.1540.2.5  tv          7: # Please see the pkgsrc/doc/guide manual for details on the
1.1540.2.1  tv          8: # variables used in this make file template.
1.1       agc         9: #
1.1540.2.1  tv         10:
                     11: ############################################################################
                     12: # Include any preferences, if not already included, and common definitions
                     13: ############################################################################
1.197     hubertf    14:
1.272     tv         15: .include "../../mk/bsd.prefs.mk"
1.1537    jlam       16: .include "../../mk/bsd.hacks.mk"
                     17:
1.1540.2.1  tv         18: # _PKG_PHASES_WRKDIR is an ordered list of phases which require ${WRKDIR}
                     19: # to exist.  _PKG_PHASES_ALL also includes the phases from before ${WRKDIR}
                     20: # is created.  These macros are used below mainly in .for loops.
                     21:
                     22: _PKG_PHASES_ALL=       fetch checksum ${_PKG_PHASES_WRKDIR}
                     23: _PKG_PHASES_WRKDIR=    depends extract patch tools wrapper \
                     24:                        configure build test install package
                     25:
                     26: # PATH is recalculated below, so save its original incarnation here.
                     27: .if !defined(_PATH_ORIG)
                     28: _PATH_ORIG:=           ${PATH}
                     29: MAKEFLAGS+=            _PATH_ORIG=${_PATH_ORIG:Q}
                     30: .endif
                     31:
                     32: ############################################################################
                     33: # Transform package Makefile variables and set defaults
                     34: ############################################################################
1.567     fredb      35:
1.1540.2.1  tv         36: CHECK_SHLIBS?=         YES     # run check-shlibs after install
1.272     tv         37: CLEANDEPENDS?=         NO
1.317     hubertf    38: DEINSTALLDEPENDS?=     NO      # add -R to pkg_delete
1.1540.2.1  tv         39: MKCRYPTO?=             YES     # build crypto packages by default
                     40: NOCLEAN?=              NO      # don't clean up after update
1.327     rh         41: REINSTALL?=            NO      # reinstall upon update
1.636     jlam       42: SHLIB_HANDLING?=       YES     # do automatic shared lib handling
1.1540.2.1  tv         43:
1.1540.2.5  tv         44: ##### Variant spellings
1.1540.2.1  tv         45:
                     46: .if defined(LICENCE) && !defined(LICENSE)
                     47: LICENSE=               ${LICENCE}
                     48: .endif
                     49: .if defined(ACCEPTABLE_LICENCES) && !defined(ACCEPTABLE_LICENSES)
                     50: ACCEPTABLE_LICENSES=   ${ACCEPTABLE_LICENCES}
                     51: .endif
                     52:
1.1540.2.5  tv         53: ##### PKGBASE, PKGNAME[_NOREV], PKGVERSION
1.5       hubertf    54:
1.460     mycroft    55: PKGBASE?=              ${PKGNAME:C/-[^-]*$//}
                     56: PKGVERSION?=           ${PKGNAME:C/^.*-//}
1.1498    jlam       57: .if defined(PKGREVISION) && !empty(PKGREVISION) && (${PKGREVISION} != "0")
                     58: .  if defined(PKGNAME)
                     59: PKGNAME_NOREV:=                ${PKGNAME}
                     60: PKGNAME:=              ${PKGNAME}nb${PKGREVISION}
                     61: .  else
                     62: PKGNAME?=              ${DISTNAME}nb${PKGREVISION}
                     63: PKGNAME_NOREV=         ${DISTNAME}
                     64: .  endif
                     65: .else
                     66: PKGNAME?=              ${DISTNAME}
                     67: PKGNAME_NOREV=         ${PKGNAME}
                     68: .endif
1.459     mycroft    69:
1.1540.2.5  tv         70: ##### PLIST
1.1540.2.1  tv         71:
                     72: .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
                     73: PLIST_TYPE?=           dynamic
                     74: .endif
                     75: PLIST_TYPE?=           static
                     76:
                     77: .if !defined(PLIST_SRC)
                     78: .  if exists(${PKGDIR}/PLIST.common)
                     79: PLIST_SRC+=            ${PKGDIR}/PLIST.common
                     80: .  endif
                     81: .  if exists(${PKGDIR}/PLIST.${OPSYS})
                     82: PLIST_SRC+=            ${PKGDIR}/PLIST.${OPSYS}
                     83: .  elif exists(${PKGDIR}/PLIST)
                     84: PLIST_SRC+=            ${PKGDIR}/PLIST
                     85: .  endif
                     86: .  if exists(${PKGDIR}/PLIST.common_end)
                     87: PLIST_SRC+=            ${PKGDIR}/PLIST.common_end
                     88: .  endif
                     89: .endif # !PLIST_SRC
1.851     jlam       90:
1.1540.2.5  tv         91: ##### Others
1.1540.2.1  tv         92:
                     93: _DISTDIR?=             ${DISTDIR}/${DIST_SUBDIR}
                     94: BUILD_DEFS?=           # empty
                     95: BUILD_DEPENDS?=                # empty
1.1540.2.7  tv         96: BUILD_TARGET?=         all
1.1540.2.1  tv         97: DEPENDS?=              # empty
                     98: DESCR_SRC?=            ${PKGDIR}/DESCR
                     99: DIGEST_ALGORITHM?=     SHA1
                    100: DISTFILES?=            ${DISTNAME}${EXTRACT_SUFX}
                    101: DISTINFO_FILE?=                ${PKGDIR}/distinfo
                    102: COMMENT?=              (no description)
                    103: CONFIGURE_DIRS?=       ${WRKSRC}
                    104: CONFIGURE_SCRIPT?=     ./configure
                    105: EXTRACT_ONLY?=         ${DISTFILES}
                    106: EXTRACT_SUFX?=         .tar.gz
1.1540.2.5  tv        107: INSTALL_DIRS?=         ${BUILD_DIRS}
                    108: INSTALL_MAKE_FLAGS?=   ${MAKE_FLAGS}
1.1540.2.1  tv        109: INSTALL_TARGET?=       install
1.999     agc       110: INTERACTIVE_STAGE?=    none
1.1540.2.1  tv        111: MAINTAINER?=           tech-pkg@NetBSD.org
                    112: MAKE_FLAGS?=           # empty
                    113: MAKEFILE?=             Makefile
                    114: PKG_SUFX?=             .tgz
                    115: PKGFILE?=              ${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
                    116: PKGREPOSITORY?=                ${PACKAGES}/${PKGREPOSITORYSUBDIR}
                    117: PKGREPOSITORYSUBDIR?=  All
                    118: PKGWILDCARD?=          ${PKGBASE}-[0-9]*
                    119: SVR4_PKGNAME?=         ${PKGNAME}
                    120: USE_DIGEST?=           YES
                    121: USE_GNU_TOOLS?=                # empty
                    122: WRKSRC?=               ${WRKDIR}/${DISTNAME}
                    123:
                    124: BUILD_DEFS_FIXED+=     PKGPATH
                    125: BUILD_DEFS_FIXED+=     OPSYS OS_VERSION MACHINE_ARCH MACHINE_GNU_ARCH
                    126: BUILD_DEFS_FIXED+=     CPPFLAGS CFLAGS FFLAGS LDFLAGS
                    127: BUILD_DEFS_FIXED+=     CONFIGURE_ENV CONFIGURE_ARGS
                    128: BUILD_DEFS_FIXED+=     OBJECT_FMT LICENSE RESTRICTED
                    129: BUILD_DEFS_FIXED+=     NO_SRC_ON_FTP NO_SRC_ON_CDROM
                    130: BUILD_DEFS_FIXED+=     NO_BIN_ON_FTP NO_BIN_ON_CDROM
                    131: BUILD_DEFS_FIXED+=     ${OSVERSION_SPECIFIC:DOSVERSION_SPECIFIC}
                    132:
1.1540.2.5  tv        133: ##### Non-overridable constants
1.1540.2.1  tv        134:
                    135: # Latest versions of tools required for correct pkgsrc operation.
                    136: DIGEST_REQD=           20010302
                    137: PKGTOOLS_REQD=         ${_OPSYS_PKGTOOLS_REQD:U20030918}
                    138:
                    139: DDIR=                  ${WRKDIR}/.DDIR
                    140: DESCR=                 ${WRKDIR}/.DESCR
                    141: DLIST=                 ${WRKDIR}/.DLIST
                    142: PLIST=                 ${WRKDIR}/.PLIST
                    143:
                    144: # Files to create for versioning and build information
                    145: BUILD_VERSION_FILE=    ${WRKDIR}/.build_version
                    146: BUILD_INFO_FILE=       ${WRKDIR}/.build_info
                    147:
                    148: # Files containing size of pkg w/o and w/ all required pkgs
                    149: SIZE_PKG_FILE=         ${WRKDIR}/.SizePkg
                    150: SIZE_ALL_FILE=         ${WRKDIR}/.SizeAll
                    151:
                    152: # File to denote "no deletion of a package"
                    153: PRESERVE_FILE=         ${WRKDIR}/.PRESERVE
                    154:
                    155: .for targ in ${_PKG_PHASES_WRKDIR}
                    156: ${targ}_COOKIE=                ${WRKDIR}/.${targ}_done
                    157: .endfor
                    158:
1.1540.2.5  tv        159: ##### Transform USE_* into dependencies
1.1540.2.1  tv        160:
                    161: .include "../../mk/bsd.pkg.use.mk"
                    162:
                    163: ############################################################################
                    164: # Sanity checks
                    165: ############################################################################
                    166:
                    167: # Fail-safe in the case of circular dependencies
                    168: .if defined(_PKGSRC_DEPS) && defined(PKGNAME) && !empty(_PKGSRC_DEPS:M${PKGNAME})
                    169: PKG_FAIL_REASON+=      "Circular dependency detected"
                    170: .endif
1.800     jlam      171:
1.1252    jlam      172: # PKG_INSTALLATION_TYPE can only be one of two values: "pkgviews" or
                    173: # "overwrite".
                    174: .if (${PKG_INSTALLATION_TYPE} != "pkgviews") && \
                    175:     (${PKG_INSTALLATION_TYPE} != "overwrite")
                    176: PKG_FAIL_REASON+=      "PKG_INSTALLATION_TYPE must be \`\`pkgviews'' or \`\`overwrite''."
                    177: .endif
                    178:
                    179: .if empty(PKG_INSTALLATION_TYPES:M${PKG_INSTALLATION_TYPE})
                    180: PKG_FAIL_REASON+=      "This package doesn't support PKG_INSTALLATION_TYPE=${PKG_INSTALLATION_TYPE}."
                    181: .endif
                    182:
                    183: .if (${PLIST_TYPE} != "dynamic") && (${PLIST_TYPE} != "static")
                    184: PKG_FAIL_REASON+=      "PLIST_TYPE must be \`\`dynamic'' or \`\`static''."
                    185: .endif
                    186:
                    187: .if (${PKG_INSTALLATION_TYPE} == "overwrite") && (${PLIST_TYPE} != "static")
                    188: PKG_FAIL_REASON+=      "PLIST_TYPE must be \`\`static'' for \`\`overwrite'' packages."
                    189: .endif
                    190:
1.1540.2.1  tv        191: # Check that we are using up-to-date pkg_* tools with this file.
                    192: .if !defined(NO_PKGTOOLS_REQD_CHECK)
                    193: .  if ${PKGTOOLS_VERSION} < ${PKGTOOLS_REQD}
                    194: PKG_FAIL_REASON+='Error: The package tools installed on this system are out of date.'
                    195: PKG_FAIL_REASON+='The installed package tools are dated ${PKGTOOLS_VERSION:C|(....)(..)(..)|\1/\2/\3|} and you must update'
                    196: PKG_FAIL_REASON+='them to at least ${PKGTOOLS_REQD:C|(....)(..)(..)|\1/\2/\3|} using the following command:'
                    197: PKG_FAIL_REASON+=''
                    198: PKG_FAIL_REASON+='     cd ${PKGSRCDIR}/pkgtools/pkg_install && ${MAKE} clean && ${MAKE} install'
1.1339    jlam      199: .  endif
1.1540.2.1  tv        200: .endif # NO_PKGTOOLS_REQD_CHECK
1.1252    jlam      201:
1.1540.2.7  tv        202: .if defined(ALL_TARGET)
                    203: PKG_FAIL_REASON+='ALL_TARGET is deprecated and must be replaced with BUILD_TARGET.'
                    204: .endif
                    205:
1.1540.2.1  tv        206: .if defined(NO_WRKSUBDIR)
                    207: PKG_FAIL_REASON+='NO_WRKSUBDIR has been deprecated - please replace it with an explicit'
                    208: PKG_FAIL_REASON+='assignment of WRKSRC= $${WRKDIR}'
                    209: .endif # NO_WRKSUBDIR
1.1252    jlam      210:
1.820     jlam      211: # We need to make sure the buildlink-x11 package is not installed since it
1.1027    jlam      212: # breaks builds that use imake.
                    213: .if defined(USE_IMAKE)
1.820     jlam      214: .  if exists(${LOCALBASE}/lib/X11/config/buildlinkX11.def) || \
                    215:       exists(${X11BASE}/lib/X11/config/buildlinkX11.def)
1.1102    schmonz   216: PKG_FAIL_REASON+= "${PKGNAME} uses imake, but the buildlink-x11 package was found." \
1.820     jlam      217:         "    Please deinstall it (pkg_delete buildlink-x11)."
                    218: .  endif
1.1027    jlam      219: .endif # USE_IMAKE
1.131     tv        220:
1.1540.2.1  tv        221: .if !defined(CATEGORIES) || !defined(DISTNAME)
                    222: PKG_FAIL_REASON+='CATEGORIES and DISTNAME are mandatory.'
1.1246    jlam      223: .endif
                    224:
1.1540.2.1  tv        225: .if defined(LIB_DEPENDS)
                    226: PKG_FAIL_REASON+='LIB_DEPENDS is deprecated and must be replaced with DEPENDS.'
1.338     kim       227: .endif
1.1015    jlam      228:
1.1540.2.1  tv        229: .if defined(PKG_PATH)
                    230: PKG_FAIL_REASON+='Please unset PKG_PATH before doing pkgsrc work!'
1.1015    jlam      231: .endif
                    232:
1.1540.2.1  tv        233: .if defined(MASTER_SITE_SUBDIR)
                    234: PKG_FAIL_REASON+='MASTER_SITE_SUBDIR is deprecated and must be replaced with MASTER_SITES.'
1.522     wiz       235: .endif
                    236:
1.1540.2.1  tv        237: .if defined(PATCH_SITE_SUBDIR)
                    238: PKG_FAIL_REASON+='PATCH_SITE_SUBDIR is deprecated and must be replaced with PATCH_SITES.'
1.758     jlam      239: .endif
1.986     schmonz   240:
1.1540.2.1  tv        241: .if defined(ONLY_FOR_ARCHS) || defined(NOT_FOR_ARCHS) \
                    242:        || defined(ONLY_FOR_OPSYS) || defined(NOT_FOR_OPSYS)
                    243: PKG_FAIL_REASON+='ONLY/NOT_FOR_ARCHS/OPSYS are deprecated and must be replaced with ONLY/NOT_FOR_PLATFORM.'
                    244: .endif
1.1539    tv        245:
1.1540.2.1  tv        246: .if (${PKGSRC_LOCKTYPE} == "sleep" || ${PKGSRC_LOCKTYPE} == "once")
1.1540.2.5  tv        247: .  if !defined(OBJHOSTNAME)
1.1540.2.1  tv        248: PKG_FAIL_REASON+='PKGSRC_LOCKTYPE needs OBJHOSTNAME defined.'
1.1540.2.5  tv        249: .  elif !exists(${SHLOCK})
1.1540.2.1  tv        250: PKG_FAIL_REASON+='The ${SHLOCK} utility does not exist, and is necessary for locking.'
                    251: PKG_FAIL_REASON+='Please "${MAKE} install" in ../../pkgtools/shlock.'
1.1540.2.5  tv        252: .  endif
1.94      agc       253: .endif
1.272     tv        254:
1.1381    jlam      255: #
1.1540.2.1  tv        256: # Many ways to disable a package.
                    257: #
                    258: # Ignore packages that can't be resold if building for a CDROM.
                    259: #
                    260: # Don't build a package if it's restricted and we don't want to
                    261: # get into that.
                    262: #
                    263: # Don't build any package that utilizes strong cryptography, for
                    264: # when the law of the land forbids it.
                    265: #
                    266: # Don't attempt to build packages against X if we don't have X.
                    267: #
                    268: # Don't build a package if it's broken.
                    269: #
1.1536    sketch    270:
1.1540.2.1  tv        271: .if (defined(NO_BIN_ON_CDROM) && defined(FOR_CDROM))
                    272: PKG_FAIL_REASON+= "${PKGNAME} may not be placed in binary form on a CDROM:" \
                    273:          "    "${NO_BIN_ON_CDROM:Q}
1.1252    jlam      274: .endif
1.1540.2.1  tv        275: .if (defined(NO_SRC_ON_CDROM) && defined(FOR_CDROM))
                    276: PKG_FAIL_REASON+= "${PKGNAME} may not be placed in source form on a CDROM:" \
                    277:          "    "${NO_SRC_ON_CDROM:Q}
                    278: .endif
                    279: .if (defined(RESTRICTED) && defined(NO_RESTRICTED))
                    280: PKG_FAIL_REASON+= "${PKGNAME} is restricted:" \
                    281:         "    "${RESTRICTED:Q}
1.1199    grant     282: .endif
1.1540.2.1  tv        283: .if !(${MKCRYPTO} == "YES" || ${MKCRYPTO} == yes)
                    284: .  if defined(CRYPTO)
                    285: PKG_FAIL_REASON+= "${PKGNAME} may not be built, because it utilizes strong cryptography"
                    286: .  endif
1.1199    grant     287: .endif
1.1540.2.1  tv        288: .if defined(USE_X11) && !exists(${X11BASE})
                    289: PKG_FAIL_REASON+= "${PKGNAME} uses X11, but ${X11BASE} not found"
1.1217    grant     290: .endif
1.1540.2.1  tv        291: .if defined(BROKEN)
                    292: PKG_FAIL_REASON+= "${PKGNAME} is marked as broken:" ${BROKEN:Q}
1.1528    recht     293: .endif
1.1209    grant     294:
1.1540.2.1  tv        295: .if defined(LICENSE)
                    296: .  ifdef ACCEPTABLE_LICENSES
                    297: .    for _lic in ${ACCEPTABLE_LICENSES}
                    298: .      if ${LICENSE} == "${_lic}"
                    299: _ACCEPTABLE=   yes
                    300: .      endif   # LICENSE == _lic
                    301: .    endfor    # _lic
                    302: .  endif       # ACCEPTABLE_LICENSES
                    303: .  ifndef _ACCEPTABLE
                    304: PKG_FAIL_REASON+= "${PKGNAME} has an unacceptable license: ${LICENSE}." \
                    305:         "    To view the license, enter \"${MAKE} show-license\"." \
                    306:         "    To indicate acceptance, add this line to your /etc/mk.conf:" \
                    307:         "    ACCEPTABLE_LICENSES+=${LICENSE}"
                    308: .  endif       # _ACCEPTABLE
                    309: .endif         # LICENSE
1.1462    jschauma  310:
1.1540.2.1  tv        311: # Define __PLATFORM_OK only if the OS matches the pkg's allowed list.
                    312: .if defined(ONLY_FOR_PLATFORM) && !empty(ONLY_FOR_PLATFORM)
                    313: .  for __tmp__ in ${ONLY_FOR_PLATFORM}
                    314: .    if ${MACHINE_PLATFORM:M${__tmp__}} != ""
                    315: __PLATFORM_OK?=        yes
                    316: .    endif     # MACHINE_PLATFORM
                    317: .  endfor      # __tmp__
                    318: .else          # !ONLY_FOR_PLATFORM
                    319: __PLATFORM_OK?=        yes
                    320: .endif         # ONLY_FOR_PLATFORM
                    321: .for __tmp__ in ${NOT_FOR_PLATFORM}
                    322: .  if ${MACHINE_PLATFORM:M${__tmp__}} != ""
                    323: .    undef __PLATFORM_OK
                    324: .  endif       # MACHINE_PLATFORM
                    325: .endfor                # __tmp__
                    326: .if !defined(__PLATFORM_OK)
                    327: PKG_SKIP_REASON+= "${PKGNAME} is not available for ${MACHINE_PLATFORM}"
                    328: .endif         # !__PLATFORM_OK
1.1295    grant     329:
1.1540.2.1  tv        330: .if !defined(NO_SKIP)
                    331: .  if defined(PKG_FAIL_REASON) || defined(PKG_SKIP_REASON)
                    332: _PKG_SKIPPED=  # defined
                    333: .  endif
1.1295    grant     334: .endif
1.1       agc       335:
1.1540.2.1  tv        336: ############################################################################
                    337: # Set up build environment
                    338: ############################################################################
1.1488    jlam      339:
1.1540.2.1  tv        340: .if !defined(_PKG_SKIPPED)
1.1488    jlam      341:
1.1540.2.1  tv        342: # Allow variables to be set on a per-OS basis
                    343: OPSYSVARS+=    CFLAGS CPPFLAGS CXXFLAGS FFLAGS LDFLAGS LIBS
                    344: .  for var in ${OPSYSVARS:O}
                    345: .    if defined(${var}.${OPSYS})
                    346: ${var}+=       ${${var}.${OPSYS}}
                    347: .    elif defined(${var}.*)
                    348: ${var}+=       ${${var}.*}
                    349: .    endif
1.1488    jlam      350: .  endfor
1.1       agc       351:
1.1540.2.1  tv        352: CPPFLAGS+=     ${CPP_PRECOMP_FLAGS}
                    353: DEPENDS+=      ${USE_USERADD:D${_USER_DEPENDS}}
                    354: DEPENDS+=      ${USE_GROUPADD:D${_USER_DEPENDS}}
                    355:
                    356: .if !empty(USE_BUILDLINK3:M[nN][oO])
                    357: LDFLAGS+=      ${COMPILER_RPATH_FLAG}${LOCALBASE}/lib
                    358: LDFLAGS+=      -L${LOCALBASE}/lib
1.1493    schmonz   359: .endif
1.1489    schmonz   360:
1.1540.2.1  tv        361: ALL_ENV+=      CC=${CC:Q}
                    362: ALL_ENV+=      CFLAGS=${CFLAGS:Q}
                    363: ALL_ENV+=      CPPFLAGS=${CPPFLAGS:Q}
                    364: ALL_ENV+=      CXX=${CXX:Q}
                    365: ALL_ENV+=      CXXFLAGS=${CXXFLAGS:Q}
                    366: ALL_ENV+=      COMPILER_RPATH_FLAG=${COMPILER_RPATH_FLAG:Q}
                    367: ALL_ENV+=      FFLAGS=${FFLAGS:Q}
                    368: ALL_ENV+=      LDFLAGS=${LDFLAGS:Q}
                    369: ALL_ENV+=      LINKER_RPATH_FLAG=${LINKER_RPATH_FLAG:Q}
                    370: ALL_ENV+=      PATH=${PATH:Q}:${LOCALBASE}/bin:${X11BASE}/bin
                    371: ALL_ENV+=      PREFIX=${PREFIX}
                    372:
                    373: MAKE_ENV+=     ${ALL_ENV}
                    374: MAKE_ENV+=     ${NO_EXPORT_CPP:D:UCPP=${CPP:Q}}
                    375: MAKE_ENV+=     LINK_ALL_LIBGCC_HACK=${LINK_ALL_LIBGCC_HACK:Q}
                    376: MAKE_ENV+=     LOCALBASE=${LOCALBASE}
                    377: MAKE_ENV+=     NO_WHOLE_ARCHIVE_FLAG=${NO_WHOLE_ARCHIVE_FLAG:Q}
                    378: MAKE_ENV+=     WHOLE_ARCHIVE_FLAG=${WHOLE_ARCHIVE_FLAG:Q}
                    379: MAKE_ENV+=     X11BASE=${X11BASE}
                    380: MAKE_ENV+=     X11PREFIX=${X11PREFIX}
                    381:
                    382: # Constants to provide a consistent environment for packages using
                    383: # BSD-style Makefiles.
                    384: MAKE_ENV+=     MAKECONF=${PKGMAKECONF:U/dev/null}
                    385: MAKE_ENV+=     OBJECT_FMT=${OBJECT_FMT:Q}
                    386: MAKE_ENV+=     ${USETOOLS:DUSETOOLS=${USETOOLS:Q}}
                    387:
                    388: SCRIPTS_ENV+=  ${ALL_ENV}
                    389: SCRIPTS_ENV+=  _PKGSRCDIR=${_PKGSRCDIR}
                    390: SCRIPTS_ENV+=  ${BATCH:DBATCH=yes}
                    391: SCRIPTS_ENV+=  CURDIR=${.CURDIR}
                    392: SCRIPTS_ENV+=  DEPENDS=${DEPENDS:Q}
                    393: SCRIPTS_ENV+=  DISTDIR=${DISTDIR}
                    394: SCRIPTS_ENV+=  FILESDIR=${FILESDIR}
                    395: SCRIPTS_ENV+=  LOCALBASE=${LOCALBASE}
                    396: SCRIPTS_ENV+=  PATCHDIR=${PATCHDIR}
                    397: SCRIPTS_ENV+=  PKGSRCDIR=${PKGSRCDIR}
                    398: SCRIPTS_ENV+=  SCRIPTDIR=${SCRIPTDIR}
                    399: SCRIPTS_ENV+=  VIEWBASE=${VIEWBASE}
                    400: SCRIPTS_ENV+=  WRKDIR=${WRKDIR}
                    401: SCRIPTS_ENV+=  WRKSRC=${WRKSRC}
                    402: SCRIPTS_ENV+=  X11BASE=${X11BASE}
1.240     agc       403:
1.1540.2.1  tv        404: # Set PLIST_SUBST to substitute "${variable}" to "value" in PLIST
                    405: PLIST_SUBST+=  CHGRP=${CHGRP:Q}
                    406: PLIST_SUBST+=  CHMOD=${CHMOD:Q}
                    407: PLIST_SUBST+=  CHOWN=${CHOWN:Q}
                    408: PLIST_SUBST+=  LN=${LN:Q}
                    409: PLIST_SUBST+=  LOCALBASE=${LOCALBASE}
                    410: PLIST_SUBST+=  LOWER_VENDOR=${LOWER_VENDOR}
                    411: PLIST_SUBST+=  LOWER_OPSYS=${LOWER_OPSYS}
                    412: PLIST_SUBST+=  LOWER_OS_VERSION=${LOWER_OS_VERSION}
                    413: PLIST_SUBST+=  MACHINE_ARCH=${MACHINE_ARCH}
                    414: PLIST_SUBST+=  MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH}
                    415: PLIST_SUBST+=  MACHINE_GNU_PLATFORM=${MACHINE_GNU_PLATFORM}
                    416: PLIST_SUBST+=  MKDIR=${MKDIR:Q}
                    417: PLIST_SUBST+=  OPSYS=${OPSYS}
                    418: PLIST_SUBST+=  OS_VERSION=${OS_VERSION}
                    419: PLIST_SUBST+=  PKGBASE=${PKGBASE}
                    420: PLIST_SUBST+=  PKGNAME=${PKGNAME_NOREV}
                    421: PLIST_SUBST+=  PKGLOCALEDIR=${PKGLOCALEDIR}
                    422: PLIST_SUBST+=  PKGVERSION=${PKGVERSION:C/nb[0-9]*$//}
                    423: PLIST_SUBST+=  QMAILDIR=${QMAILDIR} # XXXTV is this used?
                    424: PLIST_SUBST+=  RM=${RM:Q}
                    425: PLIST_SUBST+=  RMDIR=${RMDIR:Q}
                    426: PLIST_SUBST+=  SVR4_PKGNAME=${SVR4_PKGNAME}
                    427: PLIST_SUBST+=  TRUE=${TRUE:Q}
                    428: PLIST_SUBST+=  VIEWBASE=${VIEWBASE}
                    429: PLIST_SUBST+=  X11BASE=${X11BASE}
                    430: PLIST_SUBST+=  X11PREFIX=${X11PREFIX}
                    431:
                    432: # Automatically increase process limit where necessary for building.
                    433: .  if defined(UNLIMIT_RESOURCES)
                    434: .    for res in ${UNLIMIT_RESOURCES}
                    435: _ULIMIT_CMD+=  ${ULIMIT_CMD_${res}:D${ULIMIT_CMD_${res}} ; }
                    436: .    endfor
1.789     hubertf   437: .  endif
1.436     fredb     438:
1.1540.2.5  tv        439: # if automatic manual page compression is done by the package according
                    440: # to MANZ's value, set MANCOMPRESSED if MANZ is set
                    441: .  if defined(MANCOMPRESSED_IF_MANZ) && defined(MANZ)
                    442: MANCOMPRESSED= yes
                    443: MAKE_ENV+=     MANZ=${MANZ}
                    444: .  endif
                    445:
                    446: # CONF_DEPENDS notes a dependency where the config directory for the
                    447: # package matches the dependency's config directory.  CONF_DEPENDS is
                    448: # only meaningful if ${PKG_INSTALLATION_TYPE} == "pkgviews".
                    449: #
                    450: CONF_DEPENDS?=         # empty
                    451: .  if !empty(CONF_DEPENDS)
                    452: USE_PKGINSTALL=                YES
                    453: .  endif
                    454:
1.1540.2.1  tv        455: .endif # !_PKG_SKIPPED
1.221     agc       456:
1.1540.2.1  tv        457: ############################################################################
                    458: # Debug support
                    459: ############################################################################
1.221     agc       460:
                    461: # Debugging levels for this file, dependent on PKG_DEBUG_LEVEL definition
                    462: # 0 == normal, default, quiet operation
                    463: # 1 == all shell commands echoed before invocation
                    464: # 2 == shell "set -x" operation
                    465: PKG_DEBUG_LEVEL?=      0
                    466: _PKG_SILENT=           @
1.1058    jlam      467: _PKG_DEBUG=            # empty
                    468: _PKG_DEBUG_SCRIPT=     # empty
1.221     agc       469:
                    470: .if ${PKG_DEBUG_LEVEL} > 0
1.1058    jlam      471: _PKG_SILENT=           # empty
1.221     agc       472: .endif
                    473:
                    474: .if ${PKG_DEBUG_LEVEL} > 1
                    475: _PKG_DEBUG=            set -x;
1.1058    jlam      476: _PKG_DEBUG_SCRIPT=     ${SH} -x
1.57      hubertf   477: .endif
                    478:
1.1540.2.1  tv        479: ############################################################################
                    480: # External tools
                    481: ############################################################################
1.161     agc       482:
1.1540.2.1  tv        483: # top part not skipped by _PKG_SKIPPED
1.57      hubertf   484:
1.1540.2.1  tv        485: # Used to print all the '===>' style prompts - override this to turn them off.
                    486: ECHO_MSG?=             ${ECHO}
1.1       agc       487:
1.1540.2.1  tv        488: # Define SMART_MESSAGES in /etc/mk.conf for messages giving the tree
                    489: # of dependencies for building, and the current target.
                    490: .ifdef SMART_MESSAGES
                    491: _PKGSRC_IN?=           ===> ${.TARGET} [${PKGNAME}${_PKGSRC_DEPS}] ===
1.663     wiz       492: .endif
1.1540.2.1  tv        493: _PKGSRC_IN?=           ===
1.663     wiz       494:
1.1540.2.1  tv        495: DO_NADA?=              ${TRUE} # deprecated; for compatibility only
                    496: SHCOMMENT?=            ${ECHO_MSG} >/dev/null '***'
                    497: TOUCH_FLAGS?=          -f
1.1114    grant     498:
1.1540.2.1  tv        499: FETCH_BEFORE_ARGS+=    ${PASSIVE_FETCH:D-p}
                    500:
                    501: .if !defined(_PKG_SKIPPED)
                    502:
                    503: INSTALL_DATA?=                 ${INSTALL} ${COPY} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE}
                    504: INSTALL_DATA_DIR?=     ${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m ${PKGDIRMODE}
                    505: INSTALL_GAME?=         ${INSTALL} ${COPY} ${_STRIPFLAG_INSTALL} -o ${GAMEOWN} -g ${GAMEGRP} -m ${GAMEMODE}
                    506: INSTALL_GAME_DATA?=    ${INSTALL} ${COPY} -o ${GAMEOWN} -g ${GAMEGRP} -m ${GAMEDATAMODE}
                    507: INSTALL_LIB?=          ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
                    508: INSTALL_LIB_DIR?=      ${INSTALL_PROGRAM_DIR}
                    509: INSTALL_MAN?=          ${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
                    510: INSTALL_MAN_DIR?=      ${INSTALL} -d -o ${MANOWN} -g ${MANGRP} -m ${PKGDIRMODE}
                    511: INSTALL_PROGRAM?=      ${INSTALL} ${COPY} ${_STRIPFLAG_INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
                    512: INSTALL_PROGRAM_DIR?=  ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m ${PKGDIRMODE}
                    513: INSTALL_SCRIPT?=       ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
                    514: INSTALL_SCRIPT_DIR?=   ${INSTALL_PROGRAM_DIR}
                    515:
                    516: _INSTALL_MACROS=       BSD_INSTALL=${INSTALL:Q}
                    517: .  for mac in DATA GAME LIB MAN PROGRAM SCRIPT
                    518: _INSTALL_MACROS+=      BSD_INSTALL_${mac}=${INSTALL_${mac}:Q}
                    519: _INSTALL_MACROS+=      BSD_INSTALL_${mac}_DIR=${INSTALL_${mac}_DIR:Q}
                    520: CONFIGURE_ENV+=                INSTALL_${mac}=${INSTALL_${mac}:Q}
                    521: CONFIGURE_ENV+=                INSTALL_${mac}_DIR=${INSTALL_${mac}_DIR:Q}
                    522: .  endfor
                    523: MAKE_ENV+=             ${_INSTALL_MACROS}
                    524: SCRIPTS_ENV+=          ${_INSTALL_MACROS}
                    525:
                    526: .  if defined(USE_GNU_TOOLS) && !empty(USE_GNU_TOOLS:Mmake)
                    527: MAKE_PROGRAM=          ${GMAKE}
                    528: .  elif defined(USE_IMAKE)
                    529: MAKE_PROGRAM=          ${_IMAKE_MAKE}
1.1114    grant     530: .  endif
1.1540.2.1  tv        531: MAKE_PROGRAM?=         ${MAKE}
1.1114    grant     532:
1.1540.2.1  tv        533: MTREE_ARGS?=           -U -f ${MTREE_FILE} -d -e -p
                    534: MTREE_FILE?=           ${PKGSRCDIR}/mk/${OPSYS}.pkg.dist
                    535:
                    536: PKG_ARGS_COMMON=       -v -c -${COMMENT:Q}" " -d ${DESCR} -f ${PLIST}
                    537: PKG_ARGS_COMMON+=      -l -b ${BUILD_VERSION_FILE} -B ${BUILD_INFO_FILE}
                    538: PKG_ARGS_COMMON+=      -s ${SIZE_PKG_FILE} -S ${SIZE_ALL_FILE}
                    539: PKG_ARGS_COMMON+=      -P "`${MAKE} ${MAKEFLAGS} run-depends-list | ${SORT} -u`"
                    540: PKG_ARGS_COMMON+=      ${INSTALL_FILE:D-i ${INSTALL_FILE}}
                    541: PKG_ARGS_COMMON+=      ${DEINSTALL_FILE:D-k ${DEINSTALL_FILE}}
                    542: PKG_ARGS_COMMON+=      ${MESSAGE:D-D ${MESSAGE}}
                    543: PKG_ARGS_COMMON+=      ${NO_MTREE:D:U-m ${MTREE_FILE}}
                    544: PKG_ARGS_COMMON+=      ${PKG_PRESERVE:D-n ${PRESERVE_FILE}}
                    545: .  if ${PKG_INSTALLATION_TYPE} == "overwrite"
                    546: PKG_ARGS_COMMON+=      ${CONFLICTS:D-C "${CONFLICTS}"}
                    547: .  endif
1.164     agc       548:
1.1540.2.1  tv        549: PKG_ARGS_INSTALL=      -p ${PREFIX} ${PKG_ARGS_COMMON}
                    550: PKG_ARGS_BINPKG=       -p ${PREFIX:S/^${DESTDIR}//} -L ${PREFIX} ${PKG_ARGS_COMMON}
1.631     hubertf   551:
1.1540.2.1  tv        552: .endif # !_PKG_SKIPPED
                    553:
                    554: ############################################################################
1.1540.2.5  tv        555: # External bsd.pkg.mk fragments needing to perform overrides
1.1540.2.1  tv        556: ############################################################################
                    557:
                    558: .if !defined(_PKG_SKIPPED)
1.1250    jlam      559:
1.1540.2.1  tv        560: USE_PKGINSTALL?=       NO
                    561: .  if !empty(USE_PKGINSTALL:M[yY][eE][sS])
                    562: .    include "../../mk/bsd.pkg.install.mk"
                    563: .  endif
                    564:
                    565: .endif # !_PKG_SKIPPED
                    566:
                    567: ############################################################################
                    568: # Transform package Makefile variables (overridable by external fragments)
                    569: ############################################################################
                    570:
                    571: .if !defined(_PKG_SKIPPED)
1.1136    jlam      572:
1.164     agc       573: # Set INSTALL_FILE to be the name of any INSTALL file
1.1540.2.1  tv        574: .  if !defined(INSTALL_FILE) && exists(${PKGDIR}/INSTALL)
1.164     agc       575: INSTALL_FILE=          ${PKGDIR}/INSTALL
1.1540.2.1  tv        576: .  endif
1.164     agc       577:
                    578: # Set DEINSTALL_FILE to be the name of any DEINSTALL file
1.1540.2.1  tv        579: .  if !defined(DEINSTALL_FILE) && exists(${PKGDIR}/DEINSTALL)
1.164     agc       580: DEINSTALL_FILE=                ${PKGDIR}/DEINSTALL
1.1540.2.1  tv        581: .  endif
1.1       agc       582:
1.848     jlam      583: # If MESSAGE hasn't been defined, then set MESSAGE_SRC to be a space-separated
                    584: # list of files to be concatenated together to generate the MESSAGE file.
                    585: #
1.1540.2.1  tv        586: .  if !defined(MESSAGE_SRC) && !defined(MESSAGE)
                    587: .    if exists(${PKGDIR}/MESSAGE)
1.1103    seb       588: MESSAGE_SRC=           ${PKGDIR}/MESSAGE
1.1540.2.1  tv        589: .    else
                    590: .      if exists(${PKGDIR}/MESSAGE.common)
1.1101    grant     591: MESSAGE_SRC=           ${PKGDIR}/MESSAGE.common
1.1540.2.1  tv        592: .      endif
                    593: .      if exists(${PKGDIR}/MESSAGE.${OPSYS})
1.1101    grant     594: MESSAGE_SRC+=          ${PKGDIR}/MESSAGE.${OPSYS}
1.1540.2.1  tv        595: .      endif
                    596: .      if exists(${PKGDIR}/MESSAGE.${MACHINE_ARCH:C/i[3-6]86/i386/g})
1.1160    salo      597: MESSAGE_SRC+=  ${PKGDIR}/MESSAGE.${MACHINE_ARCH:C/i[3-6]86/i386/g}
1.1540.2.1  tv        598: .      endif
                    599: .      if exists(${PKGDIR}/MESSAGE.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g})
1.1104    grant     600: MESSAGE_SRC+=  ${PKGDIR}/MESSAGE.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g}
1.1540.2.1  tv        601: .      endif
1.1103    seb       602: .    endif
1.1101    grant     603: .  endif
1.654     wiz       604:
1.1540.2.1  tv        605: .  if defined(MESSAGE_SRC)
1.654     wiz       606: MESSAGE=               ${WRKDIR}/.MESSAGE
                    607:
                    608: # Set MESSAGE_SUBST to substitute "${variable}" to "value" in MESSAGE
1.1540.2.1  tv        609: MESSAGE_SUBST+=        LOCALBASE=${LOCALBASE}
                    610: MESSAGE_SUBST+=        PKG_SYSCONFDIR=${PKG_SYSCONFDIR}
                    611: MESSAGE_SUBST+=        PKGNAME=${PKGNAME}
                    612: MESSAGE_SUBST+=        PREFIX=${PREFIX}
                    613: MESSAGE_SUBST+=        QMAILDIR=${QMAILDIR} # XXXTV is this used?
                    614: MESSAGE_SUBST+=        ROOT_GROUP=${ROOT_GROUP}
                    615: MESSAGE_SUBST+=        ROOT_USER=${ROOT_USER}
                    616: MESSAGE_SUBST+=        VIEWBASE=${VIEWBASE}
                    617: MESSAGE_SUBST+=        X11BASE=${X11BASE}
                    618: MESSAGE_SUBST+=        X11PREFIX=${X11PREFIX}
1.848     jlam      619:
                    620: MESSAGE_SUBST_SED=     ${MESSAGE_SUBST:S/=/}!/:S/$/!g/:S/^/ -e s!\\\${/}
1.1540.2.1  tv        621: .  endif
1.1422    jlam      622:
1.1540.2.5  tv        623: ##### Config file related settings - see doc/guide
1.676     agc       624:
1.1540.2.1  tv        625: PKG_SYSCONFVAR?=       ${PKGBASE}
                    626: PKG_SYSCONFSUBDIR?=    # empty
                    627: .  if ${PKG_INSTALLATION_TYPE} == "overwrite"
                    628: PKG_SYSCONFDEPOTBASE=  # empty
                    629: PKG_SYSCONFBASEDIR=    ${PKG_SYSCONFBASE}
                    630: .  else
                    631: .    if !empty(PKG_SYSCONFBASE:M${PREFIX}) || \
                    632:         !empty(PKG_SYSCONFBASE:M${PREFIX}/*)
                    633: PKG_SYSCONFDEPOTBASE=  # empty
                    634: PKG_SYSCONFBASEDIR=    ${PKG_SYSCONFBASE}
                    635: .      if !empty(CONF_DEPENDS)
                    636: _PLIST_IGNORE_FILES+=  ${PKG_SYSCONFDIR:S,^${PREFIX}/,,}
                    637: .      endif
                    638: .    else
                    639: PKG_SYSCONFDEPOTBASE=  ${PKG_SYSCONFBASE}/${DEPOT_SUBDIR}
                    640: PKG_SYSCONFBASEDIR=    ${PKG_SYSCONFDEPOTBASE}/${PKGNAME}
                    641: .    endif
                    642: .  endif
                    643: .  if empty(PKG_SYSCONFSUBDIR)
                    644: DFLT_PKG_SYSCONFDIR:=  ${PKG_SYSCONFBASEDIR}
                    645: .  else
                    646: DFLT_PKG_SYSCONFDIR:=  ${PKG_SYSCONFBASEDIR}/${PKG_SYSCONFSUBDIR}
                    647: .  endif
                    648: PKG_SYSCONFDIR=                ${DFLT_PKG_SYSCONFDIR}
                    649: .  if defined(PKG_SYSCONFDIR.${PKG_SYSCONFVAR})
                    650: PKG_SYSCONFDIR=                ${PKG_SYSCONFDIR.${PKG_SYSCONFVAR}}
                    651: PKG_SYSCONFBASEDIR=    ${PKG_SYSCONFDIR.${PKG_SYSCONFVAR}}
                    652: PKG_SYSCONFDEPOTBASE=  # empty
                    653: .  endif
1.383     hubertf   654:
1.1540.2.1  tv        655: ALL_ENV+=              PKG_SYSCONFDIR=${PKG_SYSCONFDIR:Q}
                    656: BUILD_DEFS_FIXED+=     PKG_SYSCONFBASEDIR PKG_SYSCONFDIR
1.695     tron      657:
1.1540.2.1  tv        658: .endif # !_PKG_SKIPPED
1.383     hubertf   659:
1.1540.2.5  tv        660: ##### Checksum and other file handling support
1.1540.2.1  tv        661: # not skipped by _PKG_SKIPPED
1.383     hubertf   662:
1.1540.2.1  tv        663: ALLFILES?=     ${DISTFILES} ${PATCHFILES}
                    664: CKSUMFILES?=   ${ALLFILES}
                    665: .for __tmp__ in ${IGNOREFILES}
                    666: CKSUMFILES:=   ${CKSUMFILES:N${__tmp__}}
                    667: .endfor
1.1127    agc       668:
1.1540.2.1  tv        669: # List of all files, with ${DIST_SUBDIR} in front.  Used for fetch and checksum.
                    670: .if defined(DIST_SUBDIR)
                    671: .  if ${CKSUMFILES} != ""
                    672: _CKSUMFILES?=  ${CKSUMFILES:S/^/${DIST_SUBDIR}\//}
1.789     hubertf   673: .  endif
1.1540.2.1  tv        674: .  if !empty(DISTFILES)
                    675: _DISTFILES?=   ${DISTFILES:S/^/${DIST_SUBDIR}\//}
                    676: .  else
                    677: _DISTFILES?=   # empty
1.789     hubertf   678: .  endif
1.1540.2.1  tv        679: .  if defined(IGNOREFILES) && !empty(IGNOREFILES)
                    680: _IGNOREFILES?= ${IGNOREFILES:S/^/${DIST_SUBDIR}\//}
1.789     hubertf   681: .  endif
1.1540.2.1  tv        682: .  if defined(PATCHFILES) && !empty(PATCHFILES)
                    683: _PATCHFILES?=  ${PATCHFILES:S/^/${DIST_SUBDIR}\//}
                    684: .  else
                    685: _PATCHFILES?=  # empty
1.789     hubertf   686: .  endif
1.1540.2.1  tv        687: .else
                    688: _CKSUMFILES?=  ${CKSUMFILES}
                    689: _DISTFILES?=   ${DISTFILES}
                    690: _IGNOREFILES?= ${IGNOREFILES}
                    691: _PATCHFILES?=  ${PATCHFILES}
                    692: .endif
                    693: _ALLFILES?=    ${_DISTFILES} ${_PATCHFILES}
                    694:
                    695: ############################################################################
                    696: # Phase `fetch'
                    697: ############################################################################
                    698:
                    699: .if !empty(PKG_PHASES:Mfetch) && !defined(_PKG_SKIPPED)
                    700:
                    701: ##### Master site selection
                    702:
                    703: .  include "../../mk/bsd.sites.mk"
                    704:
                    705: .  if defined(DIST_SUBDIR)
                    706: _MASTER_SITE_BACKUP:=  ${MASTER_SITE_BACKUP:=${DIST_SUBDIR}/}
                    707: .    if defined(MASTER_SITE_OVERRIDE)
                    708: _MASTER_SITE_OVERRIDE:=        ${MASTER_SITE_OVERRIDE:=${DIST_SUBDIR}/}
                    709: .    endif # MASTER_SITE_OVERRIDE
                    710: .  else  # !DIST_SUBDIR
                    711: _MASTER_SITE_BACKUP:=  ${MASTER_SITE_BACKUP}
                    712: .    if defined(MASTER_SITE_OVERRIDE)
                    713: _MASTER_SITE_OVERRIDE:= ${MASTER_SITE_OVERRIDE}
                    714: .    endif # MASTER_SITE_OVERRIDE
                    715: .  endif # DIST_SUBDIR
                    716:
                    717: # Where to put distfiles that don't have any other master site
                    718: MASTER_SITE_LOCAL?=    ${MASTER_SITE_BACKUP:=LOCAL_PORTS/}
                    719:
                    720: ##### Make subtargets for "fetch".
                    721:
                    722: #===> check-vulnerable:  Check for any vulnerabilities in the package
                    723: _CHECK_VULNERABLE=                                                     \
                    724:        ${SETENV} PKGNAME="${PKGNAME}"                                  \
                    725:                  PKGBASE="${PKGBASE}"                                  \
                    726:                ${AWK} '/^$$/ { next }                                  \
                    727:                        /^\#.*/ { next }                                \
                    728:                        $$1 !~ ENVIRON["PKGBASE"] { next }              \
                    729:                        { s = sprintf("${PKG_ADMIN} pmatch \"%s\" %s && ${ECHO} \"*** WARNING - %s vulnerability in %s - see %s for more information ***\"", $$1, ENVIRON["PKGNAME"], $$2, ENVIRON["PKGNAME"], $$3); system(s); } \
                    730:                ' < ${PKGVULNDIR}/pkg-vulnerabilities || ${ECHO} 'could not check pkg-vulnerabilities file'
                    731:
                    732: _REAL_TARGETS.fetch+=          check-vulnerable
                    733: .PHONY: check-vulnerable
                    734: check-vulnerable:
                    735: .  if !defined(ALLOW_VULNERABLE_PACKAGES) && !exists(${extract_COOKIE})
                    736: .    if exists(${PKGVULNDIR}/pkg-vulnerabilities)
                    737:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                    738:        ${ECHO_MSG} "${_PKGSRC_IN}> Checking for vulnerabilities in ${PKGNAME}"; \
                    739:        vul=`${_CHECK_VULNERABLE}`;                                     \
                    740:        case "$$vul" in                                                 \
                    741:        "")     ;;                                                      \
                    742:        *)      ${ECHO} "$$vul";                                        \
                    743:                ${ECHO} "or define ALLOW_VULNERABLE_PACKAGES if this package is absolutely essential"; \
                    744:                ${FALSE} ;;                                             \
                    745:        esac
                    746: .    else
                    747:        @${ECHO_MSG} "${_PKGSRC_IN}> *** No ${PKGVULNDIR}/pkg-vulnerabilities file found,"
                    748:        @${ECHO_MSG} "${_PKGSRC_IN}> *** skipping vulnerability checks. To fix, install"
                    749:        @${ECHO_MSG} "${_PKGSRC_IN}> *** the pkgsrc/security/audit-packages package and run"
                    750:        @${ECHO_MSG} "${_PKGSRC_IN}> *** '${LOCALBASE}/sbin/download-vulnerability-list'."
                    751: .    endif
1.1127    agc       752: .  endif
1.653     jwise     753:
1.1540.2.1  tv        754: #===> "pre-fetch"
1.653     jwise     755:
1.1540.2.1  tv        756: _REAL_TARGETS.fetch+=          pre-fetch
                    757: .PHONY: pre-fetch
                    758: pre-fetch: .OPTIONAL
1.1252    jlam      759:
1.1540.2.1  tv        760: #===> "do-fetch"
1.383     hubertf   761:
1.1540.2.1  tv        762: _REAL_TARGETS.fetch+=          do-fetch
                    763: .PHONY: do-fetch
                    764: #do-fetch:
1.416     agc       765:
1.1540.2.1  tv        766: #===> "post-fetch"
1.1       agc       767:
1.1540.2.1  tv        768: _REAL_TARGETS.fetch+=          post-fetch
                    769: .PHONY: post-fetch
                    770: post-fetch: .OPTIONAL
1.43      hubertf   771:
1.1540.2.1  tv        772: .endif # !empty(PKG_PHASES:Mfetch) && !defined(_PKG_SKIPPED)
1.1       agc       773:
1.1540.2.1  tv        774: ############################################################################
                    775: # Phase `checksum'
                    776: ############################################################################
1.87      agc       777:
1.1540.2.1  tv        778: # not skipped by _PKG_SKIPPED
1.691     fredb     779:
1.1540.2.1  tv        780: #===> uptodate-digest:  Install "digest" if needed.
                    781: # this is also used by `patch' and `make*sum'
                    782: .PHONY: uptodate-digest
                    783: uptodate-digest:
                    784: .if !empty(USE_DIGEST:M[yY][eE][sS])
                    785:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                    786:        if [ -f ${DISTINFO_FILE} -a \( ! -f ${DIGEST} -o ${DIGEST_VERSION} -lt ${DIGEST_REQD} \) ]; then \
                    787:                { cd ${PKGSRCDIR}/pkgtools/digest;                      \
                    788:                ${MAKE} clean;                                          \
                    789:                if [ -f ${DIGEST} ]; then                               \
                    790:                        ${MAKE} ${MAKEFLAGS} deinstall;                 \
                    791:                fi;                                                     \
                    792:                ${MAKE} ${MAKEFLAGS} test;                              \
                    793:                if [ -f ${DIGEST} ]; then                               \
                    794:                        ${MAKE} ${MAKEFLAGS} deinstall;                 \
                    795:                fi;                                                     \
                    796:                ${MAKE} ${MAKEFLAGS} ${DEPENDS_TARGET};                 \
                    797:                ${MAKE} ${MAKEFLAGS} clean; }                           \
                    798:        fi
1.691     fredb     799: .endif
1.15      agc       800:
1.1540.2.1  tv        801: .if !empty(PKG_PHASES:Mchecksum) && !defined(_PKG_SKIPPED)
1.1067    jlam      802:
1.1540.2.1  tv        803: #===> do-checksum
                    804:
                    805: _REAL_TARGETS.checksum+=       do-checksum
                    806: .PHONY: do-checksum
                    807: do-checksum: .OPTIONAL
                    808: .  if !defined(NO_CHECKSUM) && !exists(${extract_COOKIE})
                    809: do-checksum: uptodate-digest
                    810:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                    811:        if [ ! -f ${DISTINFO_FILE} ]; then                              \
                    812:                ${ECHO_MSG} "=> No checksum file.";                     \
                    813:        else                                                            \
                    814:                (cd ${DISTDIR}; OK="true";                              \
                    815:                  for file in "" ${_CKSUMFILES}; do                     \
                    816:                        if [ "X$$file" = X"" ]; then continue; fi;      \
                    817:                        alg=`${AWK} 'NF == 4 && $$2 == "('$$file')" && $$3 == "=" {print $$1;}' ${DISTINFO_FILE}`; \
                    818:                        if [ "X$$alg" = "X" ]; then                     \
                    819:                                ${ECHO_MSG} "=> No checksum recorded for $$file."; \
                    820:                                OK="false";                             \
                    821:                        else                                            \
                    822:                                CKSUM=`${DIGEST} $$alg < $$file`;       \
                    823:                                CKSUM2=`${AWK} '$$1 == "'$$alg'" && $$2 == "('$$file')"{print $$4;}' ${DISTINFO_FILE}`; \
                    824:                                if [ "$$CKSUM2" = "IGNORE" ]; then      \
                    825:                                        ${ECHO_MSG} "=> Checksum for $$file is set to IGNORE in checksum file even though"; \
                    826:                                        ${ECHO_MSG} "   the file is not in the "'$$'"{IGNOREFILES} list."; \
                    827:                                        OK="false";                     \
                    828:                                elif [ "$$CKSUM" = "$$CKSUM2" ]; then   \
                    829:                                        ${ECHO_MSG} "=> Checksum OK for $$file."; \
                    830:                                else                                    \
                    831:                                        ${ECHO_MSG} "=> Checksum mismatch for $$file."; \
                    832:                                        OK="false";                     \
                    833:                                fi;                                     \
                    834:                        fi;                                             \
                    835:                  done;                                                 \
                    836:                  for file in "" ${_IGNOREFILES}; do                    \
                    837:                        if [ "X$$file" = X"" ]; then continue; fi;      \
                    838:                        CKSUM2=`${AWK} 'NF == 4 && $$3 == "=" && $$2 == "('$$file')"{print $$4;}' ${DISTINFO_FILE}`; \
                    839:                        if [ "$$CKSUM2" = "" ]; then                    \
                    840:                                ${ECHO_MSG} "=> No checksum recorded for $$file, file is in "'$$'"{IGNOREFILES} list."; \
                    841:                                OK="false";                             \
                    842:                        elif [ "$$CKSUM2" != "IGNORE" ]; then           \
                    843:                                ${ECHO_MSG} "=> Checksum for $$file is not set to IGNORE in checksum file even though"; \
                    844:                                ${ECHO_MSG} "   the file is in the "'$$'"{IGNOREFILES} list."; \
                    845:                                OK="false";                             \
                    846:                        fi;                                             \
                    847:                  done;                                                 \
                    848:                  if [ "$$OK" != "true" ]; then                         \
                    849:                        ${ECHO_MSG} "Make sure the Makefile and checksum file (${DISTINFO_FILE})"; \
                    850:                        ${ECHO_MSG} "are up to date.  If you want to override this check, type"; \
                    851:                        ${ECHO_MSG} "\"${MAKE} NO_CHECKSUM=yes [other args]\"."; \
                    852:                        exit 1;                                         \
                    853:                  fi) ;                                                 \
                    854:        fi
1.1067    jlam      855: .  endif
1.1540.2.1  tv        856:
                    857: .endif # !empty(PKG_PHASES:Mchecksum) && !defined(_PKG_SKIPPED)
                    858:
                    859: ############################################################################
                    860: # Phase `depends'
                    861: ############################################################################
                    862:
                    863: .if !empty(PKG_PHASES:Mdepends) && !defined(_PKG_SKIPPED)
                    864:
                    865: .  if defined(RECOMMENDED)
                    866: .    if !empty(IGNORE_RECOMMENDED:M[nN][oO])
                    867: DEPENDS+=              ${RECOMMENDED}
                    868: .    else
                    869: BUILD_DEFS_FIXED+=     IGNORE_RECOMMENDED
                    870: .    endif
1.1067    jlam      871: .  endif
                    872:
1.1540.2.5  tv        873: .  include "../../mk/tools.mk"
                    874:
                    875: # If NO_BUILD is defined, default to not needing a compiler.
                    876: .  if defined(NO_BUILD)
                    877: USE_LANGUAGES?=                # empty
                    878: .  endif
                    879: .  include "../../mk/compiler.mk"
                    880:
                    881: # USE_BUILDLINK3 == "no" implies NO_BUILDLINK
                    882: .  if !empty(USE_BUILDLINK3:M[nN][oO])
                    883: NO_BUILDLINK=          yes
                    884: .  endif
                    885: .  if !defined(NO_BUILDLINK)
                    886: .    include "../../mk/buildlink3/bsd.buildlink3.mk"
                    887: .  endif
                    888:
                    889: ##### "depends" target implementation
                    890:
1.1540.2.1  tv        891: # Remove some redundant dependencies from the DEPENDS list.
                    892: .  include "../../mk/reduce-depends.mk"
1.1067    jlam      893:
1.1540.2.1  tv        894: _REAL_TARGETS.depends+=                depends-message
1.1466    xtraeme   895:
1.1540.2.5  tv        896: #===> "do-depends"
1.1       agc       897:
1.1540.2.5  tv        898: _REAL_TARGETS.depends+=                do-depends
                    899: .PHONY: do-depends
1.1       agc       900:
1.1540.2.1  tv        901: .endif # !empty(PKG_PHASES:Mdepends) && !defined(_PKG_SKIPPED)
1.177     agc       902:
1.1540.2.1  tv        903: ############################################################################
                    904: # Phase `extract'
                    905: ############################################################################
1.135     agc       906:
1.1540.2.1  tv        907: .if !empty(PKG_PHASES:Mextract) && !defined(_PKG_SKIPPED)
1.1       agc       908:
1.1540.2.1  tv        909: _REAL_TARGETS.extract+=                extract-message
                    910:
                    911: #===> "build-defs-message"
                    912: # if BUILD_DEFS is non-empty, show a notice the the builder
                    913:
                    914: .  if !empty(PKGSRC_SHOW_BUILD_DEFS:M[yY][eE][sS])
                    915: _REAL_TARGETS.extract+=                build-defs-message
                    916: .PHONY: build-defs-message
                    917: build-defs-message:
                    918: .    if !empty(BUILD_DEFS)
                    919:        @${ECHO} "=========================================================================="
                    920:        @${ECHO} "The following variables will affect the build process of this package,"
                    921:        @${ECHO} "${PKGNAME}.  Their current value is shown below:"
                    922:        @${ECHO} ""
                    923: .      for var in ${BUILD_DEFS}
                    924: .        if !defined(${var})
                    925:        @${ECHO} "        * ${var} (not defined)"
                    926: .        elif defined(${var}) && empty(${var})
                    927:        @${ECHO} "        * ${var} (defined)"
                    928: .        else
                    929:        @${ECHO} "        * ${var} = ${${var}}"
                    930: .        endif
                    931: .      endfor
                    932:        @${ECHO} ""
                    933:        @${ECHO} "You may want to abort the process now with CTRL-C and change their value"
                    934:        @${ECHO} "before continuing.  Be sure to run \`${MAKE} clean' after"
                    935:        @${ECHO} "the changes."
                    936:        @${ECHO} "=========================================================================="
                    937: .    endif
1.789     hubertf   938: .  endif
1.1540.2.1  tv        939:
                    940: #===> "pre-extract"
                    941:
                    942: _REAL_TARGETS.extract+=                pre-extract
                    943: .PHONY: pre-extract
                    944: pre-extract: .OPTIONAL
                    945:
                    946: #===> "do-extract"
                    947:
                    948: _REAL_TARGETS.extract+=                do-extract
                    949: .PHONY: do-extract
                    950: #do-extract:
                    951:
                    952: #===> "post-extract"
                    953:
                    954: _REAL_TARGETS.extract+=                post-extract
                    955: .PHONY: post-extract
                    956: post-extract: .OPTIONAL
                    957:
                    958: .endif # !empty(PKG_PHASES:Mextract) && !defined(_PKG_SKIPPED)
                    959:
                    960: ############################################################################
                    961: # Phase `patch'
                    962: ############################################################################
                    963:
                    964: .if !empty(PKG_PHASES:Mpatch) && !defined(_PKG_SKIPPED)
                    965:
                    966: # determine if we need a working patch(1).
                    967: .  if defined(PATCHFILES)
                    968: _NEED_PATCH=           YES
                    969: .  elif defined(_OPSYS_GPATCH_REQD) && !empty(_OPSYS_GPATCH_REQD:M[yY][eE][sS])
                    970: _NEED_PATCH=           YES
1.1315    cube      971: .  else
1.1540.2.1  tv        972: _NEED_PATCH!=          if [ -d ${PATCHDIR} ]; then \
                    973:                                if [ "`${ECHO} ${PATCHDIR}/patch-*`" != "${PATCHDIR}/patch-*" ]; then \
                    974:                                        ${ECHO} YES; \
                    975:                                else \
                    976:                                        ${ECHO} NO; \
                    977:                                fi \
                    978:                        else \
                    979:                                ${ECHO} NO; \
                    980:                        fi
1.1315    cube      981: .  endif
1.1540.2.1  tv        982:
                    983: .  if ${_NEED_PATCH} == "YES"
                    984: USE_GNU_TOOLS+=                patch
1.1315    cube      985: .  endif
1.1540.2.1  tv        986:
                    987: .  if defined(PATCH_DEBUG) || defined(PKG_VERBOSE)
                    988: PATCH_DEBUG_TMP=       yes
1.1315    cube      989: .  endif
1.1540.2.1  tv        990: PATCH_DEBUG_TMP?=      no
                    991:
                    992: PATCH_STRIP?=          -p0
                    993: .  if ${PATCH_DEBUG_TMP} == "yes"
                    994: PATCH_ARGS?=           -d ${WRKSRC} -E ${PATCH_STRIP}
                    995: .  endif
                    996: PATCH_ARGS?=           -d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP}
1.1       agc       997:
1.1540.2.1  tv        998: PATCH_ARGS+=           ${BATCH:D--batch}
                    999: .  if defined(_PATCH_CAN_BACKUP) && (${_PATCH_CAN_BACKUP} == "yes")
                   1000: PATCH_ARGS+=           ${_PATCH_BACKUP_ARG} .orig
                   1001: .  endif
                   1002: PATCH_FUZZ_FACTOR?=    -F0     # Default to zero fuzz
1.1       agc      1003:
1.1540.2.1  tv       1004: # The following variables control how "distribution" patches are extracted
                   1005: # and applied to the package sources.
                   1006: #
                   1007: # PATCH_DIST_STRIP is a patch option that sets the pathname strip count.
                   1008: # PATCH_DIST_ARGS is the list of arguments to pass to the patch command.
                   1009: # PATCH_DIST_CAT is the command that outputs the patch to stdout.
                   1010: #
                   1011: # For each of these variables, there is a patch-specific variant that
                   1012: # may be set, i.e. PATCH_DIST_STRIP.<patch>, PATCH_DIST_ARGS.<patch>,
                   1013: # PATCH_DIST_CAT.<patch>.
                   1014: #
                   1015: PATCH_DIST_STRIP?=             -p0
                   1016: .  for i in ${PATCHFILES}
                   1017: PATCH_DIST_STRIP.${i:S/=/--/}?=        ${PATCH_DIST_STRIP}
                   1018: .    if defined(PATCH_DIST_ARGS)
                   1019: PATCH_DIST_ARGS.${i:S/=/--/}?= ${PATCH_DIST_ARGS}
                   1020: .    elif ${PATCH_DEBUG_TMP} == "yes"
                   1021: PATCH_DIST_ARGS.${i:S/=/--/}?= -d ${WRKSRC} -E ${PATCH_DIST_STRIP.${i:S/=/--/}}
                   1022: .    else
                   1023: PATCH_DIST_ARGS.${i:S/=/--/}?= -d ${WRKSRC} --forward --quiet -E ${PATCH_DIST_STRIP.${i:S/=/--/}}
                   1024: .    endif
                   1025: .  endfor
                   1026: .  if defined(BATCH)
                   1027: PATCH_DIST_ARGS+=              --batch
                   1028: .    for i in ${PATCHFILES}
                   1029: PATCH_DIST_ARGS.${i:S/=/--/}+= --batch
                   1030: .    endfor
                   1031: .  endif
                   1032: .  if defined(_PATCH_CAN_BACKUP) && (${_PATCH_CAN_BACKUP} == "yes")
                   1033: PATCH_DIST_ARGS+=              ${_PATCH_BACKUP_ARG} .orig_dist
                   1034: .    for i in ${PATCHFILES}
                   1035: PATCH_DIST_ARGS.${i:S/=/--/}+= ${_PATCH_BACKUP_ARG} .orig_dist
                   1036: .    endfor
                   1037: .  endif
                   1038: PATCH_DIST_CAT?=       { case $$patchfile in                           \
                   1039:                          *.Z|*.gz) ${GZCAT} $$patchfile ;;             \
                   1040:                          *.bz2)    ${BZCAT} $$patchfile ;;             \
                   1041:                          *)        ${CAT} $$patchfile ;;               \
                   1042:                          esac; }
                   1043: .  for i in ${PATCHFILES}
                   1044: PATCH_DIST_CAT.${i:S/=/--/}?=  { patchfile=${i}; ${PATCH_DIST_CAT}; }
                   1045: .  endfor
1.1       agc      1046:
1.1540.2.1  tv       1047: .  if !empty(PKGSRC_SHOW_PATCH_ERRORMSG:M[yY][eE][sS])
                   1048: PKGSRC_PATCH_FAIL=                                                     \
                   1049: if [ -n "${PKG_OPTIONS}" ] || [ -n "${_LOCALPATCHFILES}" ]; then       \
                   1050:        ${ECHO} "==========================================================================";                                                           \
                   1051:        ${ECHO};                                                        \
                   1052:        ${ECHO} "Some of the selected build options and/or local patches may be incompatible.";                                                         \
                   1053:        ${ECHO} "Please try building with fewer options or patches.";   \
                   1054:        ${ECHO};                                                        \
                   1055:        ${ECHO} "==========================================================================";                                                           \
                   1056: fi; exit 1
                   1057: .  endif
                   1058: PKGSRC_PATCH_FAIL?=    exit 1
1.602     hubertf  1059:
1.1540.2.3  tv       1060: _REAL_TARGETS.patch+=  patch-message pre-patch do-patch post-patch
                   1061:
1.1540.2.1  tv       1062: .endif # !empty(PKG_PHASES:Mpatch) && !defined(_PKG_SKIPPED)
1.254     tron     1063:
1.1540.2.1  tv       1064: ############################################################################
                   1065: # Phase `tools'
                   1066: ############################################################################
1.254     tron     1067:
1.1540.2.1  tv       1068: do-tools: .OPTIONAL
                   1069: .if !empty(PKG_PHASES:Mtools) && !defined(_PKG_SKIPPED)
1.273     tv       1070:
1.1540.2.3  tv       1071: _REAL_TARGETS.tools+=  tools-message pre-tools do-tools post-tools
                   1072:
1.1540.2.1  tv       1073: .endif # !empty(PKG_PHASES:Mtools) && !defined(_PKG_SKIPPED)
                   1074:
                   1075: ############################################################################
                   1076: # Phase `wrapper'
                   1077: ############################################################################
1.1       agc      1078:
1.1540.2.1  tv       1079: do-wrapper: .OPTIONAL
                   1080: .if !empty(PKG_PHASES:Mwrapper) && !defined(_PKG_SKIPPED)
1.907     agc      1081:
1.1540.2.1  tv       1082: .  include "../../mk/wrapper/bsd.wrapper.mk"
1.1       agc      1083:
1.1540.2.3  tv       1084: _REAL_TARGETS.wrapper+=        wrapper-message pre-wrapper do-wrapper post-wrapper
                   1085:
1.1540.2.1  tv       1086: .endif # !empty(PKG_PHASES:Mwrapper) && !defined(_PKG_SKIPPED)
                   1087:
                   1088: ############################################################################
                   1089: # Phase `configure'
                   1090: ############################################################################
                   1091:
                   1092: .if !empty(PKG_PHASES:Mconfigure) && !defined(_PKG_SKIPPED)
                   1093:
                   1094: CONFIGURE_ENV+=                ${ALL_ENV}
                   1095: CONFIGURE_ENV+=                ac_given_INSTALL="`${TYPE} ${INSTALL} | ${AWK} '{ print $$NF }'` -c -o ${BINOWN} -g ${BINGRP}"
                   1096: CONFIGURE_ENV+=                AWK=${AWK:Q}
                   1097: CONFIGURE_ENV+=                F77=${FC:Q}
                   1098: CONFIGURE_ENV+=                FC=${FC:Q}
                   1099: CONFIGURE_ENV+=                INSTALL="`${TYPE} ${INSTALL} | ${AWK} '{ print $$NF }'` -c -o ${BINOWN} -g ${BINGRP}"
                   1100: CONFIGURE_ENV+=                MAKE=${MAKE_PROGRAM:T:Q}
                   1101: CONFIGURE_ENV+=                M4=${M4:Q}
                   1102: CONFIGURE_ENV+=                YACC=${YACC:Q}
1.262     tv       1103:
1.1540.2.1  tv       1104: .  if defined(GNU_CONFIGURE)
                   1105: #
                   1106: # If GNU_CONFIGURE is defined, then pass LIBS to the GNU configure script.
                   1107: # also pass in a CONFIG_SHELL to avoid picking up bash
                   1108: #
                   1109: CONFIG_SHELL?=         ${SH}
                   1110: CONFIGURE_ENV+=                CONFIG_SHELL=${CONFIG_SHELL}
                   1111: CONFIGURE_ENV+=                install_sh=${INSTALL:Q}
                   1112: CONFIGURE_ENV+=                LIBS=${LIBS:Q}
                   1113: CONFIGURE_ENV+=                ${USE_LIBTOOL:Dlt_cv_sys_max_cmd_len=${_OPSYS_MAX_CMDLEN}}
1.996     jlam     1114: #
1.1366    jlam     1115: # GNU_CONFIGURE_PREFIX is the argument to the --prefix option passed to the
1.996     jlam     1116: # GNU configure script.
                   1117: #
                   1118: GNU_CONFIGURE_PREFIX?= ${PREFIX}
                   1119: CONFIGURE_ARGS+=       --host=${MACHINE_GNU_PLATFORM}
                   1120: CONFIGURE_ARGS+=       --prefix=${GNU_CONFIGURE_PREFIX}
1.1       agc      1121: HAS_CONFIGURE=         yes
1.1540.2.1  tv       1122: .    if defined(USE_X11)
1.1076    jlam     1123: CONFIGURE_ARGS+=       --x-includes=${X11BASE}/include
1.1536    sketch   1124: CONFIGURE_ARGS+=        --x-libraries=${X11BASE}/lib${LIBABISUFFIX}
1.1540.2.1  tv       1125: .    endif
1.1456    reed     1126: CONFIGURE_HAS_INFODIR?=        yes
1.1540.2.1  tv       1127: .    if !empty(INFO_FILES) && !empty(CONFIGURE_HAS_INFODIR:M[yY][eE][sS])
1.1455    reed     1128: CONFIGURE_ARGS+=       --infodir=${PREFIX}/${INFO_DIR}
1.1540.2.1  tv       1129: .    endif
1.1397    grant    1130: #
                   1131: # By default, override config.guess and config.sub for GNU configure
                   1132: # packages. pkgsrc's updated versions of these scripts allows GNU
                   1133: # configure to recognise NetBSD ports such as shark.
                   1134: #
1.1403    jlam     1135: CONFIG_GUESS_OVERRIDE?=                \
                   1136:        config.guess */config.guess */*/config.guess
                   1137: CONFIG_SUB_OVERRIDE?=          \
                   1138:        config.sub */config.sub */*/config.sub
1.1400    jlam     1139: #
                   1140: # By default, override config.status for GNU configure packages.  We
                   1141: # never want it to execute after the configure phase has ended as it
                   1142: # might overwrite any post-configure changes we might have made to the
                   1143: # generated files.
                   1144: #
                   1145: CONFIG_STATUS_OVERRIDE?=       \
                   1146:        config.status */config.status */*/config.status
1.1540.2.1  tv       1147: .  endif
1.865     jlam     1148:
1.1540.2.3  tv       1149: _REAL_TARGETS.configure+=configure-message pre-configure pre-configure-override do-configure post-configure
                   1150:
1.1540.2.1  tv       1151: .endif # !empty(PKG_PHASES:Mconfigure) && !defined(_PKG_SKIPPED)
                   1152:
                   1153: ############################################################################
                   1154: # Phase `build'
                   1155: ############################################################################
                   1156:
                   1157: .if !empty(PKG_PHASES:Mbuild) && !defined(_PKG_SKIPPED)
                   1158:
1.1540.2.3  tv       1159: _REAL_TARGETS.build+=  build-message pre-build do-build post-build
                   1160:
1.1540.2.1  tv       1161: .endif # !empty(PKG_PHASES:Mbuild) && !defined(_PKG_SKIPPED)
                   1162:
                   1163: ############################################################################
                   1164: # Phase `test'
                   1165: ############################################################################
                   1166:
                   1167: .if !empty(PKG_PHASES:Mtest)
1.1540.2.3  tv       1168:
                   1169: _REAL_TARGETS.test+=   test-message pre-test do-test post-test
                   1170:
1.1540.2.1  tv       1171: .endif # !empty(PKG_PHASES:Mtest)
                   1172:
                   1173: ############################################################################
                   1174: # Phase `install'
                   1175: ############################################################################
                   1176:
                   1177: .if !empty(PKG_PHASES:Minstall)
                   1178:
                   1179: ##### PLIST manipulation
                   1180:
1.1540.2.4  tv       1181: .  include "../../mk/plist.mk"
1.1540.2.1  tv       1182:
                   1183: ##### Make subtargets for non-su portion of "install".
                   1184:
                   1185: #===> "install-check-pkgname"
                   1186:
                   1187: _REAL_TARGETS.install+=                install-check-pkgname
                   1188: .PHONY: install-check-pkgname
                   1189: install-check-pkgname:
                   1190:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1191:        extractname=`${CAT} ${extract_COOKIE}`;                         \
                   1192:        case "$$extractname" in                                         \
                   1193:        "")     ${ECHO_MSG} "*** Warning: ${WRKDIR} may contain an older version of ${PKGBASE}" ;; \
                   1194:        "${PKGNAME}")   ;;                                              \
                   1195:        *)      ${ECHO_MSG} "*** Warning: Package version $$extractname in ${WRKDIR}"; \
                   1196:                ${ECHO_MSG} "*** Current version ${PKGNAME} in pkgsrc directory"; \
                   1197:                ${ECHO_MSG} "*** Cleaning and rebuilding the newer version of the package..."; \
                   1198:                ${MAKE} clean && ${MAKE} build ;;                       \
                   1199:        esac
                   1200:
                   1201: #===> "do-su-install"
                   1202: # su to root, then run real-su-install
                   1203:
                   1204: _REAL_TARGETS.install+=                do-su-install
                   1205:
                   1206: ##### Make subtargets for su portion of "install".
                   1207:
                   1208: #===> "message"
                   1209: # generate ${MESSAGE} from ${MESSAGE_SRC} by substituting
                   1210: # for MESSAGE_SUBST entries
                   1211:
                   1212: _REAL_TARGETS.su-install+=     message
                   1213: .PHONY: message
                   1214: message: ${MESSAGE}
                   1215: .  if defined(MESSAGE)
                   1216: ${MESSAGE}: ${MESSAGE_SRC}
                   1217:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1218:        if [ -z "${MESSAGE_SRC}" ]; then                                \
                   1219:                ${ECHO} "${MESSAGE_SRC} not found.";                    \
                   1220:                ${ECHO} "Please set MESSAGE_SRC correctly.";            \
                   1221:        else                                                            \
                   1222:                ${CAT} ${MESSAGE_SRC} |                                 \
                   1223:                        ${SED} ${MESSAGE_SUBST_SED}                     \
                   1224:                        > ${MESSAGE};                                   \
                   1225:        fi
1.865     jlam     1226: .  endif
                   1227:
1.1540.2.1  tv       1228: #===> "init-install"
                   1229: # check for conflicts and create install directories
1.1       agc      1230:
1.1540.2.1  tv       1231: _REAL_TARGETS.su-install+=     init-install
                   1232: .PHONY: init-install
                   1233: init-install:
                   1234: .  if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER) &&     \
                   1235:     (${PKG_INSTALLATION_TYPE} == "overwrite")
                   1236: .    if defined(CONFLICTS)
                   1237:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1238:        ${RM} -f ${WRKDIR}/.CONFLICTS
                   1239: .      for conflict in ${CONFLICTS}
                   1240:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1241:        found="`${PKG_BEST_EXISTS} \"${conflict}\" || ${TRUE}`";        \
                   1242:        if [ X"$$found" != X"" ]; then                                  \
                   1243:                ${ECHO} "$$found" >> ${WRKDIR}/.CONFLICTS;              \
                   1244:        fi
                   1245: .      endfor
                   1246:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1247:        if [ -s ${WRKDIR}/.CONFLICTS ]; then                            \
                   1248:                found=`${SED} -e s'|${_PKG_DBDIR}/||g' ${WRKDIR}/.CONFLICTS | tr '\012' ' '`; \
                   1249:                ${ECHO_MSG} "${_PKGSRC_IN}> ${PKGNAME} conflicts with installed package(s): $$found found."; \
                   1250:                ${ECHO_MSG} "*** They install the same files into the same place."; \
                   1251:                ${ECHO_MSG} "*** Please remove $$found first with pkg_delete(1)."; \
                   1252:                ${RM} -f ${WRKDIR}/.CONFLICTS;                          \
                   1253:                exit 1;                                                 \
                   1254:        fi
                   1255: .    endif     # CONFLICTS
                   1256:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1257:        found="`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`";     \
                   1258:        if [ "$$found" != "" ]; then                                    \
                   1259:                ${ECHO_MSG} "${_PKGSRC_IN}> $$found is already installed - perhaps an older version?"; \
                   1260:                ${ECHO_MSG} "*** If so, you may use either of:"; \
                   1261:                ${ECHO_MSG} "***  - \"pkg_delete $$found\" and \"${MAKE} reinstall\" to upgrade properly"; \
                   1262:                ${ECHO_MSG} "***  - \"${MAKE} update\" to rebuild the package and all of its dependencies"; \
                   1263:                ${ECHO_MSG} "***  - \"${MAKE} replace\" to replace only the package without re-linking"; \
                   1264:                ${ECHO_MSG} "***    dependencies, risking various problems."; \
                   1265:                exit 1;                                                 \
                   1266:        fi
                   1267: .  endif # !NO_PKG_REGISTER && !NO_FORCE_REGISTER && overwrite
                   1268: .  if ${PKG_INSTALLATION_TYPE} == "pkgviews"
                   1269:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1270:        found="`${PKG_INFO} -e ${PKGNAME} || ${TRUE}`";                 \
                   1271:        if [ "$$found" != "" ]; then                                    \
                   1272:                ${ECHO_MSG} "${_PKGSRC_IN}>  $$found is already installed."; \
                   1273:                exit 1;                                                 \
                   1274:        fi
                   1275: .  endif
                   1276:        ${_PKG_SILENT}${_PKG_DEBUG}if [ `${SH} -c umask` -ne ${DEF_UMASK} ]; then \
                   1277:                ${ECHO_MSG} "${_PKGSRC_IN}>  Warning: your umask is \"`${SH} -c umask`"\".; \
                   1278:                ${ECHO_MSG} "If this is not desired, set it to an appropriate value (${DEF_UMASK})"; \
                   1279:                ${ECHO_MSG} "and install this package again by \`\`${MAKE} deinstall reinstall''."; \
                   1280:        fi
                   1281: .  if defined(INSTALLATION_DIRS) && !empty(INSTALLATION_DIRS)
                   1282:        ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} "${_PKGSRC_IN}> Creating installation directories"
                   1283:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1284:        for dir in ${INSTALLATION_DIRS}; do                             \
                   1285:                case $$dir in                                           \
                   1286:                /*)     ;;                                              \
                   1287:                *bin|*bin/*|*libexec|*libexec/*)                        \
                   1288:                        ${INSTALL_PROGRAM_DIR} ${PREFIX}/$$dir ;;       \
                   1289:                *man/*)                                                 \
                   1290:                        ${INSTALL_MAN_DIR} ${PREFIX}/$$dir ;;           \
                   1291:                *)                                                      \
                   1292:                        ${INSTALL_DATA_DIR} ${PREFIX}/$$dir ;;          \
                   1293:                esac;                                                   \
                   1294:        done
                   1295: .  endif       # INSTALLATION_DIRS
                   1296: .  if !defined(NO_MTREE)
                   1297:        ${_PKG_SILENT}${_PKG_DEBUG}if [ `${ID} -u` = `${ID} -u ${ROOT_USER}` ]; then            \
                   1298:                if [ ! -f ${MTREE_FILE} ]; then                         \
                   1299:                        ${ECHO_MSG} "Error: mtree file \"${MTREE_FILE}\" is missing."; \
                   1300:                        exit 1;                                         \
                   1301:                else                                                    \
                   1302:                        if [ ! -d ${PREFIX} ]; then                     \
                   1303:                                ${MKDIR} ${PREFIX};                     \
                   1304:                        fi;                                             \
                   1305:                        ${MTREE} ${MTREE_ARGS} ${PREFIX}/;              \
                   1306:                fi;                                                     \
                   1307:        else                                                            \
                   1308:                ${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
                   1309:                ${ECHO_MSG} "Become ${ROOT_USER} and try again to ensure correct permissions."; \
                   1310:        fi
                   1311: .  else
                   1312:        ${_PKG_SILENT}${_PKG_DEBUG}[ -d ${PREFIX} ] || ${MKDIR} ${PREFIX}
                   1313: .  endif # !NO_MTREE
1.1       agc      1314:
1.1540.2.1  tv       1315: #===> "pre-install-script"
                   1316:
                   1317: _REAL_TARGETS.su-install+=     pre-install-script
                   1318: .PHONY: pre-install-script
                   1319: pre-install-script: .OPTIONAL
                   1320:
                   1321: #===> "pre-install"
                   1322:
                   1323: _REAL_TARGETS.su-install+=     pre-install
                   1324: .PHONY: pre-install
                   1325: pre-install: .OPTIONAL
                   1326:
                   1327: #===> "do-install"
                   1328:
                   1329: _REAL_TARGETS.su-install+=     do-install
1.1540.2.5  tv       1330: .PHONY: do-install
                   1331: .if !target(do-install)
                   1332: do-install:
                   1333: .  for DIR in ${INSTALL_DIRS}
                   1334:        ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD}cd ${DIR} && ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} -f ${MAKEFILE} ${INSTALL_TARGET}
                   1335: .  endfor
                   1336: .endif
1.1540.2.1  tv       1337:
                   1338: #===> "post-install"
                   1339:
                   1340: _REAL_TARGETS.su-install+=     post-install
                   1341: .PHONY: post-install
                   1342: post-install: .OPTIONAL
                   1343:
                   1344: #===> "plist"
                   1345: #
                   1346: # PLIST must be generated at this late point (instead of
                   1347: # depending on it somewhere earlier), because it needs
                   1348: # to be created _after_ the {pre,do,post}-install
                   1349: # targets are run.
                   1350: #
                   1351: # We generate _before_ post-install-script is run so
                   1352: # that the real config files and rc.d scripts aren't
                   1353: # listed in the PLIST.
                   1354: #
                   1355: _REAL_TARGETS.su-install+=     plist
                   1356: .PHONY: plist
                   1357: plist: ${PLIST}
                   1358:
                   1359: #===> "post-install-script"
                   1360:
                   1361: _REAL_TARGETS.su-install+=     post-install-script
                   1362: .PHONY: post-install-script
                   1363: post-install-script: .OPTIONAL
                   1364:
                   1365: #===> "post-install-man"
                   1366: # fixup manpages to match actual installed files
                   1367:
                   1368: _REAL_TARGETS.su-install+=     post-install-man
                   1369: .PHONY: post-install-man
                   1370: post-install-man:
                   1371:        ${_PKG_SILENT}${_PKG_DEBUG}newmanpages=`${EGREP} -h             \
                   1372:                '^([^@/]*/)*man/([^/]*/)?(man[1-9ln]/.*\.[1-9ln]|cat[1-9ln]/.*\.0)(\.gz)?$$' \
                   1373:                ${PLIST} 2>/dev/null || ${TRUE}`;                       \
                   1374:        if [ X"${MANCOMPRESSED}" != X"" -a X"${MANZ}" = X"" ]; then     \
                   1375:                ${ECHO_MSG} "${_PKGSRC_IN}> [Automatic manual page handling]";  \
                   1376:                ${ECHO_MSG} "${_PKGSRC_IN}> Decompressing manual pages for ${PKGNAME}"; \
                   1377:                for manpage in $$newmanpages; do                        \
                   1378:                        manpage=`${ECHO} $$manpage | ${SED} -e 's|\.gz$$||'`; \
                   1379:                        if [ -h ${PREFIX}/$$manpage.gz ]; then          \
                   1380:                                set - `${LS} -l ${PREFIX}/$$manpage.gz | ${SED} -e 's|\.gz$$||'`; \
                   1381:                                shift `expr $$# - 1`;                   \
                   1382:                                ${RM} -f ${PREFIX}/$$manpage;           \
                   1383:                                ${LN} -s $${1} ${PREFIX}/$$manpage;     \
                   1384:                                ${RM} ${PREFIX}/$$manpage.gz;           \
                   1385:                        else                                            \
                   1386:                                ${GUNZIP_CMD} ${PREFIX}/$$manpage.gz;   \
                   1387:                        fi;                                             \
                   1388:                        if [ X"${PKG_VERBOSE}" != X"" ]; then           \
                   1389:                                ${ECHO_MSG} "$$manpage";                \
                   1390:                        fi;                                             \
                   1391:                done;                                                   \
                   1392:        fi;                                                             \
                   1393:        if [ X"${MANCOMPRESSED}" = X"" -a X"${MANZ}" != X"" ]; then     \
                   1394:                ${ECHO_MSG} "${_PKGSRC_IN}> [Automatic manual page handling]";  \
                   1395:                ${ECHO_MSG} "${_PKGSRC_IN}> Compressing manual pages for ${PKGNAME}"; \
                   1396:                for manpage in $$newmanpages; do                        \
                   1397:                        manpage=`${ECHO} $$manpage | ${SED} -e 's|\.gz$$||'`; \
                   1398:                        if [ -h ${PREFIX}/$$manpage ]; then             \
                   1399:                                set - `${LS} -l ${PREFIX}/$$manpage`; \
                   1400:                                shift `expr $$# - 1`;                   \
                   1401:                                ${RM} -f ${PREFIX}/$$manpage.gz;        \
                   1402:                                ${LN} -s $${1}.gz ${PREFIX}/$$manpage.gz; \
                   1403:                                ${RM} ${PREFIX}/$$manpage;              \
                   1404:                        else                                            \
                   1405:                                ${GZIP_CMD} ${PREFIX}/$$manpage;        \
                   1406:                        fi;                                             \
                   1407:                        if [ X"${PKG_VERBOSE}" != X"" ]; then           \
                   1408:                                ${ECHO_MSG} "$$manpage";                \
                   1409:                        fi;                                             \
                   1410:                done;                                                   \
                   1411:        fi
                   1412:
                   1413: #===> "post-install-shlib"
                   1414:
                   1415: .  if ${_DO_SHLIB_CHECKS} == "yes"
                   1416: .    if ${PKG_INSTALLATION_TYPE} == "overwrite"
                   1417: _REAL_TARGETS.su-install+=     post-install-shlib
                   1418: .PHONY: post-install-shlib
                   1419: post-install-shlib:
                   1420:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1421:        ${MAKE} ${MAKEFLAGS} do-shlib-handling SHLIB_PLIST_MODE=0
                   1422: .    endif
                   1423: .  endif
                   1424:
                   1425: #===> "post-install-message"
                   1426: # display MESSAGE, if specified
                   1427:
                   1428: .  ifdef MESSAGE
                   1429: _REAL_TARGETS.su-install+=     post-install-message
                   1430: .PHONY: post-install-message
                   1431: post-install-message:
                   1432:        @${ECHO_MSG} "${_PKGSRC_IN}> Please note the following:"
                   1433:        @${ECHO_MSG} ""
                   1434:        @${CAT} ${MESSAGE}
                   1435:        @${ECHO_MSG} ""
                   1436: .    if !empty(PKGSRC_MESSAGE_RECIPIENTS)
                   1437:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1438:        (${ECHO} "The ${PKGNAME} package was installed on `${HOSTNAME_CMD}` at `date`"; \
                   1439:        ${ECHO} "";                                                     \
                   1440:        ${ECHO} "Please note the following:";                           \
                   1441:        ${ECHO} "";                                                     \
                   1442:        ${CAT} ${MESSAGE};                                              \
                   1443:        ${ECHO} "") |                                                   \
                   1444:        ${MAIL_CMD} -s"Package ${PKGNAME} installed on `${HOSTNAME_CMD}`" ${PKGSRC_MESSAGE_RECIPIENTS}
                   1445: .    endif
                   1446: .  endif
1.1433    grant    1447:
1.1540.2.1  tv       1448: #===> "fake-pkg"
1.1370    jlam     1449:
1.1540.2.1  tv       1450: _REAL_TARGETS.su-install+=     fake-pkg
1.1453    jlam     1451:
1.1540.2.1  tv       1452: #===> "check-shlibs"
1.1032    jlam     1453:
1.1540.2.1  tv       1454: .  if defined(PKG_DEVELOPER) && (${CHECK_SHLIBS} == "YES")
                   1455: _REAL_TARGETS.su-install+=     check-shlibs
1.1492    tv       1456: .  endif
                   1457:
1.1540.2.1  tv       1458: .endif # !empty(PKG_PHASES:Minstall)
1.1441    jmmv     1459:
1.1540.2.1  tv       1460: ############################################################################
1.1540.2.3  tv       1461: # Special install phase `replace'
                   1462: ############################################################################
                   1463:
                   1464: _REAL_TARGETS.replace+=        do-su-replace
                   1465:
                   1466: _REAL_TARGETS.su-replace+=
                   1467:
                   1468: _REAL_TARGETS.undo-replace+= do-su-undo-replace
                   1469:
                   1470: ############################################################################
1.1540.2.1  tv       1471: # Phase `package'
                   1472: ############################################################################
1.1410    jlam     1473:
1.1540.2.5  tv       1474: .PHONY: descr
                   1475: descr: ${DESCR}
                   1476: ${DESCR}: ${DESCR_SRC}
                   1477:        @${CAT} ${DESCR_SRC}     >${DESCR}
                   1478: .if defined(HOMEPAGE)
                   1479:        @\
                   1480:        ${ECHO}                 >>${DESCR} ; \
                   1481:        ${ECHO} "Homepage:"     >>${DESCR} ; \
                   1482:        ${ECHO} '${HOMEPAGE}'   >>${DESCR}
                   1483: .endif
                   1484:
1.1540.2.3  tv       1485: _REAL_TARGETS.package+=        do-su-package
                   1486:
                   1487: _REAL_TARGETS.su-package+=
                   1488:
1.1540.2.1  tv       1489: ############################################################################
1.1540.2.3  tv       1490: # Variables calculated after all the above, and recursion support
1.1540.2.1  tv       1491: ############################################################################
1.1374    jlam     1492:
1.1540.2.2  tv       1493: # explicit "-f Makefile" here to work around problems with the MAKEFILE var
                   1494: # and case-insensitive filesystems (see PR pkg/28392)
                   1495: #
1.1540.2.1  tv       1496: .for targ in ${_PKG_PHASES_ALL}
                   1497: .PHONY: recurse-${targ}
                   1498: recurse-${targ}:
1.1540.2.2  tv       1499:        ${_PKG_SILENT}${_PKG_DEBUG}cd ${PKGDIR} && ${MAKE} -f Makefile ${targ}
1.1540.2.1  tv       1500: .endfor
1.1       agc      1501:
1.1540.2.1  tv       1502: # convenience target, to display make variables from command line
                   1503: # i.e. "make show-var VARNAME=var", will print var's value
                   1504: .PHONY: show-var show-var-noeval
                   1505: show-var show-var-noeval:
                   1506:        @${ECHO} ${${VARNAME}:Q}
1.117     agc      1507:
1.1540.2.1  tv       1508: # enhanced version of target above, to display multiple variables
                   1509: .PHONY: show-vars show-vars-noeval
                   1510: show-vars show-vars-noeval:
                   1511: .for VARNAME in ${VARNAMES}
                   1512:        @${ECHO} ${${VARNAME}:Q}
                   1513: .endfor
1.1       agc      1514:
1.1540.2.3  tv       1515: # Find out the PREFIX of dependencies where the PREFIX is needed at build time.
                   1516: .if defined(EVAL_PREFIX)
                   1517: .  for def in ${EVAL_PREFIX}
                   1518: .    if !defined(${def:C/=.*$//})
                   1519: ${def:C/=.*$//}_DEFAULT?=${LOCALBASE}
                   1520: _${def:C/=.*$//}_CMD=  ${PKG_INFO} -qp ${def:C/^.*=//} 2>/dev/null | ${AWK} '{ print $$2; exit }' | grep '' || ${ECHO} ${${def:C/=.*$//}_DEFAULT}
                   1521: ${def:C/=.*$//}=       ${_${def:C/=.*$//}_CMD:sh}
                   1522: .    endif
                   1523: .  endfor
                   1524: .endif
                   1525:
1.1540.2.1  tv       1526: PREPEND_PATH?=         # empty
                   1527: .if !empty(PREPEND_PATH)
                   1528: # This is very Special.  Because PREPEND_PATH is set with += in reverse order,
                   1529: # the awk expression reverses the order again (since bootstrap bmake doesn't
                   1530: # yet support the :[-1..1] construct).
                   1531: _PATH_CMD=             ${ECHO} `${ECHO} ${PREPEND_PATH:Q} | ${AWK} '{for (i=NF;i>0;i--) print $$i}'`:${_PATH_ORIG} | ${TR} ' ' :
                   1532: PATH=                  ${_PATH_CMD:sh} # DOES NOT use :=, to defer evaluation
                   1533: .endif
                   1534:
                   1535: ############################################################################
                   1536: # User-visible make targets
                   1537: ############################################################################
                   1538:
                   1539: # Catch-all targets.
                   1540: # Without anything specified, assume "all".  Also allow "dependall" to be
                   1541: # specified for those in the habit of using that in NetBSD main source.
                   1542: # Recurses to ensure that .if make() conditionals work as expected.
1.547     hubertf  1543:
1.1540.2.1  tv       1544: .if !empty(PKGSRC_RUN_TEST:M[yY][eE][sS])
                   1545: # only invoke "test" if requested; makes SMART_MESSAGES look nicer
                   1546: _PKG_ALL_TARGET=       test
                   1547: .endif
1.547     hubertf  1548:
1.1540.2.1  tv       1549: .PHONY: all dependall
                   1550: .MAIN: all
                   1551: all dependall: recurse-${_PKG_ALL_TARGET:Ubuild}
1.1       agc      1552:
1.1540.2.5  tv       1553: # Depend is generally meaningless for arbitrary packages, but if someone wants
                   1554: # one they can override this.  This is just to catch people who've gotten into
                   1555: # the habit of typing `${MAKE} depend all install' as a matter of course.
                   1556:
                   1557: .PHONY: depend
                   1558: depend: .OPTIONAL
                   1559:
                   1560: # Same goes for tags
                   1561: .PHONY: tags
                   1562: tags: .OPTIONAL
                   1563:
1.1540.2.3  tv       1564: ##### If this package will be skipped, use placebo targets.
1.1540.2.1  tv       1565:
                   1566: .if defined(_PKG_SKIPPED)
1.1540.2.3  tv       1567:
                   1568: .  for targ in ${_PKG_PHASES_ALL} \
                   1569:                replace undo-replace \
                   1570:                update
1.1540.2.1  tv       1571: ${targ}:
                   1572: .    if !defined(SKIP_SILENT)
1.1102    schmonz  1573:        @for str in ${PKG_FAIL_REASON} ${PKG_SKIP_REASON} ; \
1.547     hubertf  1574:        do \
                   1575:                ${ECHO} "${_PKGSRC_IN}> $$str" ; \
                   1576:        done
1.789     hubertf  1577: .    endif
1.1102    schmonz  1578: .    if defined(PKG_FAIL_REASON)
                   1579:        @${FALSE}
1.789     hubertf  1580: .    endif
1.1540.2.1  tv       1581: .  endfor
1.38      hubertf  1582:
1.1540.2.3  tv       1583: .else  # !defined(_PKG_SKIPPED)
1.1       agc      1584:
1.1540.2.3  tv       1585: ##### Real targets.  These don't have any commands attached; they simply defer
                   1586: ##### to other implementation targets below.
1.1       agc      1587:
1.1540.2.1  tv       1588: .PHONY: ${_PKG_PHASES_ALL} replace undo-replace
                   1589: fetch: real-fetch
                   1590: checksum: fetch real-checksum
                   1591: depends: checksum ${WRKDIR} acquire-depends-lock ${depends_COOKIE} release-depends-lock
                   1592: extract: depends acquire-extract-lock ${extract_COOKIE} release-extract-lock
                   1593: patch: extract acquire-patch-lock ${patch_COOKIE} release-patch-lock
                   1594: tools: patch acquire-tools-lock ${tools_COOKIE} release-tools-lock
                   1595: wrapper: tools acquire-wrapper-lock ${wrapper_COOKIE} release-wrapper-lock
                   1596: configure: wrapper acquire-configure-lock ${configure_COOKIE} release-configure-lock
                   1597: build: configure acquire-build-lock ${build_COOKIE} release-build-lock
                   1598: test: build acquire-test-lock ${test_COOKIE} release-test-lock
                   1599: install: test acquire-install-lock ${install_COOKIE} release-install-lock
                   1600: package: install acquire-package-lock ${package_COOKIE} release-package-lock
                   1601: replace: build real-replace
                   1602: undo-replace: real-undo-replace
                   1603:
1.1540.2.3  tv       1604: ##### *_COOKIE to real-* layer for targets which use cookies.
                   1605:
                   1606: .  for targ in ${_PKG_PHASES_WRKDIR}
                   1607: ${${targ}_COOKIE}: real-${targ}
1.1540.2.8! tv       1608:        ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f $@ && ${ECHO} ${PKGNAME} >$@
1.1540.2.3  tv       1609: .  endfor
                   1610:
                   1611: # mark a stage as complete if its cookie (and all parent cookies) exist
                   1612: .  if exists(${depends_COOKIE})
                   1613: ${depends_COOKIE}: .MADE
                   1614: .    if exists(${extract_COOKIE})
                   1615: ${extract_COOKIE}: .MADE
                   1616: .      if exists(${patch_COOKIE})
                   1617: ${patch_COOKIE}: .MADE
                   1618: .        if exists(${tools_COOKIE})
                   1619: ${tools_COOKIE}: .MADE
                   1620: .          if exists(${wrapper_COOKIE})
                   1621: ${wrapper_COOKIE}: .MADE
                   1622: .            if exists(${configure_COOKIE})
                   1623: ${configure_COOKIE}: .MADE
                   1624: .              if exists(${build_COOKIE})
                   1625: ${build_COOKIE}: .MADE
                   1626: .                if exists(${test_COOKIE})
                   1627: ${test_COOKIE}: .MADE
                   1628: .                  if exists(${install_COOKIE})
                   1629: ${install_COOKIE}: .MADE
                   1630: .                    if exists(${package_COOKIE})
                   1631: ${package_COOKIE}: .MADE
                   1632: .                    endif
                   1633: .                  endif
                   1634: .                endif
                   1635: .              endif
                   1636: .            endif
                   1637: .          endif
                   1638: .        endif
                   1639: .      endif
                   1640: .    endif
                   1641: .  endif
                   1642:
                   1643: ##### NO_* for skipping phases
                   1644:
                   1645: .  if defined(NO_DEPENDS) || (empty(DEPENDS) && empty(BUILD_DEPENDS))
                   1646: ${depends_COOKIE}: .MADE
                   1647: .  endif
                   1648: .  if defined(NO_TOOLS)
                   1649: ${tools_COOKIE}: .MADE
                   1650: .  endif
                   1651: .  if defined(NO_WRAPPER)
                   1652: ${wrapper_COOKIE}: .MADE
                   1653: .  endif
                   1654: .  if defined(NO_CONFIGURE)
                   1655: ${configure_COOKIE}: .MADE
                   1656: .  endif
                   1657: .  if defined(NO_BUILD)
                   1658: ${build_COOKIE}: .MADE
                   1659: .  endif
                   1660: .  if empty(PKGSRC_RUN_TEST:M[yY][eE][sS])
                   1661: real-test: .MADE
                   1662: .  endif
                   1663: .  if defined(NO_INSTALL)
                   1664: ${install_COOKIE}: .MADE
                   1665: .  endif
                   1666:
                   1667: .  if defined(NO_PACKAGE) && !defined(FORCE_PACKAGE)
                   1668: _REAL_TARGETS.package:=        no-package
                   1669: no-package:
                   1670: .    if !defined(SKIP_SILENT)
                   1671:        @${ECHO_MSG} "${_PKGSRC_IN}> ${PKGNAME} may not be packaged: ${NO_PACKAGE}."
                   1672: .    endif
                   1673: .  endif
                   1674:
                   1675: .  for targ in extract configure build install
                   1676: .    if !empty(INTERACTIVE_STAGE:M${targ}) && defined(BATCH)
                   1677: _REAL_TARGETS.${targ}:=        ${targ}-is-interactive
                   1678: ${targ}-is-interactive:
                   1679:        @${ECHO} "*** The ${targ} stage of this package requires user interaction"
                   1680:        @${ECHO} "*** Please ${targ} manually with \"cd ${PKGDIR} && ${MAKE} ${targ}\""
                   1681:        @${FALSE}
                   1682: .    endif
                   1683: .  endfor
                   1684:
                   1685: ##### User-visible messages for most targets
                   1686:
                   1687: _PHASE_MSG.depends=    Verifying dependencies
                   1688: _PHASE_MSG.extract=    Extracting
                   1689: _PHASE_MSG.patch=      Patching
                   1690: _PHASE_MSG.tools=      Overriding tools
                   1691: _PHASE_MSG.wrapper=    Creating toolchain wrappers
                   1692: _PHASE_MSG.configure=  Configuring
                   1693: _PHASE_MSG.build=      Building
                   1694: _PHASE_MSG.test=       Testing
                   1695: _PHASE_MSG.install=    Installing
                   1696: _PHASE_MSG.package=    Packaging
                   1697:
                   1698: .  for targ in ${_PKG_PHASES_WRKDIR}
                   1699: .PHONY: ${targ}-message
                   1700: ${targ}-message:
                   1701:        @${ECHO_MSG} "${_PKGSRC_IN}> ${_PHASE_MSG.${targ}} for ${PKGNAME}"
                   1702: .  endfor
                   1703:
                   1704: ##### real-* to actual component target layer
                   1705:
                   1706: # Simple dependencies are not used, deliberately, so that it is possible
                   1707: # to invoke a single subtarget by hand while working on a new package.
                   1708: #
                   1709: # Please note that the order of the targets in _REAL_TARGETS.<phase> is
                   1710: # important, and should not be modified (.ORDER is not recognized by
                   1711: # make(1) in a serial make; i.e., without "-j n").
                   1712:
                   1713: .  for targ in ${_PKG_PHASES_ALL} replace undo-replace su-install
                   1714: .PHONY: real-${targ}
                   1715: .ORDER: ${_REAL_TARGETS.${targ}}
                   1716: real-${targ}: ${_REAL_TARGETS.${targ}}
                   1717: .  endfor
                   1718:
1.1540.2.1  tv       1719: .endif # !defined(_PKG_SKIPPED)
                   1720:
1.1540.2.3  tv       1721: ##### su target support
                   1722:
                   1723: .for targ in install package replace undo-replace deinstall
                   1724: .PHONY: do-su-${targ}
                   1725: do-su-${targ}:
                   1726:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1727:        if [ `${ID} -u` = `${ID} -u ${ROOT_USER}` ]; then               \
                   1728:                ${MAKE} ${MAKEFLAGS} $$realtarget;                      \
                   1729:        elif [ "X${BATCH}" != X"" ]; then                               \
                   1730:                ${ECHO_MSG} "Warning: Batch mode, not superuser, can't run $$action for ${PKGNAME}."; \
                   1731:                ${ECHO_MSG} "Become ${ROOT_USER} and try again to ensure correct permissions."; \
                   1732:        else                                                            \
                   1733:                args="DEINSTALLDEPENDS=${DEINSTALLDEPENDS}";            \
                   1734:                if [ "X${FORCE_PKG_REGISTER}" != X"" ]; then            \
                   1735:                        args="$$args FORCE_PKG_REGISTER=1";             \
                   1736:                fi;                                                     \
                   1737:                if [ "X${PKG_DEBUG_LEVEL}" != X"" ]; then               \
                   1738:                        args="$$args PKG_DEBUG_LEVEL=${PKG_DEBUG_LEVEL}"; \
                   1739:                fi;                                                     \
                   1740:                if [ "X${PRE_ROOT_CMD}" != "X${TRUE}" ]; then           \
                   1741:                        ${ECHO} "*** WARNING *** Running: ${PRE_ROOT_CMD}"; \
                   1742:                        ${PRE_ROOT_CMD};                                \
                   1743:                fi;                                                     \
                   1744:                ${ECHO_MSG} "${_PKGSRC_IN}> Becoming ${ROOT_USER}@`${HOSTNAME_CMD}` to ${targ} ${PKGBASE}."; \
                   1745:                ${ECHO_N} "`${ECHO} ${SU_CMD} | ${AWK} '{ print $$1 }'` ";\
                   1746:                ${SU_CMD} "cd ${.CURDIR}; ${SETENV} PATH=$${PATH}:${SU_CMD_PATH_APPEND} ${MAKE} $$args ${MAKEFLAGS} real-su-${targ} $$realflags"; \
                   1747:        fi
                   1748: .endfor
                   1749:
1.1540.2.1  tv       1750: ############################################################################
                   1751: # Package maintenance targets
                   1752: ############################################################################
1.1       agc      1753:
1.1540.2.1  tv       1754: # Checksumming utilities
1.1       agc      1755:
1.1540.2.1  tv       1756: .PHONY: makesum
                   1757: makesum: recurse-fetch uptodate-digest
                   1758:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1759:        newfile=${DISTINFO_FILE}.$$$$;                                  \
                   1760:        if [ -f ${DISTINFO_FILE} ]; then                                \
                   1761:                ${GREP} '^.NetBSD' ${DISTINFO_FILE} > $$newfile ||      \
                   1762:                        (${ECHO_N} "$$" > $$newfile &&                  \
                   1763:                         ${ECHO_N} "NetBSD" >> $$newfile &&             \
                   1764:                         ${ECHO} "$$" >> $$newfile)                     \
                   1765:        else                                                            \
                   1766:                ${ECHO_N} "$$" > $$newfile;                             \
                   1767:                ${ECHO_N} "NetBSD" >> $$newfile;                        \
                   1768:                ${ECHO} "$$" >> $$newfile;                              \
                   1769:        fi;                                                             \
                   1770:        ${ECHO} "" >> $$newfile;                                        \
                   1771:        cd ${DISTDIR};                                                  \
                   1772:        for sumfile in "" ${_CKSUMFILES}; do                            \
                   1773:                if [ "X$$sumfile" = "X" ]; then continue; fi;           \
                   1774:                ${DIGEST} ${DIGEST_ALGORITHM} $$sumfile >> $$newfile;   \
                   1775:                ${WC} -c $$sumfile | ${AWK} '{ print "Size (" $$2 ") = " $$1 " bytes" }' >> $$newfile; \
                   1776:        done;                                                           \
                   1777:        for ignore in "" ${_IGNOREFILES}; do                            \
                   1778:                if [ "X$$ignore" = "X" ]; then continue; fi;            \
                   1779:                ${ECHO} "${DIGEST_ALGORITHM} ($$ignore) = IGNORE" >> $$newfile; \
                   1780:        done;                                                           \
                   1781:        if [ -f ${DISTINFO_FILE} ]; then                                \
                   1782:                ${AWK} '$$2 ~ /\(patch-[a-z0-9]+\)/ { print $$0 }' < ${DISTINFO_FILE} >> $$newfile; \
                   1783:        fi;                                                             \
                   1784:        if ${CMP} -s $$newfile ${DISTINFO_FILE}; then                   \
                   1785:                ${RM} -f $$newfile;                                     \
                   1786:                ${ECHO_MSG} "=> distinfo: distfiles part unchanged.";   \
                   1787:        else                                                            \
                   1788:                ${MV} $$newfile ${DISTINFO_FILE};                       \
                   1789:        fi
                   1790:
                   1791: .PHONY: makepatchsum mps
                   1792: makepatchsum mps: uptodate-digest
                   1793:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   1794:        newfile=${DISTINFO_FILE}.$$$$;                                  \
                   1795:        if [ -f ${DISTINFO_FILE} ]; then                                \
                   1796:                ${AWK} '$$2 !~ /\(patch-[a-z0-9]+\)/ { print $$0 }' < ${DISTINFO_FILE} >> $$newfile; \
                   1797:        else \
                   1798:                ${ECHO_N} "$$" > $$newfile;                             \
                   1799:                ${ECHO_N} "NetBSD" >> $$newfile;                        \
                   1800:                ${ECHO} "$$" >> $$newfile;                              \
                   1801:                ${ECHO} "" >> $$newfile;                                \
                   1802:        fi;                                                             \
                   1803:        if [ -d ${PATCHDIR} ]; then                                     \
                   1804:                (cd ${PATCHDIR};                                        \
                   1805:                for sumfile in "" patch-*; do                           \
                   1806:                        if [ "X$$sumfile" = "X" ]; then continue; fi;   \
                   1807:                        if [ "X$$sumfile" = "Xpatch-*" ]; then break; fi; \
                   1808:                        case $$sumfile in                               \
                   1809:                                patch-local-*) ;;                       \
                   1810:                                *.orig|*.rej|*~) continue ;;            \
                   1811:                                *)      ${ECHO} "${DIGEST_ALGORITHM} ($$sumfile) = `${SED} -e '/\$$NetBSD.*/d' $$sumfile | ${DIGEST} ${DIGEST_ALGORITHM}`" >> $$newfile;; \
                   1812:                        esac;                                           \
                   1813:                done);                                                  \
                   1814:        fi;                                                             \
                   1815:        if ${CMP} -s $$newfile ${DISTINFO_FILE}; then                   \
                   1816:                ${RM} -f $$newfile;                                     \
                   1817:                ${ECHO_MSG} "=> distinfo: patches part unchanged.";     \
                   1818:        else                                                            \
                   1819:                ${MV} $$newfile ${DISTINFO_FILE};                       \
                   1820:        fi
                   1821:
                   1822: makedistinfo mdi distinfo: makesum makepatchsum
                   1823:
                   1824: ############################################################################
                   1825: # XXXTV CUT
                   1826: ############################################################################
                   1827:
                   1828: UPDATE_RUNNING?=       NO
                   1829:
                   1830: #
                   1831: # _RESUME_TRANSFER:
                   1832: #
                   1833: # Macro to resume a previous transfer, needs to have defined
                   1834: # the following options in mk.conf:
                   1835: #
                   1836: # PKG_RESUME_TRANSFERS
                   1837: # FETCH_RESUME_ARGS (if FETCH_CMD != default)
                   1838: # FETCH_OUTPUT_ARGS (if FETCH_CMD != default)
                   1839: #
                   1840: # For example if you want to use wget (pkgsrc/net/wget):
                   1841: #
                   1842: # FETCH_CMD=wget
                   1843: # FETCH_RESUME_ARGS=-c
                   1844: # FETCH_OUTPUT_ARGS=-O
                   1845: #
                   1846: # How does it work?
                   1847: #
                   1848: # FETCH_CMD downloads the file and saves it temporally into $$bfile.temp
                   1849: # if the checksum match the correct one, $$bfile.temp is renamed to
                   1850: # the original name.
                   1851: #
1.1525    xtraeme  1852:
1.1477    xtraeme  1853: _RESUME_TRANSFER=                                                      \
1.1479    xtraeme  1854:        tsize=`${AWK} '/^Size/ && $$2 == '"\"($$file)\""' { print $$4 }' ${DISTINFO_FILE}` || ${TRUE}; \
1.1525    xtraeme  1855:        if [ ! -f "${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp" ]; then      \
                   1856:                ${CP} ${DISTDIR}/${DIST_SUBDIR}/$$bfile ${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp; \
                   1857:        fi;     \
                   1858:        dsize=`${WC} -c < ${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp`;      \
                   1859:        if [ "$$dsize" -eq "$$tsize" -a -f "${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp" ]; then     \
                   1860:                ${MV} ${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp ${DISTDIR}/${DIST_SUBDIR}/$$bfile; \
                   1861:        fi;     \
1.1478    agc      1862:        case "$$tsize" in                                               \
                   1863:        "")     ${ECHO_MSG} "No size in distinfo file (${DISTINFO_FILE})"; \
                   1864:                break ;;                                                \
                   1865:        esac;                                                           \
1.1525    xtraeme  1866:        if [ -n "$$ftp_proxy" -o -n "$$http_proxy" ]; then              \
1.1477    xtraeme  1867:                ${ECHO_MSG} "===> Resume is not supported by ftp(1) using http/ftp proxies.";   \
                   1868:                break;                                                  \
                   1869:        else                                                            \
1.1525    xtraeme  1870:                if [ "$$dsize" -lt "$$tsize" ]; then            \
                   1871:                        if [ "${FETCH_CMD:T}" != "ftp" -a -z "${FETCH_RESUME_ARGS}" ]; then \
1.1479    xtraeme  1872:                                ${ECHO_MSG} "=> Resume transfers are not supported, FETCH_RESUME_ARGS is empty."; \
                   1873:                                break;                                  \
                   1874:                        else                                            \
                   1875:                                for res_site in $$sites; do                     \
1.1525    xtraeme  1876:                                        if [ -z "${FETCH_OUTPUT_ARGS}" ]; then  \
                   1877:                                                ${ECHO_MSG} "=> FETCH_OUTPUT_ARGS has to be defined.";  \
                   1878:                                                break;                  \
                   1879:                                        fi;                             \
                   1880:                                        ${ECHO_MSG} "=> $$bfile not completed, resuming:";      \
                   1881:                                        ${ECHO_MSG} "=> Downloaded: $$dsize Total: $$tsize.";   \
                   1882:                                        ${ECHO_MSG};                    \
                   1883:                                        cd ${_DISTDIR};                 \
                   1884:                                        ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${FETCH_RESUME_ARGS}  \
                   1885:                                                ${FETCH_OUTPUT_ARGS} $${bfile}.temp $${res_site}$${bfile}; \
                   1886:                                        if [ $$? -eq 0 ]; then          \
                   1887:                                                ndsize=`${WC} -c < ${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp`;     \
                   1888:                                                if [ "$$tsize" -eq "$$ndsize" ]; then   \
                   1889:                                                        ${MV} ${DISTDIR}/${DIST_SUBDIR}/$$bfile.temp ${DISTDIR}/${DIST_SUBDIR}/$$bfile;                                         \
                   1890:                                                fi;                     \
1.1479    xtraeme  1891:                                                break;                  \
                   1892:                                        fi;                             \
                   1893:                                done;                                   \
                   1894:                        fi;                                             \
1.1525    xtraeme  1895:                elif [ "$$dsize" -gt "$$tsize" ]; then                  \
1.1479    xtraeme  1896:                        ${ECHO_MSG} "==> Downloaded file larger than the recorded size.";       \
                   1897:                        break;                                          \
1.1525    xtraeme  1898:                fi;                                                     \
1.1477    xtraeme  1899:        fi
1.1478    agc      1900:
1.895     fredb    1901: #
                   1902: # Define the elementary fetch macros.
                   1903: #
1.158     tron     1904: _FETCH_FILE=                                                           \
1.307     agc      1905:        if [ ! -f $$file -a ! -f $$bfile -a ! -h $$bfile ]; then        \
1.415     agc      1906:                ${ECHO_MSG} "=> $$bfile doesn't seem to exist on this system."; \
1.444     hubertf  1907:                if [ ! -w ${_DISTDIR}/. ]; then                         \
                   1908:                        ${ECHO_MSG} "=> Can't download to ${_DISTDIR} (permission denied?)."; \
                   1909:                        exit 1;                                         \
                   1910:                fi;                                                     \
1.175     agc      1911:                for site in $$sites; do                                 \
1.415     agc      1912:                        ${ECHO_MSG} "=> Attempting to fetch $$bfile from $${site}."; \
1.935     agc      1913:                        if [ -f ${DISTINFO_FILE} ]; then                \
                   1914:                                ${AWK} 'NF == 5 && $$1 == "Size" && $$2 == "('$$bfile')" { printf("=> [%s %s]\n", $$4, $$5) }' ${DISTINFO_FILE}; \
                   1915:                        fi;                                             \
1.175     agc      1916:                        if ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${bfile} ${FETCH_AFTER_ARGS}; then \
1.753     wiz      1917:                                if [ -n "${FAILOVER_FETCH}" -a -f ${DISTINFO_FILE} -a -f ${_DISTDIR}/$$bfile ]; then \
                   1918:                                        alg=`${AWK} 'NF == 4 && $$2 == "('$$file')" && $$3 == "=" {print $$1;}' ${DISTINFO_FILE}`; \
1.699     agc      1919:                                        if [ -z "$$alg" ]; then         \
                   1920:                                                alg=${DIGEST_ALGORITHM};\
                   1921:                                        fi;                             \
1.676     agc      1922:                                        CKSUM=`${DIGEST} $$alg < ${_DISTDIR}/$$bfile`; \
1.753     wiz      1923:                                        CKSUM2=`${AWK} '$$1 == "'$$alg'" && $$2 == "('$$file')" {print $$4;}' <${DISTINFO_FILE}`; \
1.175     agc      1924:                                        if [ "$$CKSUM" = "$$CKSUM2" -o "$$CKSUM2" = "IGNORE" ]; then \
1.873     wiz      1925:                                                break;                  \
1.154     agc      1926:                                        else                            \
1.415     agc      1927:                                                ${ECHO_MSG} "=> Checksum failure - trying next site."; \
1.154     agc      1928:                                        fi;                             \
1.300     hubertf  1929:                                elif [ ! -f ${_DISTDIR}/$$bfile ]; then \
1.415     agc      1930:                                        ${ECHO_MSG} "=> FTP didn't fetch expected file, trying next site." ; \
1.175     agc      1931:                                else                                    \
1.873     wiz      1932:                                        break;                          \
1.175     agc      1933:                                fi;                                     \
                   1934:                        fi                                              \
                   1935:                done;                                                   \
1.873     wiz      1936:                if [ ! -f ${_DISTDIR}/$$bfile ]; then \
                   1937:                        ${ECHO_MSG} "=> Couldn't fetch $$bfile - please try to retrieve this";\
                   1938:                        ${ECHO_MSG} "=> file manually into ${_DISTDIR} and try again."; \
                   1939:                        exit 1;                                         \
                   1940:                fi;                                                     \
1.175     agc      1941:        fi
1.158     tron     1942:
1.305     agc      1943: _CHECK_DIST_PATH=                                                      \
                   1944:        if [ "X${DIST_PATH}" != "X" ]; then                             \
1.452     hubertf  1945:                for d in "" ${DIST_PATH:S/:/ /g}; do    \
1.305     agc      1946:                        if [ "X$$d" = "X" -o "X$$d" = "X${DISTDIR}" ]; then continue; fi; \
                   1947:                        if [ -f $$d/${DIST_SUBDIR}/$$bfile ]; then      \
                   1948:                                ${ECHO} "Using $$d/${DIST_SUBDIR}/$$bfile"; \
                   1949:                                ${RM} -f $$bfile;                       \
                   1950:                                ${LN} -s $$d/${DIST_SUBDIR}/$$bfile $$bfile; \
                   1951:                                break;                                  \
                   1952:                        fi;                                             \
                   1953:                done;                                                   \
                   1954:        fi
                   1955:
1.297     mjl      1956: #
1.941     fredb    1957: # Set up ORDERED_SITES to work out the exact list of sites for every file,
                   1958: # using the dynamic sites script, or sorting according to the master site
                   1959: # list or the patterns in MASTER_SORT or MASTER_SORT_REGEX as appropriate.
                   1960: # No actual sorting is done until ORDERED_SITES is expanded.
                   1961: #
1.944     fredb    1962: .if defined(MASTER_SORT) || defined(MASTER_SORT_REGEX)
1.297     mjl      1963: MASTER_SORT?=
                   1964: MASTER_SORT_REGEX?=
                   1965: MASTER_SORT_REGEX+= ${MASTER_SORT:S/./\\./g:C/.*/:\/\/[^\/]*&\//}
                   1966:
1.1338    wiz      1967: MASTER_SORT_AWK= BEGIN { RS = " "; ORS = " "; IGNORECASE = 1 ; gl = "${MASTER_SORT_REGEX:S/\\/\\\\/g}"; }
1.941     fredb    1968: .  for srt in ${MASTER_SORT_REGEX}
1.1338    wiz      1969: MASTER_SORT_AWK+= /${srt:C/\//\\\//g}/ { good["${srt:S/\\/\\\\/g}"] = good["${srt:S/\\/\\\\/g}"] " " $$0 ; next; }
1.941     fredb    1970: .  endfor
1.452     hubertf  1971: MASTER_SORT_AWK+= { rest = rest " " $$0; } END { n=split(gl, gla); for(i=1;i<=n;i++) { print good[gla[i]]; } print rest; }
                   1972:
1.895     fredb    1973: SORT_SITES_CMD= ${ECHO} $$unsorted_sites | ${AWK} '${MASTER_SORT_AWK}'
1.1338    wiz      1974: ORDERED_SITES= ${_MASTER_SITE_OVERRIDE} `${SORT_SITES_CMD:S/\\/\\\\/g:C/"/\"/g}`
1.895     fredb    1975: .else
1.896     fredb    1976: ORDERED_SITES= ${_MASTER_SITE_OVERRIDE} $$unsorted_sites
1.895     fredb    1977: .endif
1.297     mjl      1978:
1.895     fredb    1979: #
1.941     fredb    1980: # Associate each file to fetch with the correct site(s).
1.895     fredb    1981: #
1.944     fredb    1982: .if defined(DYNAMIC_MASTER_SITES)
                   1983: .  for fetchfile in ${_ALLFILES}
1.1060    rh       1984: SITES_${fetchfile:T:S/=/--/}?= `${SH} ${FILESDIR}/getsite.sh ${fetchfile:T}`
1.944     fredb    1985: .  endfor
                   1986: .endif
1.941     fredb    1987: .if !empty(_DISTFILES)
                   1988: .  for fetchfile in ${_DISTFILES}
1.1060    rh       1989: SITES_${fetchfile:T:S/=/--/}?= ${MASTER_SITES}
1.941     fredb    1990: .  endfor
                   1991: .endif
                   1992: .if !empty(_PATCHFILES)
                   1993: .  for fetchfile in ${_PATCHFILES}
1.1060    rh       1994: SITES_${fetchfile:T:S/=/--/}?= ${PATCH_SITES}
1.941     fredb    1995: .  endfor
                   1996: .endif
                   1997:
1.1003    agc      1998: # This code is only called in a batch case, to check for the presence of
                   1999: # the distfiles
1.1222    jmmv     2000: .PHONY: batch-check-distfiles
1.1003    agc      2001: batch-check-distfiles:
1.941     fredb    2002:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.1003    agc      2003:        gotfiles=yes;                                                   \
                   2004:        for file in "" ${_ALLFILES}; do                                 \
                   2005:                case "$$file" in                                        \
                   2006:                "")     continue ;;                                     \
                   2007:                *)      if [ ! -f ${DISTDIR}/$$file ]; then             \
                   2008:                                gotfiles=no;                            \
                   2009:                        fi ;;                                           \
                   2010:                esac;                                                   \
                   2011:        done;                                                           \
                   2012:        case "$$gotfiles" in                                            \
                   2013:        no)     ${ECHO} "*** This package requires user intervention to download the distfiles"; \
1.999     agc      2014:                ${ECHO} "*** Please fetch the distfiles manually and place them in"; \
                   2015:                ${ECHO} "*** ${DISTDIR}";                               \
                   2016:                [ ! -z "${MASTER_SITES}" ] &&                           \
                   2017:                        ${ECHO} "*** The distfiles are available from ${MASTER_SITES}"; \
                   2018:                [ ! -z "${HOMEPAGE}" ] &&                               \
                   2019:                        ${ECHO} "*** See ${HOMEPAGE} for more details"; \
                   2020:                ${ECHO};                                                \
1.1003    agc      2021:                ${FALSE} ;;                                             \
                   2022:        esac
                   2023:
1.1222    jmmv     2024: .PHONY: do-fetch
1.1003    agc      2025: .if !target(do-fetch)
                   2026: do-fetch:
                   2027: .  if !empty(_ALLFILES)
                   2028:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2029:        ${TEST} -d ${_DISTDIR} || ${MKDIR} ${_DISTDIR}
                   2030: .    if ${INTERACTIVE_STAGE:Mfetch} == "fetch" && defined(BATCH)
                   2031:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2032:        ${MAKE} ${MAKEFLAGS} batch-check-distfiles
1.999     agc      2033: .    else
                   2034: .      for fetchfile in ${_ALLFILES}
1.1159    grant    2035: .        if defined(_FETCH_MESSAGE)
1.941     fredb    2036:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2037:        file="${fetchfile}";                                            \
                   2038:        if [ ! -f ${DISTDIR}/$$file ]; then                             \
                   2039:                ${_FETCH_MESSAGE};                                      \
                   2040:        fi
1.999     agc      2041: .        else
1.941     fredb    2042:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2043:        cd ${_DISTDIR};                                                 \
1.924     abs      2044:        file="${fetchfile}";                                            \
                   2045:        bfile="${fetchfile:T}";                                         \
1.1060    rh       2046:        unsorted_sites="${SITES_${fetchfile:T:S/=/--/}} ${_MASTER_SITE_BACKUP}"; \
1.895     fredb    2047:        sites="${ORDERED_SITES}";                                       \
1.873     wiz      2048:        ${_CHECK_DIST_PATH};                                            \
1.1480    xtraeme  2049:         if ${TEST} "${PKG_RESUME_TRANSFERS:M[Yy][Ee][Ss]}" ; then      \
                   2050:                ${_FETCH_FILE}; ${_RESUME_TRANSFER};                    \
                   2051:         else                                                           \
                   2052:                ${_FETCH_FILE};                                         \
                   2053:         fi
1.999     agc      2054: .        endif # defined(_FETCH_MESSAGE)
                   2055: .      endfor
                   2056: .    endif # INTERACTIVE_STAGE == fetch
1.941     fredb    2057: .  endif # !empty(_ALLFILES)
1.646     dmcmahil 2058: .endif
                   2059:
1.929     jlam     2060: # Extract
                   2061:
                   2062: ${WRKDIR}:
                   2063: .if !defined(KEEP_WRKDIR)
                   2064: .  if ${PKGSRC_LOCKTYPE} == "sleep" || ${PKGSRC_LOCKTYPE} == "once"
                   2065: .    if !exists(${LOCKFILE})
                   2066:        ${_PKG_SILENT}${_PKG_DEBUG}${RM} -rf ${WRKDIR}
                   2067: .    endif
                   2068: .  endif
                   2069: .endif
                   2070:        ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${WRKDIR}
                   2071: .ifdef WRKOBJDIR
                   2072: .  if ${PKGSRC_LOCKTYPE} == "sleep" || ${PKGSRC_LOCKTYPE} == "once"
                   2073: .    if !exists(${LOCKFILE})
                   2074:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2075:        ${RM} -f ${WRKDIR_BASENAME} || ${TRUE}
                   2076: .    endif
                   2077: .  endif
                   2078:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2079:        if ${LN} -s ${WRKDIR} ${WRKDIR_BASENAME} 2>/dev/null; then      \
                   2080:                ${ECHO} "${WRKDIR_BASENAME} -> ${WRKDIR}";              \
                   2081:        fi
                   2082: .endif # WRKOBJDIR
1.1       agc      2083:
1.1396    wiz      2084: _EXTRACT_SUFFIXES=     .tar.gz .tgz .tar.bz2 .tbz .tar.Z .tar _tar.gz
                   2085: _EXTRACT_SUFFIXES+=    .shar.gz .shar.bz2 .shar.Z .shar
                   2086: _EXTRACT_SUFFIXES+=    .zip
                   2087: _EXTRACT_SUFFIXES+=    .lha .lzh
                   2088: _EXTRACT_SUFFIXES+=    .Z .bz2 .gz
                   2089: _EXTRACT_SUFFIXES+=    .zoo
1.1474    abs      2090: _EXTRACT_SUFFIXES+=    .bin
1.1396    wiz      2091: _EXTRACT_SUFFIXES+=    .rar
1.884     jlam     2092:
1.1540.2.1  tv       2093: .if (defined(PATCHFILES) && !empty(PATCHFILES:M*.bz2)) || \
                   2094:     !empty(EXTRACT_ONLY:M*.bz2) || !empty(EXTRACT_ONLY:M*.tbz) || \
1.918     jlam     2095:     !empty(EXTRACT_SUFX:M*.bz2) || !empty(EXTRACT_SUFX:M*.tbz)
1.884     jlam     2096: .  if exists(/usr/bin/bzcat)
                   2097: BZCAT=                 /usr/bin/bzcat <
                   2098: .  else
                   2099: BUILD_DEPENDS+=                bzip2>=0.9.0b:../../archivers/bzip2
                   2100: BZCAT=                 ${LOCALBASE}/bin/bzcat
                   2101: .  endif
                   2102: .endif
1.918     jlam     2103: .if !empty(EXTRACT_ONLY:M*.zip) || !empty(EXTRACT_SUFX:M*.zip)
1.917     jlam     2104: BUILD_DEPENDS+=                unzip-[0-9]*:../../archivers/unzip
1.884     jlam     2105: .endif
1.918     jlam     2106: .if !empty(EXTRACT_ONLY:M*.lzh) || !empty(EXTRACT_ONLY:M*.lha) || \
                   2107:     !empty(EXTRACT_SUFX:M*.lzh) || !empty(EXTRACT_SUFX:M*.lha)
1.1159    grant    2108: BUILD_DEPENDS+=                lha>=114.9:../../archivers/lha
1.1004    grant    2109: .endif
                   2110: .if !defined(GZCAT)
1.1540.2.1  tv       2111: .  if (defined(PATCHFILES) && !empty(PATCHFILES:M*.gz)) || \
                   2112: .     !empty(EXTRACT_ONLY:M*.gz) || !empty(EXTRACT_ONLY:M*.tgz) || \
1.1004    grant    2113:       !empty(EXTRACT_SUFX:M*.gz) || !empty(EXTRACT_SUFX:M*.tgz)
1.1516    tv       2114: BUILD_DEPENDS+=         gzip-base>=1.2.4b:../../archivers/gzip-base
1.1004    grant    2115: GZCAT=                  ${LOCALBASE}/bin/zcat
                   2116: .  endif
1.884     jlam     2117: .endif
1.1110    cjep     2118: .if !empty(EXTRACT_ONLY:M*.zoo) || !empty(EXTRACT_SUFX:M*.zoo)
                   2119: BUILD_DEPENDS+=                unzoo-[0-9]*:../../archivers/unzoo
                   2120: .endif
1.1393    xtraeme  2121: .if !empty(EXTRACT_ONLY:M*.rar) || !empty(EXTRACT_SUFX:M*.rar)
                   2122: BUILD_DEPENDS+=                unrar>=3.3.4:../../archivers/unrar
                   2123: .endif
1.884     jlam     2124:
                   2125: DECOMPRESS_CMD.tar.gz?=                ${GZCAT}
                   2126: DECOMPRESS_CMD.tgz?=           ${DECOMPRESS_CMD.tar.gz}
                   2127: DECOMPRESS_CMD.tar.bz2?=       ${BZCAT}
                   2128: DECOMPRESS_CMD.tbz?=           ${DECOMPRESS_CMD.tar.bz2}
1.930     jlam     2129: DECOMPRESS_CMD.tar.Z?=         ${GZCAT}
1.884     jlam     2130: DECOMPRESS_CMD.tar?=           ${CAT}
                   2131:
1.914     jlam     2132: DECOMPRESS_CMD.shar.gz?=       ${GZCAT}
                   2133: DECOMPRESS_CMD.shar.bz2?=      ${BZCAT}
                   2134: DECOMPRESS_CMD.shar.Z?=                ${GZCAT}
                   2135: DECOMPRESS_CMD.shar?=          ${CAT}
                   2136:
1.929     jlam     2137: DECOMPRESS_CMD.Z?=             ${GZCAT}
                   2138: DECOMPRESS_CMD.bz2?=           ${BZCAT}
                   2139: DECOMPRESS_CMD.gz?=            ${GZCAT}
                   2140:
1.884     jlam     2141: DECOMPRESS_CMD?=               ${GZCAT}
1.1396    wiz      2142: .for __suffix__ in ${_EXTRACT_SUFFIXES}
1.884     jlam     2143: .  if !defined(DECOMPRESS_CMD${__suffix__})
                   2144: DECOMPRESS_CMD${__suffix__}?=  ${DECOMPRESS_CMD}
                   2145: .  endif
                   2146: .endfor
                   2147:
                   2148: # If this is empty, then everything gets extracted.
                   2149: EXTRACT_ELEMENTS?=     # empty
                   2150:
1.929     jlam     2151: DOWNLOADED_DISTFILE=   $${extract_file}
1.240     agc      2152:
1.1304    jlam     2153: EXTRACT_CMD.zip?=      ${LOCALBASE}/bin/unzip ${EXTRACT_CMD_OPTS.zip} $${extract_file}
                   2154: EXTRACT_CMD_OPTS.zip?= -Laqo
                   2155: EXTRACT_CMD.lha?=      ${LOCALBASE}/bin/lha ${EXTRACT_CMD_OPTS.lha} $${extract_file}
                   2156: EXTRACT_CMD_OPTS.lha?= xq
1.929     jlam     2157: EXTRACT_CMD.lzh?=      ${EXTRACT_CMD.lha}
1.1304    jlam     2158: EXTRACT_CMD_OPTS.lzh?= ${EXTRACT_CMD_OPTS.lha}
                   2159: EXTRACT_CMD.zoo?=      ${LOCALBASE}/bin/unzoo ${EXTRACT_CMD_OPTS.zoo} $${extract_file}
                   2160: EXTRACT_CMD_OPTS.zoo?= -x
1.1393    xtraeme  2161: EXTRACT_CMD.rar?=      ${LOCALBASE}/bin/unrar ${EXTRACT_CMD_OPTS.rar} $${extract_file}
                   2162: EXTRACT_CMD_OPTS.rar?= x -inul
1.1511    tv       2163: EXTRACT_ENV.bin?=      # empty
                   2164: EXTRACT_CMD.bin?=      ${ECHO} yes | ${SETENV} ${EXTRACT_ENV.bin} $${extract_file} ${EXTRACT_CMD_OPTS.bin} >/dev/null
1.929     jlam     2165:
                   2166: .for __suffix__ in .gz .bz2 .Z
                   2167: EXTRACT_CMD${__suffix__}?=     ${DECOMPRESS_CMD${__suffix__}} $${extract_file} > `${BASENAME} $${extract_file} ${__suffix__}`
                   2168: .endfor
1.914     jlam     2169:
                   2170: .for __suffix__ in .shar.gz .shar.bz2 .shar.Z .shar
1.929     jlam     2171: EXTRACT_CMD${__suffix__}?=     ${DECOMPRESS_CMD${__suffix__}} $${extract_file} | ${SH}
1.914     jlam     2172: .endfor
1.884     jlam     2173:
1.1434    wiz      2174: # If EXTRACT_USING_PAX is defined, use pax in preference to (GNU) tar.
1.884     jlam     2175: #
                   2176: .if defined(EXTRACT_USING_PAX)
1.1434    wiz      2177: _DFLT_EXTRACT_CMD?=    ${DECOMPRESS_CMD} $${extract_file} | ${PAX} -O -r ${EXTRACT_ELEMENTS}
1.884     jlam     2178: .else
1.929     jlam     2179: _DFLT_EXTRACT_CMD?=    ${DECOMPRESS_CMD} $${extract_file} | ${GTAR} -xf - ${EXTRACT_ELEMENTS}
1.884     jlam     2180: .endif
                   2181:
1.1396    wiz      2182: .for __suffix__ in ${_EXTRACT_SUFFIXES}
1.884     jlam     2183: .  if !defined(EXTRACT_CMD${__suffix__})
                   2184: .    if defined(EXTRACT_USING_PAX)
1.1434    wiz      2185: EXTRACT_CMD${__suffix__}?=     ${DECOMPRESS_CMD${__suffix__}} $${extract_file} | ${PAX} -O -r ${EXTRACT_ELEMENTS}
1.884     jlam     2186: .  else
1.929     jlam     2187: EXTRACT_CMD${__suffix__}?=     ${DECOMPRESS_CMD${__suffix__}} $${extract_file} | ${GTAR} -xf - ${EXTRACT_ELEMENTS}
1.884     jlam     2188: .    endif
                   2189: .  endif
                   2190: .endfor
                   2191:
1.929     jlam     2192: # _SHELL_EXTRACT is a "subroutine" for extracting an archive.  It extracts
                   2193: # the contents of archive named by the shell variable "extract_file" based
                   2194: # on the file extension of the archive.
1.913     jlam     2195: #
1.929     jlam     2196: _SHELL_EXTRACT=                case $${extract_file} in
1.1396    wiz      2197: .for __suffix__ in ${_EXTRACT_SUFFIXES}
1.929     jlam     2198: _SHELL_EXTRACT+=       *${__suffix__}) ${EXTRACT_CMD${__suffix__}} ;;
1.913     jlam     2199: .endfor
1.929     jlam     2200: _SHELL_EXTRACT+=       *)              ${_DFLT_EXTRACT_CMD} ;;
                   2201: _SHELL_EXTRACT+=       esac
1.913     jlam     2202:
1.929     jlam     2203: EXTRACT_CMD?=          ${_SHELL_EXTRACT}
1.907     agc      2204:
1.1222    jmmv     2205: .PHONY: do-extract
1.907     agc      2206: .if !target(do-extract)
                   2207: do-extract: ${WRKDIR}
1.929     jlam     2208: .  for __file__ in ${EXTRACT_ONLY}
1.902     jlam     2209:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.929     jlam     2210:        extract_file="${_DISTDIR}/${__file__}"; export extract_file;    \
                   2211:        cd ${WRKDIR}; ${EXTRACT_CMD}
                   2212: .  endfor
1.1       agc      2213: .endif
                   2214:
                   2215: # Patch
                   2216:
1.968     jlam     2217: # LOCALPATCHES contains the location of local patches to packages
                   2218: #      that are maintained in a directory tree reflecting the same
                   2219: #      hierarchy as the pkgsrc tree, i.e. local patches for www/apache
                   2220: #      would be found as ${LOCALPATCHES}/www/apache/*.
                   2221: #
1.1168    grant    2222: .if defined(LOCALPATCHES)
1.968     jlam     2223: _DFLT_LOCALPATCHFILES= ${LOCALPATCHES}/${PKGPATH}/*
                   2224: _LOCALPATCHFILES=      ${_DFLT_LOCALPATCHFILES}
1.1168    grant    2225: .endif
1.968     jlam     2226:
1.1222    jmmv     2227: .PHONY: do-patch
1.1       agc      2228: .if !target(do-patch)
1.676     agc      2229: do-patch: uptodate-digest
1.789     hubertf  2230: .  if defined(PATCHFILES)
1.416     agc      2231:        @${ECHO_MSG} "${_PKGSRC_IN}> Applying distribution patches for ${PKGNAME}"
1.1488    jlam     2232: .    for i in ${PATCHFILES}
1.976     agc      2233:        ${_PKG_SILENT}${_PKG_DEBUG}cd ${_DISTDIR};                      \
1.1488    jlam     2234:        if [ ${PATCH_DEBUG_TMP} = yes ]; then                           \
                   2235:                ${ECHO_MSG} "${_PKGSRC_IN}> Applying distribution patch ${i}"; \
                   2236:        fi;                                                             \
                   2237:        ${PATCH_DIST_CAT.${i:S/=/--/}} |                                \
                   2238:        ${PATCH} ${PATCH_DIST_ARGS.${i:S/=/--/}}                        \
1.1493    schmonz  2239:                || { ${ECHO} "Patch ${i} failed"; ${PKGSRC_PATCH_FAIL}; }
1.1488    jlam     2240: .    endfor
1.789     hubertf  2241: .  endif
1.968     jlam     2242:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2243:        patchlist="";                                                   \
                   2244:        if [ -d ${PATCHDIR} ]; then                                     \
1.167     agc      2245:                if [ "`${ECHO} ${PATCHDIR}/patch-*`" = "${PATCHDIR}/patch-*" ]; then \
1.416     agc      2246:                        ${ECHO_MSG} "${_PKGSRC_IN}> Ignoring empty patch directory"; \
1.293     agc      2247:                        if [ -d ${PATCHDIR}/CVS ]; then                 \
1.910     zuntum   2248:                                ${ECHO_MSG} "${_PKGSRC_IN}> Perhaps you forgot the -P flag to 'cvs checkout' or 'cvs update'?"; \
1.293     agc      2249:                        fi;                                             \
                   2250:                else                                                    \
1.968     jlam     2251:                        patchlist=`${ECHO} ${PATCHDIR}/patch-*`;        \
                   2252:                fi;                                                     \
                   2253:        fi;                                                             \
                   2254:        if [ "X${_LOCALPATCHFILES}" = "X${_DFLT_LOCALPATCHFILES}" ]; then \
                   2255:                localpatchfiles="`${ECHO} ${_LOCALPATCHFILES}`";        \
                   2256:                if [ "$${localpatchfiles}" != "${_LOCALPATCHFILES}" ]; then \
                   2257:                        patchlist="$${patchlist} $${localpatchfiles}";  \
                   2258:                fi;                                                     \
                   2259:        else                                                            \
                   2260:                patchlist=`${ECHO} $${patchlist} ${_LOCALPATCHFILES}`;  \
                   2261:        fi;                                                             \
                   2262:        if [ -n "$${patchlist}" ]; then                                 \
1.1092    jschauma 2263:                ${ECHO_MSG} "${_PKGSRC_IN}> Applying pkgsrc patches for ${PKGNAME}" ; \
1.968     jlam     2264:                fail="";                                                \
                   2265:                for i in $${patchlist}; do                              \
                   2266:                        if [ ! -f "$$i" ]; then                         \
                   2267:                                ${ECHO_MSG} "${_PKGSRC_IN}> $$i is not a valid patch file - skipping"; \
                   2268:                                continue;                               \
                   2269:                        fi;                                             \
                   2270:                        case $$i in                                     \
                   2271:                        *.orig|*.rej|*~)                                \
                   2272:                                ${ECHO_MSG} "${_PKGSRC_IN}> Ignoring patchfile $$i"; \
                   2273:                                continue;                               \
                   2274:                                ;;                                      \
                   2275:                        ${PATCHDIR}/patch-local-*)                      \
                   2276:                                ;;                                      \
                   2277:                        ${PATCHDIR}/patch-*)                            \
                   2278:                                if [ -f ${DISTINFO_FILE} ]; then        \
                   2279:                                        filename=`expr $$i : '.*/\(.*\)'`; \
                   2280:                                        algsum=`${AWK} 'NF == 4 && $$2 == "('$$filename')" && $$3 == "=" {print $$1 " " $$4}' ${DISTINFO_FILE} || ${TRUE}`; \
                   2281:                                        if [ "X$$algsum" != "X" ]; then \
                   2282:                                                alg=`${ECHO} $$algsum | ${AWK} '{ print $$1 }'`; \
                   2283:                                                recorded=`${ECHO} $$algsum | ${AWK} '{ print $$2 }'`; \
                   2284:                                                calcsum=`${SED} -e '/\$$NetBSD.*/d' $$i | ${DIGEST} $$alg`; \
                   2285:                                                if [ ${PATCH_DEBUG_TMP} = yes ]; then \
                   2286:                                                        ${ECHO_MSG} "=> Verifying $$filename (using digest algorithm $$alg)"; \
1.293     agc      2287:                                                fi;                     \
                   2288:                                        fi;                             \
1.968     jlam     2289:                                        if [ "X$$algsum" = "X" -o "X$$recorded" = "X" ]; then \
                   2290:                                                ${ECHO_MSG} "**************************************"; \
                   2291:                                                ${ECHO_MSG} "Ignoring unknown patch file: $$i"; \
                   2292:                                                ${ECHO_MSG} "**************************************"; \
                   2293:                                                continue;               \
                   2294:                                        fi;                             \
                   2295:                                        if [ "X$$calcsum" != "X$$recorded" ]; then \
                   2296:                                                ${ECHO_MSG} "**************************************"; \
                   2297:                                                ${ECHO_MSG} "Patch file $$i has been modified"; \
                   2298:                                                ${ECHO_MSG} "**************************************"; \
                   2299:                                                fail="$$fail $$filename"; \
                   2300:                                                continue;               \
                   2301:                                        fi;                             \
1.1302    cube     2302:                                else                                    \
                   2303:                                        ${ECHO_MSG} "**************************************"; \
                   2304:                                        ${ECHO_MSG} "Ignoring unknown patch file: $$i"; \
                   2305:                                        ${ECHO_MSG} "**************************************"; \
1.1303    cube     2306:                                        continue;                       \
1.305     agc      2307:                                fi;                                     \
1.968     jlam     2308:                                ;;                                      \
                   2309:                        esac;                                           \
                   2310:                        if [ ${PATCH_DEBUG_TMP} = yes ]; then           \
1.1092    jschauma 2311:                                ${ECHO_MSG} "${_PKGSRC_IN}> Applying pkgsrc patch $$i" ; \
1.303     agc      2312:                        fi;                                             \
1.968     jlam     2313:                        fuzz="";                                        \
                   2314:                        ${PATCH} -v > /dev/null 2>&1 && fuzz="${PATCH_FUZZ_FACTOR}"; \
                   2315:                        ${PATCH} $$fuzz ${PATCH_ARGS} < $$i ||          \
1.1493    schmonz  2316:                                { ${ECHO} Patch $$i failed ; ${PKGSRC_PATCH_FAIL}; }; \
1.968     jlam     2317:                done;                                                   \
                   2318:                if [ "X$$fail" != "X" ]; then                           \
                   2319:                        ${ECHO_MSG} "Patching failed due to modified patch file(s): $$fail"; \
1.1493    schmonz  2320:                        ${PKGSRC_PATCH_FAIL};                           \
1.293     agc      2321:                fi;                                                     \
1.1       agc      2322:        fi
1.870     jlam     2323: .endif
                   2324:
                   2325: # Configure
1.1       agc      2326:
1.871     jlam     2327: # _CONFIGURE_PREREQ is a list of targets to run after pre-configure but before
                   2328: #      do-configure.  These targets typically edit the files used by the
1.1205    agc      2329: #      do-configure target.  The targets are run as dependencies of
1.1204    chris    2330: #      pre-configure-override.
1.871     jlam     2331: #
                   2332: # _CONFIGURE_POSTREQ is a list of targets to run after do-configure but before
                   2333: #      post-configure.  These targets typically edit the files generated by
                   2334: #      the do-configure target that are used during the build phase.
                   2335:
1.1248    jlam     2336: .if defined(USE_PKGLOCALEDIR)
                   2337: _PKGLOCALEDIR=                 ${PREFIX}/${PKGLOCALEDIR}/locale
                   2338: REPLACE_LOCALEDIR_PATTERNS?=   # empty
                   2339: _REPLACE_LOCALEDIR_PATTERNS=   ${REPLACE_LOCALEDIR_PATTERNS}
                   2340: .  if defined(HAS_CONFIGURE) || defined(GNU_CONFIGURE)
1.1395    sketch   2341: _REPLACE_LOCALEDIR_PATTERNS+=  [Mm]akefile.in*
1.1248    jlam     2342: .  else
1.1395    sketch   2343: _REPLACE_LOCALEDIR_PATTERNS+=  [Mm]akefile*
1.1248    jlam     2344: .  endif
                   2345: _REPLACE_LOCALEDIR_PATTERNS_FIND= \
                   2346:        \( ${_REPLACE_LOCALEDIR_PATTERNS:S/$/!/:S/^/-o -name !/:S/!/"/g:S/-o//1} \)
                   2347: REPLACE_LOCALEDIR?=            # empty
                   2348: _REPLACE_LOCALEDIR=            \
                   2349:        ${REPLACE_LOCALEDIR}    \
                   2350:        `${FIND} . ${_REPLACE_LOCALEDIR_PATTERNS_FIND} -print | ${SED} -e 's|^\./||' | ${GREP} -v '\.orig' | ${SORT} -u`
                   2351:
                   2352: _CONFIGURE_PREREQ+=            subst-pkglocaledir
                   2353: .  if empty(USE_PKGLOCALEDIR:M[nN][oO])
                   2354: SUBST_CLASSES+=                        pkglocaledir
                   2355: .  endif
                   2356: SUBST_MESSAGE.pkglocaledir=    "Fixing locale directory references."
                   2357: SUBST_FILES.pkglocaledir=      ${_REPLACE_LOCALEDIR}
                   2358: SUBST_SED.pkglocaledir=                \
                   2359:        -e 's|^\(localedir[     :]*=\).*|\1 ${_PKGLOCALEDIR}|'          \
                   2360:        -e 's|^\(gnulocaledir[  :]*=\).*|\1 ${_PKGLOCALEDIR}|'          \
1.1470    salo     2361:        -e 's|\(-DLOCALEDIR[    ]*=\)[^         ]*\(\.\*\)|\1"\\"${_PKGLOCALEDIR}\\""\2|'
1.1248    jlam     2362: .endif
                   2363:
1.870     jlam     2364: .if defined(REPLACE_PERL)
1.1208    agc      2365: REPLACE_INTERPRETER+=  perl
1.1207    agc      2366: _REPLACE.perl.old=     .*/bin/perl
                   2367: _REPLACE.perl.new=     ${PERL5}
                   2368: _REPLACE_FILES.perl=   ${REPLACE_PERL}
                   2369: .endif
                   2370:
1.1347    jlam     2371: .if defined(REPLACE_INTERPRETER)
1.1207    agc      2372: _CONFIGURE_PREREQ+=    replace-interpreter
1.1222    jmmv     2373: .PHONY: replace-interpreter
1.1207    agc      2374: replace-interpreter:
                   2375: .  for lang in ${REPLACE_INTERPRETER}
1.1415    drochner 2376: .    for pattern in ${_REPLACE_FILES.${lang}}
1.870     jlam     2377:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2378:        cd ${WRKSRC};                                                   \
1.1415    drochner 2379:        for f in ${pattern}; do                                         \
1.953     hubertf  2380:            if [ -f $${f} ]; then                                       \
1.1415    drochner 2381:                    ${SED} -e '1s|^#!${_REPLACE.${lang}.old}|#!${_REPLACE.${lang}.new}|' \
1.953     hubertf  2382:                            $${f} > $${f}.new;                          \
                   2383:                    if [ -x $${f} ]; then                               \
                   2384:                            ${CHMOD} a+x $${f}.new;                     \
                   2385:                    fi;                                                 \
                   2386:                    ${MV} -f $${f}.new $${f};                           \
                   2387:            fi;                                                         \
                   2388:        done
1.1415    drochner 2389: .    endfor
1.1207    agc      2390: .  endfor
1.770     zuntum   2391: .endif
1.522     wiz      2392:
1.1347    jlam     2393: .if defined(USE_LIBTOOL) && defined(LTCONFIG_OVERRIDE)
1.869     jlam     2394: _CONFIGURE_PREREQ+=    do-ltconfig-override
1.1222    jmmv     2395: .PHONY: do-ltconfig-override
1.869     jlam     2396: do-ltconfig-override:
1.828     jlam     2397: .  for ltconfig in ${LTCONFIG_OVERRIDE}
                   2398:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2399:        if [ -f ${ltconfig} ]; then                                     \
                   2400:                ${RM} -f ${ltconfig};                                   \
1.1381    jlam     2401:                ${ECHO} "${RM} -f libtool; ${LN} -s ${_LIBTOOL} libtool" \
1.828     jlam     2402:                        > ${ltconfig};                                  \
                   2403:                ${CHMOD} +x ${ltconfig};                                \
1.375     sakamoto 2404:        fi
1.828     jlam     2405: .  endfor
1.1006    schmonz  2406: .endif
                   2407:
                   2408: .if defined(CONFIG_GUESS_OVERRIDE) || defined(CONFIG_SUB_OVERRIDE)
                   2409: _CONFIGURE_PREREQ+=    do-config-star-override
1.1222    jmmv     2410: .PHONY: do-config-star-override
1.1006    schmonz  2411: do-config-star-override:
1.1401    jlam     2412: .  if defined(CONFIG_GUESS_OVERRIDE) && !empty(CONFIG_GUESS_OVERRIDE)
1.1403    jlam     2413: .    for _pattern_ in ${CONFIG_GUESS_OVERRIDE}
                   2414:        ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC};                        \
                   2415:        for file in ${_pattern_}; do                                    \
                   2416:                if [ -f "$$file" ]; then                                \
                   2417:                        ${RM} -f $$file;                                \
1.1510    jlam     2418:                        ${LN} -s ${PKGSRCDIR}/mk/gnu-config/config.guess \
1.1403    jlam     2419:                                $$file;                                 \
                   2420:                fi;                                                     \
1.1006    schmonz  2421:        done
1.1403    jlam     2422: .    endfor
1.1007    agc      2423: .  endif
1.1401    jlam     2424: .  if defined(CONFIG_SUB_OVERRIDE) && !empty(CONFIG_SUB_OVERRIDE)
1.1403    jlam     2425: .    for _pattern_ in ${CONFIG_SUB_OVERRIDE}
                   2426:        ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC};                        \
                   2427:        for file in ${_pattern_}; do                                    \
                   2428:                if [ -f "$$file" ]; then                                \
                   2429:                        ${RM} -f $$file;                                \
1.1510    jlam     2430:                        ${LN} -s ${PKGSRCDIR}/mk/gnu-config/config.sub  \
1.1403    jlam     2431:                                $$file;                                 \
                   2432:                fi;                                                     \
1.1006    schmonz  2433:        done
1.1403    jlam     2434: .    endfor
1.1007    agc      2435: .  endif
1.1080    rh       2436: .endif
                   2437:
1.1248    jlam     2438: PKGCONFIG_OVERRIDE_SED= \
1.1523    jmmv     2439:        '/^Libs:.*[     ]/s|-L\([       ]*[^    ]*\)|${COMPILER_RPATH_FLAG}\1 -L\1|g'
                   2440: PKGCONFIG_OVERRIDE_STAGE?=     pre-configure
1.1248    jlam     2441:
                   2442: .if defined(PKGCONFIG_OVERRIDE) && !empty(PKGCONFIG_OVERRIDE)
1.1523    jmmv     2443: .  if ${PKGCONFIG_OVERRIDE_STAGE} == "pre-configure"
1.1248    jlam     2444: _CONFIGURE_PREREQ+=            subst-pkgconfig
1.1523    jmmv     2445: .  elif ${PKGCONFIG_OVERRIDE_STAGE} == "post-configure"
                   2446: _CONFIGURE_POSTREQ+=           subst-pkgconfig
                   2447: .  else
                   2448: SUBST_STAGE.pkgconfig=         ${PKGCONFIG_OVERRIDE_STAGE}
                   2449: .  endif
1.1248    jlam     2450: SUBST_CLASSES+=                        pkgconfig
                   2451: SUBST_MESSAGE.pkgconfig=       "Adding rpaths to pkgconfig files."
                   2452: SUBST_FILES.pkgconfig=         ${PKGCONFIG_OVERRIDE:S/^${WRKSRC}\///}
                   2453: SUBST_SED.pkgconfig=           ${PKGCONFIG_OVERRIDE_SED}
1.828     jlam     2454: .endif
                   2455:
1.1540.2.7  tv       2456: # By adding this target, it makes sure the above PREREQ's work.
1.1222    jmmv     2457: .PHONY: pre-configure-override
1.1204    chris    2458: pre-configure-override: ${_CONFIGURE_PREREQ}
                   2459:
1.1222    jmmv     2460: .PHONY: do-configure
1.828     jlam     2461: .if !target(do-configure)
1.1389    jlam     2462: do-configure:
1.789     hubertf  2463: .  if defined(HAS_CONFIGURE)
1.1032    jlam     2464: .    for DIR in ${CONFIGURE_DIRS}
1.1042    abs      2465:        ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD}cd ${DIR} && ${SETENV} \
1.1358    grant    2466:            ${CONFIGURE_ENV} ${CONFIG_SHELL} \
                   2467:            ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
1.1032    jlam     2468: .    endfor
1.789     hubertf  2469: .  endif
                   2470: .  if defined(USE_IMAKE)
1.1119    jlam     2471: .    for DIR in ${CONFIGURE_DIRS}
                   2472:        ${_PKG_SILENT}${_PKG_DEBUG}cd ${DIR} && ${SETENV} ${SCRIPTS_ENV} XPROJECTROOT=${X11BASE} ${XMKMF}
                   2473: .    endfor
1.789     hubertf  2474: .  endif
1.871     jlam     2475: .endif
                   2476:
1.1347    jlam     2477: .if defined(USE_LIBTOOL) && \
                   2478:     (defined(LIBTOOL_OVERRIDE) || defined(SHLIBTOOL_OVERRIDE))
1.871     jlam     2479: _CONFIGURE_POSTREQ+=   do-libtool-override
1.1222    jmmv     2480: .PHONY: do-libtool-override
1.871     jlam     2481: do-libtool-override:
1.1126    jlam     2482: .  if defined(LIBTOOL_OVERRIDE)
1.1404    jlam     2483: .    for _pattern_ in ${LIBTOOL_OVERRIDE}
                   2484:        ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC};                        \
                   2485:        for file in ${_pattern_}; do                                    \
                   2486:                if [ -f "$$file" ]; then                                \
                   2487:                        ${RM} -f $$file;                                \
                   2488:                        (${ECHO} '#!${CONFIG_SHELL}';                   \
                   2489:                         ${ECHO} 'exec ${_LIBTOOL} "$$@"';              \
                   2490:                        ) > $$file;                                     \
                   2491:                        ${CHMOD} +x $$file;                             \
1.1368    jlam     2492:                fi;                                                     \
1.1404    jlam     2493:        done
1.1126    jlam     2494: .    endfor
                   2495: .  endif
                   2496: .  if defined(SHLIBTOOL_OVERRIDE)
1.1404    jlam     2497: .    for _pattern_ in ${SHLIBTOOL_OVERRIDE}
                   2498:        ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC};                        \
                   2499:        for file in ${_pattern_}; do                                    \
                   2500:                if [ -f "$$file" ]; then                                \
                   2501:                        ${RM} -f $$file;                                \
                   2502:                        (${ECHO} '#!${CONFIG_SHELL}';                   \
                   2503:                         ${ECHO} 'exec ${_SHLIBTOOL} "$$@"';            \
                   2504:                        ) > $$file;                                     \
                   2505:                        ${CHMOD} +x $$file;                             \
1.1382    jlam     2506:                fi;                                                     \
1.1404    jlam     2507:        done
1.1126    jlam     2508: .    endfor
                   2509: .  endif
1.1       agc      2510: .endif
1.871     jlam     2511:
1.1348    jlam     2512: .if defined(CONFIG_STATUS_OVERRIDE)
                   2513: _CONFIGURE_POSTREQ+=   do-config-status-override
                   2514: .PHONY: do-config-status-override
1.1389    jlam     2515: do-config-status-override:
1.1400    jlam     2516: .  for _pattern_ in ${CONFIG_STATUS_OVERRIDE}
1.1402    jlam     2517:        ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC};                        \
1.1400    jlam     2518:        for file in ${_pattern_}; do                                    \
1.1402    jlam     2519:                if [ -f "$$file" ]; then                                \
1.1408    jlam     2520:                        ${MV} -f $$file $$file.overridden;              \
1.1414    jdolecek 2521:                        ${AWK} '/ *-recheck *\| *--recheck.*\)/ {       \
1.1413    jlam     2522:                                        print;                          \
                   2523:                                        print "    exit 0";             \
                   2524:                                        next;                           \
                   2525:                                }                                       \
                   2526:                                { print }                               \
                   2527:                               ' $$file.overridden > $$file;            \
1.1402    jlam     2528:                        ${CHMOD} +x $$file;                             \
1.1400    jlam     2529:                fi;                                                     \
                   2530:        done
1.1389    jlam     2531: .  endfor
                   2532: .endif
1.1348    jlam     2533:
1.1222    jmmv     2534: .PHONY: post-configure
1.871     jlam     2535: post-configure: ${_CONFIGURE_POSTREQ}
1.1       agc      2536:
                   2537: # Build
                   2538:
1.1344    jlam     2539: BUILD_DIRS?=           ${WRKSRC}
                   2540: BUILD_MAKE_FLAGS?=     ${MAKE_FLAGS}
1.1045    jlam     2541:
1.1222    jmmv     2542: .PHONY: do-build
1.1       agc      2543: .if !target(do-build)
                   2544: do-build:
1.1045    jlam     2545: .  for DIR in ${BUILD_DIRS}
1.1540.2.7  tv       2546:        ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD}cd ${DIR} && ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} -f ${MAKEFILE} ${BUILD_TARGET}
1.1045    jlam     2547: .  endfor
1.1       agc      2548: .endif
                   2549:
1.1081    dillo    2550: #Test
                   2551:
1.1344    jlam     2552: TEST_DIRS?=            ${BUILD_DIRS}
                   2553: TEST_ENV+=             ${MAKE_ENV}
                   2554: TEST_MAKE_FLAGS?=      ${MAKE_FLAGS}
1.1081    dillo    2555:
1.1222    jmmv     2556: .PHONY: do-test
1.1081    dillo    2557: .if !target(do-test)
                   2558: do-test:
1.1276    jlam     2559: .  if defined(TEST_TARGET) && !empty(TEST_TARGET)
1.1081    dillo    2560: .    for DIR in ${TEST_DIRS}
1.1344    jlam     2561:        ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD}cd ${DIR} && ${SETENV} ${TEST_ENV} ${MAKE_PROGRAM} ${TEST_MAKE_FLAGS} -f ${MAKEFILE} ${TEST_TARGET}
1.1081    dillo    2562: .    endfor
                   2563: .  endif
                   2564: .endif
                   2565:
1.1       agc      2566: # Package
                   2567:
1.1222    jmmv     2568: .PHONY: real-su-package
1.810     agc      2569: real-su-package: ${PLIST} ${DESCR}
1.972     agc      2570:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.624     hubertf  2571:        ${ECHO_MSG} "${_PKGSRC_IN}> Building binary package for ${PKGNAME}"; \
1.1245    jlam     2572:        if ${PKG_INFO} -qe ${PKGNAME}; then                             \
                   2573:                : The package is installed. ;                           \
                   2574:        else                                                            \
                   2575:                ${ECHO_MSG} "=> ${PKGNAME} is not installed.";          \
                   2576:                exit 1;                                                 \
                   2577:        fi;                                                             \
1.972     agc      2578:        if [ ! -d ${PKGREPOSITORY} ]; then                              \
                   2579:                ${MKDIR} ${PKGREPOSITORY};                              \
                   2580:                if [ $$? -ne 0 ]; then                                  \
1.624     hubertf  2581:                        ${ECHO_MSG} "=> Can't create directory ${PKGREPOSITORY}."; \
1.972     agc      2582:                        exit 1;                                         \
                   2583:                fi;                                                     \
                   2584:        fi;                                                             \
                   2585:        if ${PKG_CREATE} ${PKG_ARGS_BINPKG} ${PKGFILE}; then            \
                   2586:                ${MAKE} ${MAKEFLAGS} package-links;                     \
                   2587:        else                                                            \
                   2588:                ${MAKE} ${MAKEFLAGS} delete-package;                    \
                   2589:                exit 1;                                                 \
1.1       agc      2590:        fi
1.1540.2.1  tv       2591: .if defined(NO_BIN_ON_CDROM)
1.512     rh       2592:        @${ECHO_MSG} "${_PKGSRC_IN}> Warning: ${PKGNAME} may not be put on a CD-ROM:"
1.547     hubertf  2593:        @${ECHO_MSG} "${_PKGSRC_IN}>         " ${NO_BIN_ON_CDROM:Q}
1.1540.2.1  tv       2594: .endif
                   2595: .if defined(NO_BIN_ON_FTP)
1.512     rh       2596:        @${ECHO_MSG} "${_PKGSRC_IN}> Warning: ${PKGNAME} may not be made available through FTP:"
1.547     hubertf  2597:        @${ECHO_MSG} "${_PKGSRC_IN}>         " ${NO_BIN_ON_FTP:Q}
1.1540.2.1  tv       2598: .endif
                   2599: .if defined(RECOMMENDED) && !empty(IGNORE_RECOMMENDED:M[yY][eE][sS])
1.1345    rh       2600:        @${ECHO_MSG} "${_PKGSRC_IN}> Warning: dependency recommendations are being ignored!"
                   2601:        @${ECHO_MSG} "${_PKGSRC_IN}>          ${PKGNAME} should not be uploaded nor"
                   2602:        @${ECHO_MSG} "${_PKGSRC_IN}>          otherwise be used as a binary package!"
1.1       agc      2603: .endif
                   2604:
1.810     agc      2605: # Some support rules for real-su-package
1.1       agc      2606:
1.1222    jmmv     2607: .PHONY: package-links
1.1540.2.1  tv       2608: package-links: delete-package-links
1.221     agc      2609:        ${_PKG_SILENT}${_PKG_DEBUG}for cat in ${CATEGORIES}; do         \
                   2610:                if [ ! -d ${PACKAGES}/$$cat ]; then                     \
1.222     agc      2611:                        ${MKDIR} ${PACKAGES}/$$cat;                     \
                   2612:                        if [ $$? -ne 0 ]; then                          \
1.415     agc      2613:                                ${ECHO_MSG} "=> Can't create directory ${PACKAGES}/$$cat."; \
1.221     agc      2614:                                exit 1;                                 \
                   2615:                        fi;                                             \
                   2616:                fi;                                                     \
1.468     tron     2617:                ${RM} -f ${PACKAGES}/$$cat/${PKGNAME}${PKG_SUFX};       \
1.221     agc      2618:                ${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
1.1       agc      2619:        done;
                   2620:
1.1222    jmmv     2621: .PHONY: delete-package-links
1.1       agc      2622: delete-package-links:
1.440     hubertf  2623:        ${_PKG_SILENT}${_PKG_DEBUG}\
1.1360    heinz    2624:        ${FIND} ${PACKAGES} -type l -name ${PKGNAME}${PKG_SUFX} -print | ${XARGS} ${RM} -f
1.1       agc      2625:
1.1222    jmmv     2626: .PHONY: delete-package
1.1540.2.1  tv       2627: delete-package: delete-package-links
1.221     agc      2628:        ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PKGFILE}
1.624     hubertf  2629:
1.488     hubertf  2630: # Check if all binaries and shlibs find their needed libs
                   2631: # Must be run after "make install", so that files are installed, and
                   2632: # ${PLIST} exists.
                   2633: #
1.1222    jmmv     2634: .PHONY: check-shlibs
1.488     hubertf  2635: check-shlibs:
1.678     hubertf  2636: .if !defined(NO_PKG_REGISTER)
1.972     agc      2637:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.706     hubertf  2638:        bins=`${PKG_INFO} -qL ${PKGNAME} | { ${EGREP} -h '/(bin|sbin|libexec)/' || ${TRUE}; }`; \
1.972     agc      2639:        if [ "${OBJECT_FMT}" = "ELF" ]; then                            \
1.706     hubertf  2640:                shlibs=`${PKG_INFO} -qL ${PKGNAME} | { ${EGREP} -h '/lib/lib.*.so' || ${TRUE}; }`; \
1.1244    grant    2641:        elif [ "${OBJECT_FMT}" = "Mach-O" ]; then                       \
                   2642:                shlibs=`${PKG_INFO} -qL ${PKGNAME} | { ${EGREP} -h '/lib/lib.*.dylib' || ${TRUE}; }`; \
1.972     agc      2643:        else                                                            \
                   2644:                shlibs="";                                              \
                   2645:        fi;                                                             \
1.1244    grant    2646:        if [ "X${LDD}" = X ]; then                                      \
1.1240    grant    2647:                ldd=`${TYPE} ldd 2>/dev/null | ${AWK} '{ print $$NF }'`;\
1.972     agc      2648:        else                                                            \
                   2649:                ldd="${LDD}";                                           \
                   2650:        fi;                                                             \
1.1240    grant    2651:        if [ -x "$$ldd" ]; then                                         \
                   2652:                for i in $${bins} $${shlibs}; do                        \
                   2653:                        err=`{ $$ldd $$i 2>&1 || ${TRUE}; } | { ${GREP} "not found" || ${TRUE}; }`; \
                   2654:                        if [ "${PKG_VERBOSE}" != "" ]; then             \
                   2655:                                ${ECHO} "$$ldd $$i";                    \
                   2656:                        fi;                                             \
                   2657:                        if [ "$$err" != "" ]; then                      \
                   2658:                                ${ECHO} "$$i: $$err";                   \
                   2659:                                error=1;                                \
                   2660:                        fi;                                             \
                   2661:                done;                                                   \
                   2662:        fi;                                                             \
1.972     agc      2663:        if [ "$$error" = 1 ]; then                                      \
1.488     hubertf  2664:                ${ECHO} "*** The above programs/libs will not find the listed shared libraries"; \
1.972     agc      2665:                ${ECHO} "    at runtime. Please fix the package (add -Wl,-R.../lib in the right places)!"; \
1.488     hubertf  2666:                ${SHCOMMENT} Might not error-out for non-pkg-developers; \
1.972     agc      2667:                exit 1;                                                 \
1.488     hubertf  2668:        fi
1.678     hubertf  2669: .endif # NO_PKG_REGISTER
1.488     hubertf  2670:
1.1540.2.1  tv       2671: LOCKFILE=      ${WRKDIR}/.lockfile
                   2672: .for targ in ${_PKG_PHASES_WRKDIR}
                   2673: .PHONY: acquire-${targ}-lock release-${targ}-lock
                   2674: acquire-${targ}-lock: .OPTIONAL
                   2675: release-${targ}-lock: .OPTIONAL
                   2676:
                   2677: .  if ${PKGSRC_LOCKTYPE} != "none"
                   2678: acquire-${targ}-lock:
                   2679:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2680:        ppid=`${PS} -p $$$$ -o ppid | ${AWK} 'NR == 2 { print $$1 }'`;  \
                   2681:        if ${TEST} "$$ppid" = ""; then                                  \
                   2682:                ${ECHO} "No parent process ID found.";                  \
                   2683:                ${FALSE};                                               \
                   2684:        fi;                                                             \
                   2685:        while true; do                                                  \
                   2686:                if ${TEST} -f /var/run/dmesg.boot -a -f ${LOCKFILE} -a  \
                   2687:                     /var/run/dmesg.boot -nt ${LOCKFILE}; then          \
                   2688:                        ${ECHO} "=> Removing stale ${LOCKFILE}";        \
                   2689:                        ${RM} ${LOCKFILE};                              \
                   2690:                fi;                                                     \
                   2691:                ${SHLOCK} -f ${LOCKFILE} -p $$ppid && break;            \
                   2692:                ${ECHO} "=> Lock is held by pid `cat ${LOCKFILE}`";     \
                   2693:                case "${PKGSRC_LOCKTYPE}" in                            \
                   2694:                once)   exit 1 ;;                                       \
                   2695:                sleep)  sleep ${PKGSRC_SLEEPSECS} ;;                    \
                   2696:                esac                                                    \
                   2697:        done;                                                           \
                   2698:        if [ "${PKG_VERBOSE}" != "" ]; then                             \
                   2699:                ${ECHO_MSG} "=> Lock acquired on behalf of process $$ppid"; \
                   2700:        fi
1.1342    grant    2701:
1.1540.2.1  tv       2702: release-${targ}-lock:
                   2703:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2704:        if [ "${PKG_VERBOSE}" != "" ]; then                             \
                   2705:                ${ECHO_MSG} "=> Lock released on behalf of process `${CAT} ${LOCKFILE}`"; \
                   2706:        fi;                                                             \
                   2707:        ${RM} ${LOCKFILE}
                   2708: .  endif # PKGSRC_LOCKTYPE
                   2709: .endfor
1.1       agc      2710:
                   2711:
1.1540.2.1  tv       2712: # Empty pre-* and post-* targets
1.1       agc      2713:
1.1540.2.1  tv       2714: .for targ in fetch ${_PKG_PHASES_WRKDIR} install-script clean distclean
                   2715: .PHONY: pre-${targ} post-${targ}
                   2716: pre-${targ}: .OPTIONAL
                   2717: post-${targ}: .OPTIONAL
1.1       agc      2718: .endfor
                   2719:
                   2720: # Reinstall
                   2721: #
                   2722: # Special target to re-run install
                   2723:
1.1222    jmmv     2724: .PHONY: reinstall
1.560     hubertf  2725: reinstall:
1.1540.2.1  tv       2726:        ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${install_COOKIE} ${package_COOKIE} ${PLIST}
1.1437    xtraeme  2727:        ${_PKG_SILENT}${_PKG_DEBUG}DEPENDS_TARGET=${DEPENDS_TARGET:Q} ${MAKE} ${MAKEFLAGS} install
1.46      agc      2728:
                   2729: # Deinstall
                   2730: #
                   2731: # Special target to remove installation
1.221     agc      2732:
1.1540.2.1  tv       2733: .PHONY: deinstall
1.624     hubertf  2734: deinstall: do-su-deinstall
1.243     tron     2735:
1.1540.2.1  tv       2736: .if (${DEINSTALLDEPENDS} != "NO")
                   2737: .  if (${DEINSTALLDEPENDS} != "ALL")
1.336     hubertf  2738: # used for removing stuff in bulk builds
1.624     hubertf  2739: real-su-deinstall-flags+=      -r -R
1.336     hubertf  2740: # used for "update" target
1.1540.2.1  tv       2741: .  else
1.624     hubertf  2742: real-su-deinstall-flags+=      -r
1.789     hubertf  2743: .  endif
1.1540.2.1  tv       2744: .endif
                   2745: .ifdef PKG_VERBOSE
1.624     hubertf  2746: real-su-deinstall-flags+=      -v
1.1540.2.1  tv       2747: .endif
                   2748: .ifdef PKG_PRESERVE
                   2749: .  if (${UPDATE_RUNNING} == "YES")
1.1530    erh      2750: # used to update w/o removing any files
                   2751: real-su-deinstall-flags+=      -N -f
                   2752: .  endif
1.1540.2.1  tv       2753: .endif
1.317     hubertf  2754:
1.1222    jmmv     2755: .PHONY: real-su-deinstall
1.624     hubertf  2756: real-su-deinstall:
1.972     agc      2757:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.1261    jlam     2758:        found="`${PKG_INFO} -e \"${PKGNAME}\" || ${TRUE}`";             \
                   2759:        case "$$found" in                                               \
1.1275    jlam     2760:        "") found="`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`" ;; \
1.1261    jlam     2761:        esac;                                                           \
1.972     agc      2762:        if [ "$$found" != "" ]; then                                    \
1.624     hubertf  2763:                ${ECHO} Running ${PKG_DELETE} ${real-su-deinstall-flags} $$found ; \
                   2764:                ${PKG_DELETE} ${real-su-deinstall-flags} $$found || ${TRUE} ; \
1.317     hubertf  2765:        fi
1.1540.2.1  tv       2766: .if (${DEINSTALLDEPENDS} != "NO") && (${DEINSTALLDEPENDS} != "ALL")
1.408     hubertf  2767:        @${SHCOMMENT} Also remove BUILD_DEPENDS:
1.1540.2.1  tv       2768: .  for pkg in ${BUILD_DEPENDS:C/:.*$//}
1.972     agc      2769:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.1275    jlam     2770:        found="`${PKG_BEST_EXISTS} \"${pkg}\" || ${TRUE}`";             \
1.972     agc      2771:        if [ "$$found" != "" ]; then                                    \
                   2772:                ${ECHO} Running ${PKG_DELETE} $$found;                  \
                   2773:                ${PKG_DELETE} ${real-su-deinstall-flags} $$found || ${TRUE}; \
1.408     hubertf  2774:        fi
1.1540.2.1  tv       2775: .  endfor
                   2776: .endif # DEINSTALLDEPENDS
                   2777:        @${RM} -f ${install_COOKIE} ${package_COOKIE}
1.220     hubertf  2778:
1.362     rh       2779:
1.1       agc      2780: ################################################################
                   2781: # Some more targets supplied for users' convenience
                   2782: ################################################################
1.327     rh       2783:
                   2784: # The 'update' target can be used to update a package and all
                   2785: # currently installed packages that depend upon this package.
1.362     rh       2786:
1.1222    jmmv     2787: .PHONY: update
1.958     rh       2788: .if !target(update)
1.362     rh       2789: .if exists(${DDIR})
                   2790: RESUMEUPDATE?= YES
1.509     rh       2791: CLEAR_DIRLIST?=        NO
1.362     rh       2792:
                   2793: update:
                   2794:        ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG}                          \
1.416     agc      2795:                "${_PKGSRC_IN}> Resuming update for ${PKGNAME}"
1.1178    rh       2796: .  if ${REINSTALL} != "NO" && ${UPDATE_TARGET} != "replace"
1.515     rh       2797:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.1530    erh      2798:                ${MAKE} ${MAKEFLAGS} deinstall UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL
1.789     hubertf  2799: .  endif
1.362     rh       2800: .else
                   2801: RESUMEUPDATE?= NO
1.509     rh       2802: CLEAR_DIRLIST?=        YES
1.362     rh       2803:
1.327     rh       2804: update:
1.452     hubertf  2805:        ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} ${DDIR}
1.1178    rh       2806: .  if ${UPDATE_TARGET} != "replace"
1.972     agc      2807:        ${_PKG_SILENT}${_PKG_DEBUG}if ${PKG_INFO} -qe ${PKGBASE}; then  \
1.1531    agc      2808:                ${MAKE} ${MAKEFLAGS} deinstall UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL \
1.972     agc      2809:                || (${RM} ${DDIR} && ${FALSE});                         \
1.952     tron     2810:        fi
1.1178    rh       2811: .  endif
1.362     rh       2812: .endif
1.327     rh       2813:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.590     rh       2814:                ${MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} KEEP_WRKDIR=YES   \
1.1437    xtraeme  2815:                        DEPENDS_TARGET=${DEPENDS_TARGET:Q}
1.327     rh       2816:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.466     tron     2817:        [ ! -s ${DDIR} ] || for dep in `${CAT} ${DDIR}` ; do            \
1.972     agc      2818:                (if cd ../.. && cd "$${dep}" ; then                     \
1.976     agc      2819:                        ${ECHO_MSG} "${_PKGSRC_IN}> Installing in $${dep}" && \
1.1178    rh       2820:                        if [ "(" "${RESUMEUPDATE}" = "NO" -o            \
                   2821:                             "${REINSTALL}" != "NO" ")" -a              \
                   2822:                             "${UPDATE_TARGET}" != "replace" ] ; then   \
1.1531    agc      2823:                                ${MAKE} ${MAKEFLAGS} deinstall UPDATE_RUNNING=YES; \
1.362     rh       2824:                        fi &&                                           \
1.590     rh       2825:                        ${MAKE} ${MAKEFLAGS} ${UPDATE_TARGET}           \
1.1437    xtraeme  2826:                                DEPENDS_TARGET=${DEPENDS_TARGET:Q} ;    \
1.398     rh       2827:                else                                                    \
1.976     agc      2828:                        ${ECHO_MSG} "${_PKGSRC_IN}> Skipping removed directory $${dep}"; \
1.398     rh       2829:                fi) ;                                                   \
                   2830:        done
1.362     rh       2831: .if ${NOCLEAN} == "NO"
1.398     rh       2832:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.452     hubertf  2833:                ${MAKE} ${MAKEFLAGS} clean-update CLEAR_DIRLIST=YES
1.362     rh       2834: .endif
                   2835:
                   2836:
1.1222    jmmv     2837: .PHONY: clean-update
1.362     rh       2838: clean-update:
1.452     hubertf  2839:        ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} ${DDIR}
1.362     rh       2840:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2841:        if [ -s ${DDIR} ] ; then                                        \
                   2842:                for dep in `${CAT} ${DDIR}` ; do                        \
1.972     agc      2843:                        (if cd ../.. && cd "$${dep}" ; then             \
1.452     hubertf  2844:                                ${MAKE} ${MAKEFLAGS} clean ;            \
1.398     rh       2845:                        else                                            \
1.416     agc      2846:                                ${ECHO_MSG} "${_PKGSRC_IN}> Skipping removed directory $${dep}";\
1.398     rh       2847:                        fi) ;                                           \
1.362     rh       2848:                done ;                                                  \
                   2849:        fi
1.509     rh       2850: .if ${CLEAR_DIRLIST} != "NO"
1.452     hubertf  2851:        ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} clean
1.362     rh       2852: .else
1.398     rh       2853:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.452     hubertf  2854:                ${MAKE} ${MAKEFLAGS} clean update-dirlist               \
1.362     rh       2855:                DIRLIST="`${CAT} ${DDIR}`" PKGLIST="`${CAT} ${DLIST}`"
1.515     rh       2856:        ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG}                          \
                   2857:                "${_PKGSRC_IN}> Warning: preserved leftover directory list.  Your next";\
                   2858:                ${ECHO_MSG} "${_PKGSRC_IN}>          \`\`${MAKE} update'' may fail.  It is advised to use";\
                   2859:                ${ECHO_MSG} "${_PKGSRC_IN}>          \`\`${MAKE} update REINSTALL=YES'' instead!"
1.362     rh       2860: .endif
1.958     rh       2861:
                   2862: .endif # !target(update)
1.362     rh       2863:
                   2864:
1.1222    jmmv     2865: .PHONY: update-dirlist
1.362     rh       2866: update-dirlist:
                   2867:        ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} -p ${WRKDIR}
                   2868: .ifdef PKGLIST
1.789     hubertf  2869: .  for __tmp__ in ${PKGLIST}
1.362     rh       2870:        ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} >>${DLIST} "${__tmp__}"
1.789     hubertf  2871: .  endfor
1.362     rh       2872: .endif
                   2873: .ifdef DIRLIST
1.789     hubertf  2874: .  for __tmp__ in ${DIRLIST}
1.362     rh       2875:        ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} >>${DDIR} "${__tmp__}"
1.789     hubertf  2876: .  endfor
1.362     rh       2877: .endif
                   2878:
1.327     rh       2879:
                   2880: ${DDIR}: ${DLIST}
                   2881:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.655     wiz      2882:        ddir=`${SED} 's:-[^-]*$$::' ${DLIST}`;                          \
1.508     rh       2883:        ${ECHO} >${DDIR};                                               \
                   2884:        for pkg in $${ddir} ; do                                        \
1.1048    hubertf  2885:                if ${PKG_INFO} -b "$${pkg}" >/dev/null 2>&1 ; then      \
                   2886:                        ${PKG_INFO} -b "$${pkg}" | ${SED}       -ne     \
1.510     rh       2887:                            's,\([^/]*/[^/]*\)/Makefile:.*,\1,p' |      \
                   2888:                            ${HEAD} -1 >>${DDIR};                       \
1.508     rh       2889:                fi ;                                                    \
                   2890:        done
1.327     rh       2891:
1.965     agc      2892: ${DLIST}: ${WRKDIR}
1.327     rh       2893:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.1444    tv       2894:        { ${PKG_DELETE} -n "${PKGWILDCARD}" 2>&1 |                      \
1.1520    tv       2895:                ${GREP} '^      ' |                                             \
1.1444    tv       2896:                ${AWK} '{ l[NR]=$$0 } END { for (i=NR;i>0;--i) print l[i] }' \
                   2897:        || ${TRUE}; } > ${DLIST}
1.524     tron     2898:
1.784     tron     2899: # Create a binary package from an install package using "pkg_tarup"
1.1222    jmmv     2900: .PHONY: tarup
1.784     tron     2901: tarup:
1.1252    jlam     2902: .if ${PKG_INSTALLATION_TYPE} == "overwrite"
1.972     agc      2903:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2904:        ${RM} -f ${PACKAGES}/All/${PKGNAME}${PKG_SUFX};                 \
1.1252    jlam     2905:        ${SETENV} PKG_DBDIR=${_PKG_DBDIR} PKG_SUFX=${PKG_SUFX}  \
1.972     agc      2906:                PKGREPOSITORY=${PACKAGES}/All                           \
                   2907:                ${LOCALBASE}/bin/pkg_tarup ${PKGNAME};                  \
                   2908:        for CATEGORY in ${CATEGORIES}; do                               \
                   2909:                ${MKDIR} ${PACKAGES}/$$CATEGORY;                        \
                   2910:                cd ${PACKAGES}/$$CATEGORY;                              \
                   2911:                ${RM} -f ${PKGNAME}${PKG_SUFX};                         \
                   2912:                ${LN} -s ../All/${PKGNAME}${PKG_SUFX};                  \
1.784     tron     2913:        done
1.1252    jlam     2914: .endif
1.939     agc      2915:
                   2916: # shared code for replace and undo-replace
                   2917: _REPLACE=                                                              \
1.1531    agc      2918:        if [ -f ${_PKG_DBDIR}/$$oldpkgname/+REQUIRED_BY ]; then         \
1.1252    jlam     2919:                ${MV} ${_PKG_DBDIR}/$$oldpkgname/+REQUIRED_BY ${WRKDIR}/.req; \
1.939     agc      2920:        fi;                                                             \
1.1531    agc      2921:        ${MAKE} deinstall UPDATE_RUNNING=YES;                           \
1.939     agc      2922:        $$replace_action;                                               \
                   2923:        if [ -f ${WRKDIR}/.req ]; then                                  \
1.1252    jlam     2924:                ${MV} ${WRKDIR}/.req ${_PKG_DBDIR}/$$newpkgname/+REQUIRED_BY; \
                   2925:                for pkg in `${CAT} ${_PKG_DBDIR}/$$newpkgname/+REQUIRED_BY`; do \
1.939     agc      2926:                        ${SETENV} NEWPKGNAME=$$newpkgname               \
                   2927:                                ${AWK} '/^@pkgdep '$$oldpkgname'/ { print "@pkgdep " ENVIRON["NEWPKGNAME"]; next } { print }' \
1.1252    jlam     2928:                                < ${_PKG_DBDIR}/$$pkg/+CONTENTS > ${_PKG_DBDIR}/$$pkg/+CONTENTS.$$$$ && \
                   2929:                        ${MV} ${_PKG_DBDIR}/$$pkg/+CONTENTS.$$$$ ${_PKG_DBDIR}/$$pkg/+CONTENTS; \
1.939     agc      2930:                done;                                                   \
                   2931:        fi
                   2932:
                   2933: # replace a package in place - not for the faint-hearted
1.1222    jmmv     2934: .PHONY: real-su-replace
1.939     agc      2935: real-su-replace:
1.972     agc      2936:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.939     agc      2937:        ${ECHO_MSG} "*** WARNING - experimental target - data loss may be experienced ***"; \
1.955     agc      2938:        if [ -x ${LOCALBASE}/bin/pkg_tarup ]; then                      \
                   2939:                ${SETENV} PKGREPOSITORY=${WRKDIR} ${LOCALBASE}/bin/pkg_tarup ${PKGBASE}; \
                   2940:        else                                                            \
                   2941:                ${ECHO} "No ${LOCALBASE}/bin/pkg_tarup binary - can't pkg_tarup ${PKGBASE}"; \
                   2942:                exit 1;                                                 \
                   2943:        fi
1.972     agc      2944:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.1281    jlam     2945:        oldpkgname=`${PKG_BEST_EXISTS} "${PKGWILDCARD}"`;               \
1.939     agc      2946:        newpkgname=${PKGNAME};                                          \
                   2947:        ${ECHO} "$$oldpkgname" > ${WRKDIR}/.replace;                    \
                   2948:        replace_action="${MAKE} install";                               \
                   2949:        ${_REPLACE}
                   2950:
                   2951: # undo the replacement of a package - not for the faint-hearted either
1.1222    jmmv     2952: .PHONY: real-su-undo-replace
1.939     agc      2953: real-su-undo-replace:
1.972     agc      2954:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.939     agc      2955:        if [ ! -f ${WRKDIR}/.replace ]; then                            \
                   2956:                ${ECHO_MSG} "No replacement to undo";                   \
                   2957:                exit 1;                                                 \
1.955     agc      2958:        fi
1.972     agc      2959:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.939     agc      2960:        ${ECHO_MSG} "*** WARNING - experimental target - data loss may be experienced ***"; \
                   2961:        oldpkgname=${PKGNAME};                                          \
                   2962:        newpkgname=`${CAT} ${WRKDIR}/.replace`;                         \
1.955     agc      2963:        replace_action="${SETENV} ${PKG_ADD} ${WRKDIR}/$$newpkgname${PKG_SUFX}"; \
1.939     agc      2964:        ${_REPLACE};                                                    \
                   2965:        ${RM} ${WRKDIR}/.replace
1.631     hubertf  2966:
1.251     hubertf  2967: # This is for the use of sites which store distfiles which others may
                   2968: # fetch - only fetch the distfile if it is allowed to be
                   2969: # re-distributed freely
1.1222    jmmv     2970: .PHONY: mirror-distfiles
1.251     hubertf  2971: mirror-distfiles:
1.547     hubertf  2972: .if !defined(NO_SRC_ON_FTP)
1.1481    seb      2973:        @${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} fetch NO_SKIP=yes
1.251     hubertf  2974: .endif
                   2975:
1.1       agc      2976:
                   2977: # Cleaning up
                   2978:
1.1222    jmmv     2979: .PHONY: clean
1.1       agc      2980: clean: pre-clean
1.1540.2.1  tv       2981: .if (${CLEANDEPENDS} != "NO") && (!empty(BUILD_DEPENDS) || !empty(DEPENDS))
1.452     hubertf  2982:        ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} clean-depends
1.1540.2.1  tv       2983: .endif
1.416     agc      2984:        @${ECHO_MSG} "${_PKGSRC_IN}> Cleaning for ${PKGNAME}"
1.463     mycroft  2985:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   2986:        if [ -d ${WRKDIR} ]; then                                       \
1.221     agc      2987:                if [ -w ${WRKDIR} ]; then                               \
                   2988:                        ${RM} -rf ${WRKDIR};                            \
                   2989:                else                                                    \
1.416     agc      2990:                        ${ECHO_MSG} "${_PKGSRC_IN}> ${WRKDIR} not writable, skipping"; \
1.221     agc      2991:                fi;                                                     \
1.1       agc      2992:        fi
1.1540.2.1  tv       2993: .ifdef WRKOBJDIR
1.463     mycroft  2994:        -${_PKG_SILENT}${_PKG_DEBUG}                                    \
1.469     mycroft  2995:        ${RMDIR} ${BUILD_DIR} 2>/dev/null;                              \
1.463     mycroft  2996:        ${RM} -f ${WRKDIR_BASENAME}
1.1       agc      2997: .endif
                   2998:
1.446     hubertf  2999:
1.1222    jmmv     3000: .PHONY: clean-depends
1.446     hubertf  3001: clean-depends:
1.1540.2.1  tv       3002: .if !empty(BUILD_DEPENDS) || !empty(DEPENDS)
1.469     mycroft  3003:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.1540.2.1  tv       3004:        for i in `${_SHOW_ALL_DEPENDS_DIRS_EXCL}`; do                   \
1.490     dmcmahil 3005:                cd ${.CURDIR}/../../$$i &&                              \
                   3006:                ${MAKE} ${MAKEFLAGS} CLEANDEPENDS=NO clean;             \
1.446     hubertf  3007:        done
1.172     tron     3008: .endif
                   3009:
1.446     hubertf  3010:
1.1222    jmmv     3011: .PHONY: cleandir
1.172     tron     3012: cleandir: clean
1.1       agc      3013:
1.446     hubertf  3014:
1.1222    jmmv     3015: .PHONY: distclean
1.1       agc      3016: distclean: pre-distclean clean
1.416     agc      3017:        ${_PKG_SILENT}${ECHO_MSG} "${_PKGSRC_IN}> Dist cleaning for ${PKGNAME}"
1.451     hubertf  3018:        ${_PKG_SILENT}${_PKG_DEBUG}if [ -d ${_DISTDIR} ]; then          \
1.221     agc      3019:                cd ${_DISTDIR} &&                                       \
                   3020:                ${TEST} -z "${DISTFILES}" || ${RM} -f ${DISTFILES};     \
                   3021:                ${TEST} -z "${PATCHFILES}" || ${RM} -f ${PATCHFILES};   \
1.451     hubertf  3022:        fi
1.1540.2.1  tv       3023: .if defined(DIST_SUBDIR) && exists(DIST_SUBDIR)
1.1159    grant    3024:        -${_PKG_SILENT}${_PKG_DEBUG}${RMDIR} ${_DISTDIR}
1.1       agc      3025: .endif
1.1540.2.1  tv       3026:        -${_PKG_SILENT}${_PKG_DEBUG}${RM} -f README.html
1.1       agc      3027:
1.744     hubertf  3028: # List of sites carrying binary pkgs. Variables "rel" and "arch" are
                   3029: # replaced with OS release ("1.5", ...) and architecture ("mipsel", ...)
1.1082    hubertf  3030: BINPKG_SITES?= \
1.1412    grant    3031:        ftp://ftp.NetBSD.org/pub/NetBSD/packages/$${rel}/$${arch}
1.744     hubertf  3032:
1.1252    jlam     3033: # List of flags to pass to pkg_add(1) for bin-install:
                   3034:
1.744     hubertf  3035: BIN_INSTALL_FLAGS?=    # -v
1.1252    jlam     3036: .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
1.1264    jlam     3037: PKG_ARGS_ADD=          -W ${LOCALBASE} -w ${DEFAULT_VIEW}
1.1252    jlam     3038: .endif
                   3039: _BIN_INSTALL_FLAGS=    ${BIN_INSTALL_FLAGS}
                   3040: _BIN_INSTALL_FLAGS+=   ${PKG_ARGS_ADD}
1.744     hubertf  3041:
1.499     hubertf  3042: # Install binary pkg, without strict uptodate-check first
1.1297    agc      3043: .PHONY: real-su-bin-install
                   3044: real-su-bin-install:
1.1275    jlam     3045:        @found="`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`";    \
1.744     hubertf  3046:        if [ "$$found" != "" ]; then                                    \
1.1331    grant    3047:                ${ECHO_MSG} "${_PKGSRC_IN}> $$found is already installed - perhaps an older version?"; \
1.744     hubertf  3048:                ${ECHO_MSG} "*** If so, you may wish to \`\`pkg_delete $$found'' and install"; \
                   3049:                ${ECHO_MSG} "*** this package again by \`\`${MAKE} bin-install'' to upgrade it properly."; \
                   3050:                ${SHCOMMENT} ${ECHO_MSG} "*** or use \`\`${MAKE} bin-update'' to upgrade it and all of its dependencies."; \
                   3051:                exit 1;                                                 \
                   3052:        fi
1.499     hubertf  3053:        @if [ -f ${PKGFILE} ] ; then                                    \
                   3054:                ${ECHO_MSG} "Installing from binary pkg ${PKGFILE}" ;   \
1.1252    jlam     3055:                ${PKG_ADD} ${_BIN_INSTALL_FLAGS} ${PKGFILE} ;           \
1.499     hubertf  3056:        else                                                            \
1.972     agc      3057:                rel=`${UNAME} -r | ${SED} 's@\.\([0-9]*\)[\._].*@\.\1@'`; \
1.926     hubertf  3058:                arch=${MACHINE_ARCH};                                   \
1.1082    hubertf  3059:                for site in ${BINPKG_SITES} ; do                        \
1.756     jlam     3060:                        ${ECHO} Trying `eval ${ECHO} $$site`/All ;      \
1.1252    jlam     3061:                        ${SHCOMMENT} ${ECHO} ${SETENV} PKG_PATH="`eval ${ECHO} $$site`/All" ${PKG_ADD} ${_BIN_INSTALL_FLAGS} ${PKGNAME}${PKG_SUFX} ; \
1.756     jlam     3062:                        if ${SETENV} PKG_PATH="`eval ${ECHO} $$site`/All" ${PKG_ADD} ${BIN_INSTALL_FLAGS} ${PKGNAME}${PKG_SUFX} ; then \
1.972     agc      3063:                                ${ECHO} "${PKGNAME} successfully installed."; \
1.744     hubertf  3064:                                break ;                                 \
                   3065:                        fi ;                                            \
                   3066:                done ;                                                  \
1.1048    hubertf  3067:                if ! ${PKG_INFO} -qe "${PKGNAME}" ; then                \
1.744     hubertf  3068:                        ${SHCOMMENT} Cycle through some FTP server here ;\
                   3069:                        ${ECHO_MSG} "Installing from source" ;          \
1.969     hubertf  3070:                        ${MAKE} ${MAKEFLAGS} package                    \
1.1437    xtraeme  3071:                                DEPENDS_TARGET=${DEPENDS_TARGET:Q} &&   \
1.744     hubertf  3072:                        ${MAKE} ${MAKEFLAGS} clean ;                    \
                   3073:                fi ; \
1.499     hubertf  3074:        fi
1.1297    agc      3075:
                   3076: .PHONY: bin-install
                   3077: bin-install:
                   3078:        @${ECHO_MSG} "${_PKGSRC_IN}> Binary install for ${PKGNAME}"
                   3079:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   3080:        realtarget="real-su-bin-install";                                       \
                   3081:        action="binary install";                                        \
                   3082:        ${_SU_TARGET}
                   3083:
1.1       agc      3084: ################################################################
                   3085: # The special package-building targets
                   3086: # You probably won't need to touch these
                   3087: ################################################################
                   3088:
                   3089: # Show (recursively) all the packages this package depends on.
1.414     hubertf  3090: # If PACKAGE_DEPENDS_WITH_PATTERNS is set, print as pattern (if possible)
1.399     hubertf  3091: PACKAGE_DEPENDS_WITH_PATTERNS?=true
1.1222    jmmv     3092: .PHONY: run-depends-list
1.532     hubertf  3093: run-depends-list:
1.1540.2.1  tv       3094: .for dep in ${DEPENDS}
1.747     agc      3095:        @pkg="${dep:C/:.*//}";                                          \
1.452     hubertf  3096:        dir="${dep:C/[^:]*://}";                                        \
1.472     hubertf  3097:        cd ${.CURDIR};                                                  \
1.482     hubertf  3098:        if ${PACKAGE_DEPENDS_WITH_PATTERNS}; then                       \
                   3099:                ${ECHO} "$$pkg";                                        \
                   3100:        else                                                            \
                   3101:                if cd $$dir 2>/dev/null; then                           \
1.458     hubertf  3102:                        ${MAKE} ${MAKEFLAGS} package-name PACKAGE_NAME_TYPE=${PACKAGE_NAME_TYPE}; \
1.482     hubertf  3103:                else                                                    \
                   3104:                        ${ECHO_MSG} "Warning: \"$$dir\" non-existent -- @pkgdep registration incomplete" >&2; \
1.221     agc      3105:                fi;                                                     \
1.458     hubertf  3106:        fi
1.1540.2.1  tv       3107: .endfor
1.1       agc      3108:
1.1540.2.6  tv       3109: # Set to "html" by the README.html target to generate HTML code,
                   3110: # or to "svr4" to print SVR4 (Solaris, ...) short package names, from
                   3111: # SVR4_PKGNAME variable.
                   3112: # This variable is passed down via build-depends-list and run-depends-list
                   3113: PACKAGE_NAME_TYPE?=    name
                   3114:
                   3115: # Nobody should want to override this unless PKGNAME is simply bogus.
                   3116: HTML_PKGNAME=<a href="../../${PKGPATH:S/&/\&amp;/g:S/>/\&gt;/g:S/</\&lt;/g}/README.html">${PKGNAME:S/&/\&amp;/g:S/>/\&gt;/g:S/</\&lt;/g}</A>
                   3117:
                   3118: .PHONY: package-name
                   3119: package-name:
                   3120: .if (${PACKAGE_NAME_TYPE} == "html")
                   3121:        @${ECHO} '<a href="../../${PKGPATH:S/&/\&amp;/g:S/>/\&gt;/g:S/</\&lt;/g}/README.html">${PKGNAME:S/&/\&amp;/g:S/>/\&gt;/g:S/</\&lt;/g}</A>'
                   3122: .elif (${PACKAGE_NAME_TYPE} == "svr4")
                   3123:        @${ECHO} ${SVR4_PKGNAME}
                   3124: .else
                   3125:        @${ECHO} ${PKGNAME}
                   3126: .endif # PACKAGE_NAME_TYPE
                   3127:
1.1       agc      3128: # Build a package but don't check the package cookie
                   3129:
1.1222    jmmv     3130: .PHONY: repackage
1.1       agc      3131: repackage: pre-repackage package
                   3132:
1.1222    jmmv     3133: .PHONY: pre-repackage
1.1       agc      3134: pre-repackage:
1.1540.2.1  tv       3135:        ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${package_COOKIE}
1.1       agc      3136:
                   3137: # Build a package but don't check the cookie for installation, also don't
                   3138: # install package cookie
                   3139:
1.1222    jmmv     3140: .PHONY: package-noinstall
1.1       agc      3141: package-noinstall:
1.452     hubertf  3142:        ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package
1.1       agc      3143:
                   3144: ################################################################
                   3145: # Dependency checking
                   3146: ################################################################
                   3147:
1.393     agc      3148: # Tells whether to halt execution if the object formats differ
                   3149: FATAL_OBJECT_FMT_SKEW?= yes
1.396     agc      3150: WARN_NO_OBJECT_FMT?= yes
1.393     agc      3151:
1.1540.2.5  tv       3152: do-depends:
1.1540.2.1  tv       3153: .for dep in ${DEPENDS} ${BUILD_DEPENDS}
1.701     hubertf  3154:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.454     mycroft  3155:        pkg="${dep:C/:.*//}";                                           \
                   3156:        dir="${dep:C/[^:]*://:C/:.*$//}";                               \
1.1275    jlam     3157:        found=`${PKG_BEST_EXISTS} "$$pkg" || ${TRUE}`;                  \
1.808     martin   3158:        if [ "X$$REBUILD_DOWNLEVEL_DEPENDS" != "X" ]; then              \
1.1540.2.1  tv       3159:                pkgname=`cd $$dir ; ${MAKE} ${MAKEFLAGS} show-var-noeval VARNAME=PKGNAME`; \
1.972     agc      3160:                if [ "X$$found" != "X" -a "X$$found" != "X$${pkgname}" ]; then \
                   3161:                        ${ECHO_MSG} "ignoring old installed package \"$$found\""; \
1.808     martin   3162:                        found="";                                       \
                   3163:                fi;                                                     \
                   3164:        fi;                                                             \
1.452     hubertf  3165:        if [ "$$found" != "" ]; then                                    \
1.1275    jlam     3166:                instobjfmt=`${PKG_INFO} -B "$$found" | ${AWK} -F'=[ \t]*' '/^OBJECT_FMT/ {print $$2; exit}'`; \
1.452     hubertf  3167:                if [ "$$instobjfmt" = "" ]; then                        \
1.396     agc      3168:                        if [ "X${WARN_NO_OBJECT_FMT}" != "Xno" ]; then  \
1.1275    jlam     3169:                                ${ECHO} "WARNING: Unknown object format for installed package $$found - continuing"; \
1.396     agc      3170:                        fi;                                             \
1.452     hubertf  3171:                elif [ "$$instobjfmt" != "${OBJECT_FMT}" ]; then        \
1.1275    jlam     3172:                        ${ECHO} "Installed package $$found is an $$instobjfmt package."; \
1.392     agc      3173:                        ${ECHO} "You are building an ${OBJECT_FMT} package, which will not inter-operate."; \
1.1275    jlam     3174:                        ${ECHO} "Please update the $$found package to ${OBJECT_FMT}"; \
1.537     fredb    3175:                        if [ "X${FATAL_OBJECT_FMT_SKEW}" != "Xno" ]; then \
1.393     agc      3176:                                exit 1;                                 \
                   3177:                        fi;                                             \
1.392     agc      3178:                fi;                                                     \
1.1279    jlam     3179:                ${ECHO_MSG} "${_PKGSRC_IN}> Required installed package $$pkg: $${found} found"; \
1.148     agc      3180:        else                                                            \
1.606     hubertf  3181:                ${ECHO_MSG} "${_PKGSRC_IN}> Required package $$pkg: NOT found"; \
1.1437    xtraeme  3182:                target=${DEPENDS_TARGET:Q};                             \
1.416     agc      3183:                ${ECHO_MSG} "${_PKGSRC_IN}> Verifying $$target for $$dir";      \
1.148     agc      3184:                if [ ! -d $$dir ]; then                                 \
1.415     agc      3185:                        ${ECHO_MSG} "=> No directory for $$dir.  Skipping.."; \
1.73      agc      3186:                else                                                    \
1.452     hubertf  3187:                        cd $$dir ;                                      \
1.1468    agc      3188:                        ${SETENV} _PKGSRC_DEPS=", ${PKGNAME}${_PKGSRC_DEPS}" ${MAKE} ${MAKEFLAGS} $$target PKGNAME_REQD=\'$$pkg\' || exit 1; \
1.416     agc      3189:                        ${ECHO_MSG} "${_PKGSRC_IN}> Returning to build of ${PKGNAME}"; \
1.275     tv       3190:                fi;                                                     \
                   3191:        fi
1.1540.2.1  tv       3192: .endfor        # DEPENDS
1.1       agc      3193:
1.1222    jmmv     3194: .PHONY: build-depends-list
1.532     hubertf  3195: build-depends-list:
1.1540.2.1  tv       3196:        @for dir in `${_SHOW_ALL_DEPENDS_DIRS_EXCL}`; do                \
1.937     wiz      3197:                (cd ../../$$dir &&                                      \
                   3198:                ${MAKE} ${MAKEFLAGS} package-name)                      \
                   3199:        done
1.1       agc      3200:
1.1159    grant    3201: # Stat all the files of one pkg and sum the sizes up.
                   3202: #
1.373     hubertf  3203: # XXX This is intended to be run before pkg_create is called, so the
1.577     agc      3204: # existence of ${PLIST} can be assumed.
1.1222    jmmv     3205: .PHONY: print-pkg-size-this
1.483     hubertf  3206: print-pkg-size-this:
1.485     hubertf  3207:        @${SHCOMMENT} "This pkg's files" ;                              \
1.424     hubertf  3208:        ${AWK} 'BEGIN { base = "${PREFIX}/" }                           \
                   3209:                /^@cwd/ { base = $$2 "/" }                              \
1.1328    seb      3210:                /^@/ { next }                                           \
                   3211:                { print base $$0 }'                                     \
1.488     hubertf  3212:                <${PLIST}                                               \
1.757     jlam     3213:        | ${SORT} -u                                                    \
1.1328    seb      3214:        | ${SED} -e "s/'/'\\\\''/g" -e "s/.*/'&'/"                      \
1.1383    jlam     3215:        | ${XARGS} -n 256 ${LS} -ld                                     \
1.577     agc      3216:        | ${AWK} 'BEGIN { print("0 "); }                                \
                   3217:                  { print($$5, " + "); }                                \
1.572     tron     3218:                  END { print("p"); }'                                  \
                   3219:        | ${DC}
1.386     hubertf  3220:
1.483     hubertf  3221: # Sizes of required pkgs (only)
1.1159    grant    3222: #
1.483     hubertf  3223: # XXX This is intended to be run before pkg_create is called, so the
1.1159    grant    3224: # dependencies are all installed.
1.1222    jmmv     3225: .PHONY: print-pkg-size-depends
1.483     hubertf  3226: print-pkg-size-depends:
1.1483    minskim  3227:        @pkglist=`${MAKE} ${MAKEFLAGS} run-depends-list`;               \
                   3228:        if [ "X$${pkglist}" != "X" ]; then                              \
                   3229:                ${ECHO} $${pkglist}                                     \
                   3230:                | ${XARGS} -n 1 ${SETENV} ${PKG_BEST_EXISTS}            \
                   3231:                | ${SORT} -u                                            \
                   3232:                | ${XARGS} -n 256 ${SETENV} ${PKG_INFO} -qs             \
                   3233:                | ${AWK} -- 'BEGIN { print("0 "); }                     \
                   3234:                        /^[0-9]+$$/ { print($$1, " + "); }              \
                   3235:                        END { print("p"); }'                            \
                   3236:                | ${DC};                                                \
                   3237:        else                                                            \
                   3238:                ${ECHO} "0";                                            \
                   3239:        fi
1.480     hubertf  3240:
1.1252    jlam     3241: # By default, all packages attempt to link into the views.
                   3242: .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
                   3243: BUILD_VIEWS?=  yes
                   3244: .endif
                   3245:
1.1272    jlam     3246: # DEFAULT_VIEW.${PKGBASE}      default view for ${PKGBASE}
                   3247: # VIEWBASE                     base location of files at run-time
                   3248: #
                   3249: DEFAULT_VIEW.${PKGBASE}?=      ${DEFAULT_VIEW}
                   3250: .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
                   3251: .  if empty(DEFAULT_VIEW.${PKGBASE}:M"")
                   3252: VIEWBASE=      ${LOCALBASE}/${DEFAULT_VIEW.${PKGBASE}}
                   3253: .  else
                   3254: VIEWBASE=      ${LOCALBASE}
                   3255: .  endif
                   3256: .elif ${PKG_INSTALLATION_TYPE} == "overwrite"
                   3257: VIEWBASE=      ${PREFIX}
                   3258: .endif
1.1305    jlam     3259: MAKE_ENV+=     VIEWBASE=${VIEWBASE}
1.1272    jlam     3260:
                   3261: PKGVIEWS+=     ${DEFAULT_VIEW.${PKGBASE}}
1.373     hubertf  3262:
1.1       agc      3263: # Fake installation of package so that user can pkg_delete it later.
1.311     agc      3264: # Also, make sure that an installed package is recognized correctly in
1.1252    jlam     3265: # accordance to the @pkgdep directive in the packing lists.
1.1       agc      3266:
1.1222    jmmv     3267: .PHONY: fake-pkg
1.654     wiz      3268: fake-pkg: ${PLIST} ${DESCR} ${MESSAGE}
1.972     agc      3269:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   3270:        if [ ! -f ${PLIST} -o ! -f ${DESCR} ]; then                     \
1.186     agc      3271:                ${ECHO} "** Missing package files for ${PKGNAME} - installation not recorded."; \
                   3272:                exit 1;                                                 \
                   3273:        fi
1.972     agc      3274:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.1252    jlam     3275:        if [ ! -d ${_PKG_DBDIR} ]; then                                 \
                   3276:                ${RM} -f ${_PKG_DBDIR};                                 \
                   3277:                ${MKDIR} ${_PKG_DBDIR};                                 \
1.186     agc      3278:        fi
1.1540.2.1  tv       3279: .if defined(FORCE_PKG_REGISTER)
1.1287    jlam     3280:        ${_PKG_SILENT}${_PKG_DEBUG}${PKG_ADMIN} delete ${PKGNAME}
1.1540.2.1  tv       3281: .  if ${PKG_INSTALLATION_TYPE} == "overwrite"
1.1252    jlam     3282:        ${_PKG_SILENT}${_PKG_DEBUG}${RM} -rf ${_PKG_DBDIR}/${PKGNAME}
1.789     hubertf  3283: .  endif
1.1540.2.1  tv       3284: .endif
1.221     agc      3285:        ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${BUILD_VERSION_FILE} ${BUILD_INFO_FILE}
1.373     hubertf  3286:        ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${SIZE_PKG_FILE} ${SIZE_ALL_FILE}
1.1127    agc      3287:        ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PRESERVE_FILE}
1.1540.2.1  tv       3288: .if defined(PKG_PRESERVE)
1.1127    agc      3289:        ${_PKG_SILENT}${_PKG_DEBUG}${DATE} > ${PRESERVE_FILE}
1.1540.2.1  tv       3290: .endif
1.932     agc      3291:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   3292:        files="";                                                       \
1.948     tron     3293:        for f in ${.CURDIR}/Makefile ${FILESDIR}/* ${PKGDIR}/*; do      \
1.945     agc      3294:                if [ -f "$$f" ]; then                                   \
                   3295:                        files="$$files \"$$f\"";                        \
                   3296:                fi;                                                     \
                   3297:        done;                                                           \
1.753     wiz      3298:        if [ -f ${DISTINFO_FILE} ]; then                                \
                   3299:                for f in `${AWK} 'NF == 4 && $$3 == "=" { gsub("[()]", "", $$2); print $$2 }' < ${DISTINFO_FILE}`; do \
1.662     agc      3300:                        if [ -f ${PATCHDIR}/$$f ]; then                 \
1.945     agc      3301:                                files="$$files \"${PATCHDIR}/$$f\"";    \
1.334     tron     3302:                        fi;                                             \
1.315     agc      3303:                done;                                                   \
                   3304:        fi;                                                             \
1.186     agc      3305:        if [ -d ${PATCHDIR} ]; then                                     \
                   3306:                for f in ${PATCHDIR}/patch-*; do                        \
                   3307:                        case $$f in                                     \
                   3308:                        *.orig|*.rej|*~) ;;                             \
1.315     agc      3309:                        ${PATCHDIR}/patch-local-*)                      \
1.945     agc      3310:                                files="$$files \"$$f\"" ;;              \
1.186     agc      3311:                        esac;                                           \
                   3312:                done;                                                   \
                   3313:        fi;                                                             \
1.1510    jlam     3314:        eval ${GREP} '\$$NetBSD' $$files | ${SED} -e 's|^${PKGSRCDIR}/||' > ${BUILD_VERSION_FILE}
1.1540.2.1  tv       3315: .for def in ${BUILD_DEFS} ${BUILD_DEFS_FIXED}
1.1193    grant    3316:        @${ECHO} ${def}=${${def}:Q} | ${SED} -e 's|^PATH=[^     ]*|PATH=...|' >> ${BUILD_INFO_FILE}
1.1540.2.1  tv       3317: .endfor
                   3318: .if defined(USE_LANGUAGES) && !empty(USE_LANGUAGES)
1.1294    grant    3319:        @${ECHO} "CC_VERSION=${CC_VERSION}" >> ${BUILD_INFO_FILE}
1.1540.2.1  tv       3320: .endif
                   3321: .if defined(USE_PERL5) && (${USE_PERL5} == "run")
1.1193    grant    3322:        @${ECHO} "PERL=`${PERL5} --version 2>/dev/null | ${GREP} 'This is perl'`" >> ${BUILD_INFO_FILE}
1.1540.2.1  tv       3323: .endif
                   3324: .if !empty(USE_GNU_TOOLS:Mmake)
1.1193    grant    3325:        @${ECHO} "GMAKE=`${GMAKE} --version | ${GREP} Make`" >> ${BUILD_INFO_FILE}
1.1540.2.1  tv       3326: .endif
                   3327: .if ${SHLIB_HANDLING} == "YES" && ${CHECK_SHLIBS} == "YES"
1.1219    agc      3328:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.1244    grant    3329:        case "${LDD}" in                                                \
                   3330:        "")     ldd=`${TYPE} ldd 2>/dev/null | ${AWK} '{ print $$NF }'`;; \
                   3331:        *)      ldd="${LDD}";                                           \
                   3332:        esac;                                                           \
1.1219    agc      3333:        case "${OBJECT_FMT}" in                                         \
                   3334:        ELF)    bins=`${SETENV} PREFIX=${PREFIX} ${AWK} '/^(bin|sbin|libexec)\// { print ENVIRON["PREFIX"] "/" $$0 }' ${PLIST} || ${TRUE}`; \
                   3335:                libs=`${SETENV} PREFIX=${PREFIX} ${AWK} '/^lib\/lib.*\.so\.[0-9]+$$/ { print ENVIRON["PREFIX"] "/" $$0 }' ${PLIST} || ${TRUE}`; \
                   3336:                if ${TEST} "$$bins" != "" -o "$$libs" != ""; then       \
1.1220    agc      3337:                        requires=`($$ldd $$bins $$libs 2>/dev/null || ${TRUE}) | ${AWK} 'NF == 3 { print $$3 }' | ${SORT} -u`; \
1.1219    agc      3338:                fi;                                                     \
1.1529    tv       3339:                linklibs=`${SETENV} PREFIX=${PREFIX} ${AWK} '/^[^@].*\.so\.[0-9\.]+$$/ { print ENVIRON["PREFIX"] "/" $$0 }' ${PLIST} || ${TRUE}`; \
1.1518    tv       3340:                for i in $${linklibs}; do                               \
1.1527    tv       3341:                        if ${TEST} -r $$i -a ! -x $$i -a ! -h $$i; then \
1.1529    tv       3342:                                ${TEST} "${PKG_DEVELOPER:Uno}" = "no" || \
                   3343:                                        ${ECHO} "$$i: installed without execute permission; fixing (should use [BSD_]INSTALL_LIB)"; \
1.1518    tv       3344:                                ${CHMOD} +x $$i;                        \
                   3345:                        fi;                                             \
                   3346:                done;                                                   \
1.1244    grant    3347:                ;;                                                      \
                   3348:        Mach-O) bins=`${SETENV} PREFIX=${PREFIX} ${AWK} '/^(bin|sbin|libexec)\// { print ENVIRON["PREFIX"] "/" $$0 }' ${PLIST} || ${TRUE}`; \
                   3349:                libs=`${SETENV} PREFIX=${PREFIX} ${AWK} '/^lib\/lib.*\.dylib/ { print ENVIRON["PREFIX"] "/" $$0 }' ${PLIST} || ${TRUE}`; \
                   3350:                if ${TEST} "$$bins" != "" -o "$$libs" != ""; then       \
1.1334    grant    3351:                        requires=`($$ldd $$bins $$libs 2>/dev/null || ${TRUE}) | ${AWK} '/compatibility version/ { print $$1 }' | ${SORT} -u`; \
1.1244    grant    3352:                fi;                                                     \
                   3353:                ;;                                                      \
                   3354:        esac;                                                           \
                   3355:        for i in "" $$libs; do                                          \
                   3356:                ${TEST} "$$i" = "" && continue;                         \
                   3357:                ${ECHO} "PROVIDES=$$i" >> ${BUILD_INFO_FILE};           \
                   3358:        done;                                                           \
                   3359:        for req in "" $$requires; do                                    \
                   3360:                ${TEST} "$$req" = "" && continue;                       \
                   3361:                ${ECHO} "REQUIRES=$$req" >> ${BUILD_INFO_FILE};         \
                   3362:        done
1.1540.2.1  tv       3363: .endif
1.615     hubertf  3364:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.529     hubertf  3365:        ${ECHO} "_PKGTOOLS_VER=${PKGTOOLS_VERSION}" >> ${BUILD_INFO_FILE}
1.615     hubertf  3366:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.483     hubertf  3367:        size_this=`${MAKE} ${MAKEFLAGS} print-pkg-size-this`;           \
                   3368:        size_depends=`${MAKE} ${MAKEFLAGS} print-pkg-size-depends`;     \
1.488     hubertf  3369:        ${ECHO} $$size_this >${SIZE_PKG_FILE};                          \
1.575     tron     3370:        ${ECHO} $$size_this $$size_depends + p | ${DC} >${SIZE_ALL_FILE}
1.452     hubertf  3371:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
1.1252    jlam     3372:        doit=yes;                                                       \
                   3373:        case ${PKG_INSTALLATION_TYPE} in                                \
                   3374:        overwrite)      if [ -d ${_PKG_DBDIR}/${PKGNAME} ]; then        \
                   3375:                                doit=no;                                \
                   3376:                        fi ;;                                           \
                   3377:        esac;                                                           \
                   3378:        case $$doit in                                                  \
                   3379:        yes)                                                            \
1.416     agc      3380:                ${ECHO_MSG} "${_PKGSRC_IN}> Registering installation for ${PKGNAME}"; \
1.1252    jlam     3381:                ${MKDIR} ${_PKG_DBDIR}/${PKGNAME};                      \
                   3382:                ${PKG_CREATE} ${PKG_ARGS_INSTALL} -O ${PKGFILE} > ${_PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
                   3383:                ${CP} ${DESCR} ${_PKG_DBDIR}/${PKGNAME}/+DESC;  \
                   3384:                ${ECHO} ${COMMENT:Q} > ${_PKG_DBDIR}/${PKGNAME}/+COMMENT; \
                   3385:                ${CP} ${BUILD_VERSION_FILE} ${_PKG_DBDIR}/${PKGNAME}/+BUILD_VERSION; \
                   3386:                ${CP} ${BUILD_INFO_FILE} ${_PKG_DBDIR}/${PKGNAME}/+BUILD_INFO; \
1.1471    grant    3387:                if ${TEST} -f ${SIZE_PKG_FILE}; then                    \
1.1252    jlam     3388:                        ${CP} ${SIZE_PKG_FILE} ${_PKG_DBDIR}/${PKGNAME}/+SIZE_PKG; \
1.452     hubertf  3389:                fi ;                                                    \
1.1471    grant    3390:                if ${TEST} -f ${SIZE_ALL_FILE}; then                    \
1.1252    jlam     3391:                        ${CP} ${SIZE_ALL_FILE} ${_PKG_DBDIR}/${PKGNAME}/+SIZE_ALL; \
1.1127    agc      3392:                fi ;                                                    \
1.1471    grant    3393:                if ${TEST} -f ${PRESERVE_FILE}; then                    \
1.1252    jlam     3394:                        ${CP} ${PRESERVE_FILE} ${_PKG_DBDIR}/${PKGNAME}/+PRESERVE; \
1.452     hubertf  3395:                fi ;                                                    \
1.1252    jlam     3396:                if [ "${PKG_INSTALLATION_TYPE}" = "pkgviews" ]; then    \
                   3397:                        ${TOUCH} ${_PKG_DBDIR}/${PKGNAME}/+VIEWS;       \
                   3398:                fi ;                                                    \
1.166     agc      3399:                if [ -n "${INSTALL_FILE}" ]; then                       \
1.1471    grant    3400:                        if ${TEST} -f ${INSTALL_FILE}; then             \
1.1252    jlam     3401:                                ${CP} ${INSTALL_FILE} ${_PKG_DBDIR}/${PKGNAME}/+INSTALL; \
1.166     agc      3402:                        fi;                                             \
                   3403:                fi;                                                     \
                   3404:                if [ -n "${DEINSTALL_FILE}" ]; then                     \
1.1471    grant    3405:                        if ${TEST} -f ${DEINSTALL_FILE}; then           \
1.1252    jlam     3406:                                ${CP} ${DEINSTALL_FILE} ${_PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
1.166     agc      3407:                        fi;                                             \
                   3408:                fi;                                                     \
1.757     jlam     3409:                if [ -n "${MESSAGE}" ]; then                            \
1.1471    grant    3410:                        if ${TEST} -f ${MESSAGE}; then                  \
1.1252    jlam     3411:                                ${CP} ${MESSAGE} ${_PKG_DBDIR}/${PKGNAME}/+DISPLAY; \
1.166     agc      3412:                        fi;                                             \
                   3413:                fi;                                                     \
1.1435    tv       3414:                list="`${MAKE} ${MAKEFLAGS} run-depends-list ECHO_MSG=${TRUE} | ${SORT} -u`" ; \
1.1278    jlam     3415:                for realdep in `${ECHO} $$list | ${XARGS} -n 1 ${SETENV} ${PKG_BEST_EXISTS} | ${SORT} -u`; do \
1.380     hubertf  3416:                        if ${TEST} -z "$$realdep"; then                 \
1.568     wiz      3417:                                ${ECHO} "$$dep not installed - dependency NOT registered" ; \
1.1252    jlam     3418:                        elif [ -d ${_PKG_DBDIR}/$$realdep ]; then       \
1.1471    grant    3419:                                if ${TEST} ! -f ${_PKG_DBDIR}/$$realdep/+REQUIRED_BY; then \
1.1252    jlam     3420:                                        ${TOUCH} ${_PKG_DBDIR}/$$realdep/+REQUIRED_BY; \
1.221     agc      3421:                                fi;                                     \
                   3422:                                ${AWK} 'BEGIN { found = 0; }            \
                   3423:                                        $$0 == "${PKGNAME}" { found = 1; } \
                   3424:                                        { print $$0; }                  \
                   3425:                                        END { if (!found) { printf("%s\n", "${PKGNAME}"); }}' \
1.1252    jlam     3426:                                        < ${_PKG_DBDIR}/$$realdep/+REQUIRED_BY > ${_PKG_DBDIR}/$$realdep/reqby.$$$$; \
                   3427:                                ${MV} ${_PKG_DBDIR}/$$realdep/reqby.$$$$ ${_PKG_DBDIR}/$$realdep/+REQUIRED_BY; \
1.221     agc      3428:                                ${ECHO} "${PKGNAME} requires installed package $$realdep"; \
1.175     agc      3429:                        fi;                                             \
1.1252    jlam     3430:                done ;;                                                 \
                   3431:        esac
1.1540.2.1  tv       3432: .if (${PKG_INSTALLATION_TYPE} == "pkgviews") && \
1.1265    jlam     3433:       !empty(BUILD_VIEWS:M[yY][eE][sS])
1.1252    jlam     3434:        ${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} build-views
1.1540.2.1  tv       3435: .endif # pkgviews
1.1252    jlam     3436:
                   3437: .PHONY: build-views
                   3438: build-views: do-su-build-views
                   3439:
                   3440: .PHONY: do-su-build-views
                   3441: do-su-build-views:
                   3442:        @${ECHO_MSG} "${_PKGSRC_IN}> Building views for ${PKGNAME}"
                   3443:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   3444:        realtarget="real-su-build-views";                               \
                   3445:        action="build-views";                                           \
                   3446:        ${_SU_TARGET}
                   3447:
                   3448: .PHONY: real-su-build-views
                   3449: real-su-build-views:
1.1540.2.1  tv       3450: .if (${PKG_INSTALLATION_TYPE} == "pkgviews") && defined(PKGVIEWS)
1.1252    jlam     3451:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   3452:        ${MKDIR} ${LOCALBASE};                                          \
                   3453:        for v in ${PKGVIEWS}; do                                        \
                   3454:                case "$$v" in                                           \
                   3455:                "")     dbdir=${PKG_DBDIR}; viewname=standard ;;        \
                   3456:                *)      dbdir=${LOCALBASE}/$$v/.dbdir; viewname=$$v ;;  \
                   3457:                esac;                                                   \
                   3458:                ${ECHO} "=> Performing package view clash check for ${PKGNAME} in $$viewname view"; \
                   3459:                pkg=`${PKG_INFO_CMD} -K $$dbdir -e ${PKGBASE} || ${TRUE}`; \
                   3460:                case "$$pkg" in                                         \
                   3461:                "")     ;;                                              \
                   3462:                *)      ${ECHO} "*** ${PKGBASE} exists in $$viewname view - package $$pkg ***"; \
                   3463:                        ${ECHO} "*** Not hoisting ${PKGNAME} into $$viewname view"; \
                   3464:                        continue ;;                                     \
                   3465:                esac;                                                   \
                   3466:                ${ECHO} "=> Performing package view overwrite check for ${PKGNAME} in $$viewname view"; \
                   3467:                dups=`${SETENV} PLIST_IGNORE_FILES="${_PLIST_IGNORE_FILES}" ${PKG_VIEW} --view=$$v check ${PKGNAME} || ${TRUE}`; \
                   3468:                case "$$dups" in                                        \
                   3469:                "")     ;;                                              \
                   3470:                *)      ${ECHO} "***********************************************************"; \
                   3471:                        ${ECHO} "**** The following symbolic links will be overwritten *****"; \
                   3472:                        for f in $$dups; do                             \
                   3473:                                ${LS} -l ${LOCALBASE}/$$v/$$f;          \
                   3474:                        done;                                           \
                   3475:                        ${ECHO} "***********************************************************"; \
                   3476:                        ;;                                              \
                   3477:                esac;                                                   \
                   3478:                ${ECHO} "=> Linking package into $$viewname view";      \
                   3479:                ${SETENV} PLIST_IGNORE_FILES="${_PLIST_IGNORE_FILES}" ${PKG_VIEW} --view=$$v add ${PKGNAME}; \
                   3480:        done
                   3481: .endif
                   3482:
                   3483: .PHONY: remove-views
                   3484: remove-views: do-su-remove-views
                   3485:
                   3486: .PHONY: do-su-remove-views
                   3487: do-su-remove-views:
                   3488:        @${ECHO_MSG} "${_PKGSRC_IN}> Removing ${PKGNAME} from views"
                   3489:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   3490:        realtarget="real-su-remove-views";                              \
                   3491:        action="remove-views";                                          \
                   3492:        ${_SU_TARGET}
                   3493:
                   3494: .PHONY: real-su-remove-views
                   3495: real-su-remove-views:
1.1540.2.1  tv       3496: .if (${PKG_INSTALLATION_TYPE} == "pkgviews") && defined(PKGVIEWS)
1.1252    jlam     3497:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                   3498:        for v in ${PKGVIEWS}; do                                        \
                   3499:                case "$$v" in                                           \
                   3500:                "")     dbdir=${PKG_DBDIR}; viewname=standard ;;        \
                   3501:                *)      dbdir=${LOCALBASE}/$$v/.dbdir; viewname=$$v ;;  \
                   3502:                esac;                                                   \
                   3503:                ${ECHO} "=> Removing package from $$viewname view";     \
                   3504:                ${SETENV} PLIST_IGNORE_FILES="${_PLIST_IGNORE_FILES}" ${PKG_VIEW} --view=$$v delete ${PKGNAME}; \
                   3505:        done
1.1       agc      3506: .endif
                   3507:
1.1540.2.5  tv       3508: .include "../../mk/bsd.pkg.data.mk"
1.1248    jlam     3509: .include "../../mk/subst.mk"
1.521     hubertf  3510:
                   3511: #
                   3512: # For bulk build targets (bulk-install, bulk-package), the
1.529     hubertf  3513: # BATCH variable must be set in /etc/mk.conf:
1.521     hubertf  3514: #
                   3515: .if defined(BATCH)
1.789     hubertf  3516: .  include "../../mk/bulk/bsd.bulk-pkg.mk"
1.149     tsarna   3517: .endif

CVSweb <webmaster@jp.NetBSD.org>