Import security/amavis-stats version 0.1.12_3
[dports.git] / Mk / bsd.stage.mk
1 #
2 # $FreeBSD$
3 #
4
5 STAGEDIR?=      ${WRKDIR}/stage
6 DESTDIRNAME?=   DESTDIR
7
8 .if defined(_DESTDIR_VIA_ENV)
9 MAKE_ENV+=      ${DESTDIRNAME}=${STAGEDIR}
10 .else
11 MAKE_ARGS+=     ${DESTDIRNAME}=${STAGEDIR}
12 .endif
13 QA_ENV+=        STAGEDIR=${STAGEDIR} \
14                 PREFIX=${PREFIX} \
15                 LOCALBASE=${LOCALBASE} \
16                 USESDESKTOPFILEUTILS=${USES:Mdesktop-file-utils} \
17                 USESSHAREDMIMEINFO=${USES:Mshared-mime-info} \
18                 "STRIP=${STRIP}"
19 CO_ENV+=        STAGEDIR=${STAGEDIR} \
20                 PREFIX=${PREFIX} \
21                 LOCALBASE=${LOCALBASE} \
22                 WRKDIR=${WRKDIR} \
23                 WRKSRC=${WRKSRC} \
24                 MTREE_FILE=${MTREE_FILE} \
25                 GNOME_MTREE_FILE=${GNOME_MTREE_FILE} \
26                 TMPPLIST=${TMPPLIST} \
27                 DOCSDIR=${DOCSDIR} \
28                 EXAMPLESDIR=${EXAMPLESDIR} \
29                 PLIST_SUB='${PLIST_SUB:NPREFIX=*:NLOCALBASE=*:NOSREL=*:NLIB32DIR=*:NDOCSDIR=*:NEXAMPLESDIR=*:N*="* *"}'
30
31 .if !target(stage-dir)
32 stage-dir:
33         @${MKDIR} ${STAGEDIR}${PREFIX}
34 .if !defined(NO_MTREE)
35         @${MTREE_CMD} ${MTREE_ARGS} ${STAGEDIR}${PREFIX} > /dev/null
36 .endif
37 .endif
38
39 # Compress all manpage not already compressed which are not hardlinks
40 # 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
41 # Fixes all dead symlinks left by the previous round
42 .if !target(compress-man)
43 compress-man:
44         @${ECHO_MSG} "====> Compressing man pages (compress-man)"
45         @mdirs= ; \
46         for dir in ${MANDIRS:S/^/${STAGEDIR}/} ; do \
47                 [ -d $$dir ] && mdirs="$$mdirs $$dir" ;\
48         done ; \
49         for dir in $$mdirs; do \
50                 ${FIND} $$dir -type f \! -name "*.gz" -links 1 -exec ${GZIP_CMD} {} \; ; \
51                 ${FIND} $$dir -type f \! -name "*.gz" \! -links 1 -exec ${STAT} -f '%i' {} \; | \
52                         ${SORT} -u | while read inode ; do \
53                                 unset ref ; \
54                                 for f in $$(${FIND} $$dir -type f -inum $${inode} -print); do \
55                                         if [ -z $$ref ]; then \
56                                                 ref=$${f}.gz ; \
57                                                 ${GZIP_CMD} $${f} ; \
58                                                 continue ; \
59                                         fi ; \
60                                         ${RM} -f $${f} ; \
61                                         (cd $${f%/*}; ${LN} -f $${ref##*/} $${f##*/}.gz) ; \
62                                 done ; \
63                         done ; \
64                 ${FIND} $$dir -type l \! -name "*.gz" | while read link ; do \
65                                 dest=$$(readlink $$link) ; \
66                                 rm -f $$link ; \
67                                 (cd $${link%/*} ; ${LN} -sf $${dest##*/}.gz $${link##*/}.gz) ;\
68                 done; \
69         done
70 .endif
71
72 .if !target(makeplist)
73 makeplist: stage
74         @${SETENV} ${CO_ENV} ${SH} ${SCRIPTSDIR}/check-stagedir.sh makeplist
75 .endif
76
77 .if !target(check-orphans)
78 check-orphans: stage
79         @${ECHO_MSG} "====> Items missing from pkg-plist (check-orphans)"
80         @${SETENV} ${CO_ENV} ${SH} ${SCRIPTSDIR}/check-stagedir.sh orphans
81 .endif
82
83 .if !target(stage-qa)
84 stage-qa:
85         @${ECHO_MSG} "====> Running Q/A tests (stage-qa)"
86         @${SETENV} ${QA_ENV} ${SH} ${SCRIPTSDIR}/qa.sh
87 .endif