diff --git a/atusb/fw3/Makefile b/atusb/fw3/Makefile index c32432a..8479b89 100644 --- a/atusb/fw3/Makefile +++ b/atusb/fw3/Makefile @@ -53,20 +53,39 @@ endif # ----- Rules ----------------------------------------------------------------- -.PHONY: all clean upload prog +.PHONY: all clean upload prog version.c -all: $(NAME).bin +all: $(NAME).bin $(NAME).elf: $(OBJS) - $(CC) $(CFLAGS) -mmcu=$(CHIP) -o $@ $(OBJS) + $(MAKE) version.o + $(CC) $(CFLAGS) -mmcu=$(CHIP) -o $@ $(OBJS) version.o %.bin: %.elf $(BUILD) $(OBJCOPY) -j .text -j .data -O binary $< $@ + @echo "build #`cat .version`, `ls -l $@`" # ----- Cleanup --------------------------------------------------------------- clean: rm -f $(NAME).bin $(NAME).elf $(OBJS) $(OBJS:.o=.d) + rm -f version.c version.d version.o + +# ----- Build version --------------------------------------------------------- + +version.c: + @if [ -f .version ]; then \ + v=`cat .version`; \ + expr $$v + 1 >.version; \ + else \ + echo 0 >.version; \ + fi + @[ -s .version ] || echo 0 >.version + @echo '/* MACHINE-GENERATED. DO NOT EDIT ! */' >version.c + @echo '#include "version.h"' >>version.c + @echo "const char *build_date = \"`date`\";" >>version.c + @echo "const uint16_t build_number = `cat .version`;" \ + >>version.c # ----- Dependencies ---------------------------------------------------------- diff --git a/atusb/fw3/ep0.c b/atusb/fw3/ep0.c index 443ba9f..10c920f 100644 --- a/atusb/fw3/ep0.c +++ b/atusb/fw3/ep0.c @@ -27,14 +27,12 @@ #include "at86rf230.h" #include "atusb/ep0.h" -//#include "version.h" +#include "version.h" #include "board.h" #include "spi.h" #define HW_TYPE HW_TYPE_110131 -static const char *build_date = "today"; -static unsigned build_number = 42; #define debug(...) #define error(...) diff --git a/atusb/fw3/version.h b/atusb/fw3/version.h new file mode 100644 index 0000000..0db5c44 --- /dev/null +++ b/atusb/fw3/version.h @@ -0,0 +1,23 @@ +/* + * boot/version.h - Automatically generated version string + * + * Written 2008, 2011 by Werner Almesberger + * Copyright 2008, 2011 Werner Almesberger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + + +#ifndef VERSION_H +#define VERSION_H + +#include + + +extern const char *build_date; +extern const uint16_t build_number; + +#endif /* !VERSION_H */