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 # objects in this package (and possibly sub-packages,
27 # if they do not appear in the map) will be compiled en masse
28 # from source into a single object, using the C++ ABI.
30 # objects in this package (and possibly sub-packages
31 # if they do not appear in the map) will be compiled one at
32 # a time into separate .o files.
34 # objects in this package are not used. Note however that
35 # most ignored files are actually handled by listing them in
38 # If a package does not appear in the map, the default is 'package'.
40 set package_map
(.
) package
42 # These are ignored in Classpath.
43 set package_map
(gnu
/test
) ignore
44 set package_map
(gnu
/javax
/swing
/plaf
/gtk
) ignore
46 set package_map
(gnu
/java
/awt
/peer
/swing
) bc
48 set package_map
(gnu
/xml
) bc
49 set package_map
(javax
/imageio
) bc
50 set package_map
(javax
/xml
) bc
51 set package_map
(gnu
/java
/beans
) bc
52 set package_map
(gnu
/java
/awt
/peer
/gtk
) bc
53 set package_map
(gnu
/java
/awt
/peer
/qt
) bc
54 set package_map
(gnu
/java
/awt
/peer
/x
) bc
55 set package_map
(gnu
/javax
/sound
/midi
) bc
56 set package_map
(org
/xml
) bc
57 set package_map
(org
/w3c
) bc
58 set package_map
(org
/relaxng
) bc
59 set package_map
(javax
/rmi
) bc
60 set package_map
(org
/omg
) bc
61 set package_map
(gnu
/CORBA
) bc
62 set package_map
(gnu
/javax
/rmi
) bc
64 # More special cases. These end up in their own library.
65 # Note that if we BC-compile AWT we must update these as well.
66 set package_map
(gnu
/gcj
/xlib
) package
67 set package_map
(gnu
/awt
/xlib
) package
69 # Some BC ABI packages have classes which must not be compiled BC.
70 # This maps such packages to a grep expression for excluding such
73 makearray exclusion_map
74 # set exclusion_map(java/awt) AWTPermission
76 # This maps a package name to a list of corresponding .java file base
77 # names. The package name will either appear as a key in package_map,
78 # or it will be '.' for the default.
82 # This maps a java file base name, like 'java/lang/Object.java', to
83 # the source directory in which it resides. We keep a layer of
84 # indirection here so that we can override sources in Classpath with
89 # An entry in this map means that all .properties files in the
90 # corresponding directory should be ignored.
92 makearray properties_map
94 # logging.properties is installed and is editable.
95 set properties_map
(java
/util
/logging
) _
96 # We haven't merged locale resources yet.
97 set properties_map
(gnu
/java
/locale
) _
100 # List of all properties files.
101 set properties_files
{}
103 # List of all '@' files that we are going to compile.
106 # List of all header file variables.
109 # List of all BC object files.
112 # List of regexps for matching ignored files.
113 set ignore_rx_list
{}
116 # Return true if a given file should be ignored.
117 # The argument is the path name including the package part.
118 proc ignore_file_p
{file} {
119 global ignore_rx_list
120 foreach rx
$ignore_rx_list {
121 if {[regexp -- $rx $file]} {
122 verbose
"ignoring $file for $rx"
129 # Read a '.omit' file and update the internal data structures.
130 proc read_omit_file
{name
} {
131 global ignore_rx_list
132 set fd
[open $name r
]
133 while {! [eof $fd]} {
136 # Classpath's entries bogusly start with "../".
137 if {[string match ..
/* $line]} {
138 set line
[string range
$line 3 end
]
142 lappend ignore_rx_list
$line
148 # Classify a single source file.
149 proc classify_source_file
{basedir
file} {
150 global package_map name_map dir_map
152 if {[ignore_file_p
$file]} {
156 set seen
[info exists dir_map
($file)]
157 set dir_map
($file) $basedir
160 if {[info exists package_map
($pkg)]} {
161 # If the entry is 'package', then set up a new entry for the
163 if {$package_map($pkg) == "package"} {
164 set pkg
[file dirname
$file]
165 set package_map
($pkg) package
167 verbose
"classify succeeded: $file -> $pkg"
169 lappend name_map
($pkg) $file
173 set pkg
[file dirname
$pkg]
178 # Scan a directory and its subdirectories for .java source files or
179 # .properties files. Note that we keep basedir and subdir separate so
180 # we can properly update our global data structures.
181 proc scan_directory
{basedir subdir
} {
182 global dir_map properties_map properties_files
188 foreach file [lsort [glob -nocomplain *]] {
189 if {[string match
*.java
$file]} {
190 lappend files
$subdir/$file
191 } elseif
{[string match
*.properties
$file]} {
192 if {! [info exists properties_map
($subdir)]} {
193 # We assume there aren't any overrides.
194 lappend properties_files
$basedir/$subdir/$file
196 } elseif
{[file isdirectory
$file]} {
197 lappend subdirs
$subdir/$file
198 } elseif
{$subdir == "META-INF/services"} {
199 # All service files are included as properties.
200 lappend properties_files
$basedir/$subdir/$file
205 # Recurse first, so that we don't create new packages too eagerly.
206 foreach dir
$subdirs {
207 scan_directory
$basedir $dir
210 foreach file $files {
211 classify_source_file
$basedir $file
215 # Scan known packages beneath the base directory for .java source
217 proc scan_packages
{basedir
} {
218 foreach subdir
{gnu java javax org sun META-INF
} {
219 if {[file exists
$basedir/$subdir]} {
220 scan_directory
$basedir $subdir
225 # Emit a rule for a 'bc' package.
226 proc emit_bc_rule
{package} {
227 global package_map exclusion_map bc_objects
229 if {$package == "."} {
234 set varname
[join [split $pkgname /] _
]_source_files
235 set loname
[join [split $pkgname /] -].lo
236 set tname
[join [split $pkgname /] -].
list
238 puts "$loname: \$($varname)"
239 # Create a temporary list file and then compile it. This works
240 # around the libtool problem mentioned in PR 21058. classpath was
241 # built first, so the class files are to be found there.
243 if {[info exists exclusion_map
($package)]} {
244 set omit
"| grep -v $exclusion_map($package)"
246 puts "\t@find classpath/lib/$package -name '*.class'${omit} > $tname"
247 puts "\t\$(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o $loname @$tname"
248 puts "\t@rm -f $tname"
251 # We skip these because they are built into their own libraries and
252 # are handled specially in Makefile.am.
253 if {$loname != "gnu-java-awt-peer-qt.lo" && $loname != "gnu-java-awt-peer-x.lo"} {
254 lappend bc_objects
$loname
258 # Emit a rule for a 'package' package.
259 proc emit_package_rule
{package} {
260 global package_map exclusion_map package_files
262 if {$package == "."} {
267 set varname
[join [split $pkgname /] _
]_source_files
272 # A special case due to an apparent compiler bug.
273 if {$pkgname == "java/lang"} {
274 set omit
"| tr ' ' '\\n' | fgrep -v Object.class | fgrep -v Class.class "
279 # A rule to make the phony file we are going to compile.
280 puts "$lname: \$($varname)"
281 puts "\t@\$(mkinstalldirs) \$(dir \$@)"
282 puts "\techo classpath/lib/$package/*.class $omit> $lname"
284 puts "-include $dname"
288 if {$pkgname != "gnu/gcj/xlib" && $pkgname != "gnu/awt/xlib"
289 && $pkgname != "gnu/gcj/tools/gcj_dbtool"} {
290 lappend package_files
$lname
294 # Emit a source file variable for a package, and corresponding header
295 # file variable, if needed.
296 proc emit_source_var
{package} {
297 global package_map name_map dir_map header_vars
299 if {$package == "."} {
304 set uname
[join [split $pkgname /] _
]
305 set varname
${uname
}_source_files
306 puts -nonewline "$varname ="
309 foreach base
[lsort $name_map($package)] {
310 # Terminate previous line.
312 # Having files start with './' is ugly and confuses the automake
313 # "dirstamp" code; see automake PR 461.
314 set ndir
$dir_map($base)/
318 puts -nonewline "${ndir}${base}"
319 set dirs
($dir_map($base)) 1
324 if {$package_map($package) != "bc"} {
325 # Ugly code to build up the appropriate patsubst.
326 set result
"\$(patsubst %.java,%.h,\$($varname))"
327 foreach dir
[lsort [array names dirs
]] {
329 set result
"\$(patsubst $dir/%,%,$result)"
333 if {$package == "." ||
$package == "java/lang"} {
335 set result
"\$(filter-out java/lang/Object.h java/lang/Class.h,$result)"
338 puts "${uname}_header_files = $result"
340 if {$pkgname != "gnu/gcj/xlib" && $pkgname != "gnu/awt/xlib"} {
341 lappend header_vars
"${uname}_header_files"
346 # Pretty-print a Makefile variable.
347 proc pp_var
{name valueList
{pre
""} {post
""}} {
349 puts -nonewline "$name ="
350 foreach val
$valueList {
352 puts -nonewline " ${pre}${val}${post}"
358 if {[llength $argv] > 0 && [lindex $argv 0] == "-verbose"} {
362 # Read the proper .omit files.
363 read_omit_file standard.omit.in
364 read_omit_file classpath
/lib
/standard.omit.in
366 # Scan classpath first.
367 scan_packages classpath
368 scan_packages classpath
/external
/sax
369 scan_packages classpath
/external
/w3c_dom
370 scan_packages classpath
/external
/relaxngDatatype
371 scan_packages classpath
/external
/jsr166
373 scan_packages classpath
/resource
374 # Now scan our own files; this will correctly override decisions made
375 # when scanning classpath.
377 # Files created by the build.
378 classify_source_file . java
/lang
/ConcreteProcess.java
379 classify_source_file classpath gnu
/java
/locale
/LocaleData.java
380 classify_source_file classpath gnu
/classpath
/Configuration.java
382 puts "## This file was automatically generated by scripts/makemake.tcl"
383 puts "## Do not edit!"
386 foreach package [lsort [array names package_map
]] {
387 if {$package_map($package) == "ignore"} {
390 if {! [info exists name_map
($package)]} {
394 emit_source_var
$package
396 if {$package_map($package) == "bc"} {
397 emit_bc_rule
$package
398 } elseif
{$package_map($package) == "ordinary"} {
399 # Nothing in particular to do here.
400 } elseif
{$package_map($package) == "package"} {
401 emit_package_rule
$package
403 error "unrecognized type: $package_map($package)"
407 pp_var all_packages_source_files
$package_files
408 pp_var ordinary_header_files
$header_vars "\$(" ")"
409 pp_var bc_objects
$bc_objects
410 pp_var property_files
$properties_files