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