1*f46c1de7Sapb# $NetBSD: bsd.syspkg.mk,v 1.5 2008/10/25 22:27:34 apb Exp $ 2978f7e7dSjwise# 3978f7e7dSjwise# This file is derived from: 4978f7e7dSjwise# 5978f7e7dSjwise# NetBSD: bsd.pkg.mk,v 1.636 2001/01/05 18:03:14 jlam Exp 6978f7e7dSjwise# 7978f7e7dSjwise# Plus many fixes and improvements from later revisions. 8978f7e7dSjwise# 9978f7e7dSjwise# However, it has been pared down to a minimum of targets, and 10978f7e7dSjwise# adapted to the standard bsd.*.mk world order. 11978f7e7dSjwise# 12978f7e7dSjwise# Portions of this code are copyright (c) 2000-2002 Jim Wise 13978f7e7dSjwise# 14978f7e7dSjwise 156cf1c6e6Sxtraeme.if !defined(BSD_SYSPKG_MK) 166cf1c6e6SxtraemeBSD_SYSPKG_MK= # defined 176cf1c6e6Sxtraeme 18978f7e7dSjwise.if !target(__initialized__) 19978f7e7dSjwise__initialized__: 20978f7e7dSjwise.if exists(${.CURDIR}/../Makefile.inc) 21978f7e7dSjwise.include "${.CURDIR}/../Makefile.inc" 22978f7e7dSjwise.endif 23978f7e7dSjwise.include <bsd.own.mk> 24978f7e7dSjwise.include <bsd.obj.mk> 25978f7e7dSjwise.MAIN: all 26978f7e7dSjwise.endif 27978f7e7dSjwise 2829e78943SjwisePREFIX:= ${DESTDIR}/${PREFIX} 2929e78943Sjwise 30978f7e7dSjwiseOPSYS= NetBSD 31978f7e7dSjwiseOS_VERSION!= sh ${.PARSEDIR}/../../../sys/conf/osrelease.sh 32978f7e7dSjwise 33978f7e7dSjwise# keep bsd.own.mk from generating an install: target. 34978f7e7dSjwiseNEED_OWN_INSTALL_TARGET=no 35978f7e7dSjwise 36978f7e7dSjwise##### Some overrides of defaults below on a per-OS basis. 37978f7e7dSjwise 38978f7e7dSjwiseDEINSTALLDEPENDS?= NO # add -R to pkg_delete 39978f7e7dSjwise 40978f7e7dSjwisePKGSRCDIR?= ${.CURDIR:C|/[^/]*/[^/]*$||} 41978f7e7dSjwisePKGVERSION?= ${OS_VERSION}.${TINY_VERSION} 42978f7e7dSjwisePKGWILDCARD?= ${PKGBASE}-[0-9]* 43978f7e7dSjwise 44978f7e7dSjwise# For system packages, we set this here, as the version is auto-generated. 45978f7e7dSjwisePKGNAME?= ${PKGBASE}-${PKGVERSION} 46978f7e7dSjwise 47978f7e7dSjwisePACKAGES?= ${PKGSRCDIR}/../packages 48978f7e7dSjwisePKGDIR?= ${.CURDIR} 49978f7e7dSjwise 50978f7e7dSjwise# Don't change these!!! These names are built into the _TARGET_USE macro, 51978f7e7dSjwise# there is no way to refer to them cleanly from within the macro AFAIK. 52978f7e7dSjwisePACKAGE_COOKIE= ${WRKDIR}/.package_done 53978f7e7dSjwise 54978f7e7dSjwise# Miscellaneous overridable commands: 55978f7e7dSjwiseSHCOMMENT?= ${ECHO_MSG} >/dev/null '***' 56978f7e7dSjwise 5729e78943SjwiseMAKE_ENV+= PREFIX=${PREFIX} 58978f7e7dSjwise 59978f7e7dSjwiseTOUCH_FLAGS?= -f 60978f7e7dSjwise 61978f7e7dSjwise# Debugging levels for this file, dependent on PKG_DEBUG_LEVEL definition 62978f7e7dSjwise# 0 == normal, default, quiet operation 63978f7e7dSjwise# 1 == all shell commands echoed before invocation 64978f7e7dSjwise# 2 == shell "set -x" operation 65978f7e7dSjwisePKG_DEBUG_LEVEL?= 0 66978f7e7dSjwise_PKG_SILENT= @ 67978f7e7dSjwise_PKG_DEBUG= 68978f7e7dSjwise 69978f7e7dSjwise.if ${PKG_DEBUG_LEVEL} > 0 70978f7e7dSjwise_PKG_SILENT= 71978f7e7dSjwise.endif 72978f7e7dSjwise 73978f7e7dSjwise.if ${PKG_DEBUG_LEVEL} > 1 74978f7e7dSjwise_PKG_DEBUG= set -x; 75978f7e7dSjwise.endif 76978f7e7dSjwise 77978f7e7dSjwise# In point of fact, this will often be ./obj, as per bsd.obj.mk 78978f7e7dSjwiseWRKDIR?= . 79978f7e7dSjwise 80978f7e7dSjwiseCOMMENT?= ${PKGDIR}/COMMENT 81978f7e7dSjwiseDESCR= ${PKGDIR}/DESCR 82978f7e7dSjwisePLIST= ${WRKDIR}/PLIST 83978f7e7dSjwisePLIST_SRC?= ${PKGDIR}/PLIST 84978f7e7dSjwise 85978f7e7dSjwise 86978f7e7dSjwise# Set PKG_INSTALL_FILE to be the name of any INSTALL file 87978f7e7dSjwise.if !defined(PKG_INSTALL_FILE) && exists(${PKGDIR}/INSTALL) 88978f7e7dSjwisePKG_INSTALL_FILE= ${PKGDIR}/INSTALL 89978f7e7dSjwise.endif 90978f7e7dSjwise 91978f7e7dSjwise# Set PKG_DEINSTALL_FILE to be the name of any DEINSTALL file 92978f7e7dSjwise.if !defined(PKG_DEINSTALL_FILE) && exists(${PKGDIR}/DEINSTALL) 93978f7e7dSjwisePKG_DEINSTALL_FILE= ${PKGDIR}/DEINSTALL 94978f7e7dSjwise.endif 95978f7e7dSjwise 96978f7e7dSjwise# Set MESSAGE_FILE to be the name of any MESSAGE file 97978f7e7dSjwise.if !defined(MESSAGE_FILE) && exists(${PKGDIR}/MESSAGE) 98978f7e7dSjwiseMESSAGE_FILE= ${PKGDIR}/MESSAGE 99978f7e7dSjwise.endif 100978f7e7dSjwise 10196230fabSapbAWK?= ${TOOL_AWK:U/usr/bin/awk} 102978f7e7dSjwiseCAT?= /bin/cat 103978f7e7dSjwiseCP?= /bin/cp 104978f7e7dSjwiseDC?= /usr/bin/dc 105978f7e7dSjwiseECHO?= echo # Shell builtin 106978f7e7dSjwiseFALSE?= false # Shell builtin 107978f7e7dSjwiseFIND?= /usr/bin/find 108978f7e7dSjwiseGREP?= /usr/bin/grep 109978f7e7dSjwiseIDENT?= /usr/bin/ident 110978f7e7dSjwiseLN?= /bin/ln 111978f7e7dSjwiseLS?= /bin/ls 112978f7e7dSjwiseMKDIR?= /bin/mkdir -p 113978f7e7dSjwiseMV?= /bin/mv 114978f7e7dSjwisePKG_TOOLS_BIN?= /usr/sbin 115978f7e7dSjwiseRM?= /bin/rm 116*f46c1de7SapbSED?= ${TOOL_SED:U/usr/bin/sed} 117978f7e7dSjwiseSETENV?= /usr/bin/env 118978f7e7dSjwiseSH?= /bin/sh 119978f7e7dSjwiseTEST?= test # Shell builtin 120978f7e7dSjwiseTOUCH?= /usr/bin/touch 121978f7e7dSjwiseTRUE?= true # Shell builtin 122978f7e7dSjwise 123978f7e7dSjwisePKG_ADD?= PKG_DBDIR=${PKG_DBDIR} ${PKG_TOOLS_BIN}/pkg_add 124978f7e7dSjwisePKG_ADMIN?= PKG_DBDIR=${PKG_DBDIR} ${PKG_TOOLS_BIN}/pkg_admin 125978f7e7dSjwisePKG_CREATE?= PKG_DBDIR=${PKG_DBDIR} ${PKG_TOOLS_BIN}/pkg_create 126978f7e7dSjwisePKG_DELETE?= PKG_DBDIR=${PKG_DBDIR} ${PKG_TOOLS_BIN}/pkg_delete 127978f7e7dSjwisePKG_INFO?= PKG_DBDIR=${PKG_DBDIR} ${PKG_TOOLS_BIN}/pkg_info 128978f7e7dSjwise 129978f7e7dSjwise.if !defined(PKGTOOLS_VERSION) 130978f7e7dSjwise.if !exists(${IDENT}) 131978f7e7dSjwisePKGTOOLS_VERSION=${PKGTOOLS_REQD} 132978f7e7dSjwise.else 133978f7e7dSjwisePKGTOOLS_VERSION!=${IDENT} ${PKG_TOOLS_BIN}/pkg_add ${PKG_TOOLS_BIN}/pkg_admin ${PKG_TOOLS_BIN}/pkg_create ${PKG_TOOLS_BIN}/pkg_delete ${PKG_TOOLS_BIN}/pkg_info | ${AWK} 'BEGIN {n = 0;}; $$1 ~ /\$$NetBSD/ && $$2 !~ /^crt0/ {gsub("/", "", $$4); if ($$4 > n) {n = $$4;}}; END {print n;}' 134978f7e7dSjwise.endif 135978f7e7dSjwise.endif 136978f7e7dSjwiseMAKEFLAGS+= PKGTOOLS_VERSION="${PKGTOOLS_VERSION}" 137978f7e7dSjwise 138978f7e7dSjwise# Latest version of pkgtools required for this file. 139978f7e7dSjwisePKGTOOLS_REQD= 20000202 140978f7e7dSjwise 141978f7e7dSjwise# Check that we're using up-to-date pkg_* tools with this file. 142978f7e7dSjwiseuptodate-pkgtools: 143978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG} \ 144978f7e7dSjwise if [ ${PKGTOOLS_VERSION} -lt ${PKGTOOLS_REQD} ]; then \ 145978f7e7dSjwise case ${PKGNAME} in \ 146978f7e7dSjwise pkg_install-*) \ 147978f7e7dSjwise ;; \ 148978f7e7dSjwise *) \ 149978f7e7dSjwise ${ECHO} "Your package tools need to be updated to ${PKGTOOLS_REQD:C|(....)(..)(..)|\1/\2/\3|} versions."; \ 150978f7e7dSjwise ${ECHO} "The installed package tools were last updated on ${PKGTOOLS_VERSION:C|(....)(..)(..)|\1/\2/\3|}."; \ 151978f7e7dSjwise ${FALSE} ;; \ 152978f7e7dSjwise esac \ 153978f7e7dSjwise fi 154978f7e7dSjwise 155978f7e7dSjwise# Files to create for versioning and build information 156978f7e7dSjwiseBUILD_VERSION_FILE= ${WRKDIR}/.build_version 157978f7e7dSjwiseBUILD_INFO_FILE= ${WRKDIR}/.build_info 158978f7e7dSjwise 159978f7e7dSjwise# Files containing size of pkg w/o and w/ all required pkgs 160978f7e7dSjwiseSIZE_PKG_FILE= ${WRKDIR}/.SizePkg 161978f7e7dSjwiseSIZE_ALL_FILE= ${WRKDIR}/.SizeAll 162978f7e7dSjwise 163978f7e7dSjwise.ifndef PKG_ARGS_COMMON 164978f7e7dSjwisePKG_ARGS_COMMON= -v -c ${COMMENT} -d ${DESCR} -f ${PLIST} -l 165978f7e7dSjwisePKG_ARGS_COMMON+= -b ${BUILD_VERSION_FILE} -B ${BUILD_INFO_FILE} 166978f7e7dSjwisePKG_ARGS_COMMON+= -s ${SIZE_PKG_FILE} -S ${SIZE_ALL_FILE} 167978f7e7dSjwisePKG_ARGS_COMMON+= -P "`${MAKE} ${MAKEFLAGS} run-depends-list PACKAGE_DEPENDS_QUICK=true|sort -u`" 168978f7e7dSjwise.ifdef CONFLICTS 169978f7e7dSjwisePKG_ARGS_COMMON+= -C "${CONFLICTS}" 170978f7e7dSjwise.endif 171978f7e7dSjwise.ifdef PKG_INSTALL_FILE 172978f7e7dSjwisePKG_ARGS_COMMON+= -i ${PKG_INSTALL_FILE} 173978f7e7dSjwise.endif 174978f7e7dSjwise.ifdef PKG_DEINSTALL_FILE 175978f7e7dSjwisePKG_ARGS_COMMON+= -k ${PKG_DEINSTALL_FILE} 176978f7e7dSjwise.endif 177978f7e7dSjwise.ifdef MESSAGE_FILE 178978f7e7dSjwisePKG_ARGS_COMMON+= -D ${MESSAGE_FILE} 179978f7e7dSjwise.endif 180978f7e7dSjwise 181978f7e7dSjwisePKG_ARGS_INSTALL= -p ${PREFIX} ${PKG_ARGS_COMMON} 182978f7e7dSjwisePKG_ARGS_BINPKG= -p ${PREFIX:C/^${DESTDIR}//} -L ${PREFIX} ${PKG_ARGS_COMMON} 183978f7e7dSjwise.endif # !PKG_ARGS_COMMON 184978f7e7dSjwise 185978f7e7dSjwisePKG_SUFX?= .tgz 186978f7e7dSjwise#PKG_SUFX?= .tbz # bzip2(1) pkgs 187978f7e7dSjwise# where pkg_add records its dirty deeds. 188978f7e7dSjwisePKG_DBDIR?= ${DESTDIR}/var/db/syspkg 189978f7e7dSjwise 190978f7e7dSjwise# Define SMART_MESSAGES in /etc/mk.conf for messages giving the tree 191978f7e7dSjwise# of depencies for building, and the current target. 192978f7e7dSjwise.ifdef SMART_MESSAGES 193978f7e7dSjwise_PKGSRC_IN?= ===> ${.TARGET} [${PKGNAME}${_PKGSRC_DEPS}] === 194978f7e7dSjwise.else 195978f7e7dSjwise_PKGSRC_IN?= === 196978f7e7dSjwise.endif 197978f7e7dSjwise 198978f7e7dSjwise# Used to print all the '===>' style prompts - override this to turn them off. 199978f7e7dSjwiseECHO_MSG?= ${ECHO} 200978f7e7dSjwise 201978f7e7dSjwise# How to do nothing. Override if you, for some strange reason, would rather 202978f7e7dSjwise# do something. 203978f7e7dSjwiseDO_NADA?= ${TRUE} 204978f7e7dSjwise 205978f7e7dSjwise.if !defined(PKGBASE) || !defined(SETNAME) 206978f7e7dSjwise.BEGIN: 207978f7e7dSjwise @${ECHO_MSG} "PKGBASE and SETNAME are mandatory." 208978f7e7dSjwise @${FALSE} 209978f7e7dSjwise.endif 210978f7e7dSjwise 211978f7e7dSjwisePKGREPOSITORY?= ${PACKAGES} 212978f7e7dSjwisePKGFILE?= ${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX} 213978f7e7dSjwise 214978f7e7dSjwise.MAIN: all 215978f7e7dSjwise 216978f7e7dSjwise# Add these defs to the ones dumped into +BUILD_DEFS 217978f7e7dSjwiseBUILD_DEFS+= OPSYS OS_VERSION MACHINE_ARCH OBJECT_FMT 218978f7e7dSjwise 219978f7e7dSjwise.if !target(all) 220978f7e7dSjwise# We don't build here 221978f7e7dSjwiseall: 222978f7e7dSjwise.endif 223978f7e7dSjwise 224978f7e7dSjwise################################################################ 225978f7e7dSjwise# More standard targets start here. 226978f7e7dSjwise# 227978f7e7dSjwise# These are the body of the build/install framework. If you are 228978f7e7dSjwise# not happy with the default actions, and you can't solve it by 229978f7e7dSjwise# adding pre-* or post-* targets/scripts, override these. 230978f7e7dSjwise################################################################ 231978f7e7dSjwise 232978f7e7dSjwise.if !target(show-downlevel) 233978f7e7dSjwiseshow-downlevel: 234978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG} \ 235978f7e7dSjwise found="`${PKG_INFO} -e \"${PKGBASE}<${PKGVERSION}\" || ${TRUE}`";\ 236978f7e7dSjwise if [ "X$$found" != "X" -a "X$$found" != "X${PKGNAME}" ]; then \ 237978f7e7dSjwise ${ECHO} "${PKGBASE} package: $$found installed, pkgsrc version ${PKGNAME}"; \ 238978f7e7dSjwise fi 239978f7e7dSjwise.endif 240978f7e7dSjwise 241978f7e7dSjwise# Package 242978f7e7dSjwise 243978f7e7dSjwise.if !target(do-package) 244978f7e7dSjwisedo-package: ${PLIST} 245978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}\ 246978f7e7dSjwise ${ECHO_MSG} "${_PKGSRC_IN}> Building binary package for ${PKGNAME}"; \ 247978f7e7dSjwise if [ ! -d ${PKGREPOSITORY} ]; then \ 248978f7e7dSjwise ${MKDIR} ${PKGREPOSITORY}; \ 249978f7e7dSjwise if [ $$? -ne 0 ]; then \ 250978f7e7dSjwise ${ECHO_MSG} "=> Can't create directory ${PKGREPOSITORY}."; \ 251978f7e7dSjwise exit 1; \ 252978f7e7dSjwise fi; \ 253978f7e7dSjwise fi; \ 254978f7e7dSjwise if ${PKG_CREATE} ${PKG_ARGS_BINPKG} ${PKGFILE}; then \ 255978f7e7dSjwise (cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} package-links); \ 256978f7e7dSjwise else \ 257978f7e7dSjwise (cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} delete-package); \ 258978f7e7dSjwise exit 1; \ 259978f7e7dSjwise fi 260978f7e7dSjwise.endif 261978f7e7dSjwise 262978f7e7dSjwise# Some support rules for do-package 263978f7e7dSjwise 264978f7e7dSjwise.if !target(package-links) 265978f7e7dSjwisepackage-links: 266978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} delete-package-links) 267978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}for cat in ${CATEGORIES}; do \ 268978f7e7dSjwise if [ ! -d ${PACKAGES}/$$cat ]; then \ 269978f7e7dSjwise ${MKDIR} ${PACKAGES}/$$cat; \ 270978f7e7dSjwise if [ $$? -ne 0 ]; then \ 271978f7e7dSjwise ${ECHO_MSG} "=> Can't create directory ${PACKAGES}/$$cat."; \ 272978f7e7dSjwise exit 1; \ 273978f7e7dSjwise fi; \ 274978f7e7dSjwise fi; \ 275978f7e7dSjwise ${RM} -f ${PACKAGES}/$$cat/${PKGNAME}${PKG_SUFX}; \ 276978f7e7dSjwise ${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \ 277978f7e7dSjwise done; 278978f7e7dSjwise.endif 279978f7e7dSjwise 280978f7e7dSjwise.if !target(delete-package-links) 281978f7e7dSjwisedelete-package-links: 282978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}\ 283978f7e7dSjwise ${FIND} ${PACKAGES} -type l -name ${PKGNAME}${PKG_SUFX} | xargs ${RM} -f 284978f7e7dSjwise.endif 285978f7e7dSjwise 286978f7e7dSjwise.if !target(delete-package) 287978f7e7dSjwisedelete-package: 288978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} delete-package-links) 289978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PKGFILE} 290978f7e7dSjwise.endif 291978f7e7dSjwise 292978f7e7dSjwise################################################################ 293978f7e7dSjwise# This is the "generic" package target, actually a macro used from the 294978f7e7dSjwise# six main targets. See below for more. 295978f7e7dSjwise################################################################ 296978f7e7dSjwise 297978f7e7dSjwisereal-package: 298978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKEFLAGS} ${.TARGET:S/^real-/pre-/} 299978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKEFLAGS} ${.TARGET:S/^real-/do-/} 300978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKEFLAGS} ${.TARGET:S/^real-/post-/} 301978f7e7dSjwise 302978f7e7dSjwise################################################################ 303978f7e7dSjwise# Skeleton targets start here 304978f7e7dSjwise# 305978f7e7dSjwise# You shouldn't have to change these. Either add the pre-* or 306978f7e7dSjwise# post-* targets/scripts or redefine the do-* targets. These 307978f7e7dSjwise# targets don't do anything other than checking for cookies and 308978f7e7dSjwise# call the necessary targets/scripts. 309978f7e7dSjwise################################################################ 310978f7e7dSjwise 311978f7e7dSjwise.if !target(package) 312978f7e7dSjwisepackage: uptodate-pkgtools ${PACKAGE_COOKIE} 313978f7e7dSjwise.endif 314978f7e7dSjwise 315978f7e7dSjwise${PACKAGE_COOKIE}: 316978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-package) 317978f7e7dSjwise 318978f7e7dSjwise# Empty pre-* and post-* targets, note we can't use .if !target() 319978f7e7dSjwise# in the _PORT_USE macro 320978f7e7dSjwise 321978f7e7dSjwise.for name in package 322978f7e7dSjwise 323978f7e7dSjwise.if !target(pre-${name}) 324978f7e7dSjwisepre-${name}: 325978f7e7dSjwise @${DO_NADA} 326978f7e7dSjwise.endif 327978f7e7dSjwise 328978f7e7dSjwise.if !target(post-${name}) 329978f7e7dSjwisepost-${name}: 330978f7e7dSjwise @${DO_NADA} 331978f7e7dSjwise.endif 332978f7e7dSjwise 333978f7e7dSjwise.endfor 334978f7e7dSjwise 335978f7e7dSjwise# Deinstall 336978f7e7dSjwise# 337978f7e7dSjwise# Special target to remove installation 338978f7e7dSjwise 339978f7e7dSjwise.if !target(deinstall) 340978f7e7dSjwisedeinstall: real-deinstall 341978f7e7dSjwise 342978f7e7dSjwise.if (${DEINSTALLDEPENDS} != "NO") 343978f7e7dSjwise.if (${DEINSTALLDEPENDS} != "ALL") 344978f7e7dSjwise# used for removing stuff in bulk builds 345978f7e7dSjwisereal-su-deinstall-flags+= -r -R 346978f7e7dSjwise# used for "update" target 347978f7e7dSjwise.else 348978f7e7dSjwisereal-su-deinstall-flags+= -r 349978f7e7dSjwise.endif 350978f7e7dSjwise.endif 351978f7e7dSjwise.ifdef PKG_VERBOSE 352978f7e7dSjwisereal-su-deinstall-flags+= -v 353978f7e7dSjwise.endif 354978f7e7dSjwise 355978f7e7dSjwisereal-deinstall: 356978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG} \ 357978f7e7dSjwise found="`${PKG_INFO} -e \"${PKGWILDCARD}\" || ${TRUE}`"; \ 358978f7e7dSjwise if [ "$$found" != "" ]; then \ 359978f7e7dSjwise ${ECHO} Running ${PKG_DELETE} ${real-su-deinstall-flags} $$found ; \ 360978f7e7dSjwise ${PKG_DELETE} ${real-su-deinstall-flags} $$found || ${TRUE} ; \ 361978f7e7dSjwise fi 362978f7e7dSjwise.for pkg in ${BUILD_DEPENDS:C/:.*$//} 363978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG} \ 364978f7e7dSjwise found="`${PKG_INFO} -e \"${pkg}\" || ${TRUE}`"; \ 365978f7e7dSjwise if [ "$$found" != "" ]; then \ 366978f7e7dSjwise ${ECHO} Running ${PKG_DELETE} $$found ; \ 367978f7e7dSjwise ${PKG_DELETE} ${real-su-deinstall-flags} $$found || ${TRUE} ; \ 368978f7e7dSjwise fi 369978f7e7dSjwise.endfor 370978f7e7dSjwise.endif # target(deinstall) 371978f7e7dSjwise 372978f7e7dSjwise 373978f7e7dSjwise################################################################ 374978f7e7dSjwise# Some more targets supplied for users' convenience 375978f7e7dSjwise################################################################ 376978f7e7dSjwise 377978f7e7dSjwise# The 'info' target can be used to display information about a package. 378978f7e7dSjwiseinfo: uptodate-pkgtools 379978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}${PKG_INFO} ${PKGWILDCARD} 380978f7e7dSjwise 381978f7e7dSjwise# The 'check' target can be used to check an installed package. 382978f7e7dSjwisecheck: uptodate-pkgtools 383978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}${PKG_ADMIN} check ${PKGWILDCARD} 384978f7e7dSjwise 385978f7e7dSjwise# Cleaning up 386978f7e7dSjwise 387978f7e7dSjwise.if !target(pre-clean) 388978f7e7dSjwisepre-clean: 389978f7e7dSjwise @${DO_NADA} 390978f7e7dSjwise.endif 391978f7e7dSjwise 392978f7e7dSjwise.if !target(clean) 393978f7e7dSjwiseclean: pre-clean 394978f7e7dSjwise ${RM} -f ${PLIST} ${BUILD_VERSION_FILE} ${BUILD_INFO_FILE} ${SIZE_PKG_FILE} ${SIZE_ALL_FILE} 395978f7e7dSjwise.endif 396978f7e7dSjwise 397978f7e7dSjwise.if !target(cleandir) 398978f7e7dSjwisecleandir: clean 399978f7e7dSjwise.endif 400978f7e7dSjwise 401978f7e7dSjwise# Install binary pkg, without strict uptodate-check first 402978f7e7dSjwise# (XXX should be able to snarf via FTP. Later...) 403978f7e7dSjwisebin-install: 404978f7e7dSjwise @if [ -f ${PKGFILE} ] ; then \ 405978f7e7dSjwise ${ECHO_MSG} "Installing from binary pkg ${PKGFILE}" ; \ 406978f7e7dSjwise ${PKG_ADD} ${PKGFILE} ; \ 407978f7e7dSjwise else \ 408978f7e7dSjwise ${SHCOMMENT} Cycle through some FTP server here ;\ 409978f7e7dSjwise ${ECHO_MSG} "Installing from source" ; \ 410978f7e7dSjwise (cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} package && \ 411978f7e7dSjwise ${MAKE} ${MAKEFLAGS} clean) ; \ 412978f7e7dSjwise fi 413978f7e7dSjwise 414978f7e7dSjwise 415978f7e7dSjwise################################################################ 416978f7e7dSjwise# The special package-building targets 417978f7e7dSjwise# You probably won't need to touch these 418978f7e7dSjwise################################################################ 419978f7e7dSjwise 420978f7e7dSjwise# Nobody should want to override this unless PKGNAME is simply bogus. 421978f7e7dSjwise 422978f7e7dSjwise.if !target(package-name) 423978f7e7dSjwisepackage-name: 424978f7e7dSjwise @${ECHO} ${PKGNAME} 425978f7e7dSjwise.endif # !target(package-name) 426978f7e7dSjwise 427978f7e7dSjwise# Show (recursively) all the packages this package depends on. 428978f7e7dSjwise# If PACKAGE_DEPENDS_WITH_PATTERNS is set, print as pattern (if possible) 429978f7e7dSjwisePACKAGE_DEPENDS_WITH_PATTERNS?=true 430978f7e7dSjwise# To be used (-> true) ONLY if the pkg in question is known to be installed 431978f7e7dSjwise# (i.e. when calling for pkg_create args, and for fake-pkg) 432978f7e7dSjwise# Will probably not work with PACKAGE_DEPENDS_WITH_PATTERNS=false ... 433978f7e7dSjwisePACKAGE_DEPENDS_QUICK?=false 434978f7e7dSjwise.if !target(run-depends-list) 435978f7e7dSjwiserun-depends-list: 436978f7e7dSjwise.for dep in ${DEPENDS} 437978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG} \ 438978f7e7dSjwise pkg="${dep:C/:.*//}"; \ 439978f7e7dSjwise dir="${dep:C/[^:]*://}"; \ 440978f7e7dSjwise cd ${.CURDIR}; \ 441978f7e7dSjwise if ${PACKAGE_DEPENDS_WITH_PATTERNS}; then \ 442978f7e7dSjwise ${ECHO} "$$pkg"; \ 443978f7e7dSjwise else \ 444978f7e7dSjwise if cd $$dir 2>/dev/null; then \ 445978f7e7dSjwise (cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} package-name; \ 446978f7e7dSjwise else \ 447978f7e7dSjwise ${ECHO_MSG} "Warning: \"$$dir\" non-existent -- @pkgdep registration incomplete" >&2; \ 448978f7e7dSjwise fi; \ 449978f7e7dSjwise fi; \ 450978f7e7dSjwise if ${PACKAGE_DEPENDS_QUICK} ; then \ 451978f7e7dSjwise ${PKG_INFO} -qf "$$pkg" | ${AWK} '/^@pkgdep/ {print $$2}'; \ 452978f7e7dSjwise else \ 453978f7e7dSjwise if cd $$dir 2>/dev/null; then \ 454978f7e7dSjwise (cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} run-depends-list; \ 455978f7e7dSjwise else \ 456978f7e7dSjwise ${ECHO_MSG} "Warning: \"$$dir\" non-existent -- @pkgdep registration incomplete" >&2; \ 457978f7e7dSjwise fi; \ 458978f7e7dSjwise fi 459978f7e7dSjwise.endfor 460978f7e7dSjwise.endif # target(run-depends-list) 461978f7e7dSjwise 462978f7e7dSjwise# Build a package but don't check the package cookie 463978f7e7dSjwise 464978f7e7dSjwise.if !target(repackage) 465978f7e7dSjwiserepackage: pre-repackage package 466978f7e7dSjwise 467978f7e7dSjwisepre-repackage: 468978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PACKAGE_COOKIE} 469978f7e7dSjwise.endif 470978f7e7dSjwise 471978f7e7dSjwise# Build a package but don't check the cookie for installation, also don't 472978f7e7dSjwise# install package cookie 473978f7e7dSjwise 474978f7e7dSjwise.if !target(package-noinstall) 475978f7e7dSjwisepackage-noinstall: 476978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package) 477978f7e7dSjwise.endif 478978f7e7dSjwise 479978f7e7dSjwise################################################################ 480978f7e7dSjwise# Dependency checking 481978f7e7dSjwise################################################################ 482978f7e7dSjwise 483978f7e7dSjwise.if !target(install-depends) 484978f7e7dSjwiseinstall-depends: 485978f7e7dSjwise.endif 486978f7e7dSjwise 487978f7e7dSjwise################################################################ 488978f7e7dSjwise# Everything after here are internal targets and really 489978f7e7dSjwise# shouldn't be touched by anybody but the release engineers. 490978f7e7dSjwise################################################################ 491978f7e7dSjwise 492978f7e7dSjwise.if !target(show-pkgtools-version) 493978f7e7dSjwiseshow-pkgtools-version: 494978f7e7dSjwise @${ECHO} ${PKGTOOLS_VERSION} 495978f7e7dSjwise.endif 496978f7e7dSjwise 497978f7e7dSjwise# convenience target, to display make variables from command line 498978f7e7dSjwise# i.e. "make show-var VARNAME=var", will print var's value 499978f7e7dSjwiseshow-var: 500978f7e7dSjwise @${ECHO} "${${VARNAME}}" 501978f7e7dSjwise 502978f7e7dSjwise# Stat all the files of one pkg and sum the sizes up. 503978f7e7dSjwise# 504978f7e7dSjwise# XXX This is intended to be run before pkg_create is called, so the 505978f7e7dSjwise# existence of ${PLIST} can be assumed. 506978f7e7dSjwiseprint-pkg-size-this: 507978f7e7dSjwise @${SHCOMMENT} "This pkg's files" ; \ 508978f7e7dSjwise ${AWK} 'BEGIN { base = "${PREFIX}/" } \ 509978f7e7dSjwise /^@cwd/ { base = $$2 "/" } \ 510978f7e7dSjwise /^@ignore/ { next } \ 511978f7e7dSjwise NF == 1 { print base $$1 }' \ 512978f7e7dSjwise <${PLIST} \ 513978f7e7dSjwise | sort -u \ 514978f7e7dSjwise | ${SED} -e 's, ,\\ ,g' \ 515978f7e7dSjwise | xargs ${LS} -ld \ 516978f7e7dSjwise | ${AWK} 'BEGIN { print("0 "); } \ 517978f7e7dSjwise { print($$5, " + "); } \ 518978f7e7dSjwise END { print("p"); }' \ 519978f7e7dSjwise | ${DC} 520978f7e7dSjwise 521978f7e7dSjwise# Sizes of required pkgs (only) 522978f7e7dSjwise# 523978f7e7dSjwise# XXX This is intended to be run before pkg_create is called, so the 524978f7e7dSjwise# dependencies are all installed. 525978f7e7dSjwiseprint-pkg-size-depends: 526978f7e7dSjwise @(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} run-depends-list PACKAGE_DEPENDS_QUICK=true) \ 527978f7e7dSjwise | xargs -n 1 ${SETENV} ${PKG_INFO} -e \ 528978f7e7dSjwise | sort -u \ 529978f7e7dSjwise | xargs ${SETENV} ${PKG_INFO} -qs \ 530978f7e7dSjwise | ${AWK} -- 'BEGIN { print("0 "); } \ 531978f7e7dSjwise /^[0-9]+$$/ { print($$1, " + "); } \ 532978f7e7dSjwise END { print("p"); }' \ 533978f7e7dSjwise | ${DC} 534978f7e7dSjwise 535978f7e7dSjwise 536978f7e7dSjwise# Fake installation of package so that user can pkg_delete it later. 537978f7e7dSjwise# Also, make sure that an installed package is recognized correctly in 538978f7e7dSjwise# accordance to the @pkgdep directive in the packing lists 539978f7e7dSjwise 540978f7e7dSjwise.if !target(register) 541978f7e7dSjwiseregister: fake-pkg 542978f7e7dSjwise.endif 543978f7e7dSjwise 544978f7e7dSjwise.if !target(fake-pkg) 545978f7e7dSjwisefake-pkg: ${PLIST} 546978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}\ 547978f7e7dSjwise if [ ! -f ${PLIST} -o ! -f ${COMMENT} -o ! -f ${DESCR} ]; then \ 548978f7e7dSjwise ${ECHO} "** Missing package files for ${PKGNAME} - installation not recorded."; \ 549978f7e7dSjwise exit 1; \ 550978f7e7dSjwise fi 551978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}\ 552978f7e7dSjwise if [ ! -d ${PKG_DBDIR} ]; then \ 553978f7e7dSjwise ${RM} -f ${PKG_DBDIR}; \ 554978f7e7dSjwise ${MKDIR} ${PKG_DBDIR}; \ 555978f7e7dSjwise fi 556978f7e7dSjwise.if defined(FORCE_PKG_REGISTER) 557978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}${PKG_DELETE} -O ${PKGNAME} 558978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}${RM} -rf ${PKG_DBDIR}/${PKGNAME} 559978f7e7dSjwise.endif 560978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${BUILD_VERSION_FILE} ${BUILD_INFO_FILE} 561978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${SIZE_PKG_FILE} ${SIZE_ALL_FILE} 562978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG}\ 563978f7e7dSjwise files=""; \ 564978f7e7dSjwise for f in ${.CURDIR}/Makefile ${FILESDIR}/* ${PKGDIR}/*; do \ 565978f7e7dSjwise if [ -f $$f ]; then \ 566978f7e7dSjwise files="$$files $$f"; \ 567978f7e7dSjwise fi; \ 568978f7e7dSjwise done; \ 569978f7e7dSjwise ${GREP} '\$$NetBSD' $$files | ${SED} -e 's|^${PKGSRCDIR}/||' > ${BUILD_VERSION_FILE}; 570978f7e7dSjwise.for def in ${BUILD_DEFS} 571978f7e7dSjwise @${ECHO} ${def}= ${${def}:Q} | ${SED} -e 's|^PATH=[^ ]*|PATH=...|' >> ${BUILD_INFO_FILE} 572978f7e7dSjwise.endfor 573978f7e7dSjwise @${ECHO} "CC= ${CC}-`${CC} --version`" >> ${BUILD_INFO_FILE} 574978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG} \ 575978f7e7dSjwise ${ECHO} "_PKGTOOLS_VER=${PKGTOOLS_VERSION}" >> ${BUILD_INFO_FILE} 576978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG} \ 577978f7e7dSjwise size_this=`(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} print-pkg-size-this)`; \ 578978f7e7dSjwise size_depends=`(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} print-pkg-size-depends)`; \ 579978f7e7dSjwise ${ECHO} $$size_this >${SIZE_PKG_FILE}; \ 580978f7e7dSjwise ${ECHO} $$size_this $$size_depends + p | ${DC} >${SIZE_ALL_FILE} 581978f7e7dSjwise ${_PKG_SILENT}${_PKG_DEBUG} \ 582978f7e7dSjwise if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \ 583978f7e7dSjwise ${ECHO_MSG} "${_PKGSRC_IN}> Registering installation for ${PKGNAME}"; \ 584978f7e7dSjwise ${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \ 585978f7e7dSjwise ${PKG_CREATE} ${PKG_ARGS_INSTALL} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \ 586978f7e7dSjwise ${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC; \ 587978f7e7dSjwise ${CP} ${COMMENT} ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \ 588978f7e7dSjwise ${CP} ${BUILD_VERSION_FILE} ${PKG_DBDIR}/${PKGNAME}/+BUILD_VERSION; \ 589978f7e7dSjwise ${CP} ${BUILD_INFO_FILE} ${PKG_DBDIR}/${PKGNAME}/+BUILD_INFO; \ 590978f7e7dSjwise if ${TEST} -e ${SIZE_PKG_FILE}; then \ 591978f7e7dSjwise ${CP} ${SIZE_PKG_FILE} ${PKG_DBDIR}/${PKGNAME}/+SIZE_PKG; \ 592978f7e7dSjwise fi ; \ 593978f7e7dSjwise if ${TEST} -e ${SIZE_ALL_FILE}; then \ 594978f7e7dSjwise ${CP} ${SIZE_ALL_FILE} ${PKG_DBDIR}/${PKGNAME}/+SIZE_ALL; \ 595978f7e7dSjwise fi ; \ 596978f7e7dSjwise if [ -n "${PKG_INSTALL_FILE}" ]; then \ 597978f7e7dSjwise if ${TEST} -e ${PKG_INSTALL_FILE}; then \ 598978f7e7dSjwise ${CP} ${PKG_INSTALL_FILE} ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \ 599978f7e7dSjwise fi; \ 600978f7e7dSjwise fi; \ 601978f7e7dSjwise if [ -n "${PKG_DEINSTALL_FILE}" ]; then \ 602978f7e7dSjwise if ${TEST} -e ${PKG_DEINSTALL_FILE}; then \ 603978f7e7dSjwise ${CP} ${PKG_DEINSTALL_FILE} ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \ 604978f7e7dSjwise fi; \ 605978f7e7dSjwise fi; \ 606978f7e7dSjwise if [ -n "${MESSAGE_FILE}" ]; then \ 607978f7e7dSjwise if ${TEST} -e ${MESSAGE_FILE}; then \ 608978f7e7dSjwise ${CP} ${MESSAGE_FILE} ${PKG_DBDIR}/${PKGNAME}/+DISPLAY; \ 609978f7e7dSjwise fi; \ 610978f7e7dSjwise fi; \ 611978f7e7dSjwise list="`(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} run-depends-list PACKAGE_DEPENDS_QUICK=true ECHO_MSG=${TRUE} | sort -u)`" ; \ 612978f7e7dSjwise for dep in $$list; do \ 613978f7e7dSjwise realdep="`${PKG_INFO} -e \"$$dep\" || ${TRUE}`" ; \ 614978f7e7dSjwise if [ `${ECHO} $$realdep | wc -w` -gt 1 ]; then \ 615978f7e7dSjwise ${ECHO} '***' "WARNING: '$$dep' expands to several installed packages " ; \ 616978f7e7dSjwise ${ECHO} " (" `${ECHO} $$realdep` ")." ; \ 617978f7e7dSjwise ${ECHO} " Please check if this is really intended!" ; \ 618978f7e7dSjwise continue ; \ 619978f7e7dSjwise fi ; \ 620978f7e7dSjwise done ; \ 621978f7e7dSjwise for realdep in `echo $$list | xargs -n 1 ${SETENV} ${PKG_INFO} -e | sort -u`; do \ 622978f7e7dSjwise if ${TEST} -z "$$realdep"; then \ 623978f7e7dSjwise ${ECHO} "$$dep not installed - dependency NOT registered" ; \ 624978f7e7dSjwise elif [ -d ${PKG_DBDIR}/$$realdep ]; then \ 625978f7e7dSjwise if ${TEST} ! -e ${PKG_DBDIR}/$$realdep/+REQUIRED_BY; then \ 626978f7e7dSjwise ${TOUCH} ${PKG_DBDIR}/$$realdep/+REQUIRED_BY; \ 627978f7e7dSjwise fi; \ 628978f7e7dSjwise ${AWK} 'BEGIN { found = 0; } \ 629978f7e7dSjwise $$0 == "${PKGNAME}" { found = 1; } \ 630978f7e7dSjwise { print $$0; } \ 631978f7e7dSjwise END { if (!found) { printf("%s\n", "${PKGNAME}"); }}' \ 632978f7e7dSjwise < ${PKG_DBDIR}/$$realdep/+REQUIRED_BY > ${PKG_DBDIR}/$$realdep/reqby.$$$$; \ 633978f7e7dSjwise ${MV} ${PKG_DBDIR}/$$realdep/reqby.$$$$ ${PKG_DBDIR}/$$realdep/+REQUIRED_BY; \ 634978f7e7dSjwise ${ECHO} "${PKGNAME} requires installed package $$realdep"; \ 635978f7e7dSjwise fi; \ 636978f7e7dSjwise done; \ 637978f7e7dSjwise fi 638978f7e7dSjwise.endif 639978f7e7dSjwise 640978f7e7dSjwise# Depend is generally meaningless for arbitrary packages, but if someone wants 641978f7e7dSjwise# one they can override this. This is just to catch people who've gotten into 642978f7e7dSjwise# the habit of typing `${MAKE} depend all install' as a matter of course. 643978f7e7dSjwise# 644978f7e7dSjwise.if !target(depend) 645978f7e7dSjwisedepend: 646978f7e7dSjwise.endif 647978f7e7dSjwise 648978f7e7dSjwise# Same goes for tags 649978f7e7dSjwise.if !target(tags) 650978f7e7dSjwisetags: 651978f7e7dSjwise.endif 652978f7e7dSjwise 653978f7e7dSjwise${PLIST}: 654978f7e7dSjwise sh ${.CURDIR}/../../../../sets/makeplist ${SETNAME} ${PKGBASE} > ${PLIST} 6556cf1c6e6Sxtraeme 6566cf1c6e6Sxtraeme.endif # BSD_SYSPKG_MK 657