Git (glulx interpreter) for android!

Hi, I finally did it - I got git (the glulx interpreter) to compile for android.
I know you have a version of twisty that works (mostly), but for games that don’t work in it due to the incomplete nature of its GLK, this should run them properly, besides picture display. It is nearly identical to the PC version of git with glkterm - the only change I made was to alter the non-POSIX function that converts local time to GMT time to a POSIX compliant one, so the android NDK would build it. This change is totally behind the scenes and should not be noticeable. I plan to upload a patch next time I get a chance on the computer I compiled it on, so that I am compliant with GPL.

For this to work out of the box, you need a rooted droid device and a terminal app (When I tested this in google’s android emulator, I used the program “terminal IDE”).

It should be possible to do this without rooting, but you’d have to adapt my script for running git to reflect the different paths you chose.

For convenience, the new version of the download INCLUDES ncurses and almost every terminal type definition you could possibly need, and it’s programs, like the ever-useful ‘clear’.


  1. get a terminal app. I have had problems with “terminal emulator” on larger screens, so try “terminal IDE”.

  2. root your phone, and enter your terminal program. type ‘su’ and allow the program to take root priveleges.

  3. Install busybox or some other version of tar for android. I found my copy of busybox here, but it’s probably outdated:
    move that file into your /system/xbin directory and run ‘chmod 06755 /system/xbin/busybox’ before continuing.

  4. Download

  5. Get git-droid.tar onto your droid phone, move it (still in the tarball) to /system/

  6. in your terminal, as root, do the following:

cd /system
busybox tar xf git-droid.tar
rm git-droid.tar
  1. Get a glulx game on your droid device, and cd into it’s folder in terminal. You no longer need to be root.

  2. Type:

ifgit (glux-game-file-name)

If necessary, you may also include parameters for git before the game file name.
I chose to name it ‘ifgit’ here because it would interfere with the git source code repository tool included in busybox otherwise.

That’s it! enjoy!

Original, outdated instructions:

[spoiler]1. download the program and dependencies ( either from attached file or ) and extract it (windows users: 7-zip should work. OS X users: run ‘tar zxf git-droid.tar.gz’. linux users: you know what to do.)

  1. move all of the files onto your SD card, or in some other way get the files to your droid phone.

  2. Open your terminal on your droid phone, and cd to wherever you put the files. inside the ‘git-droid’ directory is the full structure you need to put the files into. make it so the files in ‘etc’ go inside your phones ‘/etc/’ directory, and the ones in ‘system/xbin’ go in your ‘system/xbin’ directory.

  3. once you have finished this, ‘cd’ into /system/xbin and run ‘chmod +x git-interpreter’ and ‘chmod +x ifgit’.

  4. Now, in order to run this, get your favorite glulx game and cd into the directory it is in. Run ‘ifgit game.gblorb’ or whatever your game is called.

IT MIGHT work better if you are having problems if you use one of the terminal setups found here: … e/terminfo
I recommend trying vt100 or xterm.
Anyway, to use vt100, you have to edit the ‘ifgit’ file, which is a script that sets up your terminal environment for curses (the library I used). Replace the line ‘export TERM=linux’ with ‘export TERM=vt100’. for xterm, you do the same thing.[/spoiler]

I do not actually own a droid phone - I did all of this in linux with a cross-compiler for android, and tested it on google’s android emulator. This version is only aimed at ARM based droid devices, but with (i hope) minimal effort I could port it to x86 android. I know it doesn’t support graphics or sounds and it’s pretty clunky in a terminal on a phone, but I figured it was better than nothing.

I recommend ‘Terminal IDE’ over “terminal emulator” for this. For me on large screens terminal emulator is pretty crappy.

Screenshot from android emulator:
HUGE IMAGE, so wrapped in spoiler tags

This is using the glulx version of zork found at the bottom of this page:

My only patch to source code in glkterm was because of the non-POSIX timegm() function call that the android NDK doesn’t support.
In cgdate.c , everytime you see the following line:

timestamp = timegm(&tm);

Replace it with the following lines:

char *tz; tz = getenv("TZ"); setenv("TZ","",1); timestamp = mktime(&tm); if(tz) setenv("TZ",tz,1); else unsetenv("TZ"); tzset();

To compile ncurses for android, I had to make one change:
in include/ncurses_cfg.h :
replace the following line:

#define HAVE_LOCALE_H 1


//#define HAVE_LOCALE_H 1

Interesting! Is there any hope to get a more end-user friendly installation?

I do not own any android devices, and I can only emulate one. I will take a shot at it, but it’s not going to be easy. Just getting curses and git to compile for android swallowed up an afternoon, and I have no real android programming experience. I suppose I could set up a shell script, but you’d have to be able to log in as root on your device in a terminal for it to work, and I’ve had no luck getting that to work right on the emulator yet.

I think I’ll try it now, actually.

Alright, I made it a bit easier to install. Still requires that you know your way around a normal linux/unix shell. I also added a full set of ncurses definitions for terminals to make it easier to get it looking good.
If someone else wants to make a nice installer for it, feel free :slight_smile:

I would make a script to do this, but it would have to know where the SD card is mounted, and I don’t have a real droid phone to test it on.

/system isn’t read-only on a real droid, is it?

The only way I know of to get the SD card mountpoint reliably is to call android.os.Environment.getExternalStorageDirectory() from Java code.

It is, and even if you’re root, it’s a bad idea to put things on it, because different phones do /system differently, and some systems are pretty touchy about what you do on it.

ah - thanks for clarifying. I’m in a bit of a rush now, so I can’t do anything about it this minute, but in a few hours I can edit my scripts to put everything in the user’s home directory. Thanks for the tip!
Forgive me for my dangerous script - as I previously stated, I do not actually own any android devices.

I’ve updated my initial post to show the change to source code I made in glkterm so it would compile. So now I’m complying with GPL!

Thanks. I’ll make a note to add a NO_TIMEGM_AVAIL macro to the cheapglk and glkterm source.

(Note that glkterm and glulxe do not use the GPL, though.)

I compiled cheapglk on Android with this switch: -Dtimegm(x)=(time_t)timegm64((x)) It should work until 2038 at least.

winces d’oh!

what’s the license, then? or is it public domain?
Typing this from an iphone now, so it’d be harder to check than on a desktop.

doesn’t that just make it use local time instead of correctly using GMT? Or am I having another 1:00 AM (EST) stupidity streak?

Android has both a “at least 32-bit” time_t and a 64-bit time64_t. Due to an oversight, they didn’t implement timegm, but they did implement the 64-bit version, timegm64. So I created a macro that calls the 64-bit version and then casts the result down to time_t.