summaryrefslogtreecommitdiff
path: root/mk/configure
diff options
context:
space:
mode:
authorrillig <rillig>2006-10-02 15:42:47 +0000
committerrillig <rillig>2006-10-02 15:42:47 +0000
commit20f3f60ca014f5b72ff95673c929ab0f975821d5 (patch)
tree7750b7861fdca3c98e2cabb3eeadda0f4fec4863 /mk/configure
parent9c1886f0bcddea4229b47e87726e40e3621366c9 (diff)
downloadpkgsrc-20f3f60ca014f5b72ff95673c929ab0f975821d5.tar.gz
Added a new compile-time check that detects the usage of the "=="
operator in test(1). It is enabled by default when PKG_DEVELOPER is selected. In my private bulk build of about 3700 packages, there had been no false positive.
Diffstat (limited to 'mk/configure')
-rw-r--r--mk/configure/check-portability.mk63
-rw-r--r--mk/configure/configure.mk5
2 files changed, 67 insertions, 1 deletions
diff --git a/mk/configure/check-portability.mk b/mk/configure/check-portability.mk
new file mode 100644
index 00000000000..02a42fb0e3f
--- /dev/null
+++ b/mk/configure/check-portability.mk
@@ -0,0 +1,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
+
diff --git a/mk/configure/configure.mk b/mk/configure/configure.mk
index 44ba46a31ec..40a4eb11cd8 100644
--- a/mk/configure/configure.mk
+++ b/mk/configure/configure.mk
@@ -1,4 +1,4 @@
-# $NetBSD: configure.mk,v 1.9 2006/07/27 13:47:29 jlam Exp $
+# $NetBSD: configure.mk,v 1.10 2006/10/02 15:42:47 rillig Exp $
#
# CONFIGURE_SCRIPT is the path to the script to run in order to
# configure the software for building. If the path is relative,
@@ -32,6 +32,9 @@ _BUILD_DEFS+= CONFIGURE_ENV CONFIGURE_ARGS
.if defined(USE_PKGLOCALEDIR)
. include "${PKGSRCDIR}/mk/configure/replace-localedir.mk"
.endif
+.if defined(HAS_CONFIGURE)
+. include "${.PARSEDIR}/check-portability.mk"
+.endif
######################################################################
### configure (PUBLIC)