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
50 # This is handled specially by the Makefile.
51 # We still want it byte-compiled so it isn't in the .omit file.
52 set package_map
(gnu
/gcj
/tools
/gcj_dbtool
/Main.java
) ignore
54 # These are handled specially. If we list Class.java with other files
55 # in java.lang, we hit a compiler bug.
56 set package_map
(java
/lang
/Class.java
) ignore
57 set package_map
(java
/lang
/Object.java
) ignore
59 # More special cases. These end up in their own library.
60 # Note that if we BC-compile AWT we must update these as well.
61 set package_map
(gnu
/gcj
/xlib
) package
62 set package_map
(gnu
/awt
/xlib
) package
64 # Some BC ABI packages have classes which must not be compiled BC.
65 # This maps such packages to a grep expression for excluding such
68 makearray exclusion_map
69 # set exclusion_map(java/awt) AWTPermission
71 # This maps a package name to a list of corresponding .java file base
72 # names. The package name will either appear as a key in package_map,
73 # or it will be '.' for the default.
77 # This maps a java file base name, like 'java/lang/Object.java', to
78 # the source directory in which it resides. We keep a layer of
79 # indirection here so that we can override sources in Classpath with
84 # List of all '@' files that we are going to compile.
87 # List of all header file variables.
90 # List of all BC object files.
93 # List of regexps for matching ignored files.
97 # Return true if a given file should be ignored.
98 # The argument is the path name including the package part.
99 proc ignore_file_p
{file} {
100 global ignore_rx_list
101 foreach rx
$ignore_rx_list {
102 if {[regexp -- $rx $file]} {
103 verbose
"ignoring $file for $rx"
110 # Read a '.omit' file and update the internal data structures.
111 proc read_omit_file
{name
} {
112 global ignore_rx_list
113 set fd
[open $name r
]
114 while {! [eof $fd]} {
117 # Classpath's entries bogusly start with "../".
118 if {[string match ..
/* $line]} {
119 set line
[string range
$line 3 end
]
123 lappend ignore_rx_list
$line
129 # Classify a single source file.
130 proc classify_source_file
{basedir
file} {
131 global package_map name_map dir_map
133 if {[ignore_file_p
$file]} {
137 set seen
[info exists dir_map
($file)]
138 set dir_map
($file) $basedir
141 if {[info exists package_map
($pkg)]} {
142 # If the entry for '.' is 'package', then set up a new entry for
143 # the file's package.
144 if {$pkg == "." && $package_map($pkg) == "package"} {
145 set pkg
[file dirname
$file]
146 set package_map
($pkg) package
148 verbose
"classify succeeded: $file -> $pkg"
150 lappend name_map
($pkg) $file
154 set pkg
[file dirname
$pkg]
159 # Scan a directory and its subdirectories for .java source files.
160 # Note that we keep basedir and subdir separate so we can properly
161 # update our global data structures.
162 proc scan_directory
{basedir subdir
} {
169 foreach file [lsort [glob *]] {
170 if {[string match
*.java
$file]} {
171 lappend files
$subdir/$file
172 } elseif
{[file isdirectory
$file]} {
173 lappend subdirs
$subdir/$file
178 # Recurse first, so that we don't create new packages too eagerly.
179 foreach dir
$subdirs {
180 scan_directory
$basedir $dir
183 foreach file $files {
184 classify_source_file
$basedir $file
188 # Scan known packages beneath the base directory for .java source
190 proc scan_packages
{basedir
} {
191 foreach subdir
{gnu java javax org
} {
192 if {[file exists
$basedir/$subdir]} {
193 scan_directory
$basedir $subdir
198 # Emit a rule for a 'bc' package.
199 proc emit_bc_rule
{package} {
200 global package_map exclusion_map bc_objects
202 if {$package == "."} {
207 set varname
[join [split $pkgname /] _
]_source_files
208 set loname
[join [split $pkgname /] -].lo
209 set tname
[join [split $pkgname /] -].
list
211 puts "$loname: \$($varname)"
212 # Create a temporary list file and then compile it. This works
213 # around the libtool problem mentioned in PR 21058. classpath was
214 # built first, so the class files are to be found there.
216 if {[info exists exclusion_map
($package)]} {
217 set omit
"| grep -v $exclusion_map($package)"
219 puts "\t@find classpath/lib/$package -name '*.class'${omit} > $tname"
220 puts "\t\$(LTGCJCOMPILE) -fjni -findirect-dispatch -c -o $loname @$tname"
221 puts "\t@rm -f $tname"
224 # We skip these because they are built into their own libraries and
225 # are handled specially in Makefile.am.
226 if {$loname != "gnu-java-awt-peer-gtk.lo"
227 && $loname != "gnu-java-awt-peer-qt.lo"} {
228 lappend bc_objects
$loname
232 # Emit a rule for a 'package' package.
233 proc emit_package_rule
{package} {
234 global package_map exclusion_map package_files
236 if {$package == "."} {
241 set varname
[join [split $pkgname /] _
]_source_files
246 # A rule to make the phony file we are going to compile.
247 puts "$lname: \$($varname)"
248 puts "\t@\$(mkinstalldirs) \$(dir \$@)"
249 puts "\t@for file in \$($varname); do \\"
250 puts "\t if test -f \$(srcdir)/\$\$file; then \\"
251 puts "\t echo \$(srcdir)/\$\$file; \\"
252 puts "\t else echo \$\$file; fi; \\"
253 puts "\tdone > $lname"
255 puts "-include $dname"
259 if {$pkgname != "gnu/gcj/xlib" && $pkgname != "gnu/awt/xlib"} {
260 lappend package_files
$lname
264 # Emit a source file variable for a package, and corresponding header
265 # file variable, if needed.
266 proc emit_source_var
{package} {
267 global package_map name_map dir_map header_vars
269 if {$package == "."} {
274 set uname
[join [split $pkgname /] _
]
275 set varname
${uname
}_source_files
276 puts -nonewline "$varname ="
279 foreach base
[lsort $name_map($package)] {
280 # Terminate previous line.
282 # Having files start with './' is ugly and confuses the automake
283 # "dirstamp" code; see automake PR 461.
284 set ndir
$dir_map($base)/
288 puts -nonewline "${ndir}${base}"
289 set dirs
($dir_map($base)) 1
294 if {$package_map($package) != "bc"} {
295 # Ugly code to build up the appropriate patsubst.
296 set result
"\$(patsubst %.java,%.h,\$($varname))"
297 foreach dir
[lsort [array names dirs
]] {
299 set result
"\$(patsubst $dir/%,%,$result)"
303 if {$package == "." ||
$package == "java/lang"} {
305 set result
"\$(filter-out java/lang/Object.h java/lang/Class.h,$result)"
308 puts "${uname}_header_files = $result"
310 if {$pkgname != "gnu/gcj/xlib" && $pkgname != "gnu/awt/xlib"} {
311 lappend header_vars
"${uname}_header_files"
316 # Pretty-print a Makefile variable.
317 proc pp_var
{name valueList
{pre
""} {post
""}} {
319 puts -nonewline "$name ="
320 foreach val
$valueList {
322 puts -nonewline " ${pre}${val}${post}"
327 # Read the proper .omit files.
328 read_omit_file standard.omit.in
329 read_omit_file classpath
/lib
/standard.omit
331 # Scan classpath first.
332 scan_packages classpath
333 scan_packages classpath
/external
/sax
334 scan_packages classpath
/external
/w3c_dom
335 # Now scan our own files; this will correctly override decisions made
336 # when scanning classpath.
338 # Files created by the build.
339 classify_source_file . java
/lang
/ConcreteProcess.java
340 classify_source_file classpath java
/util
/LocaleData.java
341 classify_source_file classpath gnu
/classpath
/Configuration.java
343 puts "## This file was automatically generated by scripts/makemake.tcl"
344 puts "## Do not edit!"
347 foreach package [lsort [array names package_map
]] {
348 if {$package_map($package) == "ignore"} {
351 if {! [info exists name_map
($package)]} {
355 emit_source_var
$package
357 if {$package_map($package) == "bc"} {
358 emit_bc_rule
$package
359 } elseif
{$package_map($package) == "ordinary"} {
360 # Nothing in particular to do here.
361 } elseif
{$package_map($package) == "package"} {
362 emit_package_rule
$package
364 error "unrecognized type: $package_map($package)"
368 pp_var all_packages_source_files
$package_files
369 pp_var ordinary_header_files
$header_vars "\$(" ")"
370 pp_var bc_objects
$bc_objects