, 4 min read

Installing Simplified Saaze on Android

Original post is here eklausmeier.goip.de/blog/2024/12-15-installing-simplified-saaze-on-android.


Simplified Saaze is a static site generator. This very blog uses Simplified Saaze.

It is possible to generate all HTML files on Android using Simplified Saaze! This post shows the necessary steps.

The main trick is to use termux. I had written on termux here: ssh and rsync for Android, Termux.

1. Installing PHP and C compiler

Install the C compiler and Git.

pkg install clang git autoconf

gcc is not available on termux, therefore we chose clang. Git is required further down, when we install MD4C. Autoconf is required for all PHP extensions, which use configure.

Simplified Saaze is written in PHP. Therefore we need PHP and optionally composer.

pkg install php composer

composer is not strictly requiered, but convenient when you want to install one of the many themes.

2. Installing PHP yaml extension

First install libyaml library:

pkg install libyaml

Next download latest tar-ball from PECL yaml package. Untar the file

tar zxf yaml-2.2.4.tgz

Do the usual three-step:

phpize
./configure
make

Once all has been built, the module is copied or moved to the PHP extension library directory:

mv modules/yaml.so /data/data/com.termux/files/usr/lib/php/

3. Installing MD4C extension

Clone the git directory including its submodule:

git clone --recurse-submodules https://github.com/eklausme/php-md4c.git

The reason for this is that termux does not provide MD4C in its package repositories.

Now the rest is standard again with the usual three-step procedure.

phpize
./configure
make

After the build, move or copy the MD4C so-file.

mv modules/md4c.so /data/data/com.termux/files/usr/lib/php/

4. Setting php.ini

For PHP to use yaml and MD4C we have to edit php.ini:

allow_url_include = On
short_open_tag = 0

extension=md4c
extension=yaml

While the extension statement is obvious, the allow_url_include statement is only required if you want to mix PHP into your Markdown files. See Mixing PHP into Markdown.

Once all is installed and configured, then check PHP with phpinfo(): Create a file phpinfo.php with below content.

<?php
    phpinfo();
?>

Then start the builtin web-server of PHP:

php -S <your-IP-address>:8000 -t .

Assuming that the phpinfo.php file is in your current directory (therefore -t .). Check in your browser whether the yaml and MD4C extension are visible in the output of phpinfo().

5. Running Simplified Saaze

Below you will find my entire blog processed on Android. My blog happens to reside in the directory sndsaaze. For that I simply copied it to termux:

tar cf - sndsaaze | ssh x14 'cd ~/php; tar xf -'

Finally:

$ time php saaze -mort

Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0
Building static site in ./build...
        execute(): filePath=./content/error.yml, nSIentries=0, totalPages=0, entries_per_page=20
        execute(): filePath=./content/music.yml, nSIentries=83, totalPages=5, entries_per_page=20
        execute(): filePath=./content/gallery.yml, nSIentries=11, totalPages=1, entries_per_page=20
        execute(): filePath=./content/blog.yml, nSIentries=491, totalPages=25, entries_per_page=20
        execute(): filePath=./content/aux.yml, nSIentries=8, totalPages=1, entries_per_page=20
Finished creating 5 collections, 4 with index, and 625 entries (0.45 secs / 29.17MB)
#collections=5, parseEntry=0.0149/629-5, md2html=0.0364, toHtml=0.0407/625, renderEntry=0.2418/625, renderCollection=0.0105/36, content=625/0

real    0m0.490s
user    0m0.325s
sys     0m0.151s

This entire blog can be processed with Simplified Saaze on Android within less than half a second. These runtimes are for an Xiaomi 14T Pro model.

When using the parallel option in Simplified Saaze the runtime can be brought down to a quarter second.

$ time php saaze -mort -p8

Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0
Building static site in ./build...
        execute(): filePath=./content/error.yml, nSIentries=0, totalPages=0, entries_per_page=20
        execute(): filePath=./content/music.yml, nSIentries=83, totalPages=5, entries_per_page=20
        execute(): filePath=./content/gallery.yml, nSIentries=11, totalPages=1, entries_per_page=20
        execute(): filePath=./content/blog.yml, nSIentries=491, totalPages=25, entries_per_page=20
        nentries=510, procnr=00, pid=24969
        nentries=510, procnr=01, pid=24970
        nentries=510, procnr=02, pid=24971
        nentries=510, procnr=03, pid=24972
        nentries=510, procnr=04, pid=24973
        nentries=510, procnr=05, pid=24974
        nentries=510, procnr=06, pid=24975
        execute(): filePath=./content/aux.yml, nSIentries=8, totalPages=1, entries_per_page=20
Finished creating 5 collections, 4 with index, and 115 entries (0.24 secs / 19.54MB)
#collections=5, parseEntry=0.0149/629-5, md2html=0.0364, toHtml=0.0410/625, renderEntry=0.0535/115, renderCollection=0.0142/36, content=625/0

real    0m0.275s
user    0m0.182s
sys     0m0.084s