Navigate to the posix/ directory:
cd posixmake # Build lux interpreter (default)
make luxfmt # Build code formatter
make luxtest # Build test runner
make luxlint # Build linter (unused vars, unreachable code, etc.)
make clean # Clean object files and binarieslux -v prints release, os/arch, git branch, and git describe for the tree that was compiled. mk writes the same line with os plan9 and arch $objtype. If git is missing, branch and describe are unknown.
Install dependencies:
brew install curl openssl@3Build:
cd posix
make
./lux ../examples/demo.luxTo run code with SQLite support:
make USE_SQLITE=1
./lux -d # or any .lux fileInstall dependencies:
apt-get install build-essential libcurl4-openssl-dev libssl-dev
# Optional database drivers:
apt-get install libsqlite3-dev libpq-dev libmysqlclient-devBuild:
cd posix
make
./lux ../examples/demo.luxInstall dependencies:
yum groupinstall "Development Tools"
yum install curl-devel openssl-devel
# Optional:
yum install sqlite-devel postgresql-devel mariadb-develBuild:
cd posix
make
./lux ../examples/demo.luxOpenBSD requires GNU Make (Plan 9 mk is not available on OpenBSD). Install:
pkg_add gmake curl opensslBuild:
cd posix
gmake
./lux ../examples/demo.luxNote: The Makefile auto-detects OpenBSD and sets correct flags:
- Includes:
-I/usr/local/include - Libraries:
-L/usr/local/lib
See posix/README-OPENBSD.md for detailed notes.
Plan 9 uses the mk build tool (not Make). From the root directory:
mk # Compile and link all sources → 8.out
mk clean # Clean .8 files and binariesThe resulting binary is 8.out. Run:
./8.out examples/demo.luxluxfmt (code formatter):
6c luxfmt_plan9.c
6l -o luxfmt luxfmt_plan9.6
./luxfmt examples/demo.luxluxtest (test runner):
6c luxtest_plan9.c
6l -o luxtest luxtest_plan9.6
./luxtest tests/luxlint (linter):
rc luxlint.rc
./luxlint myfile.luxUsing $O and $objtype variables (more portable):
$objtype^c luxfmt_plan9.c
$objtype^l -o luxfmt luxfmt_plan9.$O
rc luxlint.rc- 8c: Intel x86-64 compiler
- 6c: AMD64 compiler (Plan 9's x86-64, also used on other arches in emulation)
- $objtype: Machine type variable (e.g.,
386,amd64,arm) - $O: Compiled object suffix (e.g.,
.8,.6)
The mkfile detects your $objtype and builds accordingly. You can also manually specify:
objtype=386 mk # Force 32-bit
objtype=amd64 mk # Force 64-bitBy default, Lux builds without database support to keep the binary lightweight. To enable:
cd posix
make USE_SQLITE=1
./lux script.luxcd posix
make USE_SQLITE=1 USE_POSTGRES=1 USE_MYSQL=1
./lux script.luxThen in Lux:
var db = dbConnect("sqlite3", "file.db");
var result = dbQuery(db, "SELECT * FROM users;");
dbClose(db);
After building, verify with:
# POSIX
cd posix
./lux -c "print 1 + 2;" # Interactive: press Ctrl+D to exit
echo 'print "Hello";' > /tmp/test.lux && ./lux /tmp/test.lux
# Plan 9
./8.out -c "print 1 + 2;"
echo 'print "Hello";' > /tmp/test.lux && ./8.out /tmp/test.luxLux includes a comprehensive test suite:
# POSIX
cd posix
make luxtest
./luxtest ../tests/
make ninep_test
./ninep_test # 9P server + client protocol (no Lux)
# Plan 9
6c luxtest_plan9.c && 6l -o luxtest luxtest_plan9.6
./luxtest tests/Options:
./luxtest -t 10 tests/ # 10-second timeout per test (default: 10s)
./luxtest -v tests/ # Verbose (show stderr for passing tests)
./luxtest -t 0 tests/ # No timeout
./luxtest tests/fib.lux # Single test filemacOS:
brew install curl openssl@3
# May need to link:
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"Linux: Install dev packages (libcurl4-openssl-dev, libssl-dev).
OpenBSD:
pkg_add curl opensslEnsure you're using GNU Make (gmake), not BSD Make:
which gmake # Should be /usr/local/bin/gmake
gmake -v # Should show "GNU Make"Often due to whitespace in mkfile (tabs vs spaces). Plan 9's mk is strict:
- Recipe lines in mkfile must start with a TAB, not spaces
- Comments use
#
If you see "missing separator", check the mkfile tabs.
For systems not explicitly documented (BSD variants, illumos, etc.):
- Install dependencies:
gcc,make,curl,openssl - Try the POSIX build:
cd posix make
If compilation fails, check:
- Compiler flags in
posix/Makefile(may need adjustment) - Header locations (
-I/path/to/openssl/include, etc.) - Library paths (
-L/path/to/openssl/lib, etc.)
Consider filing an issue with build output.
To build without cryptography, HTTP, or AWS support:
cd posix
# Comment out crypto/HTTP parts in vm.c
gcc -Wall -Wextra -std=c99 -g -c *.c
gcc *.o -o lux -lcurl # Only needs curl, no libcryptoThis trades features for minimal dependencies. Not recommended for production use.
- Make changes locally
- Test on POSIX (macOS/Linux):
cd posix && make && ./luxtest ../tests/
- Copy changes to Plan 9 environment
- Rebuild and test on Plan 9:
mk && ./luxtest tests/ - Commit and push to GitHub
For iterative development, maintain a unified source tree and sync between platforms.