+# Cross-compile lua.
+stage3-chroot/usr/bin/lua: lua-$(LUA_VERSION).tar.gz
+ rm -rf lua-$(LUA_VERSION)
+ tar -zxf $^
+ cd lua-$(LUA_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make PLAT=linux INSTALL_TOP=/usr CC=riscv64-unknown-linux-gnu-gcc AR="riscv64-unknown-linux-gnu-ar rcu" RANLIB="riscv64-unknown-linux-gnu-ranlib" MYLDFLAGS=-L$(ROOT)/stage3-chroot/usr/lib64 MYLIBS=-ltinfo MYCFLAGS="-fPIC -DLUA_COMPAT_5_1"
+ cd lua-$(LUA_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install INSTALL_TOP=$(ROOT)/stage3-chroot/usr INSTALL_LIB=$(ROOT)/stage3-chroot/usr/lib64
+
+lua-$(LUA_VERSION).tar.gz:
+ rm -f $@ $@-t
+ wget -O $@-t https://www.lua.org/ftp/lua-$(LUA_VERSION).tar.gz
+ mv $@-t $@
+
+# Cross-compile xz.
+stage3-chroot/usr/bin/xz: xz-$(XZ_VERSION).tar.gz
+ rm -rf xz-$(XZ_VERSION)
+ tar -zxf $^
+ cd xz-$(XZ_VERSION) && \
+ PATH=$(ROOT)/fixed-gcc:$$PATH \
+ ./configure \
+ --host=riscv64-unknown-linux-gnu \
+ --prefix=/usr --libdir=/usr/lib64
+ cd xz-$(XZ_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
+ cd xz-$(XZ_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make install DESTDIR=$(ROOT)/stage3-chroot
+ rm -f stage3-chroot/usr/lib64/*.la
+
+xz-$(XZ_VERSION).tar.gz:
+ rm -f $@ $@-t
+ wget -O $@-t http://tukaani.org/xz/xz-$(XZ_VERSION).tar.gz
+ mv $@-t $@
+
+# Cross-compile GNU awk.
+stage3-chroot/usr/bin/gawk: gawk-$(GAWK_VERSION).tar.gz
+ rm -rf gawk-$(GAWK_VERSION)
+ tar -zxf $^
+ cd gawk-$(GAWK_VERSION) && \
+ PATH=$(ROOT)/fixed-gcc:$$PATH \
+ ./configure \
+ --host=riscv64-unknown-linux-gnu \
+ --prefix=/usr --libdir=/usr/lib64
+ cd gawk-$(GAWK_VERSION) && PATH=$(ROOT)/fixed-gcc:$$PATH make
+ cd gawk-$(GAWK_VERSION) && make install DESTDIR=$(ROOT)/stage3-chroot
+
+gawk-$(GAWK_VERSION).tar.gz:
+ rm -f $@ $@-t
+ wget -O $@-t https://ftp.gnu.org/gnu/gawk/gawk-$(GAWK_VERSION).tar.gz
+ mv $@-t $@
+
+# Cross-compile vim.
+stage3-chroot/usr/bin/vim: vim-$(VIM_VERSION).tar.gz
+ rm -rf vim-$(VIM_VERSION)
+ bzcat $^ | tar xf -
+ cd vim74/src && \
+ PATH=$(ROOT)/fixed-gcc:$$PATH \
+ vim_cv_memmove_handles_overlap=yes \
+ vim_cv_stat_ignores_slash=no \
+ vim_cv_getcwd_broken=no \
+ vim_cv_tty_group=world \
+ vim_cv_terminfo=yes \
+ vim_cv_toupper_broken=no \
+ LDFLAGS=-L/home/rjones/d/fedora-riscv/stage3-chroot/usr/lib64 \
+ ./configure \
+ --host=riscv64-unknown-linux-gnu \
+ --prefix=/usr --libdir=/usr/lib64 \
+ --with-tlib=tinfo
+ cd vim74/src && PATH=$(ROOT)/fixed-gcc:$$PATH make
+ cd vim74/src && make install DESTDIR=$(ROOT)/stage3-chroot STRIP=riscv64-unknown-linux-gnu-strip
+
+vim-$(VIM_VERSION).tar.gz:
+ rm -f $@ $@-t
+ wget -O $@-t ftp://ftp.vim.org/pub/vim/unix/vim-$(VIM_VERSION).tar.bz2
+ mv $@-t $@
+