+dnl Try to locate valid 8051 assembler to generate test files (.hex)
+run_tests=no
+
+AC_CHECK_PROG(AS504_CHECK,as504,yes)
+if test x"$AS504_CHECK" = x"yes" ; then
+ run_tests=yes
+
+ dnl Check if as504 has been patched to support option -O:
+ dnl See http://www.hugovil.com/repository/hvlinux/patches/as504-add-output-file-option.patch
+ AS504HV_CHECK=no
+ if as504 2>&1 | grep -q Ooutfile; then
+ AS504HV_CHECK=yes
+ fi
+fi
+
+AC_CHECK_PROG(ASEM51_CHECK,asem,yes)
+if test x"$ASEM51_CHECK" = x"yes" ; then
+ run_tests=yes
+fi
+
+if test x"$run_tests" != x"yes" ; then
+ AC_MSG_WARN([Please install as504 (http://www.vanwal.nl/as504/) or ASEM-51 (http://plit.de/asem-51) to run test suite.])
+fi
+
+AM_CONDITIONAL([RUN_TESTS],[test x"$run_tests" = x"yes"])
+AM_CONDITIONAL([USE_AS504HV],[test x"$AS504HV_CHECK" = x"yes"])
+AM_CONDITIONAL([USE_AS504],[test x"$AS504_CHECK" = x"yes"])
+AM_CONDITIONAL([USE_AS51],[test x"$ASEM51_CHECK" = x"yes"])
+
+dnl zlib required for its crc32 function
+ac_have_zlib=no
+
+PKG_CHECK_MODULES([zlib], [zlib > 1.2.1],
+ [AC_CHECK_LIB([z], [crc32],
+ [ac_have_zlib=yes],
+ [ac_have_zlib=no])])
+
+if test x"$ac_have_zlib" = x"yes" ; then
+ ZLIB_LIBS='-lz'
+ AC_SUBST(ZLIB_LIBS)
+else
+ AC_MSG_ERROR([Please install zlib and zlib-devel packages])
+fi
+
+AC_SUBST(WARNINGCFLAGS)