3 # Helper to enforce array-ness.
4 proc makearray
{name
} {
21 # This maps a name to its style:
22 # * bc objects in this package and all its sub-packages
23 # are to be compiled with the BC ABI. It is an error
24 # for sub-packages to also appear in the map.
26 # as bc, but generate header files and compile with CNI.
28 # objects in this package (and possibly sub-packages,
29 # if they do not appear in the map) will be compiled en masse
30 # from source into a single object, using the C++ ABI.
32 # objects in this package (and possibly sub-packages
33 # if they do not appear in the map) will be compiled one at
34 # a time into separate .o files.
36 # objects in this package are not used. Note however that
37 # most ignored files are actually handled by listing them in
40 # If a package does not appear in the map, the default is 'package'.
42 set package_map
(.
) package
44 # These are ignored in Classpath.
45 set package_map
(gnu
/test
) ignore
46 set package_map
(gnu
/javax
/swing
/plaf
/gtk
) ignore
47 set package_map
(gnu
/gcj
/tools
/gc_analyze
) ignore
49 set package_map
(gnu
/java
/awt
/peer
/swing
) bc
51 set package_map
(gnu
/xml
/aelfred2
) bc
52 set package_map
(gnu
/xml
/dom
) bc
53 set package_map
(gnu
/xml
/libxmlj
) bc
54 set package_map
(gnu
/xml
/pipeline
) bc
55 set package_map
(gnu
/xml
/stream
) bc
56 set package_map
(gnu
/xml
/transform
) bc
57 set package_map
(gnu
/xml
/util
) bc
58 set package_map
(gnu
/xml
/validation
) bc
59 set package_map
(gnu
/xml
/xpath
) bc
60 set package_map
(javax
/imageio
) bc
61 set package_map
(javax
/xml
) bc
62 set package_map
(gnu
/java
/beans
) bc
63 set package_map
(gnu
/java
/awt
/dnd
/peer
/gtk
) bc
64 set package_map
(gnu
/java
/util
/prefs
/gconf
) bc
65 set package_map
(gnu
/java
/awt
/peer
/gtk
) bc
66 set package_map
(gnu
/java
/awt
/dnd
/peer
/gtk
) bc
67 set package_map
(gnu
/java
/awt
/peer
/qt
) bc
68 set package_map
(gnu
/java
/awt
/peer
/x
) bc
69 set package_map
(gnu
/java
/util
/prefs
/gconf
) bc
70 set package_map
(gnu
/javax
/sound
/midi
) bc
71 set package_map
(org
/xml
) bc
72 set package_map
(org
/w3c
) bc
73 set package_map
(org
/relaxng
) bc
74 set package_map
(javax
/rmi
) bc
75 set package_map
(org
/omg
) bc
76 set package_map
(gnu
/CORBA
) bc
77 set package_map
(gnu
/javax
/rmi
) bc
78 set package_map
(gnu
/java
/lang
/management
) bcheaders
79 set package_map
(java
/lang
/management
) bc
80 set package_map
(gnu
/classpath
/management
) bc
81 set package_map
(gnu
/javax
/management
) bc
83 # parser/HTML_401F.class is really big, and there have been complaints
84 # about this package requiring too much memory to build. So, we
85 # compile it as separate objects. But, we're careful to compile the
86 # sub-packages as packages.
87 set package_map
(gnu
/javax
/swing
/text/html
/parser
) ordinary
88 set package_map
(gnu
/javax
/swing
/text/html
/parser
/models
) package
89 set package_map
(gnu
/javax
/swing
/text/html
/parser
/support
) package
91 # More special cases. These end up in their own library.
92 # Note that if we BC-compile AWT we must update these as well.
93 set package_map
(gnu
/gcj
/xlib
) package
94 set package_map
(gnu
/awt
/xlib
) package
96 # Some BC ABI packages have classes which must not be compiled BC.
97 # This maps such packages to a grep expression for excluding such
100 makearray exclusion_map
101 # set exclusion_map(java/awt) AWTPermission
103 # This maps a package name to a list of corresponding .java file base
104 # names. The package name will either appear as a key in package_map,
105 # or it will be '.' for the default.
109 # This maps a java file base name, like 'java/lang/Object.java', to
110 # the source directory in which it resides. We keep a layer of
111 # indirection here so that we can override sources in Classpath with
116 # An entry in this map means that all .properties files in the
117 # corresponding directory should be ignored.
118 global properties_map
119 makearray properties_map
121 # logging.properties is installed and is editable.
122 set properties_map
(java
/util
/logging
) _
123 # We haven't merged locale resources yet.
124 set properties_map
(gnu
/java
/locale
) _
126 # We want to be able to load xerces if it is on the class path. So,
127 # we have to avoid compiling in the XML-related service files.
128 set properties_map
(META-INF
/services
/javax.xml.parsers.DocumentBuilderFactory
) _
129 set properties_map
(META-INF
/services
/javax.xml.parsers.SAXParserFactory
) _
130 set properties_map
(META-INF
/services
/javax.xml.parsers.TransformerFactory
) _
131 set properties_map
(META-INF
/services
/org.relaxng.datatype.DatatypeLibraryFactory
) _
132 set properties_map
(META-INF
/services
/org.w3c.dom.DOMImplementationSourceList
) _
133 set properties_map
(META-INF
/services
/org.xml.sax.driver
) _
135 # List of all properties files.
136 set properties_files
{}
138 # List of all '@' files that we are going to compile.
141 # List of all header file variables.
144 # List of all BC object files.
147 # List of regexps for matching ignored files.
148 set ignore_rx_list
{}
151 # Return true if a given file should be ignored.
152 # The argument is the path name including the package part.
153 proc ignore_file_p
{file} {
154 global ignore_rx_list
155 foreach rx
$ignore_rx_list {
156 if {[regexp -- $rx $file]} {
157 verbose
"ignoring $file for $rx"
164 # Read a '.omit' file and update the internal data structures.
165 proc read_omit_file
{name
} {
166 global ignore_rx_list
167 set fd
[open $name r
]
168 while {! [eof $fd]} {
171 # Classpath's entries bogusly start with "../".
172 if {[string match ..
/* $line]} {
173 set line
[string range
$line 3 end
]
177 lappend ignore_rx_list
$line
183 # Classify a single source file.
184 proc classify_source_file
{basedir
file} {
185 global package_map name_map dir_map
187 if {[ignore_file_p
$file]} {
191 set seen
[info exists dir_map
($file)]
192 set dir_map
($file) $basedir
195 if {[info exists package_map
($pkg)]} {
196 # If the entry is 'package', then set up a new entry for the
198 if {$package_map($pkg) == "package"} {
199 set pkg
[file dirname
$file]
200 set package_map
($pkg) package
202 verbose
"classify succeeded: $file -> $pkg"
204 lappend name_map
($pkg) $file
208 set pkg
[file dirname
$pkg]
213 # Scan a directory and its subdirectories for .java source files or
214 # .properties files. Note that we keep basedir and subdir separate so
215 # we can properly update our global data structures.
216 proc scan_directory
{basedir subdir
} {
217 global dir_map properties_map properties_files
223 foreach file [lsort [glob -nocomplain *]] {
224 if {[string match
*.java
$file]} {
225 lappend files
$subdir/$file
226 } elseif
{[string match
*.properties
$file]} {
227 if {! [info exists properties_map
($subdir)]} {
228 # We assume there aren't any overrides.
229 lappend properties_files
$basedir/$subdir/$file
231 } elseif
{[string match
*.css
$file]} {
232 # Special case for default.css needed by javax.swing.text.html.
233 lappend properties_files
$basedir/$subdir/$file
234 } elseif
{[file isdirectory
$file]} {
235 lappend subdirs
$subdir/$file
236 } elseif
{$subdir == "META-INF/services"} {
237 # Service files are generally included as properties.
238 if {! [info exists properties_map
($subdir/$file)]} {
239 lappend properties_files
$basedir/$subdir/$file
245 # Recurse first, so that we don't create new packages too eagerly.
246 foreach dir
$subdirs {
247 scan_directory
$basedir $dir
250 foreach file $files {
251 classify_source_file
$basedir $file
255 # Scan known packages beneath the base directory for .java source
257 proc scan_packages
{basedir
} {
258 foreach subdir
{gnu java javax org sun com META-INF
} {
259 if {[file exists
$basedir/$subdir]} {
260 scan_directory
$basedir $subdir
265 # Emit a rule for a 'bc' package.
266 proc emit_bc_rule
{package} {
267 global package_map exclusion_map bc_objects
269 if {$package == "."} {
274 set varname
[join [split $pkgname /] _
]_source_files
275 set loname
[join [split $pkgname /] -].lo
276 set tname
[join [split $pkgname /] -].
list
278 puts "$loname: \$($varname)"
279 # Create a temporary list file and then compile it. This works
280 # around the libtool problem mentioned in PR 21058. classpath was
281 # built first, so the class files are to be found there.
283 if {[info exists exclusion_map
($package)]} {
284 set omit
"| grep -v $exclusion_map($package)"
286 puts "\t@find \$(srcdir)/classpath/lib/$package -name '*.class'${omit} > $tname"
287 puts -nonewline "\t\$(LTGCJCOMPILE) -fsource-filename=\$(here)/classpath/lib/classes "
288 if {$package_map($package) == "bc"} {
289 puts -nonewline "-fjni "
291 puts "-findirect-dispatch -fno-indirect-classes -c -o $loname @$tname"
292 puts "\t@rm -f $tname"
295 # We skip these because they are built into their own libraries and
296 # are handled specially in Makefile.am.
297 if {$loname != "gnu-java-awt-peer-qt.lo" && $loname != "gnu-java-awt-peer-x.lo"} {
298 lappend bc_objects
$loname
302 # Emit a rule for a 'package' package.
303 proc emit_package_rule
{package} {
304 global package_map exclusion_map package_files
306 if {$package == "."} {
311 set varname
[join [split $pkgname /] _
]_source_files
316 if {$pkgname == "java/lang"} {
317 # Object and Class are special cases due to an apparent compiler
318 # bug. Process is a special case because we don't build all
319 # concrete implementations of Process on all platforms.
320 set omit
"| tr ' ' '\\n' | fgrep -v Object.class | fgrep -v Class.class | egrep -v '\(Ecos\|Posix\|Win32\)Process' "
325 # A rule to make the phony file we are going to compile.
326 puts "$lname: \$($varname)"
327 puts "\t@\$(mkinstalldirs) \$(dir \$@)"
328 puts "\techo \$(srcdir)/classpath/lib/$package/*.class $omit> $lname"
330 puts "-include $dname"
334 if {$pkgname != "gnu/gcj/xlib" && $pkgname != "gnu/awt/xlib"
335 && $pkgname != "gnu/gcj/tools/gcj_dbtool"} {
336 lappend package_files
$lname
340 # Emit a rule to build a package full of 'ordinary' files, that is,
341 # one .o for each .java.
342 proc emit_ordinary_rule
{package} {
343 global name_map package_files
345 foreach file $name_map($package) {
346 # Strip off the '.java'.
347 set root
[file rootname
$file]
349 # Look for all included .class files. Assumes that we don't have
350 # multiple top-level classes in a .java file.
354 puts "$lname: classpath/$file"
355 puts "\t@\$(mkinstalldirs) \$(dir \$@)"
356 puts "\techo \$(srcdir)/classpath/lib/${root}*.class> $lname"
358 puts "-include $dname"
362 lappend package_files
$lname
366 # Emit a package-like rule for a platform-specific Process
368 proc emit_process_package_rule
{platform
} {
369 set base
"java/process-$platform"
373 puts "$lname: java/lang/${platform}Process.java"
374 puts "\t@\$(mkinstalldirs) \$(dir \$@)"
375 puts "\techo \$(srcdir)/classpath/lib/java/lang/${platform}Process*.class > $lname"
377 puts "-include $dname"
382 # Emit a source file variable for a package, and corresponding header
383 # file variable, if needed.
384 proc emit_source_var
{package} {
385 global package_map name_map dir_map header_vars
387 if {$package == "."} {
392 set uname
[join [split $pkgname /] _
]
393 set varname
${uname
}_source_files
394 puts -nonewline "$varname ="
397 foreach base
[lsort $name_map($package)] {
398 # Terminate previous line.
400 # Having files start with './' is ugly and confuses the automake
401 # "dirstamp" code; see automake PR 461.
402 set ndir
$dir_map($base)/
406 puts -nonewline "${ndir}${base}"
407 set dirs
($dir_map($base)) 1
412 if {$package_map($package) != "bc"} {
413 # Ugly code to build up the appropriate patsubst.
414 set result
"\$(patsubst %.java,%.h,\$($varname))"
415 # We use -decreasing so that classpath/external will be stripped
417 foreach dir
[lsort -decreasing [array names dirs
]] {
419 set result
"\$(patsubst $dir/%,%,$result)"
423 if {$package == "." ||
$package == "java/lang"} {
425 set result
"\$(filter-out java/lang/Object.h java/lang/Class.h,$result)"
428 puts "${uname}_header_files = $result"
430 if {$pkgname != "gnu/gcj/xlib" && $pkgname != "gnu/awt/xlib"} {
431 lappend header_vars
"${uname}_header_files"
436 # Pretty-print a Makefile variable.
437 proc pp_var
{name valueList
{pre
""} {post
""}} {
439 puts -nonewline "$name ="
440 foreach val
$valueList {
442 puts -nonewline " ${pre}${val}${post}"
448 if {[llength $argv] > 0 && [lindex $argv 0] == "-verbose"} {
452 # Read the proper .omit files.
453 read_omit_file standard.omit.in
454 read_omit_file classpath
/lib
/standard.omit.in
456 # Scan classpath first.
457 scan_packages classpath
458 scan_packages classpath
/external
/sax
459 scan_packages classpath
/external
/w3c_dom
460 scan_packages classpath
/external
/relaxngDatatype
461 scan_packages classpath
/external
/jsr166
463 scan_packages classpath
/resource
464 # Now scan our own files; this will correctly override decisions made
465 # when scanning classpath.
467 # Files created by the build.
468 classify_source_file classpath gnu
/java
/locale
/LocaleData.java
469 classify_source_file classpath gnu
/java
/security
/Configuration.java
471 puts "## This file was automatically generated by scripts/makemake.tcl"
472 puts "## Do not edit!"
475 foreach package [lsort [array names package_map
]] {
476 if {$package_map($package) == "ignore"} {
479 if {! [info exists name_map
($package)]} {
483 emit_source_var
$package
485 if {$package_map($package) == "bc"} {
486 emit_bc_rule
$package
487 } elseif
{$package_map($package) == "bcheaders"} {
488 emit_bc_rule
$package
489 } elseif
{$package_map($package) == "ordinary"} {
490 emit_ordinary_rule
$package
491 } elseif
{$package_map($package) == "package"} {
492 emit_package_rule
$package
494 error "unrecognized type: $package_map($package)"
498 emit_process_package_rule Ecos
499 emit_process_package_rule Win32
500 emit_process_package_rule Posix
502 pp_var all_packages_source_files
$package_files
503 pp_var ordinary_header_files
$header_vars "\$(" ")"
504 pp_var bc_objects
$bc_objects
505 pp_var property_files
$properties_files