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