comparison src/make-src-depend @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 3ecd8885ac67
children 3d3049ae1304
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
43 43
44 for (qw (config.h sheap-adjust.h paths.h Emacs.ad.h)) { 44 for (qw (config.h sheap-adjust.h paths.h Emacs.ad.h)) {
45 $generated_header{$_} = 1; 45 $generated_header{$_} = 1;
46 } 46 }
47 47
48 # Although this is not technically true, it ought to be true,
49 # and makes the generated Makefile smaller.
50 $uses{'lisp.h'}{'config.h'} = 1;
51
48 for my $file (keys %exists) { 52 for my $file (keys %exists) {
49 open (FILE, $file) or die "$file: $!"; 53 open (FILE, $file) or die "$file: $!";
50 undef $/; $_ = <FILE>; 54 undef $/; $_ = <FILE>;
51 RemoveComments ($_); 55 RemoveComments ($_);
52 s/[ \t]+//g; 56 s/[ \t]+//g;
53 # Find include dependencies 57 # Find include dependencies
54 for (/^\#include([^\n]+)/gm) { 58 for (/^\#include([^\n]+)/gm) {
55 if (m@^\"([A-Za-z0-9_-]+\.h)\"@) { 59 if (m@^\"([A-Za-z0-9._-]+\.h)\"@) {
56 $uses{$file}{$1} = 1 if exists $exists{$1}; 60 $uses{$file}{$1} = 1 if exists $exists{$1};
57 } elsif (m@<([A-Za-z0-9_-]+\.h)>@) { 61 } elsif (m@<([A-Za-z0-9._-]+\.h)>@) {
58 $uses{$file}{$1} = 1 if exists $generated_header{$1}; 62 $uses{$file}{$1} = 1 if exists $generated_header{$1};
59 } elsif (m@\"../lwlib/([A-Za-z0-9_-]+\.h)\"@) { 63 } elsif (m@\"../lwlib/([A-Za-z0-9._-]+\.h)\"@) {
60 $uses{$file}{"\$(LWLIB_SRCDIR)/lwlib.h"} = 1; 64 $uses{$file}{"\$(LWLIB_SRCDIR)/lwlib.h"} = 1;
61 } 65 }
62 } 66 }
63 } 67 }
64 68
78 last if !$changedP; 82 last if !$changedP;
79 } 83 }
80 84
81 # Print file header 85 # Print file header
82 print 86 print
83 "## This file automatically generated by $myName. Do not modify. 87 "## This file is automatically generated by \`$myName'. Do not modify.
84 88
85 #ifdef USE_UNION_TYPE 89 #if defined(USE_UNION_TYPE)
86 LISP_UNION_H=lisp-union.h 90 LISP_UNION_H=lisp-union.h
87 #else 91 #else
88 LISP_UNION_H=lisp-disunion.h 92 LISP_UNION_H=lisp-disunion.h
89 #endif 93 #endif
90 "; 94 ";
91 95
92 my @LISP_H = ('lisp.h', 'config.h'); 96 my @LISP_H = ('lisp.h', keys %{$uses{'lisp.h'}});
93 #@LISP_H = grep (! /lisp-(dis)?union\.h/, @LISP_H); 97 print "LISP_H=@{[grep (!/lisp-(dis)?union\.h/, @LISP_H)]} \$(LISP_UNION_H)\n";
94 print "LISP_H = @{[grep (!/lisp-(dis)?union\.h/, @LISP_H)]} \$(LISP_UNION_H)\n";
95 98
96 sub PrintDeps { 99 sub PrintDeps {
97 my $file = shift; 100 my $file = shift;
98 my $ofile = $file; $ofile =~ s/c$/o/; print "$ofile: "; 101 my $ofile = $file; $ofile =~ s/c$/o/; print "$ofile: ";
99 if (exists $uses{$file}{'lisp.h'}) { 102 if (exists $uses{$file}{'lisp.h'}) {
103 print "@{[sort keys %{$uses{$file}}]}\n"; 106 print "@{[sort keys %{$uses{$file}}]}\n";
104 } 107 }
105 108
106 sub PrintPatternDeps { 109 sub PrintPatternDeps {
107 my ($pattern, $CPP_SYMBOL) = @_; 110 my ($pattern, $CPP_SYMBOL) = @_;
108 print "#ifdef $CPP_SYMBOL\n"; 111 print "#if defined($CPP_SYMBOL)\n";
109 for my $file (sort grep (/$pattern/ && /\.c$/, keys %uses)) { 112 for my $file (sort grep (/$pattern/ && /\.c$/, keys %uses)) {
110 PrintDeps($file); 113 PrintDeps($file);
111 delete $uses{$file}; 114 delete $uses{$file};
112 } 115 }
113 print "#endif\n"; 116 print "#endif\n";
114 } 117 }
115 118
116 PrintPatternDeps ('-msw', "HAVE_MS_WINDOWS"); 119 PrintPatternDeps ('-msw\\.', "HAVE_MS_WINDOWS");
117 PrintPatternDeps ('-x', "HAVE_X_WINDOWS"); 120 PrintPatternDeps ('-x\\.', "HAVE_X_WINDOWS");
118 PrintPatternDeps ('database', "HAVE_DATABASE"); 121 PrintPatternDeps ('-tty\\.', "HAVE_TTY");
119 PrintPatternDeps ('^mule', "MULE"); 122 PrintPatternDeps ('^database', "HAVE_DATABASE");
123 PrintPatternDeps ('^mule', "MULE");
120 PrintPatternDeps ('^(?:External|extw-)', "EXTERNAL_WIDGET"); 124 PrintPatternDeps ('^(?:External|extw-)', "EXTERNAL_WIDGET");
121 125
122 for my $file (sort grep (/\.c$/, keys %uses)) { PrintDeps($file); } 126 for my $file (sort grep (/\.c$/, keys %uses)) { PrintDeps($file); }
123 127
128 # Surprisingly robust regexp to remove comments from arbitrary C code
124 sub RemoveComments { 129 sub RemoveComments {
125 $_[0] =~ 130 $_[0] =~
126 s{ ( 131 s{ (
127 [^\"\'/]+ | 132 [^\"\'/]+ |
128 (?:\"[^\"\\]*(?:\\.[^\"\\]*)*\" [^\"\'/]*)+ | 133 (?:\"[^\"\\]*(?:\\.[^\"\\]*)*\" [^\"\'/]*)+ |