home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / windows / x / 20448 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  6.7 KB

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!strath-cs!cen.ex.ac.uk!JRowe
  2. From: JRowe@cen.ex.ac.uk (J.Rowe)
  3. Newsgroups: comp.windows.x
  4. Subject: Making X11R5 on Convex
  5. Message-ID: <BzMEpx.J7y@cen.ex.ac.uk>
  6. Date: 21 Dec 92 17:46:45 GMT
  7. Sender: JRowe@cen.ex.ac.uk (J.Rowe)
  8. Distribution: comp.windows.x
  9. Organization: Computer Unit. - University of Exeter. UK
  10. Lines: 195
  11.  
  12. A month or so ago I asked if anyone had managed to get X11R5 to
  13. compile on a Convex. Thanks for all the replies, this is how I did it.
  14.  
  15. First, the problem. As far as I can tell ConvexOS comes with an
  16. amazing five (count 'em FIVE) c preprocessors, all with different
  17. bugs. There's /lib/cpp which seems to have no function other than to
  18. be documented in the man page.  Then there's /usr/lib/cc/cpp which is
  19. the one that gets exec ed by cc if you do a cc - E.  This can do
  20. either ANSI or K&R preprocessing. Of course, when you actually compile
  21. the code cc doesn't use this preprocessor! No, it has its own internal
  22. one, with its own bugs. Finally, Convex also ship a K&R only c
  23. compiler which lives in /usr/lib/pcc, I assume this has its own pair
  24. of preprocessors. (Gratuitous aside - would you by an OS with five c
  25. preprocessors?) The problem is string concatenation - they jus' don'
  26. do it right.
  27.  
  28. Fortunately the technical guys are still very helpful when they are
  29. allowed to look at customers' problems and Richard Hargrove of Convex
  30. e-mailed me a patch to two files in the mit/config directory (patch
  31. follows at end of article). This didn't quite work using patch on my
  32. copy of X11R5 but since it was just two chunks of code it was trivial
  33. to edit the files by hand. This fixed the problems in whichever of the
  34. many versions of cpp that didn't work when trying to make the make
  35. files.
  36.  
  37. Well, the make files made OK! But then some compilations barfed because
  38. the compiler's internal preprocessor wan't concatenating strings.
  39.  
  40. So I wrote by own cc in perl (follows at end of article) and put it in
  41. /usr/local/bin/cc which comes first in by path. This tried a straight
  42. compile and, if that failed, stuck it through cc -E -pcc and then
  43. compiled the results.  (The script actually tried up to four different
  44. preprocessors until one worked but I don't think it needed to go past
  45. the first). This made OK and as far as I know it WORKS. 
  46.  
  47. Major caveat - all I tried it on was emacs and xterm.  There could be
  48. a million errors I don't know about, comments welcome.
  49.  
  50. Incidently I had to chmod -x /usr/local/bin/make (gnu make) because it
  51. passes its internal variables via environmental variables. Convex CC
  52. takes notice of the value of CCOPTIONS you get stung.
  53.  
  54. A couple of people said in e-mail that their system managers
  55. had managed to compile X11R5 themselves, they may have done a better
  56. job of it. If you want to ask them how they did it e-mail me and I
  57. will forward your request to them, it not being considered over
  58. ethical to quote private e-mail over the net.
  59.  
  60. The final twist is that Convex UK decided to give me their version of
  61. X-windows, and CXWindows 3.0 is R5 anyway. Does this make Convex one
  62. of the first vendors to ship R5?
  63.  
  64. Again, thanks to all those who replied.
  65.  
  66. John
  67.  
  68. Patch to files in mit/config:
  69.  
  70. *** Project.tmpl    Fri Nov  6 16:53:30 1992
  71. --- Project.tmpl.R5fixed    Thu Nov 12 17:46:24 1992
  72. ***************
  73. *** 634,640 ****
  74.    *           exists to avoid problems with some preprocessors
  75.    */
  76.   #ifndef _UseCat
  77. ! #if (defined (__STDC__) || (defined(__convex__) && defined(__stdc__))) && !defined(UnixCpp)
  78.   #ifdef UseInstalled
  79.   #define _UseCat(a,b,c) a##c
  80.   #else
  81. --- 634,640 ----
  82.    *           exists to avoid problems with some preprocessors
  83.    */
  84.   #ifndef _UseCat
  85. ! #if __STDC__ && !defined(UnixCpp)
  86.   #ifdef UseInstalled
  87.   #define _UseCat(a,b,c) a##c
  88.   #else
  89. *** imake.c    Mon Nov  9 15:55:34 1992
  90. --- imake.c.R5fixed    Thu Nov 12 17:13:05 1992
  91. ***************
  92. *** 341,384 ****
  93.       if (p = getenv("IMAKEMAKE"))
  94.           make = p;
  95.   
  96. -       /*
  97. -        * If we are running on the convex and we are using the Convex
  98. -        * cpp, then we need to add the "-pcc" switch.  This will keep
  99. -        * the pre-processor from striping backslash-newlines.
  100. -        */
  101. - #     if defined(__convex__)
  102. -       {
  103. - #     include <sys/param.h>           /* for MAXPATHLEN */
  104. - #         define FLAGS "-vn -P"       /* Flags to send to cpp */
  105. - #         define STRING "CONVEX CPP"  /* Uniquely identifies convex cpp */
  106. -           char cmd[MAXPATHLEN+sizeof(FLAGS)+20];
  107. -           char buf [sizeof(STRING)];
  108. -           FILE *fp;
  109. -           char *old_cpp = cpp;
  110. -           /* %% jrh -- ensure cpp is non-NULL
  111. -            */
  112. -           if (cpp == (char *)0) cpp = DEFAULT_CPP;
  113. -           sprintf(cmd, "%s %s < /dev/null 2>&1", cpp, FLAGS);
  114. -           cpp = old_cpp;
  115. -           if ((fp = popen(cmd, "r")) == NULL) {
  116. -               LogFatalI("Cannot run %s to find version\n", cpp);
  117. -           }
  118. -           if (fread(buf, sizeof(STRING), 1, fp) < 0) {
  119. -               LogFatal("Cannot read output from %s to find version\n", cpp);
  120. -           }
  121. -           if ( !strncmp(buf, STRING, sizeof(STRING)-1)) {
  122. -               AddCppArg("-pcc");
  123. -           }
  124. -           (void) pclose(fp);
  125. - #undef            FLAGS
  126. - #undef            STRING
  127. -       }
  128. - #     endif /* __convex__ */
  129.       if (signal(SIGINT, SIG_IGN) != SIG_IGN)
  130.           signal(SIGINT, catch);
  131.   }
  132. --- 341,346 ----
  133.  
  134.  
  135. cc program (must come first in path):
  136.  
  137. #! /usr/local/bin/perl
  138. # Caveat - this is a grunge it until it seems to work hack.
  139.  
  140. open(LOGFILE, ">>/tmp/cclog") || die ("Cannot open logfile\n");
  141.  
  142. # Protect special characters in args.
  143. foreach $n ( 0 .. $#ARGV ) {
  144.   $ARGV[$n] =~ s/(\$|\\|\s|[]['"%!(){}])/\\\1/g;
  145. }
  146. $ccopts = join(' ', @ARGV);
  147. print LOGFILE $ccopts;
  148. `/bin/cc $ccopts`;
  149. if ( $? == 0 ) {
  150.   print LOGFILE " OK\n";
  151.   exit;
  152. }
  153.  
  154. # OK, lets bodge it.
  155. print STDERR "Trying bodge...\n";
  156. print LOGFILE ':: trying: ';
  157. while ( $opt = shift ) {
  158.   if ( $opt =~ /^-[IDU]/ ) {
  159.     $opts .= "$opt ";
  160.   }
  161.   elsif ( $opt =~ /\.c$/ ) {
  162.     if ( $cfile ) {
  163.       die(": Two .c files specified\n");
  164.     }
  165.     else {
  166.       $cfile = $opt;
  167.     }
  168.   }
  169. }
  170.  
  171. if ( ! $cfile ) {
  172.   die(": No .c file specified.\n");
  173. }
  174. $backfile = 'JMR'.$cfile;
  175. print LOGFILE " > $opts , backup: $backfile";
  176. if ( ! -e $backfile ) {
  177.   `/bin/cp -p $cfile $backfile`;
  178.   if ( $? != 0 ) {
  179.     print LOGFILE " backup FAILED\n";
  180.     die("Backup failed.\n");
  181.   }
  182. }
  183.  
  184. foreach $cpp ( '/bin/cc -E -pcc', '/lib/cpp -pcc', '/usr/lib/pcc/cpp', 'gcpp -traditional -D__convex__' ) {
  185.   print LOGFILE " $cpp: ";
  186.   print STDERR "Trying $cpp\n";
  187.   `$cpp -DUNIXCPP -P $opts $backfile > $cfile`;
  188.   
  189.   `/bin/cc $ccopts`;
  190.   $stat = $?;
  191.   `/bin/cp -p  $cfile JMR_last_c_file`;
  192.   `/bin/cp -p $backfile $cfile`;
  193.   if ( $stat == 0 ) {
  194.     print LOGFILE "  OK\n";
  195.     print STDERR "   bodge seemed to work OK\n";
  196.     exit;
  197.   }
  198. }
  199.  
  200. print LOGFILE "  FAILED!!\n";
  201. exit 1;
  202.