commit 9b3d94b0dac70aa547b7ddf6206917088f83b224
Author: Chris Double <chris.double@double.co.nz>
Date:   Mon Jun 9 23:15:09 2014 +1200

    Changes to build on Android

diff --git a/pil b/pil
index e24e1cb..2573c68 100755
--- a/pil
+++ b/pil
@@ -1,2 +1 @@
-#!/bin/sh
 exec ${0%/*}/bin/picolisp ${0%/*}/lib.l @ext.l "$@"
diff --git a/src/Makefile b/src/Makefile
index 5057f26..54d8e86 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -7,13 +7,28 @@ lib = ../lib
 
 picoFiles = main.c gc.c apply.c flow.c sym.c subr.c big.c io.c net.c tab.c
 
-CFLAGS = -c -O2 -m32 -pipe \
+ifeq ($(TARGET),Android)
+CFLAGS = -DANDROID
+else
+CFLAGS = -m32
+endif
+
+CFLAGS += -c -O2 -pipe \
 	-falign-functions -fomit-frame-pointer -fno-strict-aliasing \
 	-W -Wimplicit -Wreturn-type -Wunused -Wformat \
 	-Wuninitialized -Wstrict-prototypes \
 	-D_GNU_SOURCE  -D_FILE_OFFSET_BITS=64
 
 
+ifeq ($(TARGET),Android)
+	OS = Android
+	PICOLISP-FLAGS = -rdynamic
+	LIB-FLAGS = -lc -lm -ldl
+	DYNAMIC-LIB-FLAGS = -shared -export-dynamic -lm
+	LCRYPT =
+	STRIP = arm-linux-androideabi-strip
+	CC = arm-linux-androideabi-gcc
+else
 ifeq ($(shell uname), Linux)
 	OS = Linux
 	PICOLISP-FLAGS = -m32 -rdynamic
@@ -21,6 +36,7 @@ ifeq ($(shell uname), Linux)
 	DYNAMIC-LIB-FLAGS = -m32 -shared -export-dynamic
 	LCRYPT = -lcrypt
 	STRIP = strip
+	CC = gcc
 else
 ifeq ($(shell uname), OpenBSD)
 	OS = OpenBSD
@@ -29,6 +45,7 @@ ifeq ($(shell uname), OpenBSD)
 	DYNAMIC-LIB-FLAGS = -Wl,-E -Wl,-shared
 	LCRYPT = -lcrypto
 	STRIP = strip
+	CC = gcc
 else
 ifeq ($(shell uname), FreeBSD)
 	OS = FreeBSD
@@ -37,6 +54,7 @@ ifeq ($(shell uname), FreeBSD)
 	DYNAMIC-LIB-FLAGS = -m32 -shared -export-dynamic
 	LCRYPT = -lcrypto
 	STRIP = strip
+	CC = gcc
 else
 ifeq ($(shell uname), NetBSD)
 	OS = NetBSD
@@ -45,6 +63,7 @@ ifeq ($(shell uname), NetBSD)
 	DYNAMIC-LIB-FLAGS = -m32 -shared -export-dynamic
 	LCRYPT = -lcrypto
 	STRIP = strip
+	CC = gcc
 else
 ifeq ($(shell uname), Darwin)
 	OS = Darwin
@@ -53,6 +72,7 @@ ifeq ($(shell uname), Darwin)
 	DYNAMIC-LIB-FLAGS = -m32 -dynamiclib -undefined dynamic_lookup
 	LCRYPT = -lcrypto
 	STRIP = strip -x
+	CC = gcc
 else
 ifeq ($(shell uname -o), Cygwin)
 	OS = Cygwin
@@ -63,6 +83,8 @@ ifeq ($(shell uname -o), Cygwin)
 	STRIP = strip
 	exe = .exe
 	dll = .dll
+	CC = gcc
+endif
 endif
 endif
 endif
@@ -78,7 +100,7 @@ gate: $(bin)/ssl $(bin)/httpGate
 all: picolisp tools gate
 
 .c.o:
-	gcc $(CFLAGS) -D_OS='"$(OS)"' $*.c
+	$(CC) $(CFLAGS) -D_OS='"$(OS)"' $*.c
 
 
 $(picoFiles:.c=.o) ext.o ht.o: pico.h
@@ -88,51 +110,51 @@ main.o: vers.h
 ifeq ($(OS), Cygwin)
 
 $(bin)/picolisp$(dll): $(picoFiles:.c=.o)
-	gcc -o $(bin)/picolisp$(dll) $(DYNAMIC-LIB-FLAGS) $(picoFiles:.c=.o)
+	$(CC) -o $(bin)/picolisp$(dll) $(DYNAMIC-LIB-FLAGS) $(picoFiles:.c=.o)
 	$(STRIP) $(bin)/picolisp$(dll)
 
 $(bin)/picolisp: $(picoFiles:.c=.o) $(bin)/picolisp$(dll) start.o
 	mkdir -p $(bin) $(lib)
-	gcc -o $(bin)/picolisp$(exe) $(PICOLISP-FLAGS) start.o -L$(bin) -l$(bin)/picolisp
+	$(CC) -o $(bin)/picolisp$(exe) $(PICOLISP-FLAGS) start.o -L$(bin) -l$(bin)/picolisp
 	$(STRIP) $(bin)/picolisp$(exe)
 
 else
 
 $(bin)/picolisp: $(picoFiles:.c=.o)
 	mkdir -p $(bin) $(lib)
-	gcc -o $(bin)/picolisp$(exe) $(PICOLISP-FLAGS) $(picoFiles:.c=.o) $(LIB-FLAGS)
+	$(CC) -o $(bin)/picolisp$(exe) $(PICOLISP-FLAGS) $(picoFiles:.c=.o) $(LIB-FLAGS)
 	$(STRIP) $(bin)/picolisp$(exe)
 
 endif
 
 
 $(lib)/ext$(dll): ext.o
-	gcc -o $(lib)/ext$(dll) $(DYNAMIC-LIB-FLAGS) ext.o $(DLL-DEFS) $(LCRYPT)
+	$(CC) -o $(lib)/ext$(dll) $(DYNAMIC-LIB-FLAGS) ext.o $(DLL-DEFS) $(LCRYPT)
 	$(STRIP) $(lib)/ext$(dll)
 
 $(lib)/ht$(dll): ht.o
-	gcc -o $(lib)/ht$(dll) $(DYNAMIC-LIB-FLAGS) ht.o $(DLL-DEFS)
+	$(CC) -o $(lib)/ht$(dll) $(DYNAMIC-LIB-FLAGS) ht.o $(DLL-DEFS)
 	$(STRIP) $(lib)/ht$(dll)
 
 
 $(bin)/lat1: lat1.c
-	gcc -o $(bin)/lat1$(exe) lat1.c
+	$(CC) -o $(bin)/lat1$(exe) lat1.c
 	$(STRIP) $(bin)/lat1$(exe)
 
 $(bin)/utf2: utf2.c
-	gcc -o $(bin)/utf2$(exe) utf2.c
+	$(CC) -o $(bin)/utf2$(exe) utf2.c
 	$(STRIP) $(bin)/utf2$(exe)
 
 $(bin)/balance: balance.c
-	gcc -o $(bin)/balance$(exe) balance.c
+	$(CC) -o $(bin)/balance$(exe) balance.c
 	$(STRIP) $(bin)/balance$(exe)
 
 $(bin)/ssl: ssl.c
-	gcc -o $(bin)/ssl$(exe) ssl.c -lssl -lcrypto
+	$(CC) -o $(bin)/ssl$(exe) ssl.c -lssl -lcrypto
 	$(STRIP) $(bin)/ssl$(exe)
 
 $(bin)/httpGate: httpGate.c
-	gcc -o $(bin)/httpGate$(exe) httpGate.c -lssl -lcrypto
+	$(CC) -o $(bin)/httpGate$(exe) httpGate.c -lssl -lcrypto
 	$(STRIP) $(bin)/httpGate$(exe)
 
 
diff --git a/src/ext.c b/src/ext.c
index c141d0b..257cdec 100644
--- a/src/ext.c
+++ b/src/ext.c
@@ -215,6 +215,7 @@ any Base64(any x) {
    return T;
 }
 
+#ifndef ANDROID
 /*** Password hashing ***/
 // (Ext:Crypt 'key 'salt) -> str
 any Crypt(any x) {
@@ -234,3 +235,4 @@ any Crypt(any x) {
       }
    }
 }
+#endif
