Skip to content

Instantly share code, notes, and snippets.

@cellularmitosis
Last active June 30, 2020 23:49
Show Gist options
  • Save cellularmitosis/76bb04ba8e5e0fe1e695e67fae351e86 to your computer and use it in GitHub Desktop.
Save cellularmitosis/76bb04ba8e5e0fe1e695e67fae351e86 to your computer and use it in GitHub Desktop.
Building Janet from source

Blog 2020/5/2

<- previous | index | next ->

Building Janet from source

Debian and macOS (Homebrew)

Here's a script I use to install Janet from source on Linux machines:

#!/bin/bash

set -e -o pipefail

version=1.10.1
prefix=/opt/janet-$version

tarball=janet-${version}.tar.gz
url=https://github.com/janet-lang/janet/archive/v${version}.tar.gz

mkdir -p $HOME/dist

cd $HOME/dist
test -e $tarball || wget -O $tarball $url

cd /tmp
rm -rf janet-$version
cat $HOME/dist/$tarball | gunzip | tar x
cd janet-$version
make PREFIX=$prefix
make test PREFIX=$prefix
make install PREFIX=$prefix
ln -sf ${prefix}/bin/janet /usr/local/bin/
ln -sf ${prefix}/bin/jpm /usr/local/bin/

Windows / MSYS2

Note: I was able to get Janet 1.8.1 to build on Windows 7 / MSYS2 by making two modifications to the Makefile:

  • remove -rdynamic from the LDFLAGS
  • swap the order of the two ln -sf lines in the install: target

Here is the diff:

--- Makefile    2020-05-02 21:08:04.416775300 -0500
+++ Makefile.mod        2020-05-02 20:04:05.113179600 -0500
@@ -38,7 +38,7 @@
 DEBUGGER=gdb

 CFLAGS:=$(CFLAGS) -std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fPIC -O2 -fvisibility=hidden
-LDFLAGS:=$(LDFLAGS) -rdynamic
+LDFLAGS:=$(LDFLAGS)

 # For installation
 LDCONFIG:=ldconfig "$(LIBDIR)"
@@ -254,8 +254,8 @@
        mkdir -p '$(DESTDIR)$(LIBDIR)'
        cp $(JANET_LIBRARY) '$(DESTDIR)$(LIBDIR)/libjanet.so.$(shell $(JANET_TARGET) -e '(print janet/version)')'
        cp $(JANET_STATIC_LIBRARY) '$(DESTDIR)$(LIBDIR)/libjanet.a'
-       ln -sf $(SONAME) '$(DESTDIR)$(LIBDIR)/libjanet.so'
        ln -sf libjanet.so.$(shell $(JANET_TARGET) -e '(print janet/version)') $(DESTDIR)$(LIBDIR)/$(SONAME)
+       ln -sf $(SONAME) '$(DESTDIR)$(LIBDIR)/libjanet.so'
        cp -rf auxbin/* '$(DESTDIR)$(BINDIR)'
        mkdir -p '$(DESTDIR)$(MANPATH)'
        cp janet.1 '$(DESTDIR)$(MANPATH)'

.vimrc

You can tell vim to use Clojure's syntax highlighting for Janet files:

syntax on
filetype on
au BufNewFile,BufRead *.janet set filetype=clojure
#!/bin/bash
set -e -o pipefail
version=1.10.1
prefix=/opt/janet-$version
tarball=janet-${version}.tar.gz
url=https://github.com/janet-lang/janet/archive/v${version}.tar.gz
mkdir -p $HOME/dist
cd $HOME/dist
test -e $tarball || wget -O $tarball $url
cd /tmp
rm -rf janet-$version
cat $HOME/dist/$tarball | gunzip | tar x
cd janet-$version
make PREFIX=$prefix
make test PREFIX=$prefix
make install PREFIX=$prefix
ln -sf ${prefix}/bin/janet /usr/local/bin/
ln -sf ${prefix}/bin/jpm /usr/local/bin/
@cellularmitosis
Copy link
Author

Edit: updated Linux install script for Janet 1.10.1.

@cellularmitosis
Copy link
Author

Modifying the script to install in $HOME/opt/ is simple:

--- install-janet.sh	2020-06-30 18:48:46.462512357 -0500
+++ install-janet-home.sh	2020-06-30 18:47:34.018885029 -0500
@@ -3,7 +3,7 @@
 set -e -o pipefail
 
 version=1.10.1
-prefix=/opt/janet-$version
+prefix=$HOME/opt/janet-$version
 
 tarball=janet-${version}.tar.gz
 url=https://github.com/janet-lang/janet/archive/v${version}.tar.gz
@@ -20,5 +20,5 @@
 make PREFIX=$prefix
 make test PREFIX=$prefix
 make install PREFIX=$prefix
-ln -sf ${prefix}/bin/janet /usr/local/bin/
-ln -sf ${prefix}/bin/jpm /usr/local/bin/
+ln -sf ${prefix}/bin/janet $HOME/local/bin/
+ln -sf ${prefix}/bin/jpm $HOME/local/bin/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment