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
/java
/awt
/peer
/swing
) bc
42 set package_map
(gnu
/xml
) bc
43 set package_map
(javax
/imageio
) bc
44 set package_map
(javax
/xml
) bc
45 set package_map
(gnu
/java
/beans
) bc
46 set package_map
(gnu
/java
/awt
/peer
/gtk
) bc
47 set package_map
(gnu
/java
/awt
/peer
/qt
) bc
48 set package_map
(gnu
/javax
/sound
/midi
) bc
49 set package_map
(org
/xml
) bc
50 set package_map
(org
/w3c
) bc
51 set package_map
(org
/relaxng
) bc
52 set package_map
(javax
/rmi
) bc
53 set package_map
(org
/omg
) bc
54 set package_map
(gnu
/CORBA
) bc
55 set package_map
(gnu
/javax
/rmi
) bc
57 # This is handled specially by the Makefile.
58 # We still want it byte-compiled so it isn't in the .omit file.
59 set package_map
(gnu
/gcj
/tools
/gcj_dbtool
/Main.java
) ignore
61 # These are handled specially. If we list Class.java with other files
62 # in java.lang, we hit a compiler bug.
63 set package_map
(java
/lang
/Class.java
) ignore
64 set package_map
(java
/lang
/Object.java
) ignore
66 # More special cases. These end up in their own library.
67 # Note that if we BC-compile AWT we must update these as well.
68 set package_map
(gnu
/gcj
/xlib
) package
69 set package_map
(gnu
/awt
/xlib
) package
71 # Some BC ABI packages have classes which must not be compiled BC.
72 # This maps such packages to a grep expression for excluding such
75 makearray exclusion_map
76 # set exclusion_map(java/awt) AWTPermission
78 # This maps a package name to a list of corresponding .java file base
79 # names. The package name will either appear as a key in package_map,
80 # or it will be '.' for the default.
84 # This maps a java file base name, like 'java/lang/Object.java', to
85 # the source directory in which it resides. We keep a layer of
86 # indirection here so that we can override sources in Classpath with
91 # An entry in this map means that all .properties files in the
92 # corresponding directory should be ignored.
94 makearray properties_map
96 # logging.properties is installed and is editable.
97 set properties_map
(java
/util
/logging
) _
98 # We haven't merged locale resources yet.
99 set properties_map
(gnu
/java
/locale
) _
102 # List of all properties files.
103 set properties_files
{}
105 # List of all '@' files that we are going to compile.
108 # List of all header file variables.
111 # List of all BC object files.
114 # List of regexps for matching ignored files.
115 set ignore_rx_list
{}
118 # Return true if a given file should be ignored.
119 # The argument is the path name including the package part.
120 proc ignore_file_p
{file} {
121 global ignore_rx_list
122 foreach rx
$ignore_rx_list {
123 if {[regexp -- $rx $file]} {
124 verbose
"ignoring $file for $rx"
131 # Read a '.omit' file and update the internal data structures.
132 proc read_omit_file
{name
} {
133 global ignore_rx_list
134 set fd
[open $name r
]
135 while {! [eof $fd]} {
138 # Classpath's entries bogusly start with "../".
139 if {[string match ..
/* $line]} {
140 set line
[string range
$line 3 end
]
144 lappend ignore_rx_list
$line
150 # Classify a single source file.
151 proc classify_source_file
{basedir
file} {
152 global package_map name_map dir_map
154 if {[ignore_file_p
$file]} {
158 set seen
[info exists dir_map
($file)]
159 set dir_map
($file) $basedir
162 if {[info exists package_map
($pkg)]} {
163 # If the entry for '.' is 'package', then set up a new entry for
164 # the file's package.
165 if {$pkg == "." && $package_map($pkg) == "package"} {
166 set pkg
[file dirname
$file]
167 set package_map
($pkg) package
169 verbose
"classify succeeded: $file -> $pkg"
171 lappend name_map
($pkg) $file
175 set pkg
[file dirname
$pkg]
180 # Scan a directory and its subdirectories for .java source files or
181 # .properties files. Note that we keep basedir and subdir separate so
182 # we can properly update our global data structures.
183 proc scan_directory
{basedir subdir
} {
184 global dir_map properties_map properties_files
190 foreach file [lsort [glob -nocomplain *]] {
191 if {[string match
*.java
$file]} {
192 lappend files
$subdir/$file
193 } elseif
{[string match
*.properties
$file]} {
194 if {! [info exists properties_map
($subdir)]} {
195 # We assume there aren't any overrides.
196 lappend properties_files
$basedir/$subdir/$file
198 } elseif
{[file isdirectory
$file]} {
199 lappend subdirs
$subdir/$file
200 } elseif
{$subdir == "META-INF/services"} {
201 # All service files are included as properties.
202 lappend properties_files
$basedir/$subdir/$file
207 # Recurse first, so that we don't create new packages too eagerly.
208 foreach dir
$subdirs {
209 scan_directory
$basedir $dir
212 foreach file $files {
213 classify_source_file
$basedir $file
217 # Scan known packages beneath the base directory for .java source
219 proc scan_packages
{basedir
} {
220 foreach subdir
{gnu java javax org META-INF
} {
221 if {[file exists
$basedir/$subdir]} {
222 scan_directory
$basedir $subdir
227 # Emit a rule for a 'bc' package.
228 proc emit_bc_rule
{package} {
229 global package_map exclusion_map bc_objects
231 if {$package == "."} {
236 set varname
[join [split $pkgname /] _
]_source_files
237 set loname
[join [split $pkgname /] -].lo
238 set tname
[join [split $pkgname /] -].
list
240 puts "$loname: \$($varname)"
241 # Create a temporary list file and then compile it. This works
242 # around the libtool problem mentioned in PR 21058. classpath was
243 # built first, so the class files are to be found there.
245 if {[info exists exclusion_map
($package)]} {
246 set omit
"| grep -v $exclusion_map($package)"
248 puts "\t@find classpath/lib/$package -name '*.class'${omit} > $tname"
249 puts "\t\$(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o $loname @$tname"
250 puts "\t@rm -f $tname"
253 # We skip these because they are built into their own libraries and
254 # are handled specially in Makefile.am.
255 if {$loname != "gnu-java-awt-peer-gtk.lo"
256 && $loname != "gnu-java-awt-peer-qt.lo"} {
257 lappend bc_objects
$loname
261 # Emit a rule for a 'package' package.
262 proc emit_package_rule
{package} {
263 global package_map exclusion_map package_files
265 if {$package == "."} {
270 set varname
[join [split $pkgname /] _
]_source_files
275 # A rule to make the phony file we are going to compile.
276 puts "$lname: \$($varname)"
277 puts "\t@\$(mkinstalldirs) \$(dir \$@)"
278 puts "\t@for file in \$($varname); do \\"
279 puts "\t if test -f \$(srcdir)/\$\$file; then \\"
280 puts "\t echo \$(srcdir)/\$\$file; \\"
281 puts "\t else echo \$\$file; fi; \\"
282 puts "\tdone > $lname"
284 puts "-include $dname"
288 if {$pkgname != "gnu/gcj/xlib" && $pkgname != "gnu/awt/xlib"} {
289 lappend package_files
$lname
293 # Emit a source file variable for a package, and corresponding header
294 # file variable, if needed.
295 proc emit_source_var
{package} {
296 global package_map name_map dir_map header_vars
298 if {$package == "."} {
303 set uname
[join [split $pkgname /] _
]
304 set varname
${uname
}_source_files
305 puts -nonewline "$varname ="
308 foreach base
[lsort $name_map($package)] {
309 # Terminate previous line.
311 # Having files start with './' is ugly and confuses the automake
312 # "dirstamp" code; see automake PR 461.
313 set ndir
$dir_map($base)/
317 puts -nonewline "${ndir}${base}"
318 set dirs
($dir_map($base)) 1
323 if {$package_map($package) != "bc"} {
324 # Ugly code to build up the appropriate patsubst.
325 set result
"\$(patsubst %.java,%.h,\$($varname))"
326 foreach dir
[lsort [array names dirs
]] {
328 set result
"\$(patsubst $dir/%,%,$result)"
332 if {$package == "." ||
$package == "java/lang"} {
334 set result
"\$(filter-out java/lang/Object.h java/lang/Class.h,$result)"
337 puts "${uname}_header_files = $result"
339 if {$pkgname != "gnu/gcj/xlib" && $pkgname != "gnu/awt/xlib"} {
340 lappend header_vars
"${uname}_header_files"
345 # Pretty-print a Makefile variable.
346 proc pp_var
{name valueList
{pre
""} {post
""}} {
348 puts -nonewline "$name ="
349 foreach val
$valueList {
351 puts -nonewline " ${pre}${val}${post}"
356 # Read the proper .omit files.
357 read_omit_file standard.omit.in
358 read_omit_file classpath
/lib
/standard.omit
360 # Scan classpath first.
361 scan_packages classpath
362 scan_packages classpath
/external
/sax
363 scan_packages classpath
/external
/w3c_dom
364 scan_packages classpath
/external
/relaxngDatatype
366 scan_packages classpath
/resource
367 # Now scan our own files; this will correctly override decisions made
368 # when scanning classpath.
370 # Files created by the build.
371 classify_source_file . java
/lang
/ConcreteProcess.java
372 classify_source_file classpath gnu
/java
/locale
/LocaleData.java
373 classify_source_file classpath gnu
/classpath
/Configuration.java
375 puts "## This file was automatically generated by scripts/makemake.tcl"
376 puts "## Do not edit!"
379 foreach package [lsort [array names package_map
]] {
380 if {$package_map($package) == "ignore"} {
383 if {! [info exists name_map
($package)]} {
387 emit_source_var
$package
389 if {$package_map($package) == "bc"} {
390 emit_bc_rule
$package
391 } elseif
{$package_map($package) == "ordinary"} {
392 # Nothing in particular to do here.
393 } elseif
{$package_map($package) == "package"} {
394 emit_package_rule
$package
396 error "unrecognized type: $package_map($package)"
400 pp_var all_packages_source_files
$package_files
401 pp_var ordinary_header_files
$header_vars "\$(" ")"
402 pp_var bc_objects
$bc_objects
403 pp_var property_files
$properties_files