3 # Helper to enforce array-ness.
4 proc makearray
{name
} {
15 # This maps a name to its style:
16 # * bc objects in this package and all its sub-packages
17 # are to be compiled with the BC ABI. It is an error
18 # for sub-packages to also appear in the map.
20 # objects in this package (and possibly sub-packages,
21 # if they do not appear in the map) will be compiled en masse
22 # from source into a single object, using the C++ ABI.
24 # objects in this package (and possibly sub-packages
25 # if they do not appear in the map) will be compiled one at
26 # a time into separate .o files.
28 # objects in this package are not used. Note however that
29 # most ignored files are actually handled by listing them in
32 # If a package does not appear in the map, the default is 'package'.
34 set package_map
(.
) package
36 # These are ignored in Classpath.
37 set package_map
(gnu
/test
) ignore
38 set package_map
(gnu
/javax
/swing
/plaf
/gtk
) ignore
40 set package_map
(gnu
/xml
) bc
41 set package_map
(javax
/imageio
) bc
42 set package_map
(javax
/xml
) bc
43 set package_map
(gnu
/java
/beans
) bc
44 set package_map
(gnu
/java
/awt
/peer
/gtk
) bc
45 set package_map
(gnu
/java
/awt
/peer
/qt
) bc
46 set package_map
(gnu
/javax
/sound
/midi
) bc
47 set package_map
(org
/xml
) bc
48 set package_map
(org
/w3c
) bc
49 set package_map
(javax
/rmi
) bc
50 set package_map
(org
/omg
) bc
51 set package_map
(gnu
/CORBA
) bc
52 set package_map
(gnu
/javax
/rmi
) bc
54 # This is handled specially by the Makefile.
55 # We still want it byte-compiled so it isn't in the .omit file.
56 set package_map
(gnu
/gcj
/tools
/gcj_dbtool
/Main.java
) ignore
58 # These are handled specially. If we list Class.java with other files
59 # in java.lang, we hit a compiler bug.
60 set package_map
(java
/lang
/Class.java
) ignore
61 set package_map
(java
/lang
/Object.java
) ignore
63 # More special cases. These end up in their own library.
64 # Note that if we BC-compile AWT we must update these as well.
65 set package_map
(gnu
/gcj
/xlib
) package
66 set package_map
(gnu
/awt
/xlib
) package
68 # Some BC ABI packages have classes which must not be compiled BC.
69 # This maps such packages to a grep expression for excluding such
72 makearray exclusion_map
73 # set exclusion_map(java/awt) AWTPermission
75 # This maps a package name to a list of corresponding .java file base
76 # names. The package name will either appear as a key in package_map,
77 # or it will be '.' for the default.
81 # This maps a java file base name, like 'java/lang/Object.java', to
82 # the source directory in which it resides. We keep a layer of
83 # indirection here so that we can override sources in Classpath with
88 # List of all '@' files that we are going to compile.
91 # List of all header file variables.
94 # List of all BC object files.
97 # List of regexps for matching ignored files.
101 # Return true if a given file should be ignored.
102 # The argument is the path name including the package part.
103 proc ignore_file_p
{file} {
104 global ignore_rx_list
105 foreach rx
$ignore_rx_list {
106 if {[regexp -- $rx $file]} {
107 verbose
"ignoring $file for $rx"
114 # Read a '.omit' file and update the internal data structures.
115 proc read_omit_file
{name
} {
116 global ignore_rx_list
117 set fd
[open $name r
]
118 while {! [eof $fd]} {
121 # Classpath's entries bogusly start with "../".
122 if {[string match ..
/* $line]} {
123 set line
[string range
$line 3 end
]
127 lappend ignore_rx_list
$line
133 # Classify a single source file.
134 proc classify_source_file
{basedir
file} {
135 global package_map name_map dir_map
137 if {[ignore_file_p
$file]} {
141 set seen
[info exists dir_map
($file)]
142 set dir_map
($file) $basedir
145 if {[info exists package_map
($pkg)]} {
146 # If the entry for '.' is 'package', then set up a new entry for
147 # the file's package.
148 if {$pkg == "." && $package_map($pkg) == "package"} {
149 set pkg
[file dirname
$file]
150 set package_map
($pkg) package
152 verbose
"classify succeeded: $file -> $pkg"
154 lappend name_map
($pkg) $file
158 set pkg
[file dirname
$pkg]
163 # Scan a directory and its subdirectories for .java source files.
164 # Note that we keep basedir and subdir separate so we can properly
165 # update our global data structures.
166 proc scan_directory
{basedir subdir
} {
173 foreach file [lsort [glob -nocomplain *]] {
174 if {[string match
*.java
$file]} {
175 lappend files
$subdir/$file
176 } elseif
{[file isdirectory
$file]} {
177 lappend subdirs
$subdir/$file
182 # Recurse first, so that we don't create new packages too eagerly.
183 foreach dir
$subdirs {
184 scan_directory
$basedir $dir
187 foreach file $files {
188 classify_source_file
$basedir $file
192 # Scan known packages beneath the base directory for .java source
194 proc scan_packages
{basedir
} {
195 foreach subdir
{gnu java javax org
} {
196 if {[file exists
$basedir/$subdir]} {
197 scan_directory
$basedir $subdir
202 # Emit a rule for a 'bc' package.
203 proc emit_bc_rule
{package} {
204 global package_map exclusion_map bc_objects
206 if {$package == "."} {
211 set varname
[join [split $pkgname /] _
]_source_files
212 set loname
[join [split $pkgname /] -].lo
213 set tname
[join [split $pkgname /] -].
list
215 puts "$loname: \$($varname)"
216 # Create a temporary list file and then compile it. This works
217 # around the libtool problem mentioned in PR 21058. classpath was
218 # built first, so the class files are to be found there.
220 if {[info exists exclusion_map
($package)]} {
221 set omit
"| grep -v $exclusion_map($package)"
223 puts "\t@find classpath/lib/$package -name '*.class'${omit} > $tname"
224 puts "\t\$(LTGCJCOMPILE) -fjni -findirect-dispatch -c -o $loname @$tname"
225 puts "\t@rm -f $tname"
228 # We skip these because they are built into their own libraries and
229 # are handled specially in Makefile.am.
230 if {$loname != "gnu-java-awt-peer-gtk.lo"
231 && $loname != "gnu-java-awt-peer-qt.lo"} {
232 lappend bc_objects
$loname
236 # Emit a rule for a 'package' package.
237 proc emit_package_rule
{package} {
238 global package_map exclusion_map package_files
240 if {$package == "."} {
245 set varname
[join [split $pkgname /] _
]_source_files
250 # A rule to make the phony file we are going to compile.
251 puts "$lname: \$($varname)"
252 puts "\t@\$(mkinstalldirs) \$(dir \$@)"
253 puts "\t@for file in \$($varname); do \\"
254 puts "\t if test -f \$(srcdir)/\$\$file; then \\"
255 puts "\t echo \$(srcdir)/\$\$file; \\"
256 puts "\t else echo \$\$file; fi; \\"
257 puts "\tdone > $lname"
259 puts "-include $dname"
263 if {$pkgname != "gnu/gcj/xlib" && $pkgname != "gnu/awt/xlib"} {
264 lappend package_files
$lname
268 # Emit a source file variable for a package, and corresponding header
269 # file variable, if needed.
270 proc emit_source_var
{package} {
271 global package_map name_map dir_map header_vars
273 if {$package == "."} {
278 set uname
[join [split $pkgname /] _
]
279 set varname
${uname
}_source_files
280 puts -nonewline "$varname ="
283 foreach base
[lsort $name_map($package)] {
284 # Terminate previous line.
286 # Having files start with './' is ugly and confuses the automake
287 # "dirstamp" code; see automake PR 461.
288 set ndir
$dir_map($base)/
292 puts -nonewline "${ndir}${base}"
293 set dirs
($dir_map($base)) 1
298 if {$package_map($package) != "bc"} {
299 # Ugly code to build up the appropriate patsubst.
300 set result
"\$(patsubst %.java,%.h,\$($varname))"
301 foreach dir
[lsort [array names dirs
]] {
303 set result
"\$(patsubst $dir/%,%,$result)"
307 if {$package == "." ||
$package == "java/lang"} {
309 set result
"\$(filter-out java/lang/Object.h java/lang/Class.h,$result)"
312 puts "${uname}_header_files = $result"
314 if {$pkgname != "gnu/gcj/xlib" && $pkgname != "gnu/awt/xlib"} {
315 lappend header_vars
"${uname}_header_files"
320 # Pretty-print a Makefile variable.
321 proc pp_var
{name valueList
{pre
""} {post
""}} {
323 puts -nonewline "$name ="
324 foreach val
$valueList {
326 puts -nonewline " ${pre}${val}${post}"
331 # Read the proper .omit files.
332 read_omit_file standard.omit.in
333 read_omit_file classpath
/lib
/standard.omit
335 # Scan classpath first.
336 scan_packages classpath
337 scan_packages classpath
/external
/sax
338 scan_packages classpath
/external
/w3c_dom
339 # Now scan our own files; this will correctly override decisions made
340 # when scanning classpath.
342 # Files created by the build.
343 classify_source_file . java
/lang
/ConcreteProcess.java
344 classify_source_file classpath java
/util
/LocaleData.java
345 classify_source_file classpath gnu
/classpath
/Configuration.java
347 puts "## This file was automatically generated by scripts/makemake.tcl"
348 puts "## Do not edit!"
351 foreach package [lsort [array names package_map
]] {
352 if {$package_map($package) == "ignore"} {
355 if {! [info exists name_map
($package)]} {
359 emit_source_var
$package
361 if {$package_map($package) == "bc"} {
362 emit_bc_rule
$package
363 } elseif
{$package_map($package) == "ordinary"} {
364 # Nothing in particular to do here.
365 } elseif
{$package_map($package) == "package"} {
366 emit_package_rule
$package
368 error "unrecognized type: $package_map($package)"
372 pp_var all_packages_source_files
$package_files
373 pp_var ordinary_header_files
$header_vars "\$(" ")"
374 pp_var bc_objects
$bc_objects