From 28a3689672e316cab0e0c42fb870648cb307dac6 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 29 Jun 2012 15:25:35 -0300 Subject: [PATCH] tools/: add cross-compilation for the Ben NanoNote This uses the OpenWRT toolchain. It creates a static executable that will also run on JLime. Graphical output is disabled so far. --- tools/Makefile | 16 +++++++++++----- tools/antorcha.c | 9 +++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 6811779..15604d7 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -16,16 +16,22 @@ MAIN = antorcha CFLAGS = -g -I../fw -I../../ben-wpan/tools/include \ -I../../ben-wpan/atusb/fw/include \ -Wall \ - $(shell sdl-config --cflags) -LDLIBS = -L../../ben-wpan/tools/lib -latrf -lusb \ - $(shell sdl-config --libs) -lSDL_gfx + $(if $(NOGFX),, -DGFX $(shell sdl-config --cflags)) \ + $(if $(BEN), -static) -OBJS = antorcha.o hash.o plot.o +LDLIBS = -L../../ben-wpan/tools/lib -latrf \ + $(if $(NOGFX),, $(shell sdl-config --libs) -lSDL_gfx) \ + $(if $(BEN),, -usb) -.PHONY: all update ping off +OBJS = antorcha.o hash.o $(if $(NOGFX),, plot.o) + +.PHONY: all ben update ping off all: $(MAIN) +ben: + $(MAKE) NOGFX=y BEN=y CC=mipsel-openwrt-linux-gcc + $(MAIN): $(OBJS) $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDLIBS) diff --git a/tools/antorcha.c b/tools/antorcha.c index abcd3ab..6dff424 100644 --- a/tools/antorcha.c +++ b/tools/antorcha.c @@ -437,9 +437,12 @@ static void samples(struct atrf_dsc *dsc, int gui) buf[0] = 1; packet(dsc, SAMPLE, 0, 0, buf, PAYLOAD); + +#ifdef GFX if (gui) plot_init(); else +#endif signal(SIGINT, sigint); while (run) { got = rf_recv(dsc, buf, sizeof(buf)); @@ -475,11 +478,15 @@ static void samples(struct atrf_dsc *dsc, int gui) if (!gui) printf("%11.6f\t%d\n", t, y); +#ifdef GFX if (gui && !plot(x, y)) goto quit; +#endif } } +#ifdef GFX quit: +#endif buf[0] = 0; packet(dsc, SAMPLE, 0, 0, buf, PAYLOAD); } @@ -513,7 +520,9 @@ static void usage(const char *name) " -P ping (version query)\n" " -R reset\n" " -S sample with output on stdout. Exit with ^C.\n" +#ifdef GFX " -S -S sample with graphical output. Exit with Q.\n\n" +#endif "Parameters:\n" , name, "", name, "", name, "", name, "", name); for (m = map; m->name; m++)