X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fmake-src-depend;h=b1bf8d0120fd22dbc92760022b2400a2fed18be7;hb=c1fa38c050ef3bd87e784dea66eba3cdac585536;hp=a112b6a3d8bbb2017b234b4658f13ac0e000e3c7;hpb=afa9772e3fcbb4e80e3e4cfd1a40b4fccc6d08b8;p=chise%2Fxemacs-chise.git.1 diff --git a/src/make-src-depend b/src/make-src-depend index a112b6a..b1bf8d0 100644 --- a/src/make-src-depend +++ b/src/make-src-depend @@ -45,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 $/; $_ = ; @@ -52,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; } } @@ -80,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; @@ -105,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}; @@ -113,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{ (