annotate src/make-src-depend @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents b8cc9ab3f761
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
1 : #-*- Perl -*-
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
2 # Copyright (C) 1998 Free Software Foundation, Inc.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
3
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
4 # This file is part of XEmacs.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
5 #
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
6 # XEmacs is free software; you can redistribute it and/or modify it
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
7 # under the terms of the GNU General Public License as published by the
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
8 # Free Software Foundation; either version 2, or (at your option) any
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
9 # later version.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
10 #
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
11 # XEmacs is distributed in the hope that it will be useful, but WITHOUT
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
14 # for more details.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
15 #
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
16 # You should have received a copy of the GNU General Public License
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
17 # along with XEmacs; see the file COPYING. If not, write to
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
18 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
19 # Boston, MA 02111-1307, USA.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
20
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
21 # Author: Martin Buchholz
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
22 eval 'exec perl -w -S $0 ${1+"$@"}'
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
23 if 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
24
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
25 use strict;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
26 my ($myName, $srcdir, %exists, %uses, %generated_header);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
27
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
28 ($myName = $0) =~ s@.*/@@; my $usage ="
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
29 Usage: $myName
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
30
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
31 Generates Makefile dependencies for the XEmacs src directory.
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
32 The dependencies are written to stdout.
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
33 ";
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
34
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
35 die $usage if @ARGV;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
36
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
37 ($srcdir = $0) =~ s@[^/]+$@@;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 371
diff changeset
38 $srcdir = "." if $srcdir eq "";
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
39 chdir $srcdir or die "$srcdir: $!";
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
40
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
41 opendir SRCDIR, "." or die "$srcdir: $!";
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
42 for (grep (/\.[ch]$/, readdir (SRCDIR))) { $exists{$_} = 1; }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
43 closedir SRCDIR;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
44
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
45 for (qw (config.h sheap-adjust.h paths.h Emacs.ad.h)) {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
46 $generated_header{$_} = 1;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
47 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
48
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
49 for my $file (keys %exists) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
50 open (FILE, $file) or die "$file: $!";
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
51 undef $/; $_ = <FILE>;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
52 RemoveComments ($_);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
53 s/[ \t]+//g;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
54 # Find include dependencies
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
55 for (/^\#include([^\n]+)/gm) {
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
56 if (m@^\"([A-Za-z0-9_-]+\.h)\"@) {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
57 $uses{$file}{$1} = 1 if exists $exists{$1};
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
58 } elsif (m@<([A-Za-z0-9_-]+\.h)>@) {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
59 $uses{$file}{$1} = 1 if exists $generated_header{$1};
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
60 } elsif (m@\"../lwlib/([A-Za-z0-9_-]+\.h)\"@) {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
61 $uses{$file}{"\$(LWLIB_SRCDIR)/lwlib.h"} = 1;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
62 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
63 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
64 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
65
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
66 # Make transitive closure of %uses
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
67 while (1) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
68 my $changedP = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
69 for my $x (keys %uses) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
70 for my $y (keys %{$uses{$x}}) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
71 for my $z (keys %{$uses{$y}}) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
72 if (! exists $uses{$x}{$z}) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
73 $uses{$x}{$z} = 1;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
74 $changedP = 1;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
75 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
76 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
77 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
78 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
79 last if !$changedP;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
80 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
81
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
82 # Print file header
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
83 print
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 367
diff changeset
84 "## This file automatically generated by $myName. Do not modify.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
85
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
86 #ifdef USE_UNION_TYPE
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
87 LISP_UNION_H=lisp-union.h
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
88 #else
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
89 LISP_UNION_H=lisp-disunion.h
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
90 #endif
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
91 ";
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
92
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 272
diff changeset
93 my @LISP_H = ('lisp.h', 'config.h');
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
94 #@LISP_H = grep (! /lisp-(dis)?union\.h/, @LISP_H);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
95 print "LISP_H = @{[grep (!/lisp-(dis)?union\.h/, @LISP_H)]} \$(LISP_UNION_H)\n";
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
96
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
97 sub PrintDeps {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
98 my $file = shift;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
99 my $ofile = $file; $ofile =~ s/c$/o/; print "$ofile: ";
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
100 if (exists $uses{$file}{'lisp.h'}) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
101 delete @{%{$uses{$file}}}{@LISP_H};
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
102 $uses{$file}{'$(LISP_H)'} = 1;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
103 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
104 print "@{[sort keys %{$uses{$file}}]}\n";
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
105 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
106
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
107 sub PrintPatternDeps {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
108 my ($pattern, $CPP_SYMBOL) = @_;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
109 print "#ifdef $CPP_SYMBOL\n";
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
110 for my $file (sort grep (/$pattern/ && /\.c$/, keys %uses)) {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
111 PrintDeps($file);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
112 delete $uses{$file};
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
113 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
114 print "#endif\n";
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
115 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
116
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
117 PrintPatternDeps ('-msw', "HAVE_MS_WINDOWS");
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
118 PrintPatternDeps ('-x', "HAVE_X_WINDOWS");
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
119 PrintPatternDeps ('database', "HAVE_DATABASE");
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
120 PrintPatternDeps ('^mule', "MULE");
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
121 PrintPatternDeps ('^(?:External|extw-)', "EXTERNAL_WIDGET");
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
122
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
123 for my $file (sort grep (/\.c$/, keys %uses)) { PrintDeps($file); }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
124
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
125 sub RemoveComments {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
126 $_[0] =~
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
127 s{ (
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
128 [^\"\'/]+ |
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
129 (?:\"[^\"\\]*(?:\\.[^\"\\]*)*\" [^\"\'/]*)+ |
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
130 (?:\'[^\'\\]*(?:\\.[^\'\\]*)*\' [^\"\'/]*)+
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
131 )
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
132 | / (?:
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
133 \*[^*]*\*+(?:[^/*][^*]*\*+)*/
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
134 |
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
135 /[^\n]*
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
136 )
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
137 }{defined $1 ? $1 : ""}gsxeo;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents:
diff changeset
138 }