<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">This patch adds checks to the pkgsrc wrappers to see whether all
invocations of the compiler can see the CPPFLAGS, CFLAGS and CXXFLAGS.

See also:
* http://wiki.netbsd.se/index.php/Examples_for_pkgsrc-specific_mk.conf_files

Version 2

Index: scan
===================================================================
RCS file: /cvsroot/pkgsrc/mk/wrapper/scan,v
retrieving revision 1.1
diff -u -p -r1.1 scan
--- scan	4 Oct 2004 20:28:30 -0000	1.1
+++ scan	8 Jan 2007 02:54:09 -0000
@@ -42,3 +42,53 @@ for arg do
 	*)	;;
 	esac
 done
+
+# Test whether the user-provided CFLAGS and CPPFLAGS get through to the
+# real compiler.
+
+seen_c=no
+seen_CFLAGS=no
+seen_CPPFLAGS=no
+seen_CXXFLAGS=no
+seen_c_source=no
+seen_cxx_source=no
+
+for arg; do
+	case "$arg" in
+	-c)			seen_c=yes ;;
+	-Dpkgsrc_*_CFLAGS)	seen_CFLAGS=yes ;;
+	-Dpkgsrc_*_CPPFLAGS)	seen_CPPFLAGS=yes ;;
+	-Dpkgsrc_*_CXXFLAGS)	seen_CXXFLAGS=yes ;;
+	*.c)			seen_c_source=yes ;;
+	*.C | *.cxx | *.cpp | *.c++)	seen_cxx_source=yes ;;
+	esac
+done
+
+missing_flags() { # varname language commandline
+	echo "[mk/wrapper/scan] WARNING: (in `pwd`): $1 are missing in a $2 compilation: $3" &gt;&gt; $HOME/wrapper-warnings
+}
+too_many_flags() { # varname language commandline
+	echo "[mk/wrapper/scan] WARNING: (in `pwd`): $1 should not appear in a $2 compilation: $3" &gt;&gt; $HOME/wrapper-warnings
+}
+
+if [ $seen_c = yes ]; then
+
+	[ $seen_c_source,$seen_CPPFLAGS = yes,no ] \
+	&amp;&amp; missing_flags CPPFLAGS C "${0##*/} $*"
+
+	[ $seen_cxx_source,$seen_CPPFLAGS = yes,no ] \
+	&amp;&amp; missing_flags CPPFLAGS C++ "${0##*/} $*"
+
+	[ $seen_c_source,$seen_CFLAGS = yes,no ] \
+	&amp;&amp; missing_flags CFLAGS C "${0##*/} $*"
+
+	[ $seen_cxx_source,$seen_CXXFLAGS = yes,no ] \
+	&amp;&amp; missing_flags CXXFLAGS C++ "${0##*/} $*"
+
+	[ $seen_c_source,$seen_CXXFLAGS = yes,yes ] \
+	&amp;&amp; too_many_flags CXXFLAGS C "${0##*/} $*"
+
+	[ $seen_cxx_source,$seen_CFLAGS = yes,yes ] \
+	&amp;&amp; too_many_flags CFLAGS C++ "${0##*/} $*"
+
+fi
</pre></body></html>