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;
$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>;
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;
}
}
# 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;
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};
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{ (