summaryrefslogtreecommitdiff
path: root/mk/check/check-stripped.mk
blob: 4389c2e9e17fcc0750d045a7a08f267d5b7042c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# $NetBSD: check-stripped.mk,v 1.3 2008/12/15 12:28:49 rillig Exp $
#
# This file checks that after installation, all binaries conform to the
# setting of INSTALL_UNSTRIPPED.
#
# User-settable variables:
#
# CHECK_STRIPPED
#	Whether this check should be enabled or not.
#
#	Default value: "no".
#
# Package-settable variables:
#
# CHECK_STRIPPED_SKIP
#	The list of file patterns that are skipped by the check.
#
#	Default value: (empty)
#
#	Example: bin/* sbin/foo
#

.if defined(PKG_DEVELOPER)
CHECK_STRIPPED?=		no	# XXX: change to "yes" later
.else
CHECK_STRIPPED?=		no
.endif
CHECK_STRIPPED_SKIP?=		# empty

_CHECK_STRIPPED_FILELIST_CMD?=	${SED} -e '/^@/d' ${PLIST}

.if !empty(CHECK_STRIPPED:M[Yy][Ee][Ss])
privileged-install-hook: _check-stripped
.endif

_check-stripped: error-check .PHONY
	@${STEP_MSG} "Checking whether binaries are ${_INSTALL_UNSTRIPPED:Dun:U}stripped."
	${RUN} cd ${DESTDIR}${PREFIX};					\
	want_stripped=${_INSTALL_UNSTRIPPED:Dno:Uyes};			\
	${_CHECK_STRIPPED_FILELIST_CMD} | ${SORT} | ${SED} 's,\\,\\\\,g'\
	| while read file; do						\
		case "$$file" in					\
		${CHECK_STRIPPED_SKIP:@p@${p}) continue ;;@}		\
		*) ;;							\
		esac;							\
		dpfile=${DESTDIR}${PREFIX}/$$file;			\
		test -x "$$dpfile" || continue;				\
		if [ ! -r "$$dpfile" ]; then				\
			${DELAYED_WARNING_MSG} "[check-stripped.mk] File \"$$dpfile\" cannot be read."; \
			continue;					\
		fi;							\
		ftype=`LC_ALL=C ${FILE_CMD} $$dpfile`;			\
		case $$want_stripped,$$ftype in				\
		yes,*:*\ ELF\ *,\ not\ stripped*) ${DELAYED_ERROR_MSG} "[check-stripped.mk] $$dpfile should be stripped, but is not.";; \
		no,*:*\ ELF\ *,\ stripped*) ${DELAYED_ERROR_MSG} "[check-stripped.mk] $$dpfile should NOT be stripped, but it is.";; \
		no,*:*\ ELF\ *,\ not\ stripped*) : ${INFO_MSG} "[check-stripped.mk] $$dpfile is not stripped (ok).";; \
		yes,*:*\ ELF\ *,\ stripped*) : ${INFO_MSG} "[check-stripped.mk] $$dpfile is stripped (ok).";; \
		esac;							\
	done