diff -Naur heirloom-devtools-070527/CHANGES heirloom-devtools-last-cvs/CHANGES
--- heirloom-devtools-070527/CHANGES	2007-05-27 20:22:23.000000000 +0400
+++ heirloom-devtools-last-cvs/CHANGES	2010-08-07 16:42:07.000000000 +0400
@@ -1,3 +1,12 @@
+Release ...
+* m4: Handle multibyte quote characters with defn() correctly (patch by
+  Joe Krahn).
+* make: Mac OS X compilation fix (Stefan Tramm).
+* make: Compilation fix for 64-bit environments.
+* make: Do not crash if a backslash appears at the end of the value of
+  the MAKEFLAGS environment variable, and preserve trailing spaces in macro
+  names (bug reported by Stefano Lattarini).
+
 Release 070527
 * admin: A manual page is available, based on source code released by Sun.
 * make: Macro definitions following "else" in an effective branch are
diff -Naur heirloom-devtools-070527/heirloom-devtools.spec heirloom-devtools-last-cvs/heirloom-devtools.spec
--- heirloom-devtools-070527/heirloom-devtools.spec	2007-05-27 20:56:51.000000000 +0400
+++ heirloom-devtools-last-cvs/heirloom-devtools.spec	2007-05-27 20:59:57.000000000 +0400
@@ -3,7 +3,7 @@
 #
 Summary: The Heirloom Development Tools.
 Name: heirloom-devtools
-Version: 070527
+Version: 000000
 Release: 1
 License: Other
 Source: %{name}-%{version}.tar.bz2
diff -Naur heirloom-devtools-070527/lex/getopt.c heirloom-devtools-last-cvs/lex/getopt.c
--- heirloom-devtools-070527/lex/getopt.c	2007-04-02 19:01:42.000000000 +0400
+++ heirloom-devtools-last-cvs/lex/getopt.c	2007-12-16 23:54:50.000000000 +0300
@@ -26,7 +26,7 @@
 /*
  * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
  *
- * Sccsid @(#)getopt.c	1.9 (gritter) 4/2/07
+ * Sccsid @(#)getopt.c	1.10 (gritter) 12/16/07
  */
 /* from OpenSolaris "getopt.c	1.23	05/06/08 SMI" */
 
@@ -44,10 +44,12 @@
  * ([a-z][A-Z][0-9]).
  */
 
-#include <unistd.h>
+#include <sys/types.h>
 #include <string.h>
 #include <stdio.h>
 
+extern ssize_t	write(int, const void *, size_t);
+
 char	*optarg = NULL;
 int	optind = 1;
 int	opterr = 1;
@@ -202,3 +204,19 @@
 	}
 	return (c);
 } /* getopt() */
+
+#ifdef __APPLE__
+/*
+ * Starting with Mac OS 10.5 Leopard, <unistd.h> turns getopt()
+ * into getopt$UNIX2003() by default. Consequently, this function
+ * is called instead of the one defined above. However, optind is
+ * still taken from this file, so in effect, options are not
+ * properly handled. Defining an own getopt$UNIX2003() function
+ * works around this issue.
+ */
+int
+getopt$UNIX2003(int argc, char *const argv[], const char *optstring)
+{
+	return getopt(argc, argv, optstring);
+}
+#endif	/* __APPLE__ */
diff -Naur heirloom-devtools-070527/m4/m4macs.c heirloom-devtools-last-cvs/m4/m4macs.c
--- heirloom-devtools-070527/m4/m4macs.c	2005-11-27 16:00:40.000000000 +0300
+++ heirloom-devtools-last-cvs/m4/m4macs.c	2008-11-02 21:27:35.000000000 +0300
@@ -33,7 +33,7 @@
 /*
  * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
  *
- * Sccsid @(#)m4macs.c	1.5 (gritter) 11/27/05
+ * Sccsid @(#)m4macs.c	1.6 (gritter) 11/2/08
  */
 
 #include	<inttypes.h>
@@ -124,10 +124,10 @@
 
 	while (c > 0)
 		if ((d = lookup(ap[c--])->def) != NULL) {
-			putbak(*rquote);
+			pbstr(rquote);
 			while (*d)
 				putbak(*d++);
-			putbak(*lquote);
+			pbstr(lquote);
 		}
 }
 
diff -Naur heirloom-devtools-070527/m4/version.c heirloom-devtools-last-cvs/m4/version.c
--- heirloom-devtools-070527/m4/version.c	2006-12-25 20:49:20.000000000 +0300
+++ heirloom-devtools-last-cvs/m4/version.c	2008-11-02 21:27:35.000000000 +0300
@@ -6,20 +6,16 @@
 #define	USED
 #endif
 #ifdef	XPG4
-static const char sccsid[] USED = "@(#)m4_xpg4.sl	2.5 (gritter) 12/25/06";
+static const char sccsid[] USED = "@(#)m4_xpg4.sl	2.6 (gritter) 11/2/08";
 #else
-static const char sccsid[] USED = "@(#)m4.sl	2.5 (gritter) 12/25/06";
+static const char sccsid[] USED = "@(#)m4.sl	2.6 (gritter) 11/2/08";
 #endif
 /* SLIST */
 /*
 m4.c: * Sccsid @(#)m4.c	1.3 (gritter) 10/29/05
 m4.h: * Sccsid @(#)m4.h	1.4 (gritter) 12/25/06
 m4ext.c: * Sccsid @(#)m4ext.c	1.3 (gritter) 10/29/05
-m4macs.c: * Sccsid @(#)m4macs.c	1.5 (gritter) 11/27/05
-m4y.c: * Sccsid @(#)m4y.y	1.5 (gritter) 11/27/05
-m4y.c: * Sccsid @(#)yaccpar	1.5 (gritter) 11/26/05
+m4macs.c: * Sccsid @(#)m4macs.c	1.6 (gritter) 11/2/08
 m4y.y: * Sccsid @(#)m4y.y	1.5 (gritter) 11/27/05
-m4y_xpg4.c: * Sccsid @(#)m4y_xpg4.y	1.4 (gritter) 11/27/05
-m4y_xpg4.c: * Sccsid @(#)yaccpar	1.5 (gritter) 11/26/05
 m4y_xpg4.y: * Sccsid @(#)m4y_xpg4.y	1.4 (gritter) 11/27/05
 */
diff -Naur heirloom-devtools-070527/make/include/mk/defs.h heirloom-devtools-last-cvs/make/include/mk/defs.h
--- heirloom-devtools-070527/make/include/mk/defs.h	2007-03-07 03:12:08.000000000 +0300
+++ heirloom-devtools-last-cvs/make/include/mk/defs.h	2010-08-07 16:42:07.000000000 +0400
@@ -33,7 +33,7 @@
 /*
  * Portions Copyright (c) 2007 Gunnar Ritter, Freiburg i. Br., Germany
  *
- * Sccsid @(#)defs.h	1.9 (gritter) 3/7/07
+ * Sccsid @(#)defs.h	1.10 (gritter) 8/7/10
  */
 
 /*
@@ -88,6 +88,9 @@
 #define SETVAR(name, value, append) \
 				setvar_daemon(name, value, append, no_daemon, \
 					      true, debug_level)
+#define SETVAR_KEEP_TRAILING_SPACES(name, value, append) \
+				setvar_daemon(name, value, append, no_daemon, \
+					      false, debug_level)
 #define MAX(a,b)		(((a)>(b))?(a):(b))
 /*
  * New feature added to SUN5_0 make,  invoke the vanilla svr4 make when
diff -Naur heirloom-devtools-070527/make/include/mksh/defs.h heirloom-devtools-last-cvs/make/include/mksh/defs.h
--- heirloom-devtools-070527/make/include/mksh/defs.h	2007-03-15 21:21:38.000000000 +0300
+++ heirloom-devtools-last-cvs/make/include/mksh/defs.h	2007-06-16 16:23:14.000000000 +0400
@@ -33,7 +33,7 @@
 /*
  * Portions Copyright (c) 2007 Gunnar Ritter, Freiburg i. Br., Germany
  *
- * Sccsid @(#)defs.h	1.11 (gritter) 3/15/07
+ * Sccsid @(#)defs.h	1.12 (gritter) 6/16/07
  */
 
 /*
@@ -982,7 +982,7 @@
 extern Boolean		dollarget_seen;
 extern Boolean		dollarless_flag;
 extern Name		dollarless_value;
-#ifdef __sun
+#if defined(__sun) || defined(__APPLE__)
 extern char		**environ;
 #endif
 extern Envvar		envvar;
diff -Naur heirloom-devtools-070527/make/src/getopt.c heirloom-devtools-last-cvs/make/src/getopt.c
--- heirloom-devtools-070527/make/src/getopt.c	2007-04-02 19:01:42.000000000 +0400
+++ heirloom-devtools-last-cvs/make/src/getopt.c	2007-12-16 23:54:50.000000000 +0300
@@ -26,7 +26,7 @@
 /*
  * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
  *
- * Sccsid @(#)getopt.c	1.9 (gritter) 4/2/07
+ * Sccsid @(#)getopt.c	1.10 (gritter) 12/16/07
  */
 /* from OpenSolaris "getopt.c	1.23	05/06/08 SMI" */
 
@@ -44,10 +44,12 @@
  * ([a-z][A-Z][0-9]).
  */
 
-#include <unistd.h>
+#include <sys/types.h>
 #include <string.h>
 #include <stdio.h>
 
+extern ssize_t	write(int, const void *, size_t);
+
 char	*optarg = NULL;
 int	optind = 1;
 int	opterr = 1;
@@ -202,3 +204,19 @@
 	}
 	return (c);
 } /* getopt() */
+
+#ifdef __APPLE__
+/*
+ * Starting with Mac OS 10.5 Leopard, <unistd.h> turns getopt()
+ * into getopt$UNIX2003() by default. Consequently, this function
+ * is called instead of the one defined above. However, optind is
+ * still taken from this file, so in effect, options are not
+ * properly handled. Defining an own getopt$UNIX2003() function
+ * works around this issue.
+ */
+int
+getopt$UNIX2003(int argc, char *const argv[], const char *optstring)
+{
+	return getopt(argc, argv, optstring);
+}
+#endif	/* __APPLE__ */
diff -Naur heirloom-devtools-070527/make/src/macro.cc heirloom-devtools-last-cvs/make/src/macro.cc
--- heirloom-devtools-070527/make/src/macro.cc	2007-01-13 16:51:02.000000000 +0300
+++ heirloom-devtools-last-cvs/make/src/macro.cc	2010-08-07 16:42:07.000000000 +0400
@@ -31,7 +31,7 @@
 /*
  * Portions Copyright (c) 2007 Gunnar Ritter, Freiburg i. Br., Germany
  *
- * Sccsid @(#)macro.cc	1.4 (gritter) 01/13/07
+ * Sccsid @(#)macro.cc	1.4 (gritter) 1/13/07
  */
 
 /*
diff -Naur heirloom-devtools-070527/make/src/main.cc heirloom-devtools-last-cvs/make/src/main.cc
--- heirloom-devtools-070527/make/src/main.cc	2007-03-07 03:14:43.000000000 +0300
+++ heirloom-devtools-last-cvs/make/src/main.cc	2010-08-07 16:42:07.000000000 +0400
@@ -31,7 +31,7 @@
 /*
  * Portions Copyright (c) 2007 Gunnar Ritter, Freiburg i. Br., Germany
  *
- * Sccsid @(#)main.cc	1.24 (gritter) 3/7/07
+ * Sccsid @(#)main.cc	1.26 (gritter) 8/7/10
  */
 
 /*
@@ -1529,7 +1529,7 @@
 
 	to = qstr;
 	for (from = str; *from; from++) {
-		if (*from == '\\') {
+		if (*from == '\\' && from[1]) {
 			from++;
 		}
 		*to++ = *from;
@@ -2460,13 +2460,15 @@
 	if (makeflags_string.buffer.start[1] != (int) nul_char) {
 		if (makeflags_string.buffer.start[1] != (int) space_char) {
 			MBSTOWCS(wcs_buffer, NOCATGETS("MFLAGS"));
-			SETVAR(GETNAME(wcs_buffer, FIND_LENGTH),
+			SETVAR_KEEP_TRAILING_SPACES(
+			              GETNAME(wcs_buffer, FIND_LENGTH),
 				      GETNAME(makeflags_string.buffer.start,
 					      FIND_LENGTH),
 				      false);
 		} else {
 			MBSTOWCS(wcs_buffer, NOCATGETS("MFLAGS"));
-			SETVAR(GETNAME(wcs_buffer, FIND_LENGTH),
+			SETVAR_KEEP_TRAILING_SPACES(
+			              GETNAME(wcs_buffer, FIND_LENGTH),
 				      GETNAME(makeflags_string.buffer.start + 2,
 					      FIND_LENGTH),
 				      false);
@@ -2515,7 +2517,7 @@
 				       );
 		}
 	}
-	SETVAR( makeflags
+	SETVAR_KEEP_TRAILING_SPACES( makeflags
 	             , makeflags_value_saved
 	             , false
 	             );
@@ -2676,18 +2678,18 @@
 	 && (!strcmp(mf_val->string_mb, makeflags_value_saved->string_mb)))
 	{
 		if (makeflags_string_posix.buffer.start[1] == (int) nul_char) {
-			SETVAR(makeflags,
+			SETVAR_KEEP_TRAILING_SPACES(makeflags,
 				      GETNAME(makeflags_string_posix.buffer.start + 1,
 					      FIND_LENGTH),
 				      false);
 		} else {
 			if (makeflags_string_posix.buffer.start[1] != (int) space_char) {
-				SETVAR(makeflags,
+				SETVAR_KEEP_TRAILING_SPACES(makeflags,
 					      GETNAME(makeflags_string_posix.buffer.start,
 						      FIND_LENGTH),
 					      false);
 			} else {
-				SETVAR(makeflags,
+				SETVAR_KEEP_TRAILING_SPACES(makeflags,
 					      GETNAME(makeflags_string_posix.buffer.start + 2,
 						      FIND_LENGTH),
 					      false);
@@ -3027,7 +3029,8 @@
 		} else {
 			macro = maybe_append_prop(name, macro_prop);
 			macro->body.macro.exported = true;
-			SETVAR(name, value, false)->body.macro.read_only = true;
+			SETVAR_KEEP_TRAILING_SPACES(name, value,
+				false)->body.macro.read_only = true;
 		}
 	}
 }
diff -Naur heirloom-devtools-070527/make/src/version.c heirloom-devtools-last-cvs/make/src/version.c
--- heirloom-devtools-070527/make/src/version.c	2007-03-15 21:21:44.000000000 +0300
+++ heirloom-devtools-last-cvs/make/src/version.c	2010-08-07 16:42:07.000000000 +0400
@@ -5,7 +5,7 @@
 #else
 #define USED
 #endif
-static const char id[] USED = "@(#)make.sl	1.40 (gritter) 3/15/07";
+static const char id[] USED = "@(#)make.sl	1.44 (gritter) 8/7/10";
 /* SLIST */
 /*
 ../bsd/bsd.cc: * Sccsid @(#)bsd.cc	1.6 (gritter) 01/22/07
@@ -13,25 +13,25 @@
 ../src/dist.cc: * Sccsid @(#)dist.cc	1.5 (gritter) 01/20/07
 ../src/ar.cc: * Sccsid @(#)ar.cc	1.5 (gritter) 01/13/07
 ../src/dosys.cc: * Sccsid @(#)dosys.cc	1.4 (gritter) 01/13/07
-../src/macro.cc: * Sccsid @(#)macro.cc	1.4 (gritter) 01/13/07
-../src/main.cc: * Sccsid @(#)main.cc	1.24 (gritter) 3/7/07
 ../src/make.cc: * Sccsid @(#)make.cc	1.2 (gritter) 01/07/07
 ../src/depvar.cc: * Sccsid @(#)depvar.cc	1.3 (gritter) 01/13/07
 ../src/implicit.cc: * Sccsid @(#)implicit.cc	1.5 (gritter) 2/16/07
 ../src/files.cc: * Sccsid @(#)files.cc	1.7 (gritter) 01/23/07
 ../src/posix.cc: * Sccsid @(#)posix.cc	1.1 (gritter) 01/13/07
-../src/misc.cc: * Sccsid @(#)misc.cc	1.12 (gritter) 3/7/07
 ../src/parallel.cc: * Sccsid @(#)parallel.cc	1.7 (gritter) 3/7/07
-../src/getopt.c: * Sccsid @(#)getopt.c	1.8 (gritter) 8/2/05
+../src/getopt.c: * Sccsid @(#)getopt.c	1.10 (gritter) 12/16/07
 ../src/nse.cc: * Sccsid @(#)nse.cc	1.2 (gritter) 01/07/07
 ../src/dmake.cc: * Sccsid @(#)dmake.cc	1.2 (gritter) 01/07/07
 ../src/globals.cc: * Sccsid @(#)globals.cc	1.8 (gritter) 3/6/07
 ../src/rep.cc: * Sccsid @(#)rep.cc	1.3 (gritter) 01/13/07
 ../src/state.cc: * Sccsid @(#)state.cc	1.4 (gritter) 2/26/07
-../src/doname.cc: * Sccsid @(#)doname.cc	1.11 (gritter) 3/7/07
 ../src/pmake.cc: * Sccsid @(#)pmake.cc	1.6 (gritter) 01/18/07
-../src/read2.cc: * Sccsid @(#)read2.cc	1.10 (gritter) 3/8/07
 ../src/nse_printdep.cc: * Sccsid @(#)nse_printdep.cc	1.4 (gritter) 01/13/07
+../src/misc.cc: * Sccsid @(#)misc.cc	1.12 (gritter) 3/7/07
+../src/main.cc: * Sccsid @(#)main.cc	1.26 (gritter) 8/7/10
+../src/doname.cc: * Sccsid @(#)doname.cc	1.11 (gritter) 3/7/07
+../src/read2.cc: * Sccsid @(#)read2.cc	1.10 (gritter) 3/8/07
+../src/macro.cc: * Sccsid @(#)macro.cc	1.4 (gritter) 1/13/07
 ../mksh/i18n.cc: * Sccsid @(#)i18n.cc	1.3 (gritter) 01/13/07
 ../mksh/read.cc: * Sccsid @(#)read.cc	1.3 (gritter) 01/13/07
 ../mksh/dosys.cc: * Sccsid @(#)dosys.cc	1.10 (gritter) 3/7/07
@@ -49,7 +49,7 @@
 ../vroot/setenv.cc: * Sccsid @(#)setenv.cc	1.3 (gritter) 01/13/07
 ../vroot/access.cc: * Sccsid @(#)access.cc	1.2 (gritter) 01/07/07
 ../vroot/chdir.cc: * Sccsid @(#)chdir.cc	1.2 (gritter) 01/07/07
-../vroot/lock.cc: * Sccsid @(#)lock.cc	1.4 (gritter) 01/13/07
+../vroot/lock.cc: * Sccsid @(#)lock.cc	1.5 (gritter) 10/1/07
 ../vroot/vroot.cc: * Sccsid @(#)vroot.cc	1.3 (gritter) 01/13/07
 ../vroot/stat.cc: * Sccsid @(#)stat.cc	1.2 (gritter) 01/07/07
 ../vroot/chmod.cc: * Sccsid @(#)chmod.cc	1.2 (gritter) 01/07/07
@@ -68,20 +68,20 @@
 ../vroot/readlink.cc: * Sccsid @(#)readlink.cc	1.2 (gritter) 01/07/07
 ../vroot/utimes.cc: * Sccsid @(#)utimes.cc	1.2 (gritter) 01/07/07
 ../mksdmsi18n/libmksdmsi18n_init.cc: * Sccsid @(#)libmksdmsi18n_init.cc	1.5 (gritter) 01/13/07
-../include/mk/defs.h: * Sccsid @(#)defs.h	1.9 (gritter) 3/7/07
 ../include/mk/copyright.h: * Sccsid @(#)copyright.h	1.2 (gritter) 01/07/07
+../include/mk/defs.h: * Sccsid @(#)defs.h	1.10 (gritter) 8/7/10
 ../include/avo/avo_alloca.h: * Sccsid @(#)avo_alloca.h	1.4 (gritter) 01/21/07
 ../include/avo/intl.h: * Sccsid @(#)intl.h	1.3 (gritter) 01/13/07
 ../include/bsd/bsd.h: * Sccsid @(#)bsd.h	1.4 (gritter) 01/22/07
 ../include/mksh/dosys.h: * Sccsid @(#)dosys.h	1.2 (gritter) 01/07/07
 ../include/mksh/macro.h: * Sccsid @(#)macro.h	1.2 (gritter) 01/07/07
 ../include/mksh/i18n.h: * Sccsid @(#)i18n.h	1.2 (gritter) 01/07/07
+../include/mksh/defs.h: * Sccsid @(#)defs.h	1.12 (gritter) 6/16/07
 ../include/mksh/misc.h: * Sccsid @(#)misc.h	1.2 (gritter) 01/07/07
 ../include/mksh/mksh.h: * Sccsid @(#)mksh.h	1.2 (gritter) 01/07/07
 ../include/mksh/read.h: * Sccsid @(#)read.h	1.2 (gritter) 01/07/07
 ../include/mksh/globals.h: * Sccsid @(#)globals.h	1.2 (gritter) 01/07/07
 ../include/mksh/libmksh_init.h: * Sccsid @(#)libmksh_init.h	1.2 (gritter) 01/07/07
-../include/mksh/defs.h: * Sccsid @(#)defs.h	1.11 (gritter) 3/15/07
 ../include/vroot/report.h: * Sccsid @(#)report.h	1.2 (gritter) 01/07/07
 ../include/vroot/args.h: * Sccsid @(#)args.h	1.4 (gritter) 01/23/07
 ../include/vroot/vroot.h: * Sccsid @(#)vroot.h	1.2 (gritter) 01/07/07
diff -Naur heirloom-devtools-070527/make/vroot/lock.cc heirloom-devtools-last-cvs/make/vroot/lock.cc
--- heirloom-devtools-070527/make/vroot/lock.cc	2007-01-13 16:50:54.000000000 +0300
+++ heirloom-devtools-last-cvs/make/vroot/lock.cc	2007-10-01 15:44:26.000000000 +0400
@@ -31,7 +31,7 @@
 /*
  * Portions Copyright (c) 2007 Gunnar Ritter, Freiburg i. Br., Germany
  *
- * Sccsid @(#)lock.cc	1.4 (gritter) 01/13/07
+ * Sccsid @(#)lock.cc	1.5 (gritter) 10/1/07
  */
 
 #include <avo/intl.h>	/* for NOCATGETS */
@@ -53,7 +53,7 @@
 extern	int		sys_nerr;
 #endif
 
-static	void		file_lock_error(char *msg, char *file, char *str, int arg1, int arg2);
+static	void		file_lock_error(char *msg, char *file, char *str, const char *arg1, const char *arg2);
 
 #define BLOCK_INTERUPTS sigfillset(&newset) ; \
 	sigprocmask(SIG_SETMASK, &newset, &oldset)
@@ -123,7 +123,7 @@
 
 		if (errno != EEXIST) {
 			file_lock_error(msg, name, NOCATGETS("symlink(%s, %s)"),
-			    (int) name, (int) lockname);
+			    name, lockname);
 			fprintf(stderr, "%s", msg);
 			return errno;
 		}
@@ -171,7 +171,8 @@
  * Format a message telling why the lock could not be created.
  */
 static	void
-file_lock_error(char *msg, char *file, char *str, int arg1, int arg2)
+file_lock_error(char *msg, char *file, char *str,
+	const char *arg1, const char *arg2)
 {
 	int		len;
 
diff -Naur heirloom-devtools-070527/mk.config heirloom-devtools-last-cvs/mk.config
--- heirloom-devtools-070527/mk.config	2007-05-27 20:56:51.000000000 +0400
+++ heirloom-devtools-last-cvs/mk.config	2007-03-17 17:01:03.000000000 +0300
@@ -5,7 +5,7 @@
 # compatibility with traditional tools, the Heirloom Bourne shell is
 # recommended. It then must obviously be compiled and installed first.
 #
-SHELL = /bin/sh
+SHELL = /sbin/sh
 
 #
 # Specify the path name for a POSIX-conforming shell here. For example,
@@ -47,7 +47,7 @@
 #
 # Binaries are stripped with this command after installation.
 #
-STRIP=strip
+STRIP=strip -s -R .comment -R .note
 
 #
 # C++ compiler.
@@ -71,7 +71,7 @@
 #
 # Warning flags for the compiler.
 #
-WARN=
+#WARN=
 
 #
 # Linker flags.
diff -Naur heirloom-devtools-070527/pkginfo heirloom-devtools-last-cvs/pkginfo
--- heirloom-devtools-070527/pkginfo	2007-05-27 20:56:51.000000000 +0400
+++ heirloom-devtools-last-cvs/pkginfo	2007-02-25 01:54:17.000000000 +0300
@@ -5,7 +5,7 @@
 VENDOR=Gunnar Ritter
 HOTLINE=http://heirloom.sourceforge.net
 EMAIL=gunnarr@acm.org
-VERSION=070527
+VERSION=070224
 ARCH=IA32,i386
 CATEGORY=utilities
 BASEDIR=/
diff -Naur heirloom-devtools-070527/sccs/mpwlib/getopt.c heirloom-devtools-last-cvs/sccs/mpwlib/getopt.c
--- heirloom-devtools-070527/sccs/mpwlib/getopt.c	2007-04-02 19:01:42.000000000 +0400
+++ heirloom-devtools-last-cvs/sccs/mpwlib/getopt.c	2007-12-16 23:54:50.000000000 +0300
@@ -26,7 +26,7 @@
 /*
  * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
  *
- * Sccsid @(#)getopt.c	1.9 (gritter) 4/2/07
+ * Sccsid @(#)getopt.c	1.10 (gritter) 12/16/07
  */
 /* from OpenSolaris "getopt.c	1.23	05/06/08 SMI" */
 
@@ -44,10 +44,12 @@
  * ([a-z][A-Z][0-9]).
  */
 
-#include <unistd.h>
+#include <sys/types.h>
 #include <string.h>
 #include <stdio.h>
 
+extern ssize_t	write(int, const void *, size_t);
+
 char	*optarg = NULL;
 int	optind = 1;
 int	opterr = 1;
@@ -202,3 +204,19 @@
 	}
 	return (c);
 } /* getopt() */
+
+#ifdef __APPLE__
+/*
+ * Starting with Mac OS 10.5 Leopard, <unistd.h> turns getopt()
+ * into getopt$UNIX2003() by default. Consequently, this function
+ * is called instead of the one defined above. However, optind is
+ * still taken from this file, so in effect, options are not
+ * properly handled. Defining an own getopt$UNIX2003() function
+ * works around this issue.
+ */
+int
+getopt$UNIX2003(int argc, char *const argv[], const char *optstring)
+{
+	return getopt(argc, argv, optstring);
+}
+#endif	/* __APPLE__ */
diff -Naur heirloom-devtools-070527/yacc/getopt.c heirloom-devtools-last-cvs/yacc/getopt.c
--- heirloom-devtools-070527/yacc/getopt.c	2007-04-02 19:01:42.000000000 +0400
+++ heirloom-devtools-last-cvs/yacc/getopt.c	2007-12-16 23:54:50.000000000 +0300
@@ -26,7 +26,7 @@
 /*
  * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
  *
- * Sccsid @(#)getopt.c	1.9 (gritter) 4/2/07
+ * Sccsid @(#)getopt.c	1.10 (gritter) 12/16/07
  */
 /* from OpenSolaris "getopt.c	1.23	05/06/08 SMI" */
 
@@ -44,10 +44,12 @@
  * ([a-z][A-Z][0-9]).
  */
 
-#include <unistd.h>
+#include <sys/types.h>
 #include <string.h>
 #include <stdio.h>
 
+extern ssize_t	write(int, const void *, size_t);
+
 char	*optarg = NULL;
 int	optind = 1;
 int	opterr = 1;
@@ -202,3 +204,19 @@
 	}
 	return (c);
 } /* getopt() */
+
+#ifdef __APPLE__
+/*
+ * Starting with Mac OS 10.5 Leopard, <unistd.h> turns getopt()
+ * into getopt$UNIX2003() by default. Consequently, this function
+ * is called instead of the one defined above. However, optind is
+ * still taken from this file, so in effect, options are not
+ * properly handled. Defining an own getopt$UNIX2003() function
+ * works around this issue.
+ */
+int
+getopt$UNIX2003(int argc, char *const argv[], const char *optstring)
+{
+	return getopt(argc, argv, optstring);
+}
+#endif	/* __APPLE__ */
