--- configure.ac.orig	2013-03-29 16:35:21.000000000 -0400
+++ configure.ac	2013-03-29 17:19:23.000000000 -0400
@@ -1,15 +1,16 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl $Id: configure.ac 91520 2012-04-04 00:40:40Z jmr@macports.org $
-AC_PREREQ(2.63)
+AC_PREREQ([2.63])
 AC_DEFUN([MACPORTS_VERSION_MACRO], [esyscmd(<config/macports_version tr -d '\n')])
 AC_INIT([MacPorts],MACPORTS_VERSION_MACRO,[macports-dev@lists.macosforge.org],[macports])
 AC_CONFIG_SRCDIR([src/pextlib1.0/Pextlib.c])
+AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS([src/config.h])
 
 AC_CANONICAL_TARGET
 
 # Read in the MacPorts version from the base/config/macports_version file
-AC_MSG_CHECKING(MacPorts version)
+AC_MSG_CHECKING([MacPorts version])
 MACPORTS_VERSION=MACPORTS_VERSION_MACRO
 AC_MSG_RESULT([$MACPORTS_VERSION])
 AC_SUBST(MACPORTS_VERSION)
@@ -17,12 +18,12 @@
 # Check user PATH for MP paths, and remove as necessary.
 MP_PATH_SCAN
 
-AC_PATH_PROG(SW_VERS, sw_vers)
-AC_PATH_PROG(DEFAULTS, defaults)
-AC_PATH_PROG(XCODE_SELECT, xcode-select)
+AC_PATH_PROG([SW_VERS], [sw_vers])
+AC_PATH_PROG([DEFAULTS], [defaults])
+AC_PATH_PROG([XCODE_SELECT], [xcode-select])
 
 if test "x$SW_VERS" != "x"; then
-  AC_MSG_CHECKING(Mac OS X version)
+  AC_MSG_CHECKING([Mac OS X version])
   MACOSX_VERSION=`$SW_VERS -productVersion`
   AC_MSG_RESULT([$MACOSX_VERSION])
 fi
@@ -45,7 +46,7 @@
 
 # locate currently selected Xcode path
 if test "x$XCODE_SELECT" != "x"; then
-  AC_MSG_CHECKING(Xcode location)
+  AC_MSG_CHECKING([Xcode location])
   DEVELOPER_DIR=`$XCODE_SELECT -print-path`
 fi
 if test -z "$DEVELOPER_DIR" -o ! -d "$DEVELOPER_DIR" ; then
@@ -68,7 +69,7 @@
 esac
 XCODEPLIST=${XCODEPLIST_BASE}.plist
 if test -r "$XCODEPLIST"; then
-  AC_MSG_CHECKING(Xcode version)
+  AC_MSG_CHECKING([Xcode version])
   if test "x$DEFAULTS" != "x"; then
     XCODE_VERSION=`$DEFAULTS read $XCODEPLIST_BASE CFBundleShortVersionString`
   else
@@ -94,76 +95,78 @@
 esac
 
 # Checks for programs.
+AC_PROG_AWK
 AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AC_PROG_OBJC
+AC_PROG_RANLIB
 
-AC_PATH_PROGS(BSDMAKE, [bsdmake pmake], [])
-AC_PATH_PROG(BZIP2, [bzip2], [])
-AC_PATH_PROG(BZR, [bzr], [])
-AC_PATH_PROG(CHOWN, [chown], [], [$PATH:/usr/sbin])
-AC_PATH_PROG(CP, [cp], [])
-AC_PATH_PROG(CPIO, [cpio], [])
-AC_PATH_PROG(CVS, [cvs], [])
-AC_PATH_PROG(DIFF, [diff], [])
-AC_PATH_PROG(DSCL, [dscl], [])
-AC_PATH_PROG(DSEDITGROUP, [dseditgroup], [])
-AC_PATH_PROG(FILE, [file], [])
-AC_PATH_PROG(GIT, [git], [])
-AC_PATH_PROGS(GNUMAKE, [gnumake gmake], [], [$PATH:/usr/local/bin])
-AC_PATH_PROGS(GNUPATCH, [gnupatch gpatch], [], [$PATH:/usr/local/bin])
-AC_PATH_PROGS(GNUTAR, [gnutar gtar], [], [$PATH:/usr/local/bin])
-AC_PATH_PROG(GZIP, [gzip], [])
-AC_PATH_PROG(HDIUTIL, [hdiutil], [])
-AC_PATH_PROG(HG, [hg], [])
-AC_PATH_PROG(LAUNCHCTL, [launchctl], [])
-AC_PATH_PROG(LIPO, [lipo], [])
-AC_PATH_PROG(LSBOM, [lsbom], [])
-AC_PATH_PROG(LZMA, [lzma], [])
-AC_PATH_PROG(MAKE, [make])
-AC_PATH_PROG(MDFIND, [mdfind], [])
-AC_PATH_PROG(MDLS, [mdls], [])
-AC_PATH_PROG(MKBOM, [mkbom], [])
-AC_PATH_PROG(MTREE, [mtree], [], [$PATH:/usr/sbin])
-AC_PATH_PROG(OPEN, [open], [])
-AC_PATH_PROG(OPENSSL, [openssl], [])
-AC_PATH_PROG(PATCH, [patch], [])
-AC_PATH_PROG(PAX, [pax], [])
-AC_PATH_PROG(RMDIR, [rmdir], [])
-AC_PATH_PROG(RSYNC, [rsync], [])
-AC_PATH_PROG(SED, [sed])
-AC_PATH_PROG(SVN, [svn], [])
-AC_PATH_PROG(SWIG, [swig], [], [$PATH:/usr/local/bin])
-AC_PATH_PROG(TAR, [tar])
-AC_PATH_PROG(UNZIP, [unzip])
-AC_PATH_PROG(XAR, [xar], [])
-AC_PATH_PROG(XCODEBUILD, [xcodebuild], [])
-AC_PATH_PROG(XCRUN, [xcrun], [])
-AC_PATH_PROG(XZ, [xz], [])
-AC_PATH_PROG(ZIP, [zip])
+AC_PATH_PROGS([BSDMAKE], [bsdmake pmake], [])
+AC_PATH_PROG([BZIP2], [bzip2], [])
+AC_PATH_PROG([BZR], [bzr], [])
+AC_PATH_PROG([CHOWN], [chown], [], [$PATH:/usr/sbin])
+AC_PATH_PROG([CP], [cp], [])
+AC_PATH_PROG([CPIO], [cpio], [])
+AC_PATH_PROG([CVS], [cvs], [])
+AC_PATH_PROG([DIFF], [diff], [])
+AC_PATH_PROG([DSCL], [dscl], [])
+AC_PATH_PROG([DSEDITGROUP], [dseditgroup], [])
+AC_PATH_PROG([FILE], [file], [])
+AC_PATH_PROG([GIT], [git], [])
+AC_PATH_PROGS([GNUMAKE], [gnumake gmake], [], [$PATH:/usr/local/bin])
+AC_PATH_PROGS([GNUPATCH], [gnupatch gpatch], [], [$PATH:/usr/local/bin])
+AC_PATH_PROGS([GNUTAR], [gnutar gtar], [], [$PATH:/usr/local/bin])
+AC_PATH_PROG([GZIP], [gzip], [])
+AC_PATH_PROG([HDIUTIL], [hdiutil], [])
+AC_PATH_PROG([HG], [hg], [])
+AC_PATH_PROG([LAUNCHCTL], [launchctl], [])
+AC_PATH_PROG([LIPO], [lipo], [])
+AC_PATH_PROG([LSBOM], [lsbom], [])
+AC_PATH_PROG([LZMA], [lzma], [])
+AC_PATH_PROG([MAKE], [make])
+AC_PATH_PROG([MDFIND], [mdfind], [])
+AC_PATH_PROG([MDLS], [mdls], [])
+AC_PATH_PROG([MKBOM], [mkbom], [])
+AC_PATH_PROG([MTREE], [mtree], [], [$PATH:/usr/sbin])
+AC_PATH_PROG([OPEN], [open], [])
+AC_PATH_PROG([OPENSSL], [openssl], [])
+AC_PATH_PROG([PATCH], [patch], [])
+AC_PATH_PROG([PAX], [pax], [])
+AC_PATH_PROG([RMDIR], [rmdir], [])
+AC_PATH_PROG([RSYNC], [rsync], [])
+AC_PATH_PROG([SED], [sed])
+AC_PATH_PROG([SVN], [svn], [])
+AC_PATH_PROG([SWIG], [swig], [], [$PATH:/usr/local/bin])
+AC_PATH_PROG([TAR], [tar])
+AC_PATH_PROG([UNZIP], [unzip])
+AC_PATH_PROG([XAR], [xar], [])
+AC_PATH_PROG([XCODEBUILD], [xcodebuild], [])
+AC_PATH_PROG([XCRUN], [xcrun], [])
+AC_PATH_PROG([XZ], [xz], [])
+AC_PATH_PROG([ZIP], [zip])
 
-AC_CHECK_PROG(HAVE_LAUNCHD, [launchd], [yes], [])
+AC_CHECK_PROG([HAVE_LAUNCHD], [launchd], [yes], [])
 
 # Define some precious variables allowing user to override PATH for some programs
-AC_ARG_VAR(BSDMAKE, [path to bsdmake/pmake command])
-AC_ARG_VAR(BZIP2, [path to bzip2 command])
-AC_ARG_VAR(CVS, [path to cvs command])
-AC_ARG_VAR(GNUMAKE, [path to gnumake command])
-AC_ARG_VAR(GNUTAR, [path to gnutar command])
-AC_ARG_VAR(LZMA, [path to lzma command])
-AC_ARG_VAR(MAKE, [path to make command])
-AC_ARG_VAR(MTREE, [path to mtree command])
-AC_ARG_VAR(OPEN, [path to open command])
-AC_ARG_VAR(OPENSSL, [path to openssl command])
-AC_ARG_VAR(RSYNC, [path to rsync command])
-AC_ARG_VAR(SED, [path to sed command])
-AC_ARG_VAR(SVN, [path to svn command])
-AC_ARG_VAR(SWIG, [path to swig command])
-AC_ARG_VAR(TAR, [path to tar command])
-AC_ARG_VAR(XAR, [path to xar command])
-AC_ARG_VAR(XZ, [path to xz command])
+AC_ARG_VAR([BSDMAKE], [path to bsdmake/pmake command])
+AC_ARG_VAR([BZIP2], [path to bzip2 command])
+AC_ARG_VAR([CVS], [path to cvs command])
+AC_ARG_VAR([GNUMAKE], [path to gnumake command])
+AC_ARG_VAR([GNUTAR], [path to gnutar command])
+AC_ARG_VAR([LZMA], [path to lzma command])
+AC_ARG_VAR([MAKE], [path to make command])
+AC_ARG_VAR([MTREE], [path to mtree command])
+AC_ARG_VAR([OPEN], [path to open command])
+AC_ARG_VAR([OPENSSL], [path to openssl command])
+AC_ARG_VAR([RSYNC], [path to rsync command])
+AC_ARG_VAR([SED], [path to sed command])
+AC_ARG_VAR([SVN], [path to svn command])
+AC_ARG_VAR([SWIG], [path to swig command])
+AC_ARG_VAR([TAR], [path to tar command])
+AC_ARG_VAR([XAR], [path to xar command])
+AC_ARG_VAR([XZ], [path to xz command])
 
 if test "x$MTREE" = "x"; then
     AC_MSG_ERROR([mtree not found])
@@ -235,20 +238,41 @@
 AC_HEADER_STDC
 AC_HEADER_DIRENT
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([limits.h paths.h sys/file.h crt_externs.h fcntl.h sys/fcntl.h sys/cdefs.h err.h sys/socket.h \
-	sys/sysctl.h readline/readline.h readline/history.h pwd.h sys/paths.h utime.h])
+AC_CHECK_HEADERS([crt_externs.h err.h fcntl.h limits.h mach/mach.h paths.h pwd.h readline/history.h readline/readline.h \
+	sys/cdefs.h sys/file.h sys/fcntl.h sys/ioctl.h sys/mount.h sys/param.h sys/paths.h sys/socket.h sys/sysctl.h sys/time.h \
+	utime.h])
 
 INCLUDES="-I.. -I. $INCLUDES"
 
+# Checks for typedefs, structures, and compiler characteristics.
+AC_CHECK_HEADER_STDBOOL
+AC_TYPE_UID_T
+AC_C_INLINE
+AC_TYPE_MODE_T
+AC_TYPE_OFF_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT8_T
+
 # Checks for library functions.
-AC_CHECK_FUNCS([bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy copyfile clearenv sysctlbyname])
+AC_FUNC_CHOWN
+AC_FUNC_FORK
+AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
+AC_FUNC_MALLOC
+AC_FUNC_MMAP
+AC_FUNC_REALLOC
+AC_CHECK_FUNCS([bzero clearenv copyfile dup2 fgetln flock getcwd lchown localtime_r lockf memmove memset mkdir munmap realpath regcomp \
+	rmdir select setenv setmode socket strcasecmp strchr strdup strerror strlcpy strncasecmp strrchr strstr strtol strtoul \
+	sysctlbyname utime])
 MP_CHECK_READLINK_IS_P1003_1A
 
 # Check for md5 implementation
 AC_CHECK_HEADER([CommonCrypto/CommonDigest.h], [AC_DEFINE([HAVE_COMMONCRYPTO_COMMONDIGEST_H], [1], [Define if CommonCrypto is available.])], [MP_LIB_MD5])
 
 # Check for readline
-AC_ARG_ENABLE(readline, AS_HELP_STRING([--enable-readline],[Enable addition of readline support, if readline present.]),
+AC_ARG_ENABLE([readline], [AS_HELP_STRING([--enable-readline],[Enable addition of readline support, if readline present.])],
 [
 	AC_CHECK_LIB([readline], [readline], [
 				  READLINE_LIBS=-lreadline
@@ -302,7 +326,7 @@
 
 ## Thread package.
 AC_ARG_WITH(
-		included-tclthread,
+		[included-tclthread],
 		AS_HELP_STRING([--with-included-tclthread],
 			[install included Thread package.]),
 		[with_included_tclthread=$withval],
@@ -328,7 +352,7 @@
 
 AH_TEMPLATE([TRACE_SDK], [SDK for SDK redirect in tracelib])
 AC_ARG_WITH(
-	trace-sdk,
+	[trace-sdk],
 	AS_HELP_STRING([--with-trace-sdk=SDK],
 		[SDK for redirection in trace lib (for example MacOSX10.4u.sdk)]),
 	[test -d ${DEVELOPER_DIR}/SDKs/$withval && AC_DEFINE_UNQUOTED([TRACE_SDK], "${withval}")], [])
