Apple's X11 1.0 shipped with Panther has two major problems.

Problem 1. X_LOCALE

Panther has locale support but Apple left X_LOCALE enabled. It broke
many programs' i18n support.

Problem 2. #pragma GCC

Cpp of Apple's gcc3.3 puts "#pragma GCC" at the top of preprocessed
file. X uses cpp widely and therefore X is suffered many problems.
For example:

#pragma GCC set_debug_pwd "..."
#!/bin/sh

I made a workaround package named "fix-apple-x11".

Solution 1.

Compile Xlib without X_LOCALE and install it at /sw/fix-apple-x11/lib.
Then override original libX11.6.dylib by DYLD_LIBRARY_PATH magic.
For binary compatibility I added stub _Xsetlocale.

To prevent newly built programs depend on fix-apple-x11, you must not
add -L/sw/fix-apple-x11/lib to LDFLAGS unless you link libX11.a
statically. I removed libX11.dylib to avoid the mistake.

Solution 2.

#define CppCmd /usr/bin/cpp3 as XFree86 4.4.0 does.
Then install properly generated files in /sw/fix-apple/x11/{bin,lib}.
In addition install sane imake config files for non-X programs which
depend on imake.

Please try attached package. Any comment is welcome.

Section: x11-system
Target OS: 10.3
Package: fix-apple-x11
Version: 1.0
Revision: 2
Depends: system-xfree86 (>= 2:4.3-2)
Conflicts: system-xfree86 (>= 2:4.3.99), xfree86-shlibs, xfree86-rootless, 
xfree86-rootless-threaded, xfree86
Source: 
http://www.opensource.apple.com/darwinsource/tarballs/other/X11ForMacOSXSource-%v.tar.gz
Source-MD5: 9e4b2a221e2df1b30a0bf1f92df49613
SourceDirectory: X11ForMacOSXSource-%v/xc
PatchScript: sed 's|@PREFIX@|%p|g' <%a/%n.patch | patch -p2
CompileScript: make World
InstallScript: <<
  make install DESTDIR=%d
  ( cd %i/fix-apple-x11 && xargs rm ) < files-to-remove
  install -c -m 755 prepend-path %i/fix-apple-x11/bin
  install -d -m 755 %i/etc/profile.d
  install -c -m 755 fix-apple-x11.sh fix-apple-x11.csh %i/etc/profile.d
<<
#
Description: Kit to fix problems of Apple's X11 1.0
DescDetail: <<
Apple's X11 1.0 shipped with Panther has two major problems; X_LOCALE
and #prama GCC. This kit implements workaround for these problems by
some magic.
<<
License: BSD
Homepage: http://www.xfree86.org/
Maintainer: Univ. of Tokyo Educational Computing System Tutors <[EMAIL PROTECTED]>
diff -Nru X11ForMacOSXSource-1.0.orig/xc/config/cf/Imakefile 
X11ForMacOSXSource-1.0/xc/config/cf/Imakefile
--- X11ForMacOSXSource-1.0.orig/xc/config/cf/Imakefile  Fri Mar 14 08:56:16 2003
+++ X11ForMacOSXSource-1.0/xc/config/cf/Imakefile       Fri Feb 27 02:39:42 2004
@@ -133,7 +133,7 @@
 
 all::
 
-#if BuildLibraries
+#if BuildLibraries || ForceInstallConfigFiles
 InstallMultipleDestFlags(install,$(INSTFILES),$(CONFIGDIR),$(INSTDATFLAGS))
 #endif
 
diff -Nru X11ForMacOSXSource-1.0.orig/xc/config/cf/X11.tmpl 
X11ForMacOSXSource-1.0/xc/config/cf/X11.tmpl
--- X11ForMacOSXSource-1.0.orig/xc/config/cf/X11.tmpl   Sat Mar 15 06:32:13 2003
+++ X11ForMacOSXSource-1.0/xc/config/cf/X11.tmpl        Fri Feb 27 02:39:42 2004
@@ -2181,14 +2181,14 @@
 #define GLwUseXmStubs          NO      /* create stub (weak) Motif symbols */
 #endif
 #else
-#undef  SharedLibGlw
-#define SharedLibGlw           NO
-#undef  NormalLibGlw
-#define NormalLibGlw           NO
-#undef  DebugLibGlw
-#define DebugLibGlw            NO
-#undef  ProfileLibGlw
-#define ProfileLibGlw          NO
+#undef  SharedLibGLw
+#define SharedLibGLw           NO
+#undef  NormalLibGLw
+#define NormalLibGLw           NO
+#undef  DebugLibGLw
+#define DebugLibGLw            NO
+#undef  ProfileLibGLw
+#define ProfileLibGLw          NO
 #endif
 
 #ifndef SharedLibXext
diff -Nru X11ForMacOSXSource-1.0.orig/xc/config/cf/darwin.cf 
X11ForMacOSXSource-1.0/xc/config/cf/darwin.cf
--- X11ForMacOSXSource-1.0.orig/xc/config/cf/darwin.cf  Sat Mar 15 06:32:13 2003
+++ X11ForMacOSXSource-1.0/xc/config/cf/darwin.cf       Fri Feb 27 02:39:42 2004
@@ -121,8 +121,17 @@
 
 #define MkdirHierCmd            mkdir -p
 
-/* our cpp isn't in /lib/cpp and early versions don't like -undef */
-#define CppCmd                  /usr/bin/cpp
+/*
+ * Our cpp isn't in /lib/cpp and early versions don't like -undef.
+ * The default cpp-3.3 that ships with Panther inserts spurious #pragmas,
+ * so we use the 3.1-based version.
+ */
+#if OSMajorVersion >= 7
+# define CppCmd                 /usr/bin/cpp3
+# define StandardCppOptions     -traditional -D__GNUC__
+#else
+# define CppCmd                 /usr/bin/cpp
+#endif
 #if HasGcc3
 # define RawCppCmd              CppCmd -undef
 #else
@@ -157,16 +166,22 @@
 #define OptimizedCDebugFlags   -g -Os
 #define ByteOrder              UNKNOWN_BYTE_ORDER
 
+#if OSMajorVersion < 7
+# define DarwinLocaleDefines    -DX_LOCALE
+#else
+# define DarwinLocaleDefines    /**/
+/* we use installed Apple's Xaw */
+/* # define XawI18nDefines         -DHAS_WCHAR_H -DHAS_WCTYPE_H -DNO_WIDEC_H */
+#endif
+
 /*
  * __DARWIN__ will be used for platform specific #ifdefs that can't
  * be handled by existing X defines.
  *
  * Darwin's alloca() seg faults (rather than returning NULL) on failed
  * allocations, so we can't use it.
- *
- * Darwin's setlocale() doesn't work properly, so use X11's instead.
  */
-#define StandardDefines         -D__DARWIN__ -DNO_ALLOCA -DX_LOCALE -DCSRG_BASED
+#define StandardDefines         -D__DARWIN__ -DNO_ALLOCA -DCSRG_BASED 
DarwinLocaleDefines
 
 /*
  * Set this to NO to just build the client libs, which should work without
diff -Nru X11ForMacOSXSource-1.0.orig/xc/config/cf/host.def 
X11ForMacOSXSource-1.0/xc/config/cf/host.def
--- X11ForMacOSXSource-1.0.orig/xc/config/cf/host.def   Thu Jan  1 09:00:00 1970
+++ X11ForMacOSXSource-1.0/xc/config/cf/host.def        Fri Feb 27 02:49:52 2004
@@ -0,0 +1,32 @@
+#ifdef BeforeVendorCF
+
+#define BuildServersOnly YES /* fake */
+#define BuildServer NO
+#define XAppleServer NO
+#define NormalX11Lib YES
+#define BuildX11Lib YES
+#define LinkGLToUsrInclude NO
+#define BuildGlxExt NO
+#define InstallEmptyHostDef
+#define NothingOutsideProjectRoot YES
+
+#define ProjectRoot @PREFIX@/fix-apple-x11
+#define XLocaleDir OriginalLibDir/locale
+#define X11perfcompLib OriginalLibDir/x11perfcomp
+
+/* our local facility */
+#define BuildCppScripts YES
+#define BuildCppScriptsOnly YES
+#define OriginalLibDir /usr/X11R6/lib/X11
+#define RstartLibDir OriginalLibDir/rstart
+#define DontBuildFontLib YES
+#define ForceInstallConfigFiles YES
+
+#endif /* BeforeVendorCF */
+
+#ifdef AfterVendorCF
+
+#undef BuildXInputLib
+#define BuildXInputLib NO
+
+#endif /* BeforeVendorCF */
diff -Nru X11ForMacOSXSource-1.0.orig/xc/files-to-remove 
X11ForMacOSXSource-1.0/xc/files-to-remove
--- X11ForMacOSXSource-1.0.orig/xc/files-to-remove      Thu Jan  1 09:00:00 1970
+++ X11ForMacOSXSource-1.0/xc/files-to-remove   Fri Feb 27 02:39:42 2004
@@ -0,0 +1,11 @@
+bin/lndir
+bin/cleanlinks
+bin/imake
+bin/makedepend
+bin/makeg
+bin/makestrs
+bin/mkdirhier
+bin/mkhtmlindex
+bin/revpath
+bin/rman
+lib/libX11.dylib
diff -Nru X11ForMacOSXSource-1.0.orig/xc/fix-apple-x11.csh 
X11ForMacOSXSource-1.0/xc/fix-apple-x11.csh
--- X11ForMacOSXSource-1.0.orig/xc/fix-apple-x11.csh    Thu Jan  1 09:00:00 1970
+++ X11ForMacOSXSource-1.0/xc/fix-apple-x11.csh Fri Feb 27 02:39:42 2004
@@ -0,0 +1,5 @@
+set [EMAIL PROTECTED]@/fix-apple-x11/bin
+set [EMAIL PROTECTED]@/fix-apple-x11/lib
+setenv PATH `$bindir/prepend-path "$PATH" $bindir`
+setenv DYLD_LIBRARY_PATH `$bindir/prepend-path "$DYLD_LIBRARY_PATH" $libdir`
+unset bindir libdir
diff -Nru X11ForMacOSXSource-1.0.orig/xc/fix-apple-x11.sh 
X11ForMacOSXSource-1.0/xc/fix-apple-x11.sh
--- X11ForMacOSXSource-1.0.orig/xc/fix-apple-x11.sh     Thu Jan  1 09:00:00 1970
+++ X11ForMacOSXSource-1.0/xc/fix-apple-x11.sh  Fri Feb 27 02:39:42 2004
@@ -0,0 +1,6 @@
[EMAIL PROTECTED]@/fix-apple-x11/bin
[EMAIL PROTECTED]@/fix-apple-x11/lib
+PATH=`$bindir/prepend-path "$PATH" $bindir`
+DYLD_LIBRARY_PATH=`$bindir/prepend-path "$DYLD_LIBRARY_PATH" $libdir`
+unset bindir libdir
+export PATH DYLD_LIBRARY_PATH
diff -Nru X11ForMacOSXSource-1.0.orig/xc/lib/Imakefile 
X11ForMacOSXSource-1.0/xc/lib/Imakefile
--- X11ForMacOSXSource-1.0.orig/xc/lib/Imakefile        Fri Mar 14 08:58:19 2003
+++ X11ForMacOSXSource-1.0/xc/lib/Imakefile     Fri Feb 27 02:39:42 2004
@@ -164,7 +164,9 @@
 FONTCACHELIBDIR = Xfontcache
 #endif
 
+#if !DontBuildFontLib
 FONTSUBDIR = font
+#endif
 
 #if BuildFontEncLib
 FONTENCSUBDIR = fontenc
diff -Nru X11ForMacOSXSource-1.0.orig/xc/lib/X11/Imakefile 
X11ForMacOSXSource-1.0/xc/lib/X11/Imakefile
--- X11ForMacOSXSource-1.0.orig/xc/lib/X11/Imakefile    Fri Mar 14 08:58:32 2003
+++ X11ForMacOSXSource-1.0/xc/lib/X11/Imakefile Sun Apr  4 04:17:15 2004
@@ -84,9 +84,15 @@
 
     XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines
 
+#ifdef OriginalLibDir
+     EDB_DEFINES = -DERRORDB=\"OriginalLibDir/XErrorDB\"
+     KDB_DEFINES = -DKEYSYMDB=\"OriginalLibDir/XKeysymDB\"
+     CMS_DEFINES = -DXCMSDB=\"OriginalLibDir/Xcms.txt\"
+#else
      EDB_DEFINES = -DERRORDB=\"$(LIBDIR)/XErrorDB\"
      KDB_DEFINES = -DKEYSYMDB=\"$(LIBDIR)/XKeysymDB\"
      CMS_DEFINES = -DXCMSDB=\"$(LIBDIR)/Xcms.txt\"
+#endif
 #if HasSnprintf
     MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11
 #endif
@@ -128,9 +134,12 @@
        AUTHSRCS = AuDispose.c AuGetBest.c AuFileName.c AuRead.c
            SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(EXTRASRCS) /* try *.c if you have 
trouble */
         HEADERS = Xlib.h Xresource.h Xutil.h cursorfont.h Xlibint.h \
-                       Xcms.h Xlocale.h XKBlib.h
+                       Xcms.h Xlocale.h XKBlib.h $(AUTHHEADERS)
        LINTLIBS =
 
+#if !BuildXauLib
+AUTHHEADERS = Xauth.h
+#endif
 #if BuildLoadableXlibI18n && DoSharedLib
 EXTRASHAREDSRC = $(SHAREDLCSRCS)
 #endif
@@ -1028,11 +1037,13 @@
 
SpecialCLibObjectRuleSeparateOpts(PutImage,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES))
 #endif
 
+#ifndef OriginalLibDir
 #if InstallXcmsTxt
 InstallNonExecFile(Xcms.txt,$(LIBDIR))
 #endif
 InstallNonExecFile(XErrorDB,$(LIBDIR))
 InstallNonExecFile(XKeysymDB,$(LIBDIR))
+#endif
 InstallLintLibrary(X11,$(LINTLIBDIR))
 
 
@@ -1040,6 +1051,9 @@
 LinkSourceFile(AuGetBest.c,$(XAUTHSRC))
 LinkSourceFile(AuFileName.c,$(XAUTHSRC))
 LinkSourceFile(AuRead.c,$(XAUTHSRC))
+#if !BuildXauLib
+LinkSourceFile(Xauth.h,$(XAUTHSRC))
+#endif
 #if HasKrb5
 LinkSourceFile(k5encode.c,$(XAUTHSRC))
 #endif
diff -Nru X11ForMacOSXSource-1.0.orig/xc/lib/X11/SetLocale.c 
X11ForMacOSXSource-1.0/xc/lib/X11/SetLocale.c
--- X11ForMacOSXSource-1.0.orig/xc/lib/X11/SetLocale.c  Fri Mar 14 08:58:34 2003
+++ X11ForMacOSXSource-1.0/xc/lib/X11/SetLocale.c       Fri Feb 27 02:39:43 2004
@@ -123,6 +123,17 @@
 
 #else /* X_LOCALE */
 
+#ifdef __DARWIN__
+char *
+_Xsetlocale(
+    int           category,
+    _Xconst char  *name
+)
+{
+    return setlocale(category, name);
+}
+#endif /* __DARWIN__ */
+
 /*
  * _XlcMapOSLocaleName is an implementation dependent routine that derives
  * the LC_CTYPE locale name as used in the sample implementation from that
diff -Nru X11ForMacOSXSource-1.0.orig/xc/prepend-path 
X11ForMacOSXSource-1.0/xc/prepend-path
--- X11ForMacOSXSource-1.0.orig/xc/prepend-path Thu Jan  1 09:00:00 1970
+++ X11ForMacOSXSource-1.0/xc/prepend-path      Fri Feb 27 02:39:43 2004
@@ -0,0 +1,37 @@
+#!/bin/sh
+old="$1"
+list="$2"
+oldIFS="$IFS"
+
+IFS=":"
+set x $list
+shift
+IFS="$oldIFS"
+
+rlist=
+case "$#" in
+    0)
+    rlist=
+    ;;
+    *)
+    rlist="$1"
+    shift
+    for p in "$@"; do
+       rlist="$p:$rlist"
+    done
+esac
+
+IFS=":"
+set x $rlist
+shift
+IFS="$oldIFS"
+
+new="$old"
+for p in "$@"; do
+    case "$new" in
+       "") new="$p" ;;
+       "$p"|"$p":*|*:"$p"|*:"$p":*) ;;
+       *) new="$p:$new" ;;
+    esac
+done
+echo "$new"
diff -Nru X11ForMacOSXSource-1.0.orig/xc/programs/Imakefile 
X11ForMacOSXSource-1.0/xc/programs/Imakefile
--- X11ForMacOSXSource-1.0.orig/xc/programs/Imakefile   Sat Mar 15 06:35:03 2003
+++ X11ForMacOSXSource-1.0/xc/programs/Imakefile        Fri Feb 27 02:39:43 2004
@@ -108,8 +108,12 @@
    XCURSORGENDIR = xcursorgen
 #endif
 
+#if BuildCppScripts
+CPPSCRIPTDIR = rstart x11perf xinit
+#endif
+
 #if BuildServersOnly || !BuildClients
-SUBDIRS = $(XSSRCDIR)
+SUBDIRS = $(XSSRCDIR) $(CPPSCRIPTDIR)
 #else
 SUBDIRS = \
        appres bdftopcf bitmap \
diff -Nru X11ForMacOSXSource-1.0.orig/xc/programs/rstart/Imakefile 
X11ForMacOSXSource-1.0/xc/programs/rstart/Imakefile
--- X11ForMacOSXSource-1.0.orig/xc/programs/rstart/Imakefile    Fri Mar 14 08:58:47 
2003
+++ X11ForMacOSXSource-1.0/xc/programs/rstart/Imakefile Fri Feb 27 02:39:43 2004
@@ -37,7 +37,10 @@
 OS=
 CLIENTNAME=rstart
 
-MYLIBDIR=$(LIBDIR)/rstart
+#ifndef RstartLibDir
+# define RstartLibDir $(LIBDIR)/rstart
+#endif
+MYLIBDIR=RstartLibDir
 ENVPREFIX=RSTART
 PACKAGEname=rstart
 
@@ -65,11 +68,13 @@
 PEDEFS = -DNOPUTENV
 #endif
 
+#if !BuildCppScriptsOnly
 AllTarget(ProgramTargetName($(RSERVERNAME)))
 NormalProgramTarget($(RSERVERNAME), $(OBJS),NullParameter,NullParameter,NullParameter)
 InstallProgram($(RSERVERNAME),$(MYLIBDIR))
 
 SpecialCObjectRule(server,NullParameter,$(SRVDEFS) $(PEDEFS))
+#endif
 
 AllTarget($(SSERVERNAME))
 CppScriptTarget($(SSERVERNAME),$(SSERVERSRC),$(OS) -DLIBDIR=$(MYLIBDIR) 
-DSERVERNAME=$(SERVERNAME),NullParameter)
@@ -79,6 +84,7 @@
 CppScriptTarget($(CLIENTNAME),client.cpp,-DRSHCMD=$(RSHCMD) 
-DSERVERNAME=$(SERVERNAME),NullParameter)
 InstallNamedProg($(CLIENTNAME),$(CLIENTNAME),$(BINDIR))
 
+#if !BuildCppScriptsOnly
 AllTarget(config)
 CppFileTarget(config,config.cpp,-DBINDIR=$(BINDIR) -DLIBDIR=$(MYLIBDIR) 
-DPACKAGEname=$(PACKAGEname) -DENVPREFIX=$(ENVPREFIX),NullParameter)
 InstallNonExecFile(config,$(MYLIBDIR))
@@ -146,6 +152,7 @@
        Recurse(commands,$(MYLIBDIR),FilterCommand)
        Recurse(contexts,$(MYLIBDIR),FilterContext)
        InstallAliases()
+#endif /* !BuildCppScriptsOnly */
 
 InstallManPage(rstart,$(MANDIR))
 InstallManPage(rstartd,$(MANDIR))
@@ -155,5 +162,7 @@
 XCOMM # DNS.)
 XCOMM #CFLAGS=-DODT1_DISPLAY_HACK
 
+#if !BuildCppScriptsOnly
 LinkConfDirectory(rstart,.,rstart,.)
+#endif
 
diff -Nru X11ForMacOSXSource-1.0.orig/xc/programs/x11perf/Imakefile 
X11ForMacOSXSource-1.0/xc/programs/x11perf/Imakefile
--- X11ForMacOSXSource-1.0.orig/xc/programs/x11perf/Imakefile   Fri Mar 14 08:58:49 
2003
+++ X11ForMacOSXSource-1.0/xc/programs/x11perf/Imakefile        Fri Feb 27 02:39:43 
2004
@@ -50,16 +50,20 @@
 #endif
 #endif
 
+#if !BuildCppScriptsOnly
 ComplexProgramTarget(x11perf)
+#endif
 
 all:: x11perfcomp
 
 CppScriptTarget(x11perfcomp,x11pcomp.cpp,-DLIBPATH=$(PERFLIB),$(ICONFIGFILE))
 
 InstallNamedProg(x11perfcomp,x11perfcomp,$(BINDIR))
+#if !BuildCppScriptsOnly
 InstallNamedProg(fillblnk.sh,fillblnk,$(PERFLIB))
 InstallNamedProg(perfboth.sh,perfboth,$(PERFLIB))
 InstallNamedProg(perfratio.sh,perfratio,$(PERFLIB))
 InstallNamedProg(Xmark.sh,Xmark,$(BINDIR))
 InstallManPage(Xmark,$(MANDIR))
 InstallManPageLong(x11pcomp,$(MANDIR),x11perfcomp)
+#endif
diff -Nru X11ForMacOSXSource-1.0.orig/xc/programs/xinit/Imakefile 
X11ForMacOSXSource-1.0/xc/programs/xinit/Imakefile
--- X11ForMacOSXSource-1.0.orig/xc/programs/xinit/Imakefile     Fri Mar 14 08:58:59 
2003
+++ X11ForMacOSXSource-1.0/xc/programs/xinit/Imakefile  Fri Feb 27 02:39:43 2004
@@ -26,9 +26,13 @@
      COOKIEDEFS = -DHAS_COOKIE_MAKER -DMK_COOKIE=MkCookieCmd
 #endif
 
+#if BuildCppScriptsOnly
+all:: $(SAMPLECONFIG)
+#else
 all:: startx $(SAMPLECONFIG)
 
 ComplexProgramTarget_1(xinit,$(LOCAL_LIBRARIES),$(DEFFILE))
+#endif
 
 MakeScriptFromCpp(xinitrc, -DXINITDIR=$(XINITDIR))
 

Reply via email to