Tests for wiringPi are now not fatal

Fri, 02 May 2014 23:14:50 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 02 May 2014 23:14:50 +0200
changeset 17
b802305046dc
parent 16
f4cbe008da72
child 18
3f4823083b9d

Tests for wiringPi are now not fatal

config.h.in file | annotate | diff | comparison | revisions
configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
lib/mbselib.h file | annotate | diff | comparison | revisions
lib/rdconfig.c file | annotate | diff | comparison | revisions
--- a/config.h.in	Fri May 02 21:04:20 2014 +0200
+++ b/config.h.in	Fri May 02 23:14:50 2014 +0200
@@ -9,3 +9,6 @@
 /* According to Sun we MUST define this in the source */
 #define _REENTRANT 1
 
+/* Define if you have the <wiringPi.h> header file. */
+#undef HAVE_WIRINGPI_H
+
--- a/configure	Fri May 02 21:04:20 2014 +0200
+++ b/configure	Fri May 02 23:14:50 2014 +0200
@@ -584,6 +584,42 @@
 
 ac_unique_file="thermometers/main.c"
 ac_default_prefix=/usr/local
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
 CXXFLAGS
@@ -1479,6 +1515,93 @@
 
 } # ac_fn_c_try_cpp
 
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if eval \${$3+:} false; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_mongrel
+
 # ac_fn_c_try_run LINENO
 # ----------------------
 # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
@@ -1520,6 +1643,37 @@
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_run
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -2942,6 +3096,8 @@
   as_fn_error $? "libmosquitto not found" "$LINENO" 5
 fi
 
+
+WIRINGPI=No
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wiringPiSetup in -lwiringPi" >&5
 $as_echo_n "checking for wiringPiSetup in -lwiringPi... " >&6; }
 if ${ac_cv_lib_wiringPi_wiringPiSetup+:} false; then :
@@ -2986,40 +3142,7 @@
 
 if test "$result" = "yes"; then
   LIBS="$LIBS -lwiringPi -lwiringPiDev"
-else
-  as_fn_error $? "libwiringPi not found" "$LINENO" 5
-fi
-
-
-#
-# Additional commandline switches
-#
-# Check whether --enable-experiment was given.
-if test "${enable_experiment+set}" = set; then :
-  enableval=$enable_experiment;  experiment=$enableval
-else
-   experiment=no
-fi
-
-if test "$experiment" = "yes"; then
-  $as_echo "#define USE_EXPERIMENT 1" >>confdefs.h
-
-fi
-
-# Check whether --enable-debugging was given.
-if test "${enable_debugging+set}" = set; then :
-  enableval=$enable_debugging;  debugging=$enableval
-else
-   debugging=no
-fi
-
-if test "$debugging" = "yes"; then
-  CFLAGS="-O -g -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline"
-else
-  CFLAGS="-g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline"
-fi
-
-ac_ext=c
+  ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -3399,6 +3522,180 @@
 
 fi
 
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+		  inttypes.h stdint.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in wiringPi.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "wiringPi.h" "ac_cv_header_wiringPi_h" "$ac_includes_default"
+if test "x$ac_cv_header_wiringPi_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_WIRINGPI_H 1
+_ACEOF
+ WIRINGPI=Yes
+else
+  WIRINGPI=No
+fi
+
+done
+
+fi
+
+
+#
+# Additional commandline switches
+#
+# Check whether --enable-experiment was given.
+if test "${enable_experiment+set}" = set; then :
+  enableval=$enable_experiment;  experiment=$enableval
+else
+   experiment=no
+fi
+
+if test "$experiment" = "yes"; then
+  $as_echo "#define USE_EXPERIMENT 1" >>confdefs.h
+
+fi
+
+# Check whether --enable-debugging was given.
+if test "${enable_debugging+set}" = set; then :
+  enableval=$enable_debugging;  debugging=$enableval
+else
+   debugging=no
+fi
+
+if test "$debugging" = "yes"; then
+  CFLAGS="-O -g -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline"
+else
+  CFLAGS="-g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline"
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+		   (('a' <= (c) && (c) <= 'i') \
+		     || ('j' <= (c) && (c) <= 'r') \
+		     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+	|| toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
 
 
 
@@ -4685,6 +4982,7 @@
 
     Version : ............ ${VERSION}
     Main directory : ..... ${prefix}
+    WiringPi : ........... ${WIRINGPI}
 
   Now type 'make' and 'sudo make install'
 " >&5
@@ -4695,6 +4993,7 @@
 
     Version : ............ ${VERSION}
     Main directory : ..... ${prefix}
+    WiringPi : ........... ${WIRINGPI}
 
   Now type 'make' and 'sudo make install'
 " >&6; }
--- a/configure.ac	Fri May 02 21:04:20 2014 +0200
+++ b/configure.ac	Fri May 02 23:14:50 2014 +0200
@@ -27,7 +27,6 @@
 dnl Try to find GNU install
 AC_CHECK_PROG(INSTALL, ginstall, ginstall)
 AC_CHECK_PROG(INSTALL, install, install)
-dnl AC_PROG_MAKE_SET
 AC_CHECK_PROG(TAR, tar, tar)
 
 #
@@ -40,11 +39,12 @@
   AC_MSG_ERROR(libmosquitto not found)
 fi
 
+
+WIRINGPI=No
 AC_CHECK_LIB(wiringPi,wiringPiSetup,result=yes,result=no)
 if test "$result" = "yes"; then
   LIBS="$LIBS -lwiringPi -lwiringPiDev"
-else
-  AC_MSG_ERROR(libwiringPi not found)
+  AC_CHECK_HEADERS(wiringPi.h,WIRINGPI=Yes,WIRINGPI=No)
 fi
 
 
@@ -80,6 +80,7 @@
 
     Version : ............ ${VERSION}
     Main directory : ..... ${prefix}
+    WiringPi : ........... ${WIRINGPI}
 
   Now type 'make' and 'sudo make install'
 ])
--- a/lib/mbselib.h	Fri May 02 21:04:20 2014 +0200
+++ b/lib/mbselib.h	Fri May 02 23:14:50 2014 +0200
@@ -51,6 +51,10 @@
     char		*mosq_host;		/* mosquitto server hostname	*/
     int			mosq_port;		/* mosquitto server port	*/
     w1_therm		*w1therms;		/* 1-wire temp sensors		*/
+#ifdef HAVE_WIRINGPI_H
+    int			lcd_cols;		/* LCD display columns		*/
+    int			lcd_rows;		/* LCD display rows		*/
+#endif
 } sys_config;
 
 
--- a/lib/rdconfig.c	Fri May 02 21:04:20 2014 +0200
+++ b/lib/rdconfig.c	Fri May 02 23:14:50 2014 +0200
@@ -48,6 +48,10 @@
     {(char *)"mosq_host",	getstr,		&Config.mosq_host},
     {(char *)"mosq_port",	getint,		(char **)&Config.mosq_port},
     {(char *)"w1therm",		getw1,		(char **)&Config.w1therms},
+#ifdef HAVE_WIRINGPI_H
+    {(char *)"lcd_cols",	getint,		(char **)&Config.lcd_cols},
+    {(char *)"lcd_rows",	getint,		(char **)&Config.lcd_rows},
+#endif
     {NULL,			NULL,		NULL}
 };
 
@@ -77,6 +81,11 @@
 	free(tmp1);
     }
     Config.w1therms = NULL;
+
+#ifdef HAVE_WIRINGPI_H
+    Config.lcd_cols = 16;
+    Config.lcd_rows = 2;
+#endif
 }
 
 

mercurial