Check-in [31fd5b44cf]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Compress all manpages in manpath
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:31fd5b44cfbad7ca18e0c24f11c55f981aa08b81
User & Date: bapt 2013-09-22 18:27:10
Context
2013-09-22
18:27
Remove debug Leaf check-in: 7ac5ba9ba3 user: bapt tags: trunk
18:27
Compress all manpages in manpath check-in: 31fd5b44cf user: bapt tags: trunk
09:56
Really fix info/dir leftovers check-in: 92591e0f1e user: bapt tags: trunk
Changes

Changes to stage.patch.

1
2
3
4
5
6
7
8
9
10
11
..
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
...
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
...
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
...
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
...
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
...
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
...
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
...
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
...
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
...
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
...
608
609
610
611
612
613
614
615






616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633

634
635
636
637
638
639
640
Index: bsd.licenses.mk
===================================================================
diff --git a/head/Mk/bsd.licenses.mk b/head/Mk/bsd.licenses.mk
--- a/head/Mk/bsd.licenses.mk	(revision 327843)
+++ b/head/Mk/bsd.licenses.mk	(working copy)
@@ -749,14 +749,14 @@
 .endif
 
 install-license:
-	@${MKDIR} ${_LICENSE_DIR}
-	@${INSTALL_DATA} ${_LICENSE_CATALOG_TMP} ${_LICENSE_CATALOG}
................................................................................
+	@${INSTALL_DATA} ${_LICENSE_FILE_${lic}} ${STAGEDIR}${_LICENSE_DIR}/${lic}
 .	endfor
 .endif
 # XXX @dirrmtry entry must be here (no way to do with PLIST_* vars)
Index: bsd.pkgng.mk
===================================================================
diff --git a/head/Mk/bsd.pkgng.mk b/head/Mk/bsd.pkgng.mk
--- a/head/Mk/bsd.pkgng.mk	(revision 327843)
+++ b/head/Mk/bsd.pkgng.mk	(working copy)
@@ -36,14 +36,7 @@
 		${PKG_QUERY} "%dn: {origin: %do, version: \"%dv\"}" " " ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,:C,${PORTSDIR}/,,} 2>/dev/null || : ; \
 	fi
 
-.if !target(fake-pkg)
-fake-pkg:
................................................................................
 .endif
+.endif
 
 .endif # defined(_POSTMKINCLUDED)
Index: bsd.port.mk
===================================================================
diff --git a/head/Mk/bsd.port.mk b/head/Mk/bsd.port.mk
--- a/head/Mk/bsd.port.mk	(revision 327843)
+++ b/head/Mk/bsd.port.mk	(working copy)
@@ -1121,6 +1121,10 @@
 USESDIR?=		${PORTSDIR}/Mk/Uses
 LIB_DIRS?=		/lib /usr/lib ${LOCALBASE}/lib
 
+.if defined(FORCE_STAGE)
+.undef NO_STAGE
+.endif
+
 # make sure bmake treats -V as expected 
 .MAKE.EXPAND_VARIABLES= yes
 # tell bmake we use the old :L :U modifiers
@@ -1912,9 +1916,14 @@
 . endfor
 .endif
 
+.if !defined(NO_STAGE)
+.include "${PORTSDIR}/Mk/bsd.stage.mk"
+.endif
+
................................................................................
 .if defined(WITH_PKGNG)
 .include "${PORTSDIR}/Mk/bsd.pkgng.mk"
 .endif
+
 .if defined(USE_LOCAL_MK)
 .include "${PORTSDIR}/Mk/bsd.local.mk"
 .endif
@@ -2093,6 +2102,7 @@
 BUILD_COOKIE?=		${WRKDIR}/.build_done.${PORTNAME}.${PREFIX:S/\//_/g}
 PATCH_COOKIE?=		${WRKDIR}/.patch_done.${PORTNAME}.${PREFIX:S/\//_/g}
 PACKAGE_COOKIE?=	${WRKDIR}/.package_done.${PORTNAME}.${PREFIX:S/\//_/g}
+STAGE_COOKIE?=		${WRKDIR}/.stage_done.${PORTNAME}.${PREFIX:S/\//_/g}
 
 # How to do nothing.  Override if you, for some strange reason, would rather
 # do something.
@@ -3128,7 +3138,12 @@
 IGNORECMD=	${ECHO_MSG} "===>  ${PKGNAME} "${IGNORE:Q}.;exit 1
 .endif
 
-.for target in check-sanity fetch checksum extract patch configure all build install reinstall package
+.if !defined(NO_STAGE)
+_TARGETS=	check-sanity fetch checksum extract patch configure all build stage restage install reinstall package
+.else
+_TARGETS=	check-sanity fetch checksum extract patch configure all build install reinstall package
+.endif
+.for target in ${_TARGETS}
 .if !target(${target})
 ${target}:
 	@${IGNORECMD}
@@ -3836,6 +3851,7 @@
 			fi; \
 		fi; \
 	fi
+.if defined(NO_STAGE)
 	@if ${PKG_CMD} -b ${PKGNAME} ${PKGFILE}; then \
 		if [ -d ${PACKAGES} ]; then \
 			cd ${.CURDIR} && eval ${MAKE} package-links; \
@@ -3844,7 +3860,30 @@
 		cd ${.CURDIR} && eval ${MAKE} delete-package; \
 		exit 1; \
 	fi
+.else
+	@_LATE_PKG_ARGS=""; \
+	if [ -f ${PKGINSTALL} ]; then \
+		_LATE_PKG_ARGS="$${_LATE_PKG_ARGS} -i ${PKGINSTALL}"; \
................................................................................
+		exit 1; \
+	fi
 .endif
+.endif
 
 # Some support rules for do-package
 
@@ -3900,6 +3939,12 @@
 	@${ECHO_CMD} "[ -f ${PKGFILE} ] && (${ECHO_CMD} deleting ${PKGFILE}; ${RM} -f ${PKGFILE})"
 .endif
 
+.if !target(install-package)
+install-package:
+	@${PKG_ADD} ${PKGFILE}
+.endif
+
+
 # Utility targets follow
 
 .if !target(check-already-installed)
@@ -3989,9 +4034,12 @@
 .if defined(USE_LDCONFIG) || defined(USE_LDCONFIG32)
 .if defined(USE_LDCONFIG)
 .if defined(USE_LINUX_PREFIX)
+.if defined(NO_STAGE)
 	@${ECHO_MSG} "===>   Running linux ldconfig"
 	${LDCONFIG_CMD}
+.endif
 .else
+.if defined(NO_STAGE)
 .if !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Running ldconfig"
 	${LDCONFIG} -m ${USE_LDCONFIG}
@@ -3999,13 +4047,14 @@
 	@${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
 	-${LDCONFIG} -m ${USE_LDCONFIG}
 .endif
+.endif
 .if ${USE_LDCONFIG} != "${PREFIX}/lib" && !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Installing ldconfig configuration file"
 .if defined(NO_LDCONFIG_MTREE)
................................................................................
 .endif
 	@${ECHO_CMD} ${USE_LDCONFIG} | ${TR} ' ' '\n' \
-		> ${PREFIX}/${LDCONFIG_DIR}/${UNIQUENAME}
+		> ${STAGEDIR}${PREFIX}/${LDCONFIG_DIR}/${UNIQUENAME}
 	@${ECHO_CMD} "@cwd" >> ${TMPPLIST}
 	@${ECHO_CMD} ${LDCONFIG_DIR}/${UNIQUENAME} >> ${TMPPLIST}
 .if defined(NO_LDCONFIG_MTREE)
@@ -4015,6 +4064,7 @@
 .endif
 .endif
 .if defined(USE_LDCONFIG32)
+.if defined(NO_STAGE)
 .if !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Running ldconfig"
 	${LDCONFIG} -32 -m ${USE_LDCONFIG32}
@@ -4022,10 +4072,11 @@
 	@${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
 	-${LDCONFIG} -32 -m ${USE_LDCONFIG32}
 .endif
+.endif
 .if !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Installing 32-bit ldconfig configuration file"
 .if defined(NO_LDCONFIG_MTREE)
-	@${MKDIR} ${PREFIX}/${LDCONFIG_32DIR}
+	@${MKDIR} ${STAGEDIR}${PREFIX}/${LDCONFIG_32DIR}
 .endif
 	@${ECHO_CMD} ${USE_LDCONFIG32} | ${TR} ' ' '\n' \
 		> ${PREFIX}/${LDCONFIG32_DIR}/${UNIQUENAME}
@@ -4236,6 +4287,35 @@
 _BUILD_DEP=		configure
 _BUILD_SEQ=		build-message pre-build pre-build-script do-build \
 				post-build post-build-script
+.if !defined(NO_STAGE)
+
+_STAGE_DEP=		build
+_STAGE_SEQ=		stage-message stage-dir run-depends lib-depends apply-slist pre-install generate-plist \
................................................................................
+.endif
+
+.else
+
 _INSTALL_DEP=	build
 _INSTALL_SEQ=	install-message check-install-conflicts run-depends lib-depends apply-slist pre-install \
 				pre-install-script generate-plist check-already-installed
@@ -4249,6 +4329,7 @@
 _PACKAGE_DEP=	install
 _PACKAGE_SEQ=	package-message pre-package pre-package-script \
 				do-package post-package-script
+.endif
 
 .if !target(post-chroot)
 post-chroot:
@@ -4271,7 +4352,7 @@
 # Main logic. The loop generates 6 main targets and using cookies
 # ensures that those already completed are skipped.
 
-.for target in extract patch configure build install package
+.for target in extract patch configure build stage install package
 
 .if !target(${target}) && defined(_OPTIONS_OK)
 ${target}: ${${target:U}_COOKIE}
@@ -4325,6 +4406,9 @@
 .ORDER: ${_PATCH_DEP} ${_PATCH_SEQ}
 .ORDER: ${_CONFIGURE_DEP} ${_CONFIGURE_SEQ}
 .ORDER: ${_BUILD_DEP} ${_BUILD_SEQ}
+.if !defined(NO_STAGE)
+.ORDER: ${_STAGE_DEP} ${_STAGE_SEQ}
+.endif
 .ORDER: ${_INSTALL_DEP} ${_INSTALL_SEQ}
 .ORDER: ${_PACKAGE_DEP} ${_PACKAGE_SEQ}
 
@@ -4336,6 +4420,8 @@
 	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
 build-message:
 	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
+stage-message:
+	@${ECHO_MSG} "===>  Staging for ${PKGNAME}"
 install-message:
 	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
 package-message:
@@ -4344,7 +4430,7 @@
 # Empty pre-* and post-* targets
 
 .for stage in pre post
-.for name in pkg check-sanity fetch extract patch configure build install package
+.for name in pkg check-sanity fetch extract patch configure build stage install package
 
 .if !target(${stage}-${name})
 ${stage}-${name}:
@@ -4407,6 +4493,12 @@
 	@cd ${.CURDIR} && DEPENDS_TARGET="${DEPENDS_TARGET}" ${MAKE} -DFORCE_PKG_REGISTER install
 .endif
 
+.if !target(restage)
+restage:
+	@${RM} -rf ${STAGE_DESTDIR} ${STAGE_COOKIE} ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
+	@cd ${.CURDIR} && ${MAKE} stage
+.endif
+
 # Deinstall
 #
 # Special target to remove installation
@@ -4473,6 +4565,12 @@
 
 .if !target(do-clean)
 do-clean:
+.if !defined(NO_STAGE) && ${UID} != 0 && !defined(INSTALL_AS_USER)
+	@${ECHO_MSG} "===>  Switching to root credentials for '${.TARGET}' target"
+	@cd ${.CURDIR} && \
+		${SU_CMD} "${MAKE} ${.TARGET}"
+	@${ECHO_MSG} "===>  Returning to user credentials"
+.else
 	@if [ -d ${WRKDIR} ]; then \
 		if [ -w ${WRKDIR} ]; then \
 			${RM} -rf ${WRKDIR}; \
@@ -4481,6 +4579,7 @@
 		fi; \
 	fi
 .endif
+.endif
 
 .if !target(clean)
 clean:
@@ -5623,6 +5722,7 @@
 	@for file in ${PLIST_FILES}; do \
 		${ECHO_CMD} $${file} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} >> ${TMPPLIST}; \
 	done
+.if defined(NO_STAGE)
 	@for man in ${__MANPAGES}; do \
 		${ECHO_CMD} $${man} >> ${TMPPLIST}; \
 	done
@@ -5640,6 +5740,7 @@
 	@${ECHO_CMD} '@cwd ${PREFIX}' >> ${TMPPLIST}
 .endif
 .endfor
+.endif
 	@if [ -f ${PLIST} ]; then \
 		${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} ${PLIST} >> ${TMPPLIST}; \
 	fi
@@ -5702,14 +5803,14 @@
 	fi
 .for x in ${PORTDOCS}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${DOCSDIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${DOCSDIR}/${x} ]; then \
 		${ECHO_CMD} ${DOCSDIR_REL}/${x} >> ${TMPPLIST}; \
 	fi;fi
................................................................................
+	@${FIND} -P ${STAGEDIR}${PORTDOCS:S/^/${STAGEDIR}${DOCSDIR}\//} ! -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTDOCS:S/^/${STAGEDIR}${DOCSDIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
 	@${ECHO_CMD} "@dirrm ${DOCSDIR_REL}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
@@ -5725,16 +5826,16 @@
 	fi
 .for x in ${PORTEXAMPLES}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${EXAMPLESDIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${EXAMPLESDIR}/${x} ]; then \
 		${ECHO_CMD} ${EXAMPLESDIR}/${x} | \
 			${SED} -e 's,^${PREFIX}/,,' >> ${TMPPLIST}; \
................................................................................
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTEXAMPLES:S/^/${STAGEDIR}${EXAMPLESDIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${EXAMPLESDIR_REL}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
 .endif
@@ -5749,16 +5850,16 @@
 	fi
 .for x in ${PORTDATA}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${DATADIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${DATADIR}/${x} ]; then \
 		${ECHO_CMD} ${DATADIR}/${x} | \
 			${SED} -e 's,^${PREFIX}/,,' >> ${TMPPLIST}; \
................................................................................
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTDATA:S/^/${STAGEDIR}${DATADIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${DATADIR_REL}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
 .endif
@@ -5780,6 +5881,8 @@
 .if !defined(WITH_PKGNG)
 	@${ECHO_CMD} "@unexec install-info --quiet --delete %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
 		>> ${TMPPLIST}
+	@${ECHO_CMD} "@unexec [ \`info -d %D/${INFO_PATH}  --output - 2>/dev/null | grep -c '^*'\` -eq 1 ] && rm -f %D/${INFO_PATH}/dir || :"\
+		>> ${TMPPLIST}
 	@${LS} ${PREFIX}/${INFO_PATH}/$i.info* | ${SED} -e s:${PREFIX}/::g >> ${TMPPLIST}
 	@${ECHO_CMD} "@exec install-info --quiet %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
 		>> ${TMPPLIST}
@@ -5814,19 +5917,19 @@
 install-rc-script:
 .if defined(USE_RCORDER) || defined(USE_RC_SUBR) && ${USE_RC_SUBR:U} != "YES"
 .if defined(USE_RCORDER)
-	@${ECHO_MSG} "===> Installing early rc.d startup script(s)"
+	@${ECHO_MSG} "===> Staging early rc.d startup script(s)"
 	@${ECHO_CMD} "@cwd /" >> ${TMPPLIST}
 	@for i in ${USE_RCORDER}; do \
................................................................................
 	@${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
 	@for i in ${USE_RC_SUBR}; do \
-		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${PREFIX}/etc/rc.d/$${i%.sh}; \
+		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${STAGEDIR}${PREFIX}/etc/rc.d/$${i%.sh}; \
 		${ECHO_CMD} "etc/rc.d/$${i%.sh}" >> ${TMPPLIST}; \
 	done
 .endif
@@ -6447,7 +6550,7 @@
 .if !target(install-desktop-entries)
 install-desktop-entries:
 .if defined(DESKTOP_ENTRIES)
-	@(${MKDIR} "${DESKTOPDIR}" 2> /dev/null) || \
+	@(${MKDIR} "${STAGEDIR}${DESKTOPDIR}" 2> /dev/null) || \
 		(${ECHO_MSG} "===> Cannot create ${DESKTOPDIR}, check permissions"; exit 1)
 	@set -- ${DESKTOP_ENTRIES} XXX; \
 	if [ -z "${_DESKTOPDIR_REL}" ]; then \
Index: bsd.python.mk
===================================================================
diff --git a/head/Mk/bsd.python.mk b/head/Mk/bsd.python.mk
--- a/head/Mk/bsd.python.mk	(revision 327843)
+++ b/head/Mk/bsd.python.mk	(working copy)
@@ -534,6 +534,9 @@
 PYDISTUTILS_CONFIGUREARGS?=
 PYDISTUTILS_BUILDARGS?=
 PYDISTUTILS_INSTALLARGS?=	-c -O1 --prefix=${PREFIX}
+.if !defined(NO_STAGE)
+PYDISTUTILS_INSTALLARGS+=	--root=${STAGEDIR}
................................................................................
+.endif
 PYDISTUTILS_PKGNAME?=	${PORTNAME}
 PYDISTUTILS_PKGVERSION?=${PORTVERSION}
 PYDISTUTILS_EGGINFO?=	${PYDISTUTILS_PKGNAME:C/[^A-Za-z0-9.]+/_/g}-${PYDISTUTILS_PKGVERSION:C/[^A-Za-z0-9.]+/_/g}-py${PYTHON_VER}.egg-info
Index: bsd.sanity.mk
===================================================================
diff --git a/head/Mk/bsd.sanity.mk b/head/Mk/bsd.sanity.mk
--- a/head/Mk/bsd.sanity.mk	(revision 327843)
+++ b/head/Mk/bsd.sanity.mk	(working copy)
@@ -96,6 +96,14 @@
 DEV_WARNING+=	"USE_TCL and USE_TK are deprecated, please use USES=tcl or USES=tk"
 .endif
 
+.if !defined(NO_STAGE) && defined(_MANPAGES)
+DEV_WARNING+=	"MAN* macros are deprecated when using stage directory"
................................................................................
 .endif
Index: bsd.stage.mk
===================================================================
diff --git a/head/Mk/bsd.stage.mk b/head/Mk/bsd.stage.mk
new file mode 10644
--- /dev/null	(revision 0)
+++ b/head/Mk/bsd.stage.mk	(working copy)
@@ -0,0 +1,94 @@
+#
+# $FreeBSD$
+#
+
+STAGEDIR?=	${WRKDIR}/stage
+DESTDIRNAME?=	DESTDIR
+
................................................................................
+.endif
+
+# Compress all manpage not already compressed which are not hardlinks
+# Find all manpages which are not compressed and are hadlinks, and only get the list of inodes concerned, for each of them compress the first one found and recreate the hardlinks for the others
+# Fixes all dead symlinks left by the previous round
+.if !target(compress-man)
+compress-man:
+	@${ECHO_CMD} "====> Compressing man pages"






+	@${FIND} ${STAGEDIR}${MANPREFIX}/man -type f \! -name "*.gz" -links 1 -exec ${GZIP_CMD} {} \;
+	@${FIND} ${STAGEDIR}${MANPREFIX}/man -type f \! -name "*.gz" \! -links 1 -print -exec ${STAT} -f '%i' {} \; | \
+		${SORT} -u | while read inode ; do \
+			unset ref ; \
+			for f in $$(${FIND} -type f -inum $${inode} -print); do \
+				if [ -z $$ref ]; then \
+					ref=$${f}.gz ; \
+					${GZIP_CMD} $${f} ; \
+					continue ; \
+				fi ; \
+				${RM} -f $${f} ; \
+				(cd $${f%/*}; ${LN} -f $${ref##*/} $${f##*/}.gz) ; \
+			done ; \
+		done
+	@${FIND} ${STAGEDIR}${MANPREFIX}/man -type l \! -name "*.gz" | while read link ; do \
+			dest=$$(readlink $$link) ; \
+			rm -f $$link ; \
+			(cd $${link%/*} ; ${LN} -sf $${dest##*/}.gz $${link##*/}.gz) ;\

+	done
+.endif
+
+.if !target(add-plist-info)
+add-plist-info:
+.for i in ${INFO}
+.if !defined(WITH_PKGNG)



|







 







|







 







|

|










|







 







|







|













|







|







 







|












|












|







 







|







|












|







 







|







|








|









|








|








|












|












|







|







|







|







 







|







 







|







 







|








|







 







|











|







 







|







 







|







 







|
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







1
2
3
4
5
6
7
8
9
10
11
..
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
...
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
...
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
...
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
...
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
...
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
...
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
...
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
...
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
...
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
...
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
Index: bsd.licenses.mk
===================================================================
diff --git a/head/Mk/bsd.licenses.mk b/head/Mk/bsd.licenses.mk
--- a/head/Mk/bsd.licenses.mk	(revision 327860)
+++ b/head/Mk/bsd.licenses.mk	(working copy)
@@ -749,14 +749,14 @@
 .endif
 
 install-license:
-	@${MKDIR} ${_LICENSE_DIR}
-	@${INSTALL_DATA} ${_LICENSE_CATALOG_TMP} ${_LICENSE_CATALOG}
................................................................................
+	@${INSTALL_DATA} ${_LICENSE_FILE_${lic}} ${STAGEDIR}${_LICENSE_DIR}/${lic}
 .	endfor
 .endif
 # XXX @dirrmtry entry must be here (no way to do with PLIST_* vars)
Index: bsd.pkgng.mk
===================================================================
diff --git a/head/Mk/bsd.pkgng.mk b/head/Mk/bsd.pkgng.mk
--- a/head/Mk/bsd.pkgng.mk	(revision 327860)
+++ b/head/Mk/bsd.pkgng.mk	(working copy)
@@ -36,14 +36,7 @@
 		${PKG_QUERY} "%dn: {origin: %do, version: \"%dv\"}" " " ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,:C,${PORTSDIR}/,,} 2>/dev/null || : ; \
 	fi
 
-.if !target(fake-pkg)
-fake-pkg:
................................................................................
 .endif
+.endif
 
 .endif # defined(_POSTMKINCLUDED)
Index: bsd.port.mk
===================================================================
diff --git a/head/Mk/bsd.port.mk b/head/Mk/bsd.port.mk
--- a/head/Mk/bsd.port.mk	(revision 327860)
+++ b/head/Mk/bsd.port.mk	(working copy)
@@ -1122,6 +1122,10 @@
 USESDIR?=		${PORTSDIR}/Mk/Uses
 LIB_DIRS?=		/lib /usr/lib ${LOCALBASE}/lib
 
+.if defined(FORCE_STAGE)
+.undef NO_STAGE
+.endif
+
 # make sure bmake treats -V as expected 
 .MAKE.EXPAND_VARIABLES= yes
 # tell bmake we use the old :L :U modifiers
@@ -1913,9 +1917,14 @@
 . endfor
 .endif
 
+.if !defined(NO_STAGE)
+.include "${PORTSDIR}/Mk/bsd.stage.mk"
+.endif
+
................................................................................
 .if defined(WITH_PKGNG)
 .include "${PORTSDIR}/Mk/bsd.pkgng.mk"
 .endif
+
 .if defined(USE_LOCAL_MK)
 .include "${PORTSDIR}/Mk/bsd.local.mk"
 .endif
@@ -2094,6 +2103,7 @@
 BUILD_COOKIE?=		${WRKDIR}/.build_done.${PORTNAME}.${PREFIX:S/\//_/g}
 PATCH_COOKIE?=		${WRKDIR}/.patch_done.${PORTNAME}.${PREFIX:S/\//_/g}
 PACKAGE_COOKIE?=	${WRKDIR}/.package_done.${PORTNAME}.${PREFIX:S/\//_/g}
+STAGE_COOKIE?=		${WRKDIR}/.stage_done.${PORTNAME}.${PREFIX:S/\//_/g}
 
 # How to do nothing.  Override if you, for some strange reason, would rather
 # do something.
@@ -3129,7 +3139,12 @@
 IGNORECMD=	${ECHO_MSG} "===>  ${PKGNAME} "${IGNORE:Q}.;exit 1
 .endif
 
-.for target in check-sanity fetch checksum extract patch configure all build install reinstall package
+.if !defined(NO_STAGE)
+_TARGETS=	check-sanity fetch checksum extract patch configure all build stage restage install reinstall package
+.else
+_TARGETS=	check-sanity fetch checksum extract patch configure all build install reinstall package
+.endif
+.for target in ${_TARGETS}
 .if !target(${target})
 ${target}:
 	@${IGNORECMD}
@@ -3837,6 +3852,7 @@
 			fi; \
 		fi; \
 	fi
+.if defined(NO_STAGE)
 	@if ${PKG_CMD} -b ${PKGNAME} ${PKGFILE}; then \
 		if [ -d ${PACKAGES} ]; then \
 			cd ${.CURDIR} && eval ${MAKE} package-links; \
@@ -3845,7 +3861,30 @@
 		cd ${.CURDIR} && eval ${MAKE} delete-package; \
 		exit 1; \
 	fi
+.else
+	@_LATE_PKG_ARGS=""; \
+	if [ -f ${PKGINSTALL} ]; then \
+		_LATE_PKG_ARGS="$${_LATE_PKG_ARGS} -i ${PKGINSTALL}"; \
................................................................................
+		exit 1; \
+	fi
 .endif
+.endif
 
 # Some support rules for do-package
 
@@ -3901,6 +3940,12 @@
 	@${ECHO_CMD} "[ -f ${PKGFILE} ] && (${ECHO_CMD} deleting ${PKGFILE}; ${RM} -f ${PKGFILE})"
 .endif
 
+.if !target(install-package)
+install-package:
+	@${PKG_ADD} ${PKGFILE}
+.endif
+
+
 # Utility targets follow
 
 .if !target(check-already-installed)
@@ -3990,9 +4035,12 @@
 .if defined(USE_LDCONFIG) || defined(USE_LDCONFIG32)
 .if defined(USE_LDCONFIG)
 .if defined(USE_LINUX_PREFIX)
+.if defined(NO_STAGE)
 	@${ECHO_MSG} "===>   Running linux ldconfig"
 	${LDCONFIG_CMD}
+.endif
 .else
+.if defined(NO_STAGE)
 .if !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Running ldconfig"
 	${LDCONFIG} -m ${USE_LDCONFIG}
@@ -4000,13 +4048,14 @@
 	@${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
 	-${LDCONFIG} -m ${USE_LDCONFIG}
 .endif
+.endif
 .if ${USE_LDCONFIG} != "${PREFIX}/lib" && !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Installing ldconfig configuration file"
 .if defined(NO_LDCONFIG_MTREE)
................................................................................
 .endif
 	@${ECHO_CMD} ${USE_LDCONFIG} | ${TR} ' ' '\n' \
-		> ${PREFIX}/${LDCONFIG_DIR}/${UNIQUENAME}
+		> ${STAGEDIR}${PREFIX}/${LDCONFIG_DIR}/${UNIQUENAME}
 	@${ECHO_CMD} "@cwd" >> ${TMPPLIST}
 	@${ECHO_CMD} ${LDCONFIG_DIR}/${UNIQUENAME} >> ${TMPPLIST}
 .if defined(NO_LDCONFIG_MTREE)
@@ -4016,6 +4065,7 @@
 .endif
 .endif
 .if defined(USE_LDCONFIG32)
+.if defined(NO_STAGE)
 .if !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Running ldconfig"
 	${LDCONFIG} -32 -m ${USE_LDCONFIG32}
@@ -4023,10 +4073,11 @@
 	@${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
 	-${LDCONFIG} -32 -m ${USE_LDCONFIG32}
 .endif
+.endif
 .if !defined(INSTALL_AS_USER)
 	@${ECHO_MSG} "===>   Installing 32-bit ldconfig configuration file"
 .if defined(NO_LDCONFIG_MTREE)
-	@${MKDIR} ${PREFIX}/${LDCONFIG_32DIR}
+	@${MKDIR} ${STAGEDIR}${PREFIX}/${LDCONFIG_32DIR}
 .endif
 	@${ECHO_CMD} ${USE_LDCONFIG32} | ${TR} ' ' '\n' \
 		> ${PREFIX}/${LDCONFIG32_DIR}/${UNIQUENAME}
@@ -4237,6 +4288,35 @@
 _BUILD_DEP=		configure
 _BUILD_SEQ=		build-message pre-build pre-build-script do-build \
 				post-build post-build-script
+.if !defined(NO_STAGE)
+
+_STAGE_DEP=		build
+_STAGE_SEQ=		stage-message stage-dir run-depends lib-depends apply-slist pre-install generate-plist \
................................................................................
+.endif
+
+.else
+
 _INSTALL_DEP=	build
 _INSTALL_SEQ=	install-message check-install-conflicts run-depends lib-depends apply-slist pre-install \
 				pre-install-script generate-plist check-already-installed
@@ -4250,6 +4330,7 @@
 _PACKAGE_DEP=	install
 _PACKAGE_SEQ=	package-message pre-package pre-package-script \
 				do-package post-package-script
+.endif
 
 .if !target(post-chroot)
 post-chroot:
@@ -4272,7 +4353,7 @@
 # Main logic. The loop generates 6 main targets and using cookies
 # ensures that those already completed are skipped.
 
-.for target in extract patch configure build install package
+.for target in extract patch configure build stage install package
 
 .if !target(${target}) && defined(_OPTIONS_OK)
 ${target}: ${${target:U}_COOKIE}
@@ -4326,6 +4407,9 @@
 .ORDER: ${_PATCH_DEP} ${_PATCH_SEQ}
 .ORDER: ${_CONFIGURE_DEP} ${_CONFIGURE_SEQ}
 .ORDER: ${_BUILD_DEP} ${_BUILD_SEQ}
+.if !defined(NO_STAGE)
+.ORDER: ${_STAGE_DEP} ${_STAGE_SEQ}
+.endif
 .ORDER: ${_INSTALL_DEP} ${_INSTALL_SEQ}
 .ORDER: ${_PACKAGE_DEP} ${_PACKAGE_SEQ}
 
@@ -4337,6 +4421,8 @@
 	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
 build-message:
 	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
+stage-message:
+	@${ECHO_MSG} "===>  Staging for ${PKGNAME}"
 install-message:
 	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
 package-message:
@@ -4345,7 +4431,7 @@
 # Empty pre-* and post-* targets
 
 .for stage in pre post
-.for name in pkg check-sanity fetch extract patch configure build install package
+.for name in pkg check-sanity fetch extract patch configure build stage install package
 
 .if !target(${stage}-${name})
 ${stage}-${name}:
@@ -4408,6 +4494,12 @@
 	@cd ${.CURDIR} && DEPENDS_TARGET="${DEPENDS_TARGET}" ${MAKE} -DFORCE_PKG_REGISTER install
 .endif
 
+.if !target(restage)
+restage:
+	@${RM} -rf ${STAGE_DESTDIR} ${STAGE_COOKIE} ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
+	@cd ${.CURDIR} && ${MAKE} stage
+.endif
+
 # Deinstall
 #
 # Special target to remove installation
@@ -4474,6 +4566,12 @@
 
 .if !target(do-clean)
 do-clean:
+.if !defined(NO_STAGE) && ${UID} != 0 && !defined(INSTALL_AS_USER)
+	@${ECHO_MSG} "===>  Switching to root credentials for '${.TARGET}' target"
+	@cd ${.CURDIR} && \
+		${SU_CMD} "${MAKE} ${.TARGET}"
+	@${ECHO_MSG} "===>  Returning to user credentials"
+.else
 	@if [ -d ${WRKDIR} ]; then \
 		if [ -w ${WRKDIR} ]; then \
 			${RM} -rf ${WRKDIR}; \
@@ -4482,6 +4580,7 @@
 		fi; \
 	fi
 .endif
+.endif
 
 .if !target(clean)
 clean:
@@ -5624,6 +5723,7 @@
 	@for file in ${PLIST_FILES}; do \
 		${ECHO_CMD} $${file} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} >> ${TMPPLIST}; \
 	done
+.if defined(NO_STAGE)
 	@for man in ${__MANPAGES}; do \
 		${ECHO_CMD} $${man} >> ${TMPPLIST}; \
 	done
@@ -5641,6 +5741,7 @@
 	@${ECHO_CMD} '@cwd ${PREFIX}' >> ${TMPPLIST}
 .endif
 .endfor
+.endif
 	@if [ -f ${PLIST} ]; then \
 		${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} ${PLIST} >> ${TMPPLIST}; \
 	fi
@@ -5703,14 +5804,14 @@
 	fi
 .for x in ${PORTDOCS}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${DOCSDIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${DOCSDIR}/${x} ]; then \
 		${ECHO_CMD} ${DOCSDIR_REL}/${x} >> ${TMPPLIST}; \
 	fi;fi
................................................................................
+	@${FIND} -P ${STAGEDIR}${PORTDOCS:S/^/${STAGEDIR}${DOCSDIR}\//} ! -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTDOCS:S/^/${STAGEDIR}${DOCSDIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
 	@${ECHO_CMD} "@dirrm ${DOCSDIR_REL}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
@@ -5726,16 +5827,16 @@
 	fi
 .for x in ${PORTEXAMPLES}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${EXAMPLESDIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${EXAMPLESDIR}/${x} ]; then \
 		${ECHO_CMD} ${EXAMPLESDIR}/${x} | \
 			${SED} -e 's,^${PREFIX}/,,' >> ${TMPPLIST}; \
................................................................................
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTEXAMPLES:S/^/${STAGEDIR}${EXAMPLESDIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${EXAMPLESDIR_REL}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
 .endif
@@ -5750,16 +5851,16 @@
 	fi
 .for x in ${PORTDATA}
 	@if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
-		if [ ! -e ${DATADIR}/${x} ]; then \
+		if [ ! -e ${STAGEDIR}${DATADIR}/${x} ]; then \
 		${ECHO_CMD} ${DATADIR}/${x} | \
 			${SED} -e 's,^${PREFIX}/,,' >> ${TMPPLIST}; \
................................................................................
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
+	@${FIND} -P -d ${STAGEDIR}${PORTDATA:S/^/${STAGEDIR}${DATADIR}\//} -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@dirrm ${DATADIR_REL}" >> ${TMPPLIST}
 .else
 	@${DO_NADA}
 .endif
@@ -5781,6 +5882,8 @@
 .if !defined(WITH_PKGNG)
 	@${ECHO_CMD} "@unexec install-info --quiet --delete %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
 		>> ${TMPPLIST}
+	@${ECHO_CMD} "@unexec [ \`info -d %D/${INFO_PATH}  --output - 2>/dev/null | grep -c '^*'\` -eq 1 ] && rm -f %D/${INFO_PATH}/dir || :"\
+		>> ${TMPPLIST}
 	@${LS} ${PREFIX}/${INFO_PATH}/$i.info* | ${SED} -e s:${PREFIX}/::g >> ${TMPPLIST}
 	@${ECHO_CMD} "@exec install-info --quiet %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
 		>> ${TMPPLIST}
@@ -5815,19 +5918,19 @@
 install-rc-script:
 .if defined(USE_RCORDER) || defined(USE_RC_SUBR) && ${USE_RC_SUBR:U} != "YES"
 .if defined(USE_RCORDER)
-	@${ECHO_MSG} "===> Installing early rc.d startup script(s)"
+	@${ECHO_MSG} "===> Staging early rc.d startup script(s)"
 	@${ECHO_CMD} "@cwd /" >> ${TMPPLIST}
 	@for i in ${USE_RCORDER}; do \
................................................................................
 	@${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
 	@for i in ${USE_RC_SUBR}; do \
-		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${PREFIX}/etc/rc.d/$${i%.sh}; \
+		${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${STAGEDIR}${PREFIX}/etc/rc.d/$${i%.sh}; \
 		${ECHO_CMD} "etc/rc.d/$${i%.sh}" >> ${TMPPLIST}; \
 	done
 .endif
@@ -6448,7 +6551,7 @@
 .if !target(install-desktop-entries)
 install-desktop-entries:
 .if defined(DESKTOP_ENTRIES)
-	@(${MKDIR} "${DESKTOPDIR}" 2> /dev/null) || \
+	@(${MKDIR} "${STAGEDIR}${DESKTOPDIR}" 2> /dev/null) || \
 		(${ECHO_MSG} "===> Cannot create ${DESKTOPDIR}, check permissions"; exit 1)
 	@set -- ${DESKTOP_ENTRIES} XXX; \
 	if [ -z "${_DESKTOPDIR_REL}" ]; then \
Index: bsd.python.mk
===================================================================
diff --git a/head/Mk/bsd.python.mk b/head/Mk/bsd.python.mk
--- a/head/Mk/bsd.python.mk	(revision 327860)
+++ b/head/Mk/bsd.python.mk	(working copy)
@@ -534,6 +534,9 @@
 PYDISTUTILS_CONFIGUREARGS?=
 PYDISTUTILS_BUILDARGS?=
 PYDISTUTILS_INSTALLARGS?=	-c -O1 --prefix=${PREFIX}
+.if !defined(NO_STAGE)
+PYDISTUTILS_INSTALLARGS+=	--root=${STAGEDIR}
................................................................................
+.endif
 PYDISTUTILS_PKGNAME?=	${PORTNAME}
 PYDISTUTILS_PKGVERSION?=${PORTVERSION}
 PYDISTUTILS_EGGINFO?=	${PYDISTUTILS_PKGNAME:C/[^A-Za-z0-9.]+/_/g}-${PYDISTUTILS_PKGVERSION:C/[^A-Za-z0-9.]+/_/g}-py${PYTHON_VER}.egg-info
Index: bsd.sanity.mk
===================================================================
diff --git a/head/Mk/bsd.sanity.mk b/head/Mk/bsd.sanity.mk
--- a/head/Mk/bsd.sanity.mk	(revision 327860)
+++ b/head/Mk/bsd.sanity.mk	(working copy)
@@ -96,6 +96,14 @@
 DEV_WARNING+=	"USE_TCL and USE_TK are deprecated, please use USES=tcl or USES=tk"
 .endif
 
+.if !defined(NO_STAGE) && defined(_MANPAGES)
+DEV_WARNING+=	"MAN* macros are deprecated when using stage directory"
................................................................................
 .endif
Index: bsd.stage.mk
===================================================================
diff --git a/head/Mk/bsd.stage.mk b/head/Mk/bsd.stage.mk
new file mode 10644
--- /dev/null	(revision 0)
+++ b/head/Mk/bsd.stage.mk	(working copy)
@@ -0,0 +1,101 @@
+#
+# $FreeBSD$
+#
+
+STAGEDIR?=	${WRKDIR}/stage
+DESTDIRNAME?=	DESTDIR
+
................................................................................
+.endif
+
+# Compress all manpage not already compressed which are not hardlinks
+# Find all manpages which are not compressed and are hadlinks, and only get the list of inodes concerned, for each of them compress the first one found and recreate the hardlinks for the others
+# Fixes all dead symlinks left by the previous round
+.if !target(compress-man)
+compress-man:
+	@${ECHO_CMD} "====> Compressing man pages" ; \
+	mdirs="${STAGEDIR}${MANPREFIX}/man"; \
+	for dir in `cat /usr/local/etc/man.d/*.conf ${STAGEDIR}/usr/local/etc/man.d/*.conf 2>/dev/null| awk -vstagedir=${STAGEDIR} '{ print stagedir$$2 }'` ; do \
+		[ -d $$dir ] && mdirs="$$mdirs $$dir" ;\
+	done ; \
+	${ECHO_MSG} $$mdirs ; \
+	for dir in $$mdirs; do \
+		${FIND} $$dir -type f \! -name "*.gz" -links 1 -exec ${GZIP_CMD} {} \; ; \
+		${FIND} $$dir -type f \! -name "*.gz" \! -links 1 -print -exec ${STAT} -f '%i' {} \; | \
+			${SORT} -u | while read inode ; do \
+				unset ref ; \
+				for f in $$(${FIND} -type f -inum $${inode} -print); do \
+					if [ -z $$ref ]; then \
+						ref=$${f}.gz ; \
+						${GZIP_CMD} $${f} ; \
+						continue ; \
+					fi ; \
+					${RM} -f $${f} ; \
+					(cd $${f%/*}; ${LN} -f $${ref##*/} $${f##*/}.gz) ; \
+				done ; \
+			done ; \
+		${FIND} $$dir -type l \! -name "*.gz" | while read link ; do \
+				dest=$$(readlink $$link) ; \
+				rm -f $$link ; \
+				(cd $${link%/*} ; ${LN} -sf $${dest##*/}.gz $${link##*/}.gz) ;\
+		done; \
+	done
+.endif
+
+.if !target(add-plist-info)
+add-plist-info:
+.for i in ${INFO}
+.if !defined(WITH_PKGNG)