ao-tools: Allow building without stlink and readline
authorKeith Packard <keithp@keithp.com>
Sun, 8 Dec 2013 19:07:46 +0000 (11:07 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 8 Dec 2013 19:07:46 +0000 (11:07 -0800)
This adds --without-stlink and --without-readline options to configure
to disable these features, and adjusts the build process and code to
handle that.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/Makefile.am
ao-tools/ao-dbg/Makefile.am
ao-tools/ao-dbg/ao-dbg-main.c
ao-tools/ao-elftohex/Makefile.am
ao-tools/ao-stmload/Makefile.am
ao-tools/ao-usbload/Makefile.am
configure.ac

index 02d6c227e2a9835cf9f5fe3831a95c7583e22490..d40648d84fda007adc588283ecdb4d449f255fdb 100644 (file)
@@ -1,4 +1,7 @@
 SUBDIRS=lib ao-rawload ao-dbg ao-bitbang ao-eeprom ao-list \
-       ao-load ao-telem ao-stmload ao-send-telem ao-sky-flash \
+       ao-load ao-telem ao-send-telem ao-sky-flash \
        ao-dumpflash ao-edit-telem ao-dump-up ao-elftohex \
        ao-flash
+if LIBSTLINK
+SUBDIRS += ao-stmload
+endif
index ad2cb28081a4811cec5cc4dbb252a054d36b9521..2c33cf0677cee345151df0716a580971c4454be2 100644 (file)
@@ -7,6 +7,6 @@ man_MANS = ao-dbg.1
 
 ao_dbg_DEPENDENCIES = $(AO_DBG_LIBS)
 
-ao_dbg_LDADD=$(AO_DBG_LIBS) $(LIBUSB_LIBS)  -lreadline
+ao_dbg_LDADD=$(AO_DBG_LIBS) $(LIBUSB_LIBS) $(LIBREADLINE)
 
 ao_dbg_SOURCES = ao-dbg-parse.c ao-dbg-command.c ao-dbg-main.c
index 21b83a3dbc2b6c01327f05fe1e72ae59111b400a..25eca54b149cb7dae8ec654721ddd4ca043cbfd9 100644 (file)
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "ao-dbg.h"
 #include <unistd.h>
 #include <sys/types.h>
@@ -204,13 +208,16 @@ s51_putc(int c)
        putc(c, s51_output);
 }
 
+#if HAVE_LIBREADLINE
 #include <readline/readline.h>
 #include <readline/history.h>
+#endif
 
 int
 s51_read_line(char *line, int len)
 {
        int ret;
+#if HAVE_LIBREADLINE
        if (s51_output == stdout && s51_input == stdin && s51_prompt) {
                char *r;
 
@@ -221,7 +228,9 @@ s51_read_line(char *line, int len)
                line[len-1] = '\0';
                add_history(r);
                return 1;
-       } else {
+       } else
+#endif
+       {
                if (s51_prompt)
                        s51_printf("%s", s51_prompt);
                else
index 33c9923f46ca752089af40f1ec54b05663a2581e..dd0046d7b04bfbb56c26c5e5283776dae66d3d0b 100644 (file)
@@ -1,18 +1,12 @@
-if LIBSTLINK
-
 bin_PROGRAMS=ao-elftohex
 
-LIBSTLINKDIR=/local/src/stlink
-
-AM_CFLAGS=-I$(top_srcdir)/ao-tools/lib $(LIBSTLINK_CFLAGS) $(LIBUSB_CFLAGS)
-AO_STMLOAD_LIBS=$(top_builddir)/ao-tools/lib/libao-tools.a
+AM_CFLAGS=-I$(top_srcdir)/ao-tools/lib $(LIBUSB_CFLAGS)
+AO_ELFTOHEX_LIBS=$(top_builddir)/ao-tools/lib/libao-tools.a
 
-ao_elftohex_DEPENDENCIES = $(AO_STMLOAD_LIBS)
+ao_elftohex_DEPENDENCIES = $(AO_ELFTOHEX_LIBS)
 
-ao_elftohex_LDADD=$(AO_STMLOAD_LIBS) $(LIBSTLINK_LIBS) $(LIBUSB_LIBS) -lelf
+ao_elftohex_LDADD=$(AO_ELFTOHEX_LIBS) -lelf
 
 ao_elftohex_SOURCES=ao-elftohex.c
 
 man_MANS = ao-elftohex.1
-
-endif
index 9ed286cc33ec54b0f2262a3ba881fe78816bd230..45eb6216787f5afe2d50e68f497eb9b34744c914 100644 (file)
@@ -2,14 +2,12 @@ if LIBSTLINK
 
 bin_PROGRAMS=ao-stmload
 
-LIBSTLINKDIR=/local/src/stlink
-
-AM_CFLAGS=-I$(top_srcdir)/ao-tools/lib $(LIBSTLINK_CFLAGS) $(LIBUSB_CFLAGS)
+AM_CFLAGS=-I$(top_srcdir)/ao-tools/lib $(STLINK_CFLAGS) $(LIBUSB_CFLAGS)
 AO_STMLOAD_LIBS=$(top_builddir)/ao-tools/lib/libao-tools.a
 
 ao_stmload_DEPENDENCIES = $(AO_STMLOAD_LIBS)
 
-ao_stmload_LDADD=$(AO_STMLOAD_LIBS) $(LIBSTLINK_LIBS) $(LIBUSB_LIBS) -lelf
+ao_stmload_LDADD=$(AO_STMLOAD_LIBS) $(STLINK_LIBS) $(LIBUSB_LIBS) -lelf
 
 ao_stmload_SOURCES=ao-stmload.c ao-stmload.h
 
index 144e25df0a9d66f962eb2c65687100e1e9cfa9a2..e3b63a85f6fffeb01c0451a3bac4946397f16292 100644 (file)
@@ -1,5 +1,3 @@
-if LIBSTLINK
-
 bin_PROGRAMS=ao-usbload
 
 AM_CFLAGS=-I$(top_srcdir)/ao-tools/lib $(LIBUSB_CFLAGS)
@@ -12,5 +10,3 @@ ao_usbload_LDADD=$(AO_STMLOAD_LIBS) $(LIBUSB_LIBS) -lelf
 ao_usbload_SOURCES=ao-usbload.c ao-usbload.h
 
 man_MANS = ao-usbload.1
-
-endif
index a2a22063d3e78db216a7cc0f0e7d051a7d34e9a7..aa957b1fb5112bbf766de420a49ed3b7befbf5a4 100644 (file)
@@ -26,7 +26,6 @@ AM_MAINTAINER_MODE
 VERSION_DASH=`echo $VERSION | sed 's/\./-/g'`
 AC_SUBST(VERSION_DASH)
 
-
 dnl ==========================================================================
 dnl Java library versions
 
@@ -365,16 +364,50 @@ if test "x$HAVE_NICKLE" = "xno"; then
        AC_MSG_ERROR([Please install nickle to build AltOs])
 fi
 
-AC_CHECK_LIB(readline, readline)
+AC_ARG_WITH([readline],
+           [AS_HELP_STRING([--with-readline],
+                             [enable readline functionality in ao-dbg @<:@default=auto@:>@])],
+             [],
+             [with_readline=auto])
+                             
+LIBREADLINE_LIBS=
+
+if test x"$with_readline" != "xno"; then
+       AC_CHECK_LIB([readline], [main],
+                      [AC_SUBST([LIBREADLINE], ["-lreadline -lncurses"])
+                      AC_DEFINE([HAVE_LIBREADLINE], [1],
+                         [Define if you have libreadline])],
+                     [if test "x$with_readline" != xauto; then
+                        AC_MSG_ERROR([--with-readline was given, but test for readline failed])
+                      fi],
+                      -lncurses)
+fi
 
 PKG_CHECK_MODULES([LIBUSB], [libusb-1.0])
 
 AC_CHECK_HEADERS(libelf.h libelf/libelf.h, [break])
 AC_CHECK_HEADERS(gelf.h libelf/gelf.h, [break])
 
-PKG_CHECK_MODULES([LIBSTLINK], [stlink], [HAVE_STLINK=yes], [HAVE_STLINK=no])
+AC_ARG_WITH([stlink],
+           [AS_HELP_STRING([--with-stlink],
+                           [Build tools that use the stlink library (default: auto)])],
+           [],
+           [with_stlink=auto])
+
+if test x"$with_stlink" != "xno"; then
+       PKG_CHECK_MODULES([STLINK], [stlink], [HAVE_STLINK=yes], [HAVE_STLINK=no])
+       if test x"$HAVE_STLINK" = "xno" -a x"$with_stlink" != "xauto"; then
+               AC_MSG_ERROR([--with-stlink was given, but stlink was not found])
+       fi
+else
+       HAVE_STLINK=no
+fi
+
+if test x"$HAVE_STLINK" = "xyes"; then
+       AC_DEFINE(HAVE_STLINK,1,[Using STlink library])
+fi
 
-AM_CONDITIONAL([LIBSTLINK], [test x$HAVE_STLINK != xno])
+AM_CONDITIONAL([LIBSTLINK], [test x$HAVE_STLINK == xyes])
 
 AC_OUTPUT([
 Makefile