diff --git a/Makefile b/Makefile index d73f160..3e82ec7 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # LuPI2 Makefile # Default compiler settings. -PREFIX?=musl +PREFIX?=x86_64-linux-musl CC = $(PREFIX)-gcc CFLAGS?=-O2 -std=c99 diff --git a/README.md b/README.md index 0041c80..2d6949b 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ intuitive languages. It has only 6 types, very simple syntax, yet supports many Build ----- 1. Clone this repository -2. Get musl libc (with musl-gcc wrapper), or compile musl cross compiler(like arm-linux-musleabihf) +2. Get musl cross compiler(like arm-linux-musleabihf), simplest way is to use [musl-cross](https://github.com/GregorR/musl-cross) 3. Get `xxd` utility (usually packaged with vim) -4. Build dependencies using scripts/dependencies.sh script +4. Build dependencies using scripts/dependencies.sh script for your platform(s) 5. Execute `make build` 6. You will need to put some OS to `root` directory where you run the binary. For now you can get plan9k at https://cloud.magik6k.net/index.php/s/7jPRAU037dzt8Ga/download diff --git a/scripts/dependencies.sh b/scripts/dependencies.sh index 7d52649..263a821 100755 --- a/scripts/dependencies.sh +++ b/scripts/dependencies.sh @@ -1,32 +1,39 @@ #!/bin/bash #TOOL=arm-musl-linuxeabihf -TOOL=x86_64-unknown-linux-gnu -OPENSSL_TARGET=linux-generic32 +TOOL=x86_64-linux-musl +OPENSSL_TARGET=linux-generic64 OUT=$TOOL -# TODO: more targets / host target / musl target from host +# TODO: more targets / host target if [ $# -lt 1 ] then - echo "Usage : $0 [arm32-musl|x86_64|musl]" + echo "Usage : $0 [all|arm32|x86_64|i486]" exit fi case "$1" in - arm32-musl ) + all ) + TARGETS=(arm32 i486 x86_64) + for i in ${TARGETS[@]}; do + ./$0 $i + done + ;; + arm32 ) TOOL=arm-linux-musleabihf OUT=$TOOL OPENSSL_TARGET=linux-generic32 ;; + i486 ) + TOOL=i486-linux-musl + OUT=$TOOL + OPENSSL_TARGET=linux-generic32 + ;; x86_64 ) - TOOL=x86_64-unknown-linux-gnu + TOOL=x86_64-linux-musl OUT=$TOOL OPENSSL_TARGET=linux-generic64 ;; - musl ) - TOOL=x86_64-unknown-linux-gnu - OUT=musl - OPENSSL_TARGET=linux-generic64 - ;; + *) echo "Invalid target!" ; exit 1 ;; esac diff --git a/src/lua/core/gpio.lua b/src/lua/core/gpio.lua index 85abc38..31f72b1 100644 --- a/src/lua/core/gpio.lua +++ b/src/lua/core/gpio.lua @@ -51,7 +51,7 @@ gpio.register = function () checkArg(1, pin, "number") checkArg(2, pin, "boolean", "number", "nil") pin = tostring(math.floor(pin)) - value = (value == true or value > 0) and "1" or "0" + value = (value == true or (type(value) == "number" and value & 1 == 1) ) and "1" or "0" if not fexists("/sys/class/gpio/gpio" .. pin) then return false, "Set pin mode first" end