summaryrefslogtreecommitdiff
path: root/mk/configure/check-portability.mk
blob: 02a42fb0e3f37f2c3774ef861e38f059dd10e5b2 (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
60
61
62
63
# $NetBSD: check-portability.mk,v 1.1 2006/10/02 15:42:47 rillig Exp $
#
# This file contains some checks that are applied to the configure
# scripts to check for certain constructs that are known to cause
# problems on some platforms.
#
# The following variables may be set by the pkgsrc user in mk.conf:
#
# CHECK_PORTABILITY: YesNo
#	Whether to enable some portability checks for the configure
#	scripts before they are run.
#
#	Default value: yes for PKG_DEVELOPERs, no otherwise.
#
# The following variables may be set by the package:
#
# SKIP_PORTABILITY_CHECKS: YesNo
#	Whether the above checks should be skipped for the current
#	package.
#
#	Default value: no
#

.if !empty(PKG_DEVELOPER:M[Yy][Ee][Ss])
CHECK_PORTABILITY?=		yes
.endif
CHECK_PORTABILITY?=		no
SKIP_PORTABILITY_CHECK?=	no

_RE_TEST=	-e "test[ 	]*[^	 ].*=="
_RE_TEST+=	-e "\\[[ 	].*==.*[ 	]\\]"

.if ${CHECK_PORTABILITY:M[Yy][Ee][Ss]} != "" && \
    ${SKIP_PORTABILITY_CHECK:M[Yy][Ee][Ss]} == ""
do-configure-pre-hook: _configure-check-for-test
.endif
.PHONY: _configure-check-for-test
_configure-check-for-test:
	@${STEP_MSG} "Checking for \"test ... == ...\" in configure scripts"
.for d in ${CONFIGURE_DIRS}
	${_PKG_SILENT}${_PKG_DEBUG}set -e;				\
	cd ${WRKSRC}; cd ${d};						\
	case `sed '1q' < ${CONFIGURE_SCRIPT}` in			\
	"#!"*"/bin/sh")							\
		found=no;						\
		while read line; do					\
			set args $$line; shift;				\
			while [ $$# -ge 3 ]; do				\
				if [ ":$$1" = ":test" ] && [ ":$$3" = ":==" ]; then \
					found=yes;			\
					${ERROR_MSG} "[configure.mk] $$line"; \
				fi;					\
				shift;					\
			done;						\
			if [ "$$found" = "yes" ]; then			\
				${ERROR_MSG} "[configure.mk] Found test ... == ... in configure script."; \
				exit 1;					\
			fi;						\
		done < ${CONFIGURE_SCRIPT};				\
		;;							\
	esac
.endfor