X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=src%2Fmake-src-depend;h=b1bf8d0120fd22dbc92760022b2400a2fed18be7;hp=a5ace1a0eed973529d24c94b1545105143adcb8c;hb=7b241b273a632ab80d7c620b5add28d5f11b0fd3;hpb=6883ee56ec887c2c48abe5b06b5e66aa74031910 diff --git a/src/make-src-depend b/src/make-src-depend index a5ace1a..b1bf8d0 100644 --- a/src/make-src-depend +++ b/src/make-src-depend @@ -29,22 +29,26 @@ 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; ($srcdir = $0) =~ s@[^/]+$@@; +$srcdir = "." if $srcdir eq ""; chdir $srcdir or die "$srcdir: $!"; opendir SRCDIR, "." or die "$srcdir: $!"; for (grep (/\.[ch]$/, readdir (SRCDIR))) { $exists{$_} = 1; } closedir SRCDIR; -for (qw (config.h puresize-adjust.h sheap-adjust.h paths.h Emacs.ad.h)) { +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{ (