[Snek] [PATCH] Document dependency on a GNU awk extension

Rhys Kidd rhyskidd at gmail.com
Thu Feb 13 04:26:41 PST 2020


strtonum() is a GNU awk (gawk)-only extension. It is not portable, and other
implementations of awk may not support it.

Accordingly, document the dependency upon gawk specifically, and ensure snek
only calls gawk in it's Makefiles.

See further:
  - https://www.gnu.org/software/gawk/manual/html_node/Strtonum-Function.html
  - https://www.gnu.org/software/gawk/manual/html_node/String-Functions.html#index-strtonum_0028_0029-function-_0028gawk_0029

Signed-off-by: Rhys Kidd <rhyskidd at gmail.com>
---

Noticed this when trying to build and run the snek test suite on a big CPU
platform, which happened to have a non-GNU awk.

There are other ways to convert hexadecimals to integers in portable ways,
but for now -- let's at least to clear that a non-portable GNU awk
extension is being relied upon.

 README.md                  | 1 +
 ports/duemilanove/Makefile | 2 +-
 ports/itsybitsy3v/Makefile | 2 +-
 ports/itsybitsy5v/Makefile | 2 +-
 ports/mega/Makefile        | 2 +-
 ports/uduino/Makefile      | 2 +-
 6 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 8d4b2d1..f92f769 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,7 @@ tools and other dependencies installed.
 To build Snek you need these dependencies:
 
   * [Lola](https://keithp.com/cgit/lola.git/)
+  * [gawk](https://www.gnu.org/software/gawk/)
   * [gcc-avr](https://ccrma.stanford.edu/~juanig/articles/wiriavrlib/AVR_GCC.html)
   * [avr-libc](https://www.nongnu.org/avr-libc/)
   * [gcc-arm-none-eabi](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
diff --git a/ports/duemilanove/Makefile b/ports/duemilanove/Makefile
index 8e7a5a4..4ff49c9 100644
--- a/ports/duemilanove/Makefile
+++ b/ports/duemilanove/Makefile
@@ -84,7 +84,7 @@ $(HEX): $(ELF)
 
 $(ELF): $(SNEK_OBJ)
 	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
-	@awk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP)
+	@gawk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP)
 
 snek-duemilanove-install: snek-duemilanove-install.in
 	$(SNEK_SED) $^ > $@
diff --git a/ports/itsybitsy3v/Makefile b/ports/itsybitsy3v/Makefile
index e7c2a41..1c36f2d 100644
--- a/ports/itsybitsy3v/Makefile
+++ b/ports/itsybitsy3v/Makefile
@@ -38,7 +38,7 @@ all: $(ELF) $(HEX)
 
 $(PROG): Makefile $(SNEK_OBJ)
 	$(CC) $(CFLAGS) -o $@ $(SNEK_OBJ) $(LDFLAGS)
-	@awk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP)
+	@gawk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP)
 
 $(SNEK_OBJ): $(SNEK_INC)
 
diff --git a/ports/itsybitsy5v/Makefile b/ports/itsybitsy5v/Makefile
index f14cb0c..ee6974a 100644
--- a/ports/itsybitsy5v/Makefile
+++ b/ports/itsybitsy5v/Makefile
@@ -38,7 +38,7 @@ all: $(ELF) $(HEX) snek-itsybitsy-install
 
 $(PROG): Makefile $(SNEK_OBJ)
 	$(CC) $(CFLAGS) -o $@ $(SNEK_OBJ) $(LDFLAGS)
-	@awk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP)
+	@gawk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP)
 
 snek-itsybitsy-install: snek-itsybitsy-install.in
 	$(SNEK_SED) $^ > $@
diff --git a/ports/mega/Makefile b/ports/mega/Makefile
index 2c4c6ad..fb39d81 100644
--- a/ports/mega/Makefile
+++ b/ports/mega/Makefile
@@ -63,7 +63,7 @@ $(HEX): $(ELF)
 
 $(ELF): $(SNEK_OBJ)
 	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
-	@awk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP)
+	@gawk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP)
 
 snek-mega-install: snek-mega-install.in
 	$(SNEK_SED) $^ > $@
diff --git a/ports/uduino/Makefile b/ports/uduino/Makefile
index cfb93dd..9770600 100644
--- a/ports/uduino/Makefile
+++ b/ports/uduino/Makefile
@@ -38,7 +38,7 @@ all: $(ELF) $(HEX) snek-uduino-install
 
 $(PROG): Makefile $(SNEK_OBJ)
 	$(CC) $(CFLAGS) -o $@ $(SNEK_OBJ) $(LDFLAGS)
-	@awk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP)
+	@gawk '/__data_load_end/{printf("ROM used: %d bytes\n", strtonum($$1)); }' $(MAP)
 
 snek-uduino-install: snek-uduino-install.in
 	$(SNEK_SED) $^ > $@
-- 
2.20.1



More information about the Snek mailing list