[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.11

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

CVSweb <webmaster@jp.NetBSD.org>