Index: project/main/build.mak
===================================================================
--- /pjproject/main/build.mak	(revision 21)
+++ 	(revision )
@@ -1,63 +1,0 @@
-# Build configurations:
-#
-# MACHINE_NAME values: 
-#	- i386 (generic x86)
-#	- m68k
-#
-# OS_NAME values:
-#	- win32 (generic windows)
-#	- linux
-#
-# CC_NAME values:
-#	- gcc
-#	- msvc
-#
-# HOST_NAME values:
-#	- win32 (Windows command line)
-#	- mingw (Windows, mingw)
-#
-
-#
-# PalmOS 6 cross-compile, cygwin
-#
-#export MACHINE_NAME := m68k
-#export OS_NAME := palmos
-#export CC_NAME := gcc
-#export HOST_NAME := mingw
-
-#
-# Win32, mingw
-#
-#export MACHINE_NAME := i386
-#export OS_NAME := win32
-#export CC_NAME := gcc
-#export HOST_NAME := mingw
-
-#
-# Linux i386, gcc
-#
-export MACHINE_NAME := i386
-export OS_NAME := linux
-export CC_NAME := gcc
-export HOST_NAME := unix
-
-#
-# Linux KERNEL i386, gcc
-#
-#export MACHINE_NAME := i386
-#export OS_NAME := linux-kernel
-#export CC_NAME := gcc
-#export HOST_NAME := unix
-#export PJPROJECT_DIR := /usr/src/pjproject-0.3
-##export KERNEL_DIR = /usr/src/linux
-#export KERNEL_DIR = /usr/src/uml/linux
-#export KERNEL_ARCH = ARCH=um
-
-#
-# SunOS, sparc, gcc
-#
-#export MACHINE_NAME := sparc
-#export OS_NAME := sunos
-#export CC_NAME := gcc
-#export HOST_NAME := unix
-
Index: /pjproject/main/build.mak.txt
===================================================================
--- /pjproject/main/build.mak.txt	(revision 22)
+++ /pjproject/main/build.mak.txt	(revision 22)
@@ -0,0 +1,66 @@
+# Build configurations:
+#
+# MACHINE_NAME values: 
+#	- i386 (generic x86)
+#	- sparc
+#	- alpha
+#
+# OS_NAME values:
+#	- win32 (generic windows)
+#	- linux
+#	- sunos
+#
+# CC_NAME values:
+#	- gcc
+#	- msvc
+#
+# HOST_NAME values:
+#	- win32 (Windows command line)
+#	- mingw (Windows, mingw)
+#	- unix
+#
+
+#
+# PalmOS 6 cross-compile, cygwin
+#
+#export MACHINE_NAME := m68k
+#export OS_NAME := palmos
+#export CC_NAME := gcc
+#export HOST_NAME := mingw
+
+#
+# Win32, mingw
+#
+#export MACHINE_NAME := i386
+#export OS_NAME := win32
+#export CC_NAME := gcc
+#export HOST_NAME := mingw
+
+#
+# Linux i386, gcc
+#
+export MACHINE_NAME := i386
+export OS_NAME := linux
+export CC_NAME := gcc
+export HOST_NAME := unix
+
+#
+# Linux KERNEL i386, gcc
+#
+#export MACHINE_NAME := i386
+#export OS_NAME := linux-kernel
+#export CC_NAME := gcc
+#export HOST_NAME := unix
+#export PJPROJECT_DIR := /usr/src/pjproject-0.3
+##export KERNEL_DIR = /usr/src/linux
+#export KERNEL_DIR = /usr/src/uml/linux
+#export KERNEL_ARCH = ARCH=um
+
+#
+# SunOS, sparc, gcc
+#
+#export MACHINE_NAME := sparc
+#export OS_NAME := sunos
+#export CC_NAME := gcc
+#export HOST_NAME := unix
+
Index: /pjproject/main/configure
===================================================================
--- /pjproject/main/configure	(revision 22)
+++ /pjproject/main/configure	(revision 22)
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+#
+# Detect machine
+#
+MACHINE=`uname -m`
+
+if echo $MACHINE | grep sun4u > /dev/null; then
+    MACHINE_NAME=sparc
+elif echo $MACHINE | grep i.86 > /dev/null; then
+    MACHINE_NAME=i386
+elif echo $MACHINE | grep alpha > /dev/null; then
+    MACHINE_NAME=alpha
+else
+    echo "Unable to detect processor type ('uname -m' == '$MACHINE')"
+    exit 1
+fi
+
+#
+# Detect OS and host
+#
+SYSTEM=`uname -s`
+
+if echo $SYSTEM | grep -i sunos > /dev/null; then
+    OS_NAME=sunos
+    HOST_NAME=unix
+elif echo $SYSTEM | grep -i linux > /dev/null; then
+    OS_NAME=linux
+    HOST_NAME=unix
+elif echo $SYSTEM | grep -i mingw > /dev/null; then
+    OS_NAME=win32
+    HOST_NAME=mingw
+elif echo $SYSTEM | grep -i cygwin > /dev/null; then
+    OS_NAME=win32
+    HOST_NAME=mingw
+else
+    echo "Unable to detect system type ('uname -s' == '$SYSTEM')"
+    exit 1
+fi
+
+#
+# Detect gcc
+#
+if gcc --version 2>&1 > /dev/null; then
+    CC_NAME=gcc
+else
+    echo "Unable to find gcc"
+    exit 1
+fi
+
+echo 'Writing build.mak as follows:'
+echo " MACHINE_NAME=$MACHINE_NAME"
+echo " OS_NAME=$OS_NAME"
+echo " HOST_NAME=$HOST_NAME"
+echo " CC_NAME=$CC_NAME"
+
+echo "# Auto-generated build.mak" > build.mak
+echo "export MACHINE_NAME := $MACHINE_NAME" >> build.mak
+echo "export OS_NAME := $OS_NAME" >> build.mak
+echo "export HOST_NAME := $HOST_NAME" >> build.mak
+echo "export CC_NAME := $CC_NAME" >> build.mak
+echo "Done."
+
