From 17b940c610b3d0d2f5728cc43c4441a2ea63e4a8 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Mon, 4 Oct 2010 10:24:45 +0000 Subject: [PATCH] Finalize pn53x-tamashell integration (add readline m4, fiw minor warnings, adjust Makefile.am) --- configure.ac | 1 + examples/Makefile.am | 4 +-- examples/pn53x-diagnose.c | 1 - examples/pn53x-tamashell.c | 7 +++++ m4/readline.m4 | 52 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 m4/readline.m4 diff --git a/configure.ac b/configure.ac index 07bd952..87fcc52 100644 --- a/configure.ac +++ b/configure.ac @@ -125,6 +125,7 @@ if test x$ac_cv_with_cutter = xyes -a x$ac_cv_use_cutter = xno; then fi AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"]) +AC_CHECK_READLINE # Defines and C flags CFLAGS="$CFLAGS -std=c99" diff --git a/examples/Makefile.am b/examples/Makefile.am index 35c4e5a..830e456 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -66,9 +66,7 @@ pn53x_diagnose_LDADD = $(top_builddir)/libnfc/libnfc.la \ pn53x_tamashell_SOURCES = pn53x-tamashell.c pn53x_tamashell_LDADD = $(top_builddir)/libnfc/libnfc.la \ libnfcutils.la -# Should be guarded by test on availability of readline -#pn53x_tamashell_CFLAGS = -DHAVE_READLINE -#pn53x_tamashell_LDFLAGS = -lreadline +pn53x_tamashell_LDFLAGS = @READLINE_LIBS@ nfc_sam_SOURCES = nfc-sam.c nfc_sam_LDADD = $(top_builddir)/libnfc/libnfc.la \ diff --git a/examples/pn53x-diagnose.c b/examples/pn53x-diagnose.c index 78f9583..c26ed04 100644 --- a/examples/pn53x-diagnose.c +++ b/examples/pn53x-diagnose.c @@ -29,7 +29,6 @@ #include #include "nfc-utils.h" -// FIXME: Delete me #include "chips/pn53x.h" #define MAX_DEVICE_COUNT 16 diff --git a/examples/pn53x-tamashell.c b/examples/pn53x-tamashell.c index 4c91dd2..f2d08a7 100644 --- a/examples/pn53x-tamashell.c +++ b/examples/pn53x-tamashell.c @@ -17,23 +17,30 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif // HAVE_CONFIG_H #include #include #include #include #include + #if defined(HAVE_READLINE) # include # include #else extern FILE* stdin; #endif //HAVE_READLINE + #include #include #include "nfc-utils.h" +#include "chips/pn53x.h" + #define MAX_FRAME_LEN 264 int main(int argc, const char* argv[]) diff --git a/m4/readline.m4 b/m4/readline.m4 new file mode 100644 index 0000000..62f47ae --- /dev/null +++ b/m4/readline.m4 @@ -0,0 +1,52 @@ +dnl Based on wojtekka's m4 from http://wloc.wsinf.edu.pl/~kklos/ekg-20080219/m4/readline.m4 + +AC_DEFUN(AC_CHECK_READLINE,[ + AC_SUBST(READLINE_LIBS) + AC_SUBST(READLINE_INCLUDES) + + AC_ARG_WITH(readline, + [[ --with-readline[=dir] Compile with readline/locate base dir]], + if test "x$withval" = "xno" ; then + without_readline=yes + elif test "x$withval" != "xyes" ; then + with_arg="$withval/include:-L$withval/lib $withval/include/readline:-L$withval/lib" + fi) + + AC_MSG_CHECKING(for readline.h) + + if test "x$without_readline" != "xyes"; then + for i in $with_arg \ + /usr/include: \ + /usr/local/include:-L/usr/local/lib \ + /usr/pkg/include:-L/usr/pkg/lib; do + + incl=`echo "$i" | sed 's/:.*//'` + lib=`echo "$i" | sed 's/.*://'` + + if test -f $incl/readline/readline.h ; then + AC_MSG_RESULT($incl/readline/readline.h) + READLINE_LIBS="$lib -lreadline" + if test "$incl" != "/usr/include"; then + READLINE_INCLUDES="-I$incl/readline -I$incl" + else + READLINE_INCLUDES="-I$incl/readline" + fi + AC_DEFINE(HAVE_READLINE, 1, [define if you have readline]) + have_readline=yes + break + elif test -f $incl/readline.h -a "x$incl" != "x/usr/include"; then + AC_MSG_RESULT($incl/readline.h) + READLINE_LIBS="$lib -lreadline" + READLINE_INCLUDES="-I$incl" + AC_DEFINE(HAVE_READLINE, 1, [define if you have readline]) + have_readline=yes + break + fi + done + fi + + if test "x$have_readline" != "xyes"; then + AC_MSG_RESULT(not found) + fi +]) +