(g2-UU+5B73): Add `=decomposition@hanyo-denshi'.
[chise/xemacs-chise.git.1] / src / make-src-depend
index 4f604f4..b1bf8d0 100644 (file)
@@ -29,8 +29,7 @@ my ($myName, $srcdir, %exists, %uses, %generated_header);
 Usage: $myName
 
 Generates Makefile dependencies for the XEmacs src directory.
-The dependencies are written to stdout.
-";
+The dependencies are written to stdout.\n";
 
 die $usage if @ARGV;
 
@@ -46,6 +45,10 @@ for (qw (config.h sheap-adjust.h paths.h Emacs.ad.h)) {
   $generated_header{$_} = 1;
 }
 
+# Although this is not technically true, it ought to be true,
+# and makes the generated Makefile smaller.
+$uses{'lisp.h'}{'config.h'} = 1;
+
 for my $file (keys %exists) {
   open (FILE, $file) or die "$file: $!";
   undef $/; $_ = <FILE>;
@@ -53,11 +56,11 @@ for my $file (keys %exists) {
   s/[ \t]+//g;
   # Find include dependencies
   for (/^\#include([^\n]+)/gm) {
-    if (m@^\"([A-Za-z0-9_-]+\.h)\"@) {
+    if (m@^\"([A-Za-z0-9._-]+\.[ch])\"@) {
       $uses{$file}{$1} = 1 if exists $exists{$1};
-    } elsif (m@<([A-Za-z0-9_-]+\.h)>@) {
+    } elsif (m@<([A-Za-z0-9._-]+\.h)>@) {
       $uses{$file}{$1} = 1 if exists $generated_header{$1};
-    } elsif (m@\"../lwlib/([A-Za-z0-9_-]+\.h)\"@) {
+    } elsif (m@\"../lwlib/([A-Za-z0-9._-]+\.h)\"@) {
       $uses{$file}{"\$(LWLIB_SRCDIR)/lwlib.h"} = 1;
     }
   }
@@ -81,18 +84,17 @@ while (1) {
 
 # Print file header
 print
-"## This file automatically generated by $myName.  Do not modify.
+"## This file is automatically generated by \`$myName'.  Do not modify.
 
-#ifdef USE_UNION_TYPE
+#if defined(USE_UNION_TYPE)
 LISP_UNION_H=lisp-union.h
 #else
 LISP_UNION_H=lisp-disunion.h
 #endif
 ";
 
-my @LISP_H = ('lisp.h', 'config.h');
-#@LISP_H = grep (! /lisp-(dis)?union\.h/, @LISP_H);
-print "LISP_H = @{[grep (!/lisp-(dis)?union\.h/, @LISP_H)]} \$(LISP_UNION_H)\n";
+my @LISP_H = ('lisp.h', sort keys %{$uses{'lisp.h'}});
+print "LISP_H=@{[grep (!/lisp-(dis)?union\.h/, @LISP_H)]} \$(LISP_UNION_H)\n";
 
 sub PrintDeps {
   my $file = shift;
@@ -106,7 +108,7 @@ sub PrintDeps {
 
 sub PrintPatternDeps {
   my ($pattern, $CPP_SYMBOL) = @_;
-  print "#ifdef $CPP_SYMBOL\n";
+  print "#if defined($CPP_SYMBOL)\n";
   for my $file (sort grep (/$pattern/ && /\.c$/, keys %uses)) {
     PrintDeps($file);
     delete $uses{$file};
@@ -114,14 +116,17 @@ sub PrintPatternDeps {
   print "#endif\n";
 }
 
-PrintPatternDeps ('-msw',     "HAVE_MS_WINDOWS");
-PrintPatternDeps ('-x',       "HAVE_X_WINDOWS");
-PrintPatternDeps ('database', "HAVE_DATABASE");
-PrintPatternDeps ('^mule',    "MULE");
+PrintPatternDeps ('-msw\\.',   "HAVE_MS_WINDOWS");
+PrintPatternDeps ('-x\\.',     "HAVE_X_WINDOWS");
+PrintPatternDeps ('-tty\\.',   "HAVE_TTY");
+PrintPatternDeps ('-gtk\\.',   "HAVE_GTK");
+PrintPatternDeps ('^database', "HAVE_DATABASE");
+PrintPatternDeps ('^mule',     "MULE");
 PrintPatternDeps ('^(?:External|extw-)', "EXTERNAL_WIDGET");
 
 for my $file (sort grep (/\.c$/, keys %uses)) { PrintDeps($file); }
 
+# Surprisingly robust regexp to remove comments from arbitrary C code
 sub RemoveComments {
   $_[0] =~
     s{ (