1 # $NetBSD: checksum.mk,v 1.16 2011/09/08 20:17:15 abs Exp $
3 # See bsd.checksum.mk for helpful comments.
6 _DIGEST_ALGORITHMS?
= SHA1 RMD160
7 _PATCH_DIGEST_ALGORITHMS?
= SHA1
9 # These variables are set by pkgsrc/mk/fetch/bsd.fetch-vars.mk.
10 #_CKSUMFILES?= # empty
11 #_IGNOREFILES?= # empty
14 # The file whose presence determines whether or not the checksum
17 # This is not a traditional cookie file. We do not actually
18 # wish to create a cookie file for the completion of the checksum
19 # phase because we want to be able to detect if any of the files
20 # have changed right up until the distfiles are extracted.
21 # Therefore, we use the presence of the cookie file from the
22 # "extract" phase to determine whether we need to continue to
25 # _COOKIE.extract is defined in pkgsrc/mk/extract/extract.mk.
27 _COOKIE.checksum
= ${_COOKIE.extract
}
30 ${PKGSRC_SETENV} DIGEST
=${TOOLS_DIGEST
:Q
} CAT
=${TOOLS_CAT
:Q
} \
31 ECHO
=${TOOLS_ECHO
:Q
} SED
=${TOOLS_SED
:Q
} \
32 TEST
=${TOOLS_TEST
:Q
} \
33 ${SH} ${PKGSRCDIR}/mk
/checksum
/checksum \
35 .if defined
(NO_CHECKSUM
) || empty
(_CKSUMFILES
)
36 checksum checksum-phase
:
39 checksum checksum-phase
:
41 case
${.TARGET
:Q
} in \
42 *-phase
) ${TEST} ! -f
${_COOKIE.checksum
} || exit
0 ;; \
44 if cd
${DISTDIR} && ${_CHECKSUM_CMD} ${DISTINFO_FILE} ${_CKSUMFILES}; then \
47 ${ERROR_MSG} "Make sure the Makefile and checksum file (${DISTINFO_FILE})"; \
48 ${ERROR_MSG} "are up to date. If you want to override this check, type"; \
49 ${ERROR_MSG} "\"${MAKE} NO_CHECKSUM=yes [other args]\"."; \
54 _DISTINFO_CMD
= ${PKGSRC_SETENV} DIGEST
=${TOOLS_DIGEST
:Q
} SED
=${TOOLS_SED
:Q
} \
55 TEST
=${TOOLS_TEST
:Q
} WC
=${TOOLS_WC
:Q
} LC_ALL
=C \
56 ${AWK} -f
${PKGSRCDIR}/mk
/checksum
/distinfo.awk
--
58 .if exists
(${DISTDIR})
59 _DISTINFO_ARGS_COMMON
+= -d
${DISTDIR}
61 .if exists
(${DISTINFO_FILE})
62 _DISTINFO_ARGS_COMMON
+= -f
${DISTINFO_FILE}
64 .if defined
(_DIGEST_ALGORITHMS
) && !empty
(_DIGEST_ALGORITHMS
)
65 _DISTINFO_ARGS_COMMON
+= ${_DIGEST_ALGORITHMS
:S
/^
/-a
/}
67 .if defined
(_PATCH_DIGEST_ALGORITHMS
) && !empty
(_PATCH_DIGEST_ALGORITHMS
)
68 _DISTINFO_ARGS_COMMON
+= ${_PATCH_DIGEST_ALGORITHMS
:S
/^
/-p
/}
71 .if defined
(_CKSUMFILES
) && !empty
(_CKSUMFILES
)
72 _DISTINFO_ARGS_DISTSUM
+= ${_CKSUMFILES
:S
/^
/-c
/}
74 .if defined
(_IGNOREFILES
) && !empty
(_IGNOREFILES
)
75 _DISTINFO_ARGS_DISTSUM
+= ${_IGNOREFILES
:S
/^
/-i
/}
78 _DISTINFO_ARGS_PATCHSUM
+= ${PATCHDIR}/patch-
*
79 _DISTINFO_ARGS_PATCHSUM
+= ${PATCHDIR}/emul-
*-patch-
*
83 newfile
=${DISTINFO_FILE}.
$$$$; \
84 if
${_DISTINFO_CMD} ${_DISTINFO_ARGS_COMMON} \
85 ${_DISTINFO_ARGS_DISTSUM} \
86 ${_DISTINFO_ARGS_PATCHSUM} > $$newfile; \
89 ${ECHO_MSG} "=> distinfo: unchanged."; \
91 ${MV} -f
$$newfile ${DISTINFO_FILE}; \
96 newfile
=${DISTINFO_FILE}.
$$$$; \
97 if
${_DISTINFO_CMD} ${_DISTINFO_ARGS_COMMON} \
98 ${_DISTINFO_ARGS_DISTSUM} > $$newfile; \
100 ${RM} -f
$$newfile; \
101 ${ECHO_MSG} "=> distinfo: distfiles part unchanged."; \
103 ${MV} -f
$$newfile ${DISTINFO_FILE}; \
108 newfile
=${DISTINFO_FILE}.
$$$$; \
109 if
${_DISTINFO_CMD} ${_DISTINFO_ARGS_COMMON} \
110 ${_DISTINFO_ARGS_PATCHSUM} > $$newfile; \
112 ${RM} -f
$$newfile; \
113 ${ECHO_MSG} "=> distinfo: patches part unchanged."; \
115 ${MV} -f
$$newfile ${DISTINFO_FILE}; \
118 .PHONY
: depends-checksum
121 ${_DEPENDS_WALK_CMD} ${PKGPATH} | \
123 ${ECHO} "===> Checksumming for $${dir}" && \
124 cd
${.CURDIR
}/..
/..
/$$dir && \
125 ${RECURSIVE_MAKE} ${MAKEFLAGS} checksum
; \