Makefile bits adapted from regress/lib/libssl/interop/botan/Makefile.

<stdio.h>  required for stderr
<stdlib.h> required for exit(3)
<string.h> required for memcmp(3)

g++-8.4.0p12 on sparc64 prints coloured warnings/errors, but that is
enother issue.

On sparc64, `make CXX=clang++' without patch works as well.

A follow-up commit could skip only google chromium's unit tests as the only
C++ code, this way the other tests are always run.

Feedback? OK?
---
 regress/lib/libz/Makefile          | 15 +++++++++++++++
 regress/lib/libz/utils_unittest.cc |  3 +++
 2 files changed, 18 insertions(+)

diff --git a/regress/lib/libz/Makefile b/regress/lib/libz/Makefile
index 73e7871294d..ac760edd2af 100644
--- a/regress/lib/libz/Makefile
+++ b/regress/lib/libz/Makefile
@@ -6,6 +6,19 @@
 # google chromium has special test for libz bugs
 # 
https://chromium.googlesource.com/chromium/src/third_party/+/refs/heads/main/zlib/contrib/tests/utils_unittest.cc
 
+.include <bsd.own.mk>
+
+.if (${COMPILER_VERSION:L} != "clang" && ! exists(/usr/local/bin/eg++))
+regress:
+       @echo 'Run "pkg_add g++" to run unittests on GCC architectures'
+       @echo SKIPPED
+.else
+
+.if ${COMPILER_VERSION:L} != "clang" && ${CXX} == "c++"
+# C++11
+CXX = /usr/local/bin/eg++
+.endif
+
 PROGS=         example infcover minigzip utils_unittest
 SRCS_utils_unittest =  utils_unittest.cc
 LDADD=         -lz
@@ -43,4 +56,6 @@ run-utils_unittest-${tst}: utils_unittest
 
 .endfor
 
+.endif # (${COMPILER_VERSION:L} != "clang" && ! exists(/usr/local/bin/eg++))
+
 .include <bsd.regress.mk>
diff --git a/regress/lib/libz/utils_unittest.cc 
b/regress/lib/libz/utils_unittest.cc
index edb6a91b960..0c1228ba5af 100644
--- a/regress/lib/libz/utils_unittest.cc
+++ b/regress/lib/libz/utils_unittest.cc
@@ -33,6 +33,9 @@
 
 #include <assert.h>
 #include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <zlib.h>
 
 #define TEST(a, b)             void b(void)
-- 
2.38.1

Reply via email to