1 1.5 apb # $NetBSD: bsd.syspkg.mk,v 1.5 2008/10/25 22:27:34 apb Exp $ 2 1.1 jwise # 3 1.1 jwise # This file is derived from: 4 1.1 jwise # 5 1.1 jwise # NetBSD: bsd.pkg.mk,v 1.636 2001/01/05 18:03:14 jlam Exp 6 1.1 jwise # 7 1.1 jwise # Plus many fixes and improvements from later revisions. 8 1.1 jwise # 9 1.1 jwise # However, it has been pared down to a minimum of targets, and 10 1.1 jwise # adapted to the standard bsd.*.mk world order. 11 1.1 jwise # 12 1.1 jwise # Portions of this code are copyright (c) 2000-2002 Jim Wise 13 1.1 jwise # 14 1.1 jwise 15 1.3 xtraeme .if !defined(BSD_SYSPKG_MK) 16 1.3 xtraeme BSD_SYSPKG_MK= # defined 17 1.3 xtraeme 18 1.1 jwise .if !target(__initialized__) 19 1.1 jwise __initialized__: 20 1.1 jwise .if exists(${.CURDIR}/../Makefile.inc) 21 1.1 jwise .include "${.CURDIR}/../Makefile.inc" 22 1.1 jwise .endif 23 1.1 jwise .include <bsd.own.mk> 24 1.1 jwise .include <bsd.obj.mk> 25 1.1 jwise .MAIN: all 26 1.1 jwise .endif 27 1.1 jwise 28 1.2 jwise PREFIX:= ${DESTDIR}/${PREFIX} 29 1.2 jwise 30 1.1 jwise OPSYS= NetBSD 31 1.1 jwise OS_VERSION!= sh ${.PARSEDIR}/../../../sys/conf/osrelease.sh 32 1.1 jwise 33 1.1 jwise # keep bsd.own.mk from generating an install: target. 34 1.1 jwise NEED_OWN_INSTALL_TARGET=no 35 1.1 jwise 36 1.1 jwise ##### Some overrides of defaults below on a per-OS basis. 37 1.1 jwise 38 1.1 jwise DEINSTALLDEPENDS?= NO # add -R to pkg_delete 39 1.1 jwise 40 1.1 jwise PKGSRCDIR?= ${.CURDIR:C|/[^/]*/[^/]*$||} 41 1.1 jwise PKGVERSION?= ${OS_VERSION}.${TINY_VERSION} 42 1.1 jwise PKGWILDCARD?= ${PKGBASE}-[0-9]* 43 1.1 jwise 44 1.1 jwise # For system packages, we set this here, as the version is auto-generated. 45 1.1 jwise PKGNAME?= ${PKGBASE}-${PKGVERSION} 46 1.1 jwise 47 1.1 jwise PACKAGES?= ${PKGSRCDIR}/../packages 48 1.1 jwise PKGDIR?= ${.CURDIR} 49 1.1 jwise 50 1.1 jwise # Don't change these!!! These names are built into the _TARGET_USE macro, 51 1.1 jwise # there is no way to refer to them cleanly from within the macro AFAIK. 52 1.1 jwise PACKAGE_COOKIE= ${WRKDIR}/.package_done 53 1.1 jwise 54 1.1 jwise # Miscellaneous overridable commands: 55 1.1 jwise SHCOMMENT?= ${ECHO_MSG} >/dev/null '***' 56 1.1 jwise 57 1.2 jwise MAKE_ENV+= PREFIX=${PREFIX} 58 1.1 jwise 59 1.1 jwise TOUCH_FLAGS?= -f 60 1.1 jwise 61 1.1 jwise # Debugging levels for this file, dependent on PKG_DEBUG_LEVEL definition 62 1.1 jwise # 0 == normal, default, quiet operation 63 1.1 jwise # 1 == all shell commands echoed before invocation 64 1.1 jwise # 2 == shell "set -x" operation 65 1.1 jwise PKG_DEBUG_LEVEL?= 0 66 1.1 jwise _PKG_SILENT= @ 67 1.1 jwise _PKG_DEBUG= 68 1.1 jwise 69 1.1 jwise .if ${PKG_DEBUG_LEVEL} > 0 70 1.1 jwise _PKG_SILENT= 71 1.1 jwise .endif 72 1.1 jwise 73 1.1 jwise .if ${PKG_DEBUG_LEVEL} > 1 74 1.1 jwise _PKG_DEBUG= set -x; 75 1.1 jwise .endif 76 1.1 jwise 77 1.1 jwise # In point of fact, this will often be ./obj, as per bsd.obj.mk 78 1.1 jwise WRKDIR?= . 79 1.1 jwise 80 1.1 jwise COMMENT?= ${PKGDIR}/COMMENT 81 1.1 jwise DESCR= ${PKGDIR}/DESCR 82 1.1 jwise PLIST= ${WRKDIR}/PLIST 83 1.1 jwise PLIST_SRC?= ${PKGDIR}/PLIST 84 1.1 jwise 85 1.1 jwise 86 1.1 jwise # Set PKG_INSTALL_FILE to be the name of any INSTALL file 87 1.1 jwise .if !defined(PKG_INSTALL_FILE) && exists(${PKGDIR}/INSTALL) 88 1.1 jwise PKG_INSTALL_FILE= ${PKGDIR}/INSTALL 89 1.1 jwise .endif 90 1.1 jwise 91 1.1 jwise # Set PKG_DEINSTALL_FILE to be the name of any DEINSTALL file 92 1.1 jwise .if !defined(PKG_DEINSTALL_FILE) && exists(${PKGDIR}/DEINSTALL) 93 1.1 jwise PKG_DEINSTALL_FILE= ${PKGDIR}/DEINSTALL 94 1.1 jwise .endif 95 1.1 jwise 96 1.1 jwise # Set MESSAGE_FILE to be the name of any MESSAGE file 97 1.1 jwise .if !defined(MESSAGE_FILE) && exists(${PKGDIR}/MESSAGE) 98 1.1 jwise MESSAGE_FILE= ${PKGDIR}/MESSAGE 99 1.1 jwise .endif 100 1.1 jwise 101 1.4 apb AWK?= ${TOOL_AWK:U/usr/bin/awk} 102 1.1 jwise CAT?= /bin/cat 103 1.1 jwise CP?= /bin/cp 104 1.1 jwise DC?= /usr/bin/dc 105 1.1 jwise ECHO?= echo # Shell builtin 106 1.1 jwise FALSE?= false # Shell builtin 107 1.1 jwise FIND?= /usr/bin/find 108 1.1 jwise GREP?= /usr/bin/grep 109 1.1 jwise IDENT?= /usr/bin/ident 110 1.1 jwise LN?= /bin/ln 111 1.1 jwise LS?= /bin/ls 112 1.1 jwise MKDIR?= /bin/mkdir -p 113 1.1 jwise MV?= /bin/mv 114 1.1 jwise PKG_TOOLS_BIN?= /usr/sbin 115 1.1 jwise RM?= /bin/rm 116 1.5 apb SED?= ${TOOL_SED:U/usr/bin/sed} 117 1.1 jwise SETENV?= /usr/bin/env 118 1.1 jwise SH?= /bin/sh 119 1.1 jwise TEST?= test # Shell builtin 120 1.1 jwise TOUCH?= /usr/bin/touch 121 1.1 jwise TRUE?= true # Shell builtin 122 1.1 jwise 123 1.1 jwise PKG_ADD?= PKG_DBDIR=${PKG_DBDIR} ${PKG_TOOLS_BIN}/pkg_add 124 1.1 jwise PKG_ADMIN?= PKG_DBDIR=${PKG_DBDIR} ${PKG_TOOLS_BIN}/pkg_admin 125 1.1 jwise PKG_CREATE?= PKG_DBDIR=${PKG_DBDIR} ${PKG_TOOLS_BIN}/pkg_create 126 1.1 jwise PKG_DELETE?= PKG_DBDIR=${PKG_DBDIR} ${PKG_TOOLS_BIN}/pkg_delete 127 1.1 jwise PKG_INFO?= PKG_DBDIR=${PKG_DBDIR} ${PKG_TOOLS_BIN}/pkg_info 128 1.1 jwise 129 1.1 jwise .if !defined(PKGTOOLS_VERSION) 130 1.1 jwise .if !exists(${IDENT}) 131 1.1 jwise PKGTOOLS_VERSION=${PKGTOOLS_REQD} 132 1.1 jwise .else 133 1.1 jwise PKGTOOLS_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;}' 134 1.1 jwise .endif 135 1.1 jwise .endif 136 1.1 jwise MAKEFLAGS+= PKGTOOLS_VERSION="${PKGTOOLS_VERSION}" 137 1.1 jwise 138 1.1 jwise # Latest version of pkgtools required for this file. 139 1.1 jwise PKGTOOLS_REQD= 20000202 140 1.1 jwise 141 1.1 jwise # Check that we're using up-to-date pkg_* tools with this file. 142 1.1 jwise uptodate-pkgtools: 143 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG} \ 144 1.1 jwise if [ ${PKGTOOLS_VERSION} -lt ${PKGTOOLS_REQD} ]; then \ 145 1.1 jwise case ${PKGNAME} in \ 146 1.1 jwise pkg_install-*) \ 147 1.1 jwise ;; \ 148 1.1 jwise *) \ 149 1.1 jwise ${ECHO} "Your package tools need to be updated to ${PKGTOOLS_REQD:C|(....)(..)(..)|\1/\2/\3|} versions."; \ 150 1.1 jwise ${ECHO} "The installed package tools were last updated on ${PKGTOOLS_VERSION:C|(....)(..)(..)|\1/\2/\3|}."; \ 151 1.1 jwise ${FALSE} ;; \ 152 1.1 jwise esac \ 153 1.1 jwise fi 154 1.1 jwise 155 1.1 jwise # Files to create for versioning and build information 156 1.1 jwise BUILD_VERSION_FILE= ${WRKDIR}/.build_version 157 1.1 jwise BUILD_INFO_FILE= ${WRKDIR}/.build_info 158 1.1 jwise 159 1.1 jwise # Files containing size of pkg w/o and w/ all required pkgs 160 1.1 jwise SIZE_PKG_FILE= ${WRKDIR}/.SizePkg 161 1.1 jwise SIZE_ALL_FILE= ${WRKDIR}/.SizeAll 162 1.1 jwise 163 1.1 jwise .ifndef PKG_ARGS_COMMON 164 1.1 jwise PKG_ARGS_COMMON= -v -c ${COMMENT} -d ${DESCR} -f ${PLIST} -l 165 1.1 jwise PKG_ARGS_COMMON+= -b ${BUILD_VERSION_FILE} -B ${BUILD_INFO_FILE} 166 1.1 jwise PKG_ARGS_COMMON+= -s ${SIZE_PKG_FILE} -S ${SIZE_ALL_FILE} 167 1.1 jwise PKG_ARGS_COMMON+= -P "`${MAKE} ${MAKEFLAGS} run-depends-list PACKAGE_DEPENDS_QUICK=true|sort -u`" 168 1.1 jwise .ifdef CONFLICTS 169 1.1 jwise PKG_ARGS_COMMON+= -C "${CONFLICTS}" 170 1.1 jwise .endif 171 1.1 jwise .ifdef PKG_INSTALL_FILE 172 1.1 jwise PKG_ARGS_COMMON+= -i ${PKG_INSTALL_FILE} 173 1.1 jwise .endif 174 1.1 jwise .ifdef PKG_DEINSTALL_FILE 175 1.1 jwise PKG_ARGS_COMMON+= -k ${PKG_DEINSTALL_FILE} 176 1.1 jwise .endif 177 1.1 jwise .ifdef MESSAGE_FILE 178 1.1 jwise PKG_ARGS_COMMON+= -D ${MESSAGE_FILE} 179 1.1 jwise .endif 180 1.1 jwise 181 1.1 jwise PKG_ARGS_INSTALL= -p ${PREFIX} ${PKG_ARGS_COMMON} 182 1.1 jwise PKG_ARGS_BINPKG= -p ${PREFIX:C/^${DESTDIR}//} -L ${PREFIX} ${PKG_ARGS_COMMON} 183 1.1 jwise .endif # !PKG_ARGS_COMMON 184 1.1 jwise 185 1.1 jwise PKG_SUFX?= .tgz 186 1.1 jwise #PKG_SUFX?= .tbz # bzip2(1) pkgs 187 1.1 jwise # where pkg_add records its dirty deeds. 188 1.1 jwise PKG_DBDIR?= ${DESTDIR}/var/db/syspkg 189 1.1 jwise 190 1.1 jwise # Define SMART_MESSAGES in /etc/mk.conf for messages giving the tree 191 1.1 jwise # of depencies for building, and the current target. 192 1.1 jwise .ifdef SMART_MESSAGES 193 1.1 jwise _PKGSRC_IN?= ===> ${.TARGET} [${PKGNAME}${_PKGSRC_DEPS}] === 194 1.1 jwise .else 195 1.1 jwise _PKGSRC_IN?= === 196 1.1 jwise .endif 197 1.1 jwise 198 1.1 jwise # Used to print all the '===>' style prompts - override this to turn them off. 199 1.1 jwise ECHO_MSG?= ${ECHO} 200 1.1 jwise 201 1.1 jwise # How to do nothing. Override if you, for some strange reason, would rather 202 1.1 jwise # do something. 203 1.1 jwise DO_NADA?= ${TRUE} 204 1.1 jwise 205 1.1 jwise .if !defined(PKGBASE) || !defined(SETNAME) 206 1.1 jwise .BEGIN: 207 1.1 jwise @${ECHO_MSG} "PKGBASE and SETNAME are mandatory." 208 1.1 jwise @${FALSE} 209 1.1 jwise .endif 210 1.1 jwise 211 1.1 jwise PKGREPOSITORY?= ${PACKAGES} 212 1.1 jwise PKGFILE?= ${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX} 213 1.1 jwise 214 1.1 jwise .MAIN: all 215 1.1 jwise 216 1.1 jwise # Add these defs to the ones dumped into +BUILD_DEFS 217 1.1 jwise BUILD_DEFS+= OPSYS OS_VERSION MACHINE_ARCH OBJECT_FMT 218 1.1 jwise 219 1.1 jwise .if !target(all) 220 1.1 jwise # We don't build here 221 1.1 jwise all: 222 1.1 jwise .endif 223 1.1 jwise 224 1.1 jwise ################################################################ 225 1.1 jwise # More standard targets start here. 226 1.1 jwise # 227 1.1 jwise # These are the body of the build/install framework. If you are 228 1.1 jwise # not happy with the default actions, and you can't solve it by 229 1.1 jwise # adding pre-* or post-* targets/scripts, override these. 230 1.1 jwise ################################################################ 231 1.1 jwise 232 1.1 jwise .if !target(show-downlevel) 233 1.1 jwise show-downlevel: 234 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG} \ 235 1.1 jwise found="`${PKG_INFO} -e \"${PKGBASE}<${PKGVERSION}\" || ${TRUE}`";\ 236 1.1 jwise if [ "X$$found" != "X" -a "X$$found" != "X${PKGNAME}" ]; then \ 237 1.1 jwise ${ECHO} "${PKGBASE} package: $$found installed, pkgsrc version ${PKGNAME}"; \ 238 1.1 jwise fi 239 1.1 jwise .endif 240 1.1 jwise 241 1.1 jwise # Package 242 1.1 jwise 243 1.1 jwise .if !target(do-package) 244 1.1 jwise do-package: ${PLIST} 245 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}\ 246 1.1 jwise ${ECHO_MSG} "${_PKGSRC_IN}> Building binary package for ${PKGNAME}"; \ 247 1.1 jwise if [ ! -d ${PKGREPOSITORY} ]; then \ 248 1.1 jwise ${MKDIR} ${PKGREPOSITORY}; \ 249 1.1 jwise if [ $$? -ne 0 ]; then \ 250 1.1 jwise ${ECHO_MSG} "=> Can't create directory ${PKGREPOSITORY}."; \ 251 1.1 jwise exit 1; \ 252 1.1 jwise fi; \ 253 1.1 jwise fi; \ 254 1.1 jwise if ${PKG_CREATE} ${PKG_ARGS_BINPKG} ${PKGFILE}; then \ 255 1.1 jwise (cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} package-links); \ 256 1.1 jwise else \ 257 1.1 jwise (cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} delete-package); \ 258 1.1 jwise exit 1; \ 259 1.1 jwise fi 260 1.1 jwise .endif 261 1.1 jwise 262 1.1 jwise # Some support rules for do-package 263 1.1 jwise 264 1.1 jwise .if !target(package-links) 265 1.1 jwise package-links: 266 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} delete-package-links) 267 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}for cat in ${CATEGORIES}; do \ 268 1.1 jwise if [ ! -d ${PACKAGES}/$$cat ]; then \ 269 1.1 jwise ${MKDIR} ${PACKAGES}/$$cat; \ 270 1.1 jwise if [ $$? -ne 0 ]; then \ 271 1.1 jwise ${ECHO_MSG} "=> Can't create directory ${PACKAGES}/$$cat."; \ 272 1.1 jwise exit 1; \ 273 1.1 jwise fi; \ 274 1.1 jwise fi; \ 275 1.1 jwise ${RM} -f ${PACKAGES}/$$cat/${PKGNAME}${PKG_SUFX}; \ 276 1.1 jwise ${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \ 277 1.1 jwise done; 278 1.1 jwise .endif 279 1.1 jwise 280 1.1 jwise .if !target(delete-package-links) 281 1.1 jwise delete-package-links: 282 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}\ 283 1.1 jwise ${FIND} ${PACKAGES} -type l -name ${PKGNAME}${PKG_SUFX} | xargs ${RM} -f 284 1.1 jwise .endif 285 1.1 jwise 286 1.1 jwise .if !target(delete-package) 287 1.1 jwise delete-package: 288 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} delete-package-links) 289 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PKGFILE} 290 1.1 jwise .endif 291 1.1 jwise 292 1.1 jwise ################################################################ 293 1.1 jwise # This is the "generic" package target, actually a macro used from the 294 1.1 jwise # six main targets. See below for more. 295 1.1 jwise ################################################################ 296 1.1 jwise 297 1.1 jwise real-package: 298 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKEFLAGS} ${.TARGET:S/^real-/pre-/} 299 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKEFLAGS} ${.TARGET:S/^real-/do-/} 300 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKEFLAGS} ${.TARGET:S/^real-/post-/} 301 1.1 jwise 302 1.1 jwise ################################################################ 303 1.1 jwise # Skeleton targets start here 304 1.1 jwise # 305 1.1 jwise # You shouldn't have to change these. Either add the pre-* or 306 1.1 jwise # post-* targets/scripts or redefine the do-* targets. These 307 1.1 jwise # targets don't do anything other than checking for cookies and 308 1.1 jwise # call the necessary targets/scripts. 309 1.1 jwise ################################################################ 310 1.1 jwise 311 1.1 jwise .if !target(package) 312 1.1 jwise package: uptodate-pkgtools ${PACKAGE_COOKIE} 313 1.1 jwise .endif 314 1.1 jwise 315 1.1 jwise ${PACKAGE_COOKIE}: 316 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-package) 317 1.1 jwise 318 1.1 jwise # Empty pre-* and post-* targets, note we can't use .if !target() 319 1.1 jwise # in the _PORT_USE macro 320 1.1 jwise 321 1.1 jwise .for name in package 322 1.1 jwise 323 1.1 jwise .if !target(pre-${name}) 324 1.1 jwise pre-${name}: 325 1.1 jwise @${DO_NADA} 326 1.1 jwise .endif 327 1.1 jwise 328 1.1 jwise .if !target(post-${name}) 329 1.1 jwise post-${name}: 330 1.1 jwise @${DO_NADA} 331 1.1 jwise .endif 332 1.1 jwise 333 1.1 jwise .endfor 334 1.1 jwise 335 1.1 jwise # Deinstall 336 1.1 jwise # 337 1.1 jwise # Special target to remove installation 338 1.1 jwise 339 1.1 jwise .if !target(deinstall) 340 1.1 jwise deinstall: real-deinstall 341 1.1 jwise 342 1.1 jwise .if (${DEINSTALLDEPENDS} != "NO") 343 1.1 jwise .if (${DEINSTALLDEPENDS} != "ALL") 344 1.1 jwise # used for removing stuff in bulk builds 345 1.1 jwise real-su-deinstall-flags+= -r -R 346 1.1 jwise # used for "update" target 347 1.1 jwise .else 348 1.1 jwise real-su-deinstall-flags+= -r 349 1.1 jwise .endif 350 1.1 jwise .endif 351 1.1 jwise .ifdef PKG_VERBOSE 352 1.1 jwise real-su-deinstall-flags+= -v 353 1.1 jwise .endif 354 1.1 jwise 355 1.1 jwise real-deinstall: 356 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG} \ 357 1.1 jwise found="`${PKG_INFO} -e \"${PKGWILDCARD}\" || ${TRUE}`"; \ 358 1.1 jwise if [ "$$found" != "" ]; then \ 359 1.1 jwise ${ECHO} Running ${PKG_DELETE} ${real-su-deinstall-flags} $$found ; \ 360 1.1 jwise ${PKG_DELETE} ${real-su-deinstall-flags} $$found || ${TRUE} ; \ 361 1.1 jwise fi 362 1.1 jwise .for pkg in ${BUILD_DEPENDS:C/:.*$//} 363 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG} \ 364 1.1 jwise found="`${PKG_INFO} -e \"${pkg}\" || ${TRUE}`"; \ 365 1.1 jwise if [ "$$found" != "" ]; then \ 366 1.1 jwise ${ECHO} Running ${PKG_DELETE} $$found ; \ 367 1.1 jwise ${PKG_DELETE} ${real-su-deinstall-flags} $$found || ${TRUE} ; \ 368 1.1 jwise fi 369 1.1 jwise .endfor 370 1.1 jwise .endif # target(deinstall) 371 1.1 jwise 372 1.1 jwise 373 1.1 jwise ################################################################ 374 1.1 jwise # Some more targets supplied for users' convenience 375 1.1 jwise ################################################################ 376 1.1 jwise 377 1.1 jwise # The 'info' target can be used to display information about a package. 378 1.1 jwise info: uptodate-pkgtools 379 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}${PKG_INFO} ${PKGWILDCARD} 380 1.1 jwise 381 1.1 jwise # The 'check' target can be used to check an installed package. 382 1.1 jwise check: uptodate-pkgtools 383 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}${PKG_ADMIN} check ${PKGWILDCARD} 384 1.1 jwise 385 1.1 jwise # Cleaning up 386 1.1 jwise 387 1.1 jwise .if !target(pre-clean) 388 1.1 jwise pre-clean: 389 1.1 jwise @${DO_NADA} 390 1.1 jwise .endif 391 1.1 jwise 392 1.1 jwise .if !target(clean) 393 1.1 jwise clean: pre-clean 394 1.1 jwise ${RM} -f ${PLIST} ${BUILD_VERSION_FILE} ${BUILD_INFO_FILE} ${SIZE_PKG_FILE} ${SIZE_ALL_FILE} 395 1.1 jwise .endif 396 1.1 jwise 397 1.1 jwise .if !target(cleandir) 398 1.1 jwise cleandir: clean 399 1.1 jwise .endif 400 1.1 jwise 401 1.1 jwise # Install binary pkg, without strict uptodate-check first 402 1.1 jwise # (XXX should be able to snarf via FTP. Later...) 403 1.1 jwise bin-install: 404 1.1 jwise @if [ -f ${PKGFILE} ] ; then \ 405 1.1 jwise ${ECHO_MSG} "Installing from binary pkg ${PKGFILE}" ; \ 406 1.1 jwise ${PKG_ADD} ${PKGFILE} ; \ 407 1.1 jwise else \ 408 1.1 jwise ${SHCOMMENT} Cycle through some FTP server here ;\ 409 1.1 jwise ${ECHO_MSG} "Installing from source" ; \ 410 1.1 jwise (cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} package && \ 411 1.1 jwise ${MAKE} ${MAKEFLAGS} clean) ; \ 412 1.1 jwise fi 413 1.1 jwise 414 1.1 jwise 415 1.1 jwise ################################################################ 416 1.1 jwise # The special package-building targets 417 1.1 jwise # You probably won't need to touch these 418 1.1 jwise ################################################################ 419 1.1 jwise 420 1.1 jwise # Nobody should want to override this unless PKGNAME is simply bogus. 421 1.1 jwise 422 1.1 jwise .if !target(package-name) 423 1.1 jwise package-name: 424 1.1 jwise @${ECHO} ${PKGNAME} 425 1.1 jwise .endif # !target(package-name) 426 1.1 jwise 427 1.1 jwise # Show (recursively) all the packages this package depends on. 428 1.1 jwise # If PACKAGE_DEPENDS_WITH_PATTERNS is set, print as pattern (if possible) 429 1.1 jwise PACKAGE_DEPENDS_WITH_PATTERNS?=true 430 1.1 jwise # To be used (-> true) ONLY if the pkg in question is known to be installed 431 1.1 jwise # (i.e. when calling for pkg_create args, and for fake-pkg) 432 1.1 jwise # Will probably not work with PACKAGE_DEPENDS_WITH_PATTERNS=false ... 433 1.1 jwise PACKAGE_DEPENDS_QUICK?=false 434 1.1 jwise .if !target(run-depends-list) 435 1.1 jwise run-depends-list: 436 1.1 jwise .for dep in ${DEPENDS} 437 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG} \ 438 1.1 jwise pkg="${dep:C/:.*//}"; \ 439 1.1 jwise dir="${dep:C/[^:]*://}"; \ 440 1.1 jwise cd ${.CURDIR}; \ 441 1.1 jwise if ${PACKAGE_DEPENDS_WITH_PATTERNS}; then \ 442 1.1 jwise ${ECHO} "$$pkg"; \ 443 1.1 jwise else \ 444 1.1 jwise if cd $$dir 2>/dev/null; then \ 445 1.1 jwise (cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} package-name; \ 446 1.1 jwise else \ 447 1.1 jwise ${ECHO_MSG} "Warning: \"$$dir\" non-existent -- @pkgdep registration incomplete" >&2; \ 448 1.1 jwise fi; \ 449 1.1 jwise fi; \ 450 1.1 jwise if ${PACKAGE_DEPENDS_QUICK} ; then \ 451 1.1 jwise ${PKG_INFO} -qf "$$pkg" | ${AWK} '/^@pkgdep/ {print $$2}'; \ 452 1.1 jwise else \ 453 1.1 jwise if cd $$dir 2>/dev/null; then \ 454 1.1 jwise (cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} run-depends-list; \ 455 1.1 jwise else \ 456 1.1 jwise ${ECHO_MSG} "Warning: \"$$dir\" non-existent -- @pkgdep registration incomplete" >&2; \ 457 1.1 jwise fi; \ 458 1.1 jwise fi 459 1.1 jwise .endfor 460 1.1 jwise .endif # target(run-depends-list) 461 1.1 jwise 462 1.1 jwise # Build a package but don't check the package cookie 463 1.1 jwise 464 1.1 jwise .if !target(repackage) 465 1.1 jwise repackage: pre-repackage package 466 1.1 jwise 467 1.1 jwise pre-repackage: 468 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PACKAGE_COOKIE} 469 1.1 jwise .endif 470 1.1 jwise 471 1.1 jwise # Build a package but don't check the cookie for installation, also don't 472 1.1 jwise # install package cookie 473 1.1 jwise 474 1.1 jwise .if !target(package-noinstall) 475 1.1 jwise package-noinstall: 476 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package) 477 1.1 jwise .endif 478 1.1 jwise 479 1.1 jwise ################################################################ 480 1.1 jwise # Dependency checking 481 1.1 jwise ################################################################ 482 1.1 jwise 483 1.1 jwise .if !target(install-depends) 484 1.1 jwise install-depends: 485 1.1 jwise .endif 486 1.1 jwise 487 1.1 jwise ################################################################ 488 1.1 jwise # Everything after here are internal targets and really 489 1.1 jwise # shouldn't be touched by anybody but the release engineers. 490 1.1 jwise ################################################################ 491 1.1 jwise 492 1.1 jwise .if !target(show-pkgtools-version) 493 1.1 jwise show-pkgtools-version: 494 1.1 jwise @${ECHO} ${PKGTOOLS_VERSION} 495 1.1 jwise .endif 496 1.1 jwise 497 1.1 jwise # convenience target, to display make variables from command line 498 1.1 jwise # i.e. "make show-var VARNAME=var", will print var's value 499 1.1 jwise show-var: 500 1.1 jwise @${ECHO} "${${VARNAME}}" 501 1.1 jwise 502 1.1 jwise # Stat all the files of one pkg and sum the sizes up. 503 1.1 jwise # 504 1.1 jwise # XXX This is intended to be run before pkg_create is called, so the 505 1.1 jwise # existence of ${PLIST} can be assumed. 506 1.1 jwise print-pkg-size-this: 507 1.1 jwise @${SHCOMMENT} "This pkg's files" ; \ 508 1.1 jwise ${AWK} 'BEGIN { base = "${PREFIX}/" } \ 509 1.1 jwise /^@cwd/ { base = $$2 "/" } \ 510 1.1 jwise /^@ignore/ { next } \ 511 1.1 jwise NF == 1 { print base $$1 }' \ 512 1.1 jwise <${PLIST} \ 513 1.1 jwise | sort -u \ 514 1.1 jwise | ${SED} -e 's, ,\\ ,g' \ 515 1.1 jwise | xargs ${LS} -ld \ 516 1.1 jwise | ${AWK} 'BEGIN { print("0 "); } \ 517 1.1 jwise { print($$5, " + "); } \ 518 1.1 jwise END { print("p"); }' \ 519 1.1 jwise | ${DC} 520 1.1 jwise 521 1.1 jwise # Sizes of required pkgs (only) 522 1.1 jwise # 523 1.1 jwise # XXX This is intended to be run before pkg_create is called, so the 524 1.1 jwise # dependencies are all installed. 525 1.1 jwise print-pkg-size-depends: 526 1.1 jwise @(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} run-depends-list PACKAGE_DEPENDS_QUICK=true) \ 527 1.1 jwise | xargs -n 1 ${SETENV} ${PKG_INFO} -e \ 528 1.1 jwise | sort -u \ 529 1.1 jwise | xargs ${SETENV} ${PKG_INFO} -qs \ 530 1.1 jwise | ${AWK} -- 'BEGIN { print("0 "); } \ 531 1.1 jwise /^[0-9]+$$/ { print($$1, " + "); } \ 532 1.1 jwise END { print("p"); }' \ 533 1.1 jwise | ${DC} 534 1.1 jwise 535 1.1 jwise 536 1.1 jwise # Fake installation of package so that user can pkg_delete it later. 537 1.1 jwise # Also, make sure that an installed package is recognized correctly in 538 1.1 jwise # accordance to the @pkgdep directive in the packing lists 539 1.1 jwise 540 1.1 jwise .if !target(register) 541 1.1 jwise register: fake-pkg 542 1.1 jwise .endif 543 1.1 jwise 544 1.1 jwise .if !target(fake-pkg) 545 1.1 jwise fake-pkg: ${PLIST} 546 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}\ 547 1.1 jwise if [ ! -f ${PLIST} -o ! -f ${COMMENT} -o ! -f ${DESCR} ]; then \ 548 1.1 jwise ${ECHO} "** Missing package files for ${PKGNAME} - installation not recorded."; \ 549 1.1 jwise exit 1; \ 550 1.1 jwise fi 551 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}\ 552 1.1 jwise if [ ! -d ${PKG_DBDIR} ]; then \ 553 1.1 jwise ${RM} -f ${PKG_DBDIR}; \ 554 1.1 jwise ${MKDIR} ${PKG_DBDIR}; \ 555 1.1 jwise fi 556 1.1 jwise .if defined(FORCE_PKG_REGISTER) 557 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}${PKG_DELETE} -O ${PKGNAME} 558 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}${RM} -rf ${PKG_DBDIR}/${PKGNAME} 559 1.1 jwise .endif 560 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${BUILD_VERSION_FILE} ${BUILD_INFO_FILE} 561 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${SIZE_PKG_FILE} ${SIZE_ALL_FILE} 562 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG}\ 563 1.1 jwise files=""; \ 564 1.1 jwise for f in ${.CURDIR}/Makefile ${FILESDIR}/* ${PKGDIR}/*; do \ 565 1.1 jwise if [ -f $$f ]; then \ 566 1.1 jwise files="$$files $$f"; \ 567 1.1 jwise fi; \ 568 1.1 jwise done; \ 569 1.1 jwise ${GREP} '\$$NetBSD' $$files | ${SED} -e 's|^${PKGSRCDIR}/||' > ${BUILD_VERSION_FILE}; 570 1.1 jwise .for def in ${BUILD_DEFS} 571 1.1 jwise @${ECHO} ${def}= ${${def}:Q} | ${SED} -e 's|^PATH=[^ ]*|PATH=...|' >> ${BUILD_INFO_FILE} 572 1.1 jwise .endfor 573 1.1 jwise @${ECHO} "CC= ${CC}-`${CC} --version`" >> ${BUILD_INFO_FILE} 574 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG} \ 575 1.1 jwise ${ECHO} "_PKGTOOLS_VER=${PKGTOOLS_VERSION}" >> ${BUILD_INFO_FILE} 576 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG} \ 577 1.1 jwise size_this=`(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} print-pkg-size-this)`; \ 578 1.1 jwise size_depends=`(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} print-pkg-size-depends)`; \ 579 1.1 jwise ${ECHO} $$size_this >${SIZE_PKG_FILE}; \ 580 1.1 jwise ${ECHO} $$size_this $$size_depends + p | ${DC} >${SIZE_ALL_FILE} 581 1.1 jwise ${_PKG_SILENT}${_PKG_DEBUG} \ 582 1.1 jwise if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \ 583 1.1 jwise ${ECHO_MSG} "${_PKGSRC_IN}> Registering installation for ${PKGNAME}"; \ 584 1.1 jwise ${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \ 585 1.1 jwise ${PKG_CREATE} ${PKG_ARGS_INSTALL} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \ 586 1.1 jwise ${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC; \ 587 1.1 jwise ${CP} ${COMMENT} ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \ 588 1.1 jwise ${CP} ${BUILD_VERSION_FILE} ${PKG_DBDIR}/${PKGNAME}/+BUILD_VERSION; \ 589 1.1 jwise ${CP} ${BUILD_INFO_FILE} ${PKG_DBDIR}/${PKGNAME}/+BUILD_INFO; \ 590 1.1 jwise if ${TEST} -e ${SIZE_PKG_FILE}; then \ 591 1.1 jwise ${CP} ${SIZE_PKG_FILE} ${PKG_DBDIR}/${PKGNAME}/+SIZE_PKG; \ 592 1.1 jwise fi ; \ 593 1.1 jwise if ${TEST} -e ${SIZE_ALL_FILE}; then \ 594 1.1 jwise ${CP} ${SIZE_ALL_FILE} ${PKG_DBDIR}/${PKGNAME}/+SIZE_ALL; \ 595 1.1 jwise fi ; \ 596 1.1 jwise if [ -n "${PKG_INSTALL_FILE}" ]; then \ 597 1.1 jwise if ${TEST} -e ${PKG_INSTALL_FILE}; then \ 598 1.1 jwise ${CP} ${PKG_INSTALL_FILE} ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \ 599 1.1 jwise fi; \ 600 1.1 jwise fi; \ 601 1.1 jwise if [ -n "${PKG_DEINSTALL_FILE}" ]; then \ 602 1.1 jwise if ${TEST} -e ${PKG_DEINSTALL_FILE}; then \ 603 1.1 jwise ${CP} ${PKG_DEINSTALL_FILE} ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \ 604 1.1 jwise fi; \ 605 1.1 jwise fi; \ 606 1.1 jwise if [ -n "${MESSAGE_FILE}" ]; then \ 607 1.1 jwise if ${TEST} -e ${MESSAGE_FILE}; then \ 608 1.1 jwise ${CP} ${MESSAGE_FILE} ${PKG_DBDIR}/${PKGNAME}/+DISPLAY; \ 609 1.1 jwise fi; \ 610 1.1 jwise fi; \ 611 1.1 jwise list="`(cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} run-depends-list PACKAGE_DEPENDS_QUICK=true ECHO_MSG=${TRUE} | sort -u)`" ; \ 612 1.1 jwise for dep in $$list; do \ 613 1.1 jwise realdep="`${PKG_INFO} -e \"$$dep\" || ${TRUE}`" ; \ 614 1.1 jwise if [ `${ECHO} $$realdep | wc -w` -gt 1 ]; then \ 615 1.1 jwise ${ECHO} '***' "WARNING: '$$dep' expands to several installed packages " ; \ 616 1.1 jwise ${ECHO} " (" `${ECHO} $$realdep` ")." ; \ 617 1.1 jwise ${ECHO} " Please check if this is really intended!" ; \ 618 1.1 jwise continue ; \ 619 1.1 jwise fi ; \ 620 1.1 jwise done ; \ 621 1.1 jwise for realdep in `echo $$list | xargs -n 1 ${SETENV} ${PKG_INFO} -e | sort -u`; do \ 622 1.1 jwise if ${TEST} -z "$$realdep"; then \ 623 1.1 jwise ${ECHO} "$$dep not installed - dependency NOT registered" ; \ 624 1.1 jwise elif [ -d ${PKG_DBDIR}/$$realdep ]; then \ 625 1.1 jwise if ${TEST} ! -e ${PKG_DBDIR}/$$realdep/+REQUIRED_BY; then \ 626 1.1 jwise ${TOUCH} ${PKG_DBDIR}/$$realdep/+REQUIRED_BY; \ 627 1.1 jwise fi; \ 628 1.1 jwise ${AWK} 'BEGIN { found = 0; } \ 629 1.1 jwise $$0 == "${PKGNAME}" { found = 1; } \ 630 1.1 jwise { print $$0; } \ 631 1.1 jwise END { if (!found) { printf("%s\n", "${PKGNAME}"); }}' \ 632 1.1 jwise < ${PKG_DBDIR}/$$realdep/+REQUIRED_BY > ${PKG_DBDIR}/$$realdep/reqby.$$$$; \ 633 1.1 jwise ${MV} ${PKG_DBDIR}/$$realdep/reqby.$$$$ ${PKG_DBDIR}/$$realdep/+REQUIRED_BY; \ 634 1.1 jwise ${ECHO} "${PKGNAME} requires installed package $$realdep"; \ 635 1.1 jwise fi; \ 636 1.1 jwise done; \ 637 1.1 jwise fi 638 1.1 jwise .endif 639 1.1 jwise 640 1.1 jwise # Depend is generally meaningless for arbitrary packages, but if someone wants 641 1.1 jwise # one they can override this. This is just to catch people who've gotten into 642 1.1 jwise # the habit of typing `${MAKE} depend all install' as a matter of course. 643 1.1 jwise # 644 1.1 jwise .if !target(depend) 645 1.1 jwise depend: 646 1.1 jwise .endif 647 1.1 jwise 648 1.1 jwise # Same goes for tags 649 1.1 jwise .if !target(tags) 650 1.1 jwise tags: 651 1.1 jwise .endif 652 1.1 jwise 653 1.1 jwise ${PLIST}: 654 1.1 jwise sh ${.CURDIR}/../../../../sets/makeplist ${SETNAME} ${PKGBASE} > ${PLIST} 655 1.3 xtraeme 656 1.3 xtraeme .endif # BSD_SYSPKG_MK 657