root/configure

Revision 269, 43.8 KB (checked in by Guillaume Mazoyer <respawneral@…>, 5 months ago)

Launcher script enhancement.

Fix for arguments interpretation when they
contain spaces.

  • Property executable set to True
Line 
1#!/usr/bin/perl -w
2
3#
4# configure
5# part of Equivalence, version 0.2.x
6#
7# Copyright (c) 2005-2010 Operational Dynamics Consulting Pty Ltd, and Others
8#
9# The code in this file, and the library it is a part of, are made available
10# to you by the authors under the terms of the "GNU General Public Licence,
11# version 2". See the LICENCE file for the terms governing usage and
12# redistribution.
13#
14
15#
16# THIS IS A PROTOTYPE. Although functional enough, this has grown to the point
17# of being a somewhat embarrassing and monolithic piece of code. Patches are
18# gladly accepted to this file to fix bugs and improve prerequisite detection,
19# but be aware that a new and refactored version is in progress.  With any
20# luck, it will be easier to extend and suitable for use by other projects. See
21# http://research.operationaldynamics.com/projects/equivalence/ In the mean
22# time, see README for instructions on how to use this one.
23#
24
25use strict;
26use File::Basename;
27
28#
29# Configure GNOME Split for building. We:
30#
31# - determine the operating system
32#
33# - set known defaults that correspond to that OS
34#
35# - for items where we have multiple possibilities, work through the
36#   possibilities until we find one
37#
38# - for items where there are options to choose from (notably which java
39#   compiler and VM we're using), we select a sensible default unless
40#   instructed otherwise on the command line.
41#
42
43my $os;
44my $quiet;
45
46# There's nothing worse than having an old config file, getting half way
47# through this, having it break, and then being able to build, but getting
48# errors because configure really didn't finish. We do leave .config.tmp
49# in place on error to facilitate troubleshooting.
50
51`rm -f .config`;
52`rm -f Hello.java Hello.class`;
53
54# --------------------------------------------------------------------
55# Utility and checking functions
56# --------------------------------------------------------------------
57
58#
59# Very simply: if the msg does not contain a newline, then it is assumed
60# to introduce a statement, so we print it and left pad it with spaces.
61# If the text does contain a newline, then probably it is concluding a
62# statement (ok, failed, whatever) but not necessarily - just print the thing
63# without any padding.
64#
65sub output {
66        my $str = shift;
67        if ($str =~ /\n/) {
68                print $str unless $quiet;
69        } else {
70                printf "%-35s", $str unless $quiet;
71        }
72}
73
74sub which {
75        use Cwd 'abs_path';
76        my $program   = shift;
77        my $path      = $ENV{'PATH'};
78        my @path_dirs = split /:+/, $path;
79
80        foreach my $dir (@path_dirs) {
81                if (-f "$dir/$program") {
82                        return abs_path("$dir/$program");
83                }
84        }
85        return $program;
86}
87
88sub bail {
89        my $status = shift || "failed";
90        my $msg    = shift || "";
91
92        # assuming that we're in an incomplete line
93        output "$status\n\n";
94
95        print "$msg\n\n" if $msg;
96        print "Failed to complete configuration.\n";
97        exit(1);
98}
99
100# The files (jars) to check for should be listed in order of preference, as the
101# first one found will be the one selected.  For example, if you want version 3
102# but version 2 will do, list them in that order.  Typically, this means that
103# you list newer libraries first, on the presumption that you'd rather use the
104# newer one than the older one; when adding upgrades put them above the
105# already present entries.
106sub check_prereq(\@$$@) {
107        my ($jararrayref, $item, $package, @files) = @_;
108
109        output " - ".$item;
110
111        my $str;
112        my $tries = "";
113        my $found = "";
114
115        foreach my $file (@files) {
116                if ( -f "$file" ) {
117                        $found = $file;
118                        last;
119                }
120                $tries .= ($tries ? ", or" : "") . "\n\t".  basename($file) . "\t(looked in ".dirname($file).")";
121        }
122
123        if (!"$found") {
124                $str = "In order to build GNOME Split, you need\n".$tries;
125                $str .= "\n\nwhich is part of the $item Java library.\n";
126                $str .= "On a ".ucfirst($os)." system, you should be able to get this requirement by doing:\n\n";
127                $str .= "     # ";
128
129                if ($os eq "gentoo") {
130                        $str .= "emerge";
131                } elsif ($os eq "debian") {
132                        $str .= "apt-get install";
133                } elsif ($os eq "fedora") {
134                        $str .= "yum install";
135                } elsif ($os eq "suse") {
136                        $str .= "zypper install";
137                } elsif ($os eq "mandriva") {
138                        $str .= "urpmi";
139                } elsif ($os eq "solaris") {
140                        $str .= "pkgadd";
141                } elsif ($os eq "arch") {
142                        $str .= "pacman -S"
143                } else {
144                        $str .= "[FIXME fetch and install command for this OS]"; 
145                }
146                $str .= " $package";
147
148                bail "not found!", $str;
149        }
150        print "found\n";
151
152        push(@$jararrayref, $found);
153}
154
155# if we return without setting the variable pointed at by scalarref, its being
156# empty will be used later to indicate that this compiler wasn't present /
157# usable.
158#
159# The "not present" check is somewhat spurious given the input in many cases
160# is the result of a `which` call.
161
162sub check_compiler(\$$$$) {
163        my $scalarref = $_[0];
164        my $item      = $_[1];
165        my $program   = $_[2];
166        my $args      = $_[3];
167
168        chomp $program;
169        if ( ! -f "$program") {
170                $$scalarref = "";
171                return;
172        }
173
174        # appealing to my sense of economy, we only print something out if
175        # it's there - that way we can list lots of options to check without
176        # cluttering things endlessly.
177        output " - ".$item;
178
179        if (! -x "$program") {
180                output "found but not executable\n";
181                $$scalarref = "";
182                return;
183        }
184
185        # Ok, so inline code is lame, but it's so small, and only one,
186        # and, avoids having a file in tests/ that will be picked up later
187        # as neededing compiling.
188        if (! -f "Hello.java") {
189                open HELLO, ">Hello.java";
190                print HELLO <<HERE ;
191public class Hello {
192        public static void main(String[] args) {
193                System.out.println("Hello");
194        }
195}
196HERE
197                close HELLO;
198        }
199
200        `$program $args Hello.java >/dev/null 2>&1`;
201        if ($? != 0) {
202                output "doesn't work\n";
203                $$scalarref = "";
204                return
205        }
206
207        output "works\n";
208        $$scalarref = "$program $args";
209}
210
211#
212# Check that a jar program somewhere works.
213#
214sub check_jar(\$$$$) {
215        my $scalarref = $_[0];
216        my $item      = $_[1];
217        my $program   = $_[2];
218        my $args      = $_[3];
219
220        chomp $program;
221        if ( ! -f "$program") {
222                $$scalarref = "";
223                return;
224        }
225
226        # appealing to my sense of economy, we only print something out if
227        # it's there - that way we can list lots of options to check without
228        # cluttering things endlessly.
229        output " - ".$item;
230
231        if ( ! -x "$program") {
232                output "found but not executable\n";
233                $$scalarref = "";
234                return;
235        }
236
237        `$program cf Hello.jar $args Hello.class >/dev/null 2>&1`;
238        if (($? != 0) || (! -f "Hello.jar")) {
239                output "doesn't work\n";
240                $$scalarref = "";
241                return
242        }
243
244        # TODO validate the result
245
246        output "works\n";
247        $$scalarref = "$program $args";
248}
249
250#
251# Check that a javadoc program somewhere works.
252#
253sub check_javadoc(\$$$$) {
254        my $scalarref = $_[0];
255        my $item      = $_[1];
256        my $program   = $_[2];
257        my $args      = $_[3];
258
259        chomp $program;
260        if (! -f "$program") {
261                $$scalarref = "";
262                return;
263        }
264
265        # appealing to my sense of economy, we only print something out if
266        # it's there - that way we can list lots of options to check without
267        # cluttering things endlessly.
268        output " - ".$item;
269
270        if (! -x "$program") {
271                output "found but not executable\n";
272                $$scalarref = "";
273                return;
274        }
275
276        # TODO validate the result
277
278        output "found\n";
279        $$scalarref = "$program $args";
280}
281
282sub check_runtime(\$$$$) {
283        my $scalarref = $_[0];
284        my $item      = $_[1];
285        my $program   = $_[2];
286        my $args      = $_[3];
287
288        chomp $program;
289        if (! -f "$program") {
290                $$scalarref = "";
291                return;
292        }
293
294        output " - ".$item;
295
296        if (! -x "$program") {
297                output "found but not executable\n";
298                $$scalarref = "";
299                return;
300        }
301
302        my $output  = `$program -version 2>&1 | grep 'version "'`;
303        $output     =~ s/.*version \"(.*)\".*/$1/g;
304        my @version = split(/[\.\-\_]/, $output);
305
306        for (my $i = 0; $i < 3; $i++) {
307                chomp $version[$i];
308
309                if (!($version[$i] =~ /^\d+$/)) {
310                        output "can't parse version\n";
311                        $$scalarref = "";
312                        return
313                }
314        }
315        if (($version[0] < 1) || ($version[0] == 1 && ($version[1] < 4 || ($version[1] == 4 && $version[2] < 2)))) {
316                output "not >= 1.4.2\n";
317                $$scalarref = "";
318                return
319        }
320
321        $output = `$program $args Hello 2>/dev/null`;
322        chomp $output;
323
324        if (($? != 0) || ($output ne "Hello")) {
325                output "doesn't work\n";
326                $$scalarref = "";
327                return
328        }
329
330        output "works\n";
331        $$scalarref = "$program $args";
332}
333
334# --------------------------------------------------------------------
335# Process command line arguments for overrides
336# --------------------------------------------------------------------
337
338my $prefix;
339my $libdir;
340my $jardir;
341my $compiler;
342my $runtime;
343my $jdk_home;
344my $jamvm_bin;
345my $cacao_bin;
346my $cpu_arch;
347
348foreach my $arg (@ARGV) {
349        my ($key, $value) = split /=/, "$arg";
350
351        if ($key eq "quiet") {
352                $quiet = 1;
353        } elsif (($key =~ /^-\?$/)    || ($key =~ /^-h$/)    ||
354                 ($key =~ /^--help$/) || ($key =~ /^-help$/) || ($key =~ /^help$/)) {
355                print <<HERE ;
356
357This is Equivalence, a simple build system suited to the
358unique needs of configuring and compiling Java programs on
359Linux and Unix.
360
361Look at the README file in this directory for information
362about this project and instructions on how to adjust the
363./configure script's behaviour.
364
365HERE
366                exit 4;
367        } elsif (($key =~ /^--prefix$/) || ($key =~ /^prefix$/)) {
368                $prefix="$value";
369        } elsif (($key =~ /^--libdir$/) || ($key =~ /^libdir$/)) {
370                $libdir="$value";
371        } elsif (($key =~ /^--jardir$/) || ($key =~ /^jardir$/)) {
372                $jardir="$value";
373        } elsif ($key =~ /^runtime/) {
374                $runtime="$value";
375        } elsif ($key =~ /^compiler/) {
376                $compiler="$value";
377        } elsif ($key =~ /^jdk/) {
378                $jdk_home="$value";
379        } elsif ($key =~ /^cacao/) {
380                $cacao_bin="$value";
381        } elsif ($key =~ /^jamvm/) {
382                $jamvm_bin="$value";
383        }
384}
385
386if (!$prefix) {
387        $prefix="/usr/local";
388}
389
390if (!$jardir) {
391        $jardir=$prefix . "/share/java";
392}
393
394# check jdk_home override. compiler and runtime are checked
395# later (at the end) against choices that have been validated.
396
397if ($jdk_home) {
398        $jdk_home =~ s/\/$//;
399        if (! -x "$jdk_home/bin/javac") {
400                bail "bad override", "jdk_home specified doesn't seem to be a Java Development Kit home directory!";
401        }
402}
403
404# --------------------------------------------------------------------
405# Determine Operating System
406# --------------------------------------------------------------------
407
408output "\n";
409
410open CONFIG, ">.config.tmp";
411print CONFIG <<HERE ;
412# This is an automatically generated Makefile fragment which is used
413# to configure GNOME Split for building. Do not edit (your changes will
414# be overwritten next time ./configure is run), do not commit to
415# repository. Anyone packaging GNOME Split on any operating system:
416# please do not override this file by patching it! Figure out what the
417# problem is, and let us know so we can improve the ./configure perl
418# script which generates it.
419
420HERE
421
422output "equivalence, v0.2\n";
423output "...configuring Java projects to build and run on Linux & Unix\n";
424output "\n";
425
426output "Identify operating system:";
427
428if ((-f "/etc/gentoo-release") || (-f "/etc/make.conf")) {
429        output "Gentoo\n";
430        $os = "gentoo";
431} elsif (-f "/etc/debian_version") {
432        output "Debian\n"; # and Ubuntu
433        $os = "debian";
434} elsif (-f "/etc/fedora-release") {
435        output "Fedora";
436        $os = "fedora";
437
438        # Detect architecture for file locations
439        if (-x "/bin/arch") {
440                my $arch = `/bin/arch`;
441                if ($arch =~ m/_64/) {
442                        $cpu_arch = "64"
443                }
444        }
445} elsif (-f "/etc/SuSE-release") {
446        output "Open SuSE";
447        $os = "suse";
448} elsif (-f "/etc/arch-release") {
449        output "Arch Linux";
450        $os = "arch";
451} elsif (-f "/etc/mandriva-release") {
452        output "Mandriva";
453        $os = "mandriva";
454} elsif (-f "/etc/release") {
455        if (`grep Solaris /etc/release`) {
456                output "Solaris";
457                $os = "solaris";
458        }
459} elsif (-f "/etc/centos-release") {
460    output "CentOS";
461    $os = "fedora";
462} elsif (-f "/etc/redhat-release") {
463    output "RedHat";
464    $os = "fedora";
465} elsif (-f "/etc/java/jpackage-release") {
466    output "JPackage";
467    $os = "fedora";
468}
469
470if ($os) {
471        print CONFIG "OS=$os\n\n";
472} else {
473        bail "unknown!", <<HERE ;
474What we really need you to do is to look into this configure program,
475and tell us what to add. Based on the examples of what is specified
476for other distributions, you can probably quickly figure out what the
477appropriate settings are for your platform.
478
479Letting us know what changes you had to make here (ie, whatever
480actions resulted in a .config that allows you to build and test
481GNOME Split, and run the GNOME Split demo) we can help others with your
482operating system take advantage of this program.
483
484HERE
485}
486
487output "\n";
488
489# --------------------------------------------------------------------
490# Specify locations of dependencies, by operating system, and
491# verify pre-requisites are present.
492# --------------------------------------------------------------------
493
494my @java_gnome_jar;
495my @dbus_java_jar;
496my @debug_disable_jar;
497my @debug_enable_jar;
498my @hexdump_jar;
499my @unix_jar;
500
501output "Check for required jar files:\n";
502
503if ($os eq "gentoo") {
504        check_prereq(@java_gnome_jar,
505        "java-gnome library",
506        ">=dev-java/java-gnome-4.0",
507        "/usr/share/java-gnome-4.0/lib/gtk.jar");
508
509    check_prereq(@dbus_java_jar,
510        "dbus-java library",
511        ">=dev-java/dbus-java-2.7-r1",
512        "/usr/share/dbus-java/lib/dbus.jar");
513
514    check_prereq(@debug_disable_jar,
515        "matthew-debug disable library",
516        ">=dev-java/libmatthew-java-0.7-r1",
517        "/usr/share/libmatthew-java/lib/debug-disable.jar");
518
519    check_prereq(@debug_enable_jar,
520        "matthew-debug enable library",
521        ">=dev-java/libmatthew-java-0.7-r1",
522        "/usr/share/libmatthew-java/lib/debug-enable.jar");
523
524    check_prereq(@hexdump_jar,
525        "matthew-debug hexdump library",
526        ">=dev-java/libmatthew-java-0.7-r1",
527        "/usr/share/libmatthew-java/lib/hexdump.jar");
528
529    check_prereq(@unix_jar,
530        "Unix socket library",
531        ">=dev-java/libmatthew-java-0.7-r1",
532        "/usr/share/libmatthew-java/lib/unix.jar");
533} elsif ($os eq "debian") {
534        check_prereq(@java_gnome_jar,
535                "java-gnome library",
536                "libjava-gnome-java",
537                "/usr/share/java/gtk.jar");
538
539        check_prereq(@dbus_java_jar,
540                "dbus-java library",
541                "libdbus-java",
542                "/usr/share/java/dbus.jar");
543
544        check_prereq(@debug_disable_jar,
545                "matthew-debug disable library",
546                "libmatthew-debug-java",
547                "/usr/share/java/debug-disable.jar");
548
549        check_prereq(@debug_enable_jar,
550                "matthew-debug enable library",
551                "libmatthew-debug-java",
552                "/usr/share/java/debug-enable.jar");
553
554        check_prereq(@hexdump_jar,
555                "matthew-debug hexdump library",
556                "libmatthew-debug-java",
557                "/usr/share/java/hexdump.jar");
558
559        check_prereq(@unix_jar,
560                "Unix socket library",
561                "libunixsocket-java",
562                "/usr/share/java/unix.jar");
563} elsif ($os eq "fedora") {
564        my $dir = ($cpu_arch eq "64") ? "lib64" : "lib";
565
566        check_prereq(@java_gnome_jar,
567                "java-gnome library",
568                "java-gnome",
569                "/usr/$dir/java-gnome/gtk.jar");
570
571        check_prereq(@dbus_java_jar,
572                "dbus-java library",
573                "dbus-java",
574                "/usr/share/java/dbus-java/dbus.jar");
575
576        check_prereq(@debug_disable_jar,
577                "matthew-debug disable library",
578                "libmatthew-java",
579                "/usr/$dir/libmatthew-java/debug-disable.jar");
580
581        check_prereq(@debug_enable_jar,
582                "matthew-debug enable library",
583                "libmatthew-java",
584                "/usr/$dir/libmatthew-java/debug-enable.jar");
585
586        check_prereq(@hexdump_jar,
587                "matthew-debug hexdump library",
588                "libmatthew-java",
589                "/usr/$dir/libmatthew-java/hexdump.jar");
590
591        check_prereq(@unix_jar,
592                "Unix socket library",
593                "libmatthew-java",
594                "/usr/$dir/libmatthew-java/unix.jar");
595} elsif ($os eq "arch") {
596        check_prereq(@java_gnome_jar,
597                "java-gnome library",
598                "java-gnome",
599                "/usr/share/java/gtk.jar");
600
601        check_prereq(@dbus_java_jar,
602                "dbus-java library",
603                "dbus-java",
604                "/usr/share/java/dbus-java/dbus.jar");
605
606        check_prereq(@debug_disable_jar,
607                "matthew-debug disable library",
608                "libmatthew-java",
609                "/usr/share/java/libmatthew-java/debug-disable.jar");
610
611        check_prereq(@debug_enable_jar,
612                "matthew-debug enable library",
613                "libmatthew-java",
614                "/usr/share/java/libmatthew-java/debug-enable.jar");
615
616        check_prereq(@hexdump_jar,
617                "matthew-debug hexdump library",
618                "libmatthew-java",
619                "/usr/share/java/libmatthew-java/hexdump.jar");
620
621        check_prereq(@unix_jar,
622                "Unix socket library",
623                "libmatthew-java",
624                "/usr/share/java/libmatthew-java/unix.jar");
625} elsif ($os eq "suse") {
626        check_prereq(@java_gnome_jar,
627                "java-gnome library",
628                "libjava-gnome-java",
629                "/usr/share/java/gtk.jar");
630
631        check_prereq(@dbus_java_jar,
632                "dbus-java library",
633                "libdbus-java",
634                "/usr/share/java/dbus.jar");
635
636        check_prereq(@debug_disable_jar,
637                "matthew-debug disable library",
638                "libmatthew-debug-java",
639                "/usr/share/java/debug-disable.jar");
640
641        check_prereq(@debug_enable_jar,
642                "matthew-debug enable library",
643                "libmatthew-debug-java",
644                "/usr/share/java/debug-enable.jar");
645
646        check_prereq(@hexdump_jar,
647                "matthew-debug hexdump library",
648                "libmatthew-debug-java",
649                "/usr/share/java/hexdump.jar");
650
651        check_prereq(@unix_jar,
652                "Unix socket library",
653                "libunixsocket-java",
654                "/usr/share/java/unix.jar");
655} elsif ($os eq "mandriva") {
656        check_prereq(@java_gnome_jar,
657                "java-gnome library",
658                "libjava-gnome-java",
659                "/usr/share/java/gtk.jar");
660
661        check_prereq(@dbus_java_jar,
662                "dbus-java library",
663                "libdbus-java",
664                "/usr/share/java/dbus.jar");
665
666        check_prereq(@debug_disable_jar,
667                "matthew-debug disable library",
668                "libmatthew-debug-java",
669                "/usr/share/java/debug-disable.jar");
670
671        check_prereq(@debug_enable_jar,
672                "matthew-debug enable library",
673                "libmatthew-debug-java",
674                "/usr/share/java/debug-enable.jar");
675
676        check_prereq(@hexdump_jar,
677                "matthew-debug hexdump library",
678                "libmatthew-debug-java",
679                "/usr/share/java/hexdump.jar");
680
681        check_prereq(@unix_jar,
682                "Unix socket library",
683                "libunixsocket-java",
684                "/usr/share/java/unix.jar");
685} elsif ($os eq "solaris") {
686        check_prereq(@java_gnome_jar,
687                "java-gnome library",
688                "libjava-gnome-java",
689                "/usr/share/java/gtk.jar");
690
691        check_prereq(@dbus_java_jar,
692                "dbus-java library",
693                "libdbus-java",
694                "/usr/share/java/dbus.jar");
695
696        check_prereq(@debug_disable_jar,
697                "matthew-debug disable library",
698                "libmatthew-debug-java",
699                "/usr/share/java/debug-disable.jar");
700
701        check_prereq(@debug_enable_jar,
702                "matthew-debug enable library",
703                "libmatthew-debug-java",
704                "/usr/share/java/debug-enable.jar");
705
706        check_prereq(@hexdump_jar,
707                "matthew-debug hexdump library",
708                "libmatthew-debug-java",
709                "/usr/share/java/hexdump.jar");
710
711        check_prereq(@unix_jar,
712                "Unix socket library",
713                "libunixsocket-java",
714                "/usr/share/java/unix.jar");
715} else {
716        bail "failed!", "This OS not configured with defaults!\nTHIS IS AN INTERNAL ERROR, PLEASE FILE A BUG.";
717}
718
719# --------------------------------------------------------------------
720# Record jar locations
721# --------------------------------------------------------------------
722
723print CONFIG <<HERE ;
724
725# The lists of jars are colon separated, suitable for being
726# concatenated into a CLASSPATH
727
728HERE
729
730print CONFIG "JAVA_GNOME_JAR=".join(":", @java_gnome_jar)."\n";
731print CONFIG "DBUS_JAVA_JAR=".join(":", @dbus_java_jar)."\n";
732print CONFIG "DEBUG_DISABLE_JAR=".join(":", @debug_disable_jar)."\n";
733print CONFIG "DEBUG_ENABLE_JAR=".join(":", @debug_enable_jar)."\n";
734print CONFIG "HEXDUMP_JAR=".join(":", @hexdump_jar)."\n";
735print CONFIG "UNIX_SOCKET_JAR=".join(":", @unix_jar)."\n";
736
737output "\n";
738
739# --------------------------------------------------------------------
740# Check compilers: locations, necessary arguments, and that they work
741# --------------------------------------------------------------------
742
743output "Check Java compilers:\n";
744
745# compilers we will check for:
746my $javac;
747my $ecj;
748my $kaffec;
749
750# tools we check at same time (not switchable)
751my $javah;
752my $jar;
753my $javadoc;
754
755if ($os eq "gentoo") {
756        if ( ! -x "/usr/bin/java-config") {
757                bail "", "INTERNAL ERROR couldn't find java-config";
758        }
759        # this is getting ridiculous
760        my $java_home;
761        if ($jdk_home) {
762                $java_home = "$jdk_home";
763        } else {
764                $java_home = `java-config -O`;
765                chomp $java_home;
766        }
767
768        # check ecj, the standalone Eclipse compiler.
769        check_compiler($ecj, "Eclipse ecj", "/usr/bin/ecj-3.4", "-g -preserveAllLocals -nowarn -source 1.5 -target 1.5");
770        check_compiler($ecj, "Eclipse ecj", "/usr/bin/ecj-3.3", "-g -preserveAllLocals -nowarn -source 1.5 -target 1.5") unless $ecj;
771
772       
773        # check javac (the one specified by Gentoo's java-config tool)
774        # The $vendor business is just some precision prettiness for the
775        # display.
776        my $javac_candidate;
777        my $javah_candidate;
778        my $jar_candidate;
779        my $javadoc_candidate;
780        my $vendor;
781
782        if ($jdk_home) {
783                $javac_candidate   = "$jdk_home/bin/javac";
784                $javah_candidate   = "$jdk_home/bin/javah";
785                $jar_candidate     = "$jdk_home/bin/jar";
786                $javadoc_candidate = "$jdk_home/bin/javadoc";
787                $vendor            = "Specified";
788        } else {
789                $javac_candidate = `java-config --javac`;
790
791                $javah_candidate = `java-config -O`;
792                chomp $javah_candidate;
793                $javadoc_candidate = $javah_candidate;
794
795                $javah_candidate   .= "/bin/javah";
796                $javadoc_candidate .= "/bin/javadoc";
797
798                $jar_candidate = `java-config --jar`;
799                $vendor        = "System";
800        }
801
802        if ($javac_candidate =~ /sun/i) {
803                $vendor = "Sun";
804        } elsif ($javac_candidate =~ /blackdown/i) {
805                $vendor = "Blackdown";
806        } elsif ($javac_candidate =~ /ibm/i) {
807                $vendor = "IBM";
808        }
809        check_compiler($javac, "$vendor javac", $javac_candidate, "-g");
810
811        # check tools
812        check_jar($jar, "$vendor jar", $jar_candidate, "");
813        check_javadoc($javadoc, "$vendor javadoc", $javadoc_candidate, "");
814} elsif ($os eq "debian") {
815        # we can do much better than this, especially for java/javac.
816        # Do we access the alternatives system, or just go with known
817        # paths, or...? `which` is lame
818
819        # check ecj, the standalone Eclipse compiler.
820        check_compiler($ecj, "Eclipse ecj", which("ecj"), "-g -preserveAllLocals -nowarn -source 1.5 -target 1.5");
821
822        # check for a proper "real" JDK's javac as installed (and maybe
823        # selected in the alternatives system) by the user. In other words,
824        # javac -> /opt/sun-jdk-1.4.2.02/bin/javac, not javac -> kaffec.
825        my $javac_candidate;
826        my $javah_candidate;
827        my $jar_candidate;
828        my $javadoc_candidate;
829        my $vendor;
830
831        if ($jdk_home) {
832                $javac_candidate   = "$jdk_home/bin/javac";
833                $javah_candidate   = "$jdk_home/bin/javah";
834                $jar_candidate     = "$jdk_home/bin/jar";
835                $javadoc_candidate = "$jdk_home/bin/javadoc";
836                $vendor            = "Specified";
837        } else {
838                $javac_candidate   = which("javac");
839                $javah_candidate   = "";
840                $jar_candidate     = "";
841                $javadoc_candidate = "";
842                $vendor            = "System";
843        }
844        if ($javac_candidate =~ /sun/i) {
845                $vendor = "Sun";
846        } elsif ($javac_candidate =~ /blackdown/i) {
847                $vendor = "Blackdown";
848        } elsif ($javac_candidate =~ /ibm/i) {
849                $vendor = "IBM";
850        }
851        check_compiler($javac, "$vendor javac", $javac_candidate, "-g");
852
853        # check for kaffe's compiler
854        check_compiler($kaffec, "Kaffe javac", "/usr/lib/kaffe/bin/javac", "");
855
856        # check for JDK tools. To suit Debian prejudices, use GNU tools if found.
857
858        check_jar($jar, "$vendor jar", $jar_candidate, "");
859        check_jar($jar, "GNU fastjar", which("fastjar"), "") unless $jar;
860        check_jar($jar, "System jar", which("jar"), "") unless $jar;
861
862        check_javadoc($javadoc, "$vendor javadoc", $javadoc_candidate, "");
863        check_javadoc($javadoc, "GNU gjdoc", which("gjdoc"), "") unless $javadoc;
864        check_javadoc($javadoc, "System javadoc", which("javadoc"), "") unless $javadoc;
865} elsif ($os eq "fedora") {
866        # we can do much better than this, especially for java/javac.
867        # Should we just go with known paths, or...? `which` is so lame
868
869        # check ecj, the standalone Eclipse compiler.
870        check_compiler($ecj, "Eclipse ecj", which("ecj"), "-g -preserveAllLocals -nowarn -source 1.5 -target 1.5");
871
872        my $javac_candidate;
873        my $javah_candidate;
874        my $jar_candidate;
875        my $javadoc_candidate;
876        my $vendor;
877        if ($jdk_home) {
878                $javac_candidate   = "$jdk_home/bin/javac";
879                $javah_candidate   = "$jdk_home/bin/javah";
880                $jar_candidate     = "$jdk_home/bin/jar";
881                $javadoc_candidate = "$jdk_home/bin/javadoc";
882                $vendor            = "Specified";
883        } else {
884                $javac_candidate   = "/usr/bin/javac";
885                $javah_candidate   = "/usr/bin/javah";
886                $jar_candidate     = "/usr/bin/jar";
887                $javadoc_candidate = "/usr/bin/javadoc";
888                $vendor            = "System Default";
889        }
890        check_compiler($javac, "$vendor javac", $javac_candidate, "-g");
891
892        # check for kaffe's compiler
893        check_compiler($kaffec, "Kaffe javac", which("kaffec"), "");
894
895        check_jar($jar, "$vendor jar", $jar_candidate, "");
896        check_javadoc($javadoc, "$vendor javadoc", $javadoc_candidate, "");
897} elsif ($os eq "suse") {
898        # check ecj, the standalone Eclipse compiler.
899        check_compiler($ecj, "Eclipse ecj", which("ecj"), "-g -preserveAllLocals -nowarn -source 1.5 -target 1.5");
900
901        my $javac_candidate;
902        my $javah_candidate;
903        my $jar_candidate;
904        my $javadoc_candidate;
905        my $vendor;
906        if ($jdk_home) {
907                $javac_candidate   = "$jdk_home/bin/javac";
908                $javah_candidate   = "$jdk_home/bin/javah";
909                $jar_candidate     = "$jdk_home/bin/jar";
910                $javadoc_candidate = "$jdk_home/bin/javadoc";
911                $vendor            = "Specified";
912        } else {
913                $javac_candidate   = "/usr/lib/jvm/java/bin/javac";
914                $javah_candidate   = "/usr/lib/jvm/java/bin/javah";
915                $jar_candidate     = "/usr/lib/jvm/java/bin/jar";
916                $javadoc_candidate = "/usr/lib/jvm/java/bin/javadoc";
917                $vendor            = "Sun";
918        }
919        check_compiler($javac, "$vendor javac", $javac_candidate, "-g");
920
921        # check for kaffe's compiler
922        check_compiler($kaffec, "Kaffe javac", which("kaffec"), "");
923
924        check_jar($jar, "$vendor jar", $jar_candidate, "");
925        check_javadoc($javadoc, "$vendor javadoc", $javadoc_candidate, "");
926} elsif ($os eq "arch") {
927        # we can do much better than this, especially for java/javac.
928        # Should we just go with known paths, or...? `which` is so lame
929
930        # check ecj, the standalone Eclipse compiler.
931        check_compiler($ecj, "Eclipse ecj", which("ecj"), "-g -preserveAllLocals -nowarn -source 1.5 -target 1.5");
932
933        my $javac_candidate;
934        my $javah_candidate;
935        my $jar_candidate;
936        my $javadoc_candidate;
937        my $vendor;
938        if ($jdk_home) {
939                $javac_candidate   = "$jdk_home/bin/javac";
940                $javah_candidate   = "$jdk_home/bin/javah";
941                $jar_candidate     = "$jdk_home/bin/jar";
942                $javadoc_candidate = "$jdk_home/bin/javadoc";
943                $vendor            = "Specified";
944        } else {
945                $javac_candidate   = "/opt/java/bin/javac";
946                $javah_candidate   = "/opt/java/bin/javah";
947                $jar_candidate     = "/opt/java/bin/jar";
948                $javadoc_candidate = "/opt/java/bin/javadoc";
949                $vendor            = "Sun";
950        }
951        check_compiler($javac, "$vendor javac", $javac_candidate, "-g");
952
953        # check for kaffe's compiler
954        check_compiler($kaffec, "Kaffe javac", which("kaffec"), "");
955
956        check_jar($jar, "$vendor jar", $jar_candidate, "");
957        check_javadoc($javadoc, "$vendor javadoc", $javadoc_candidate, "");
958} elsif ($os eq "mandriva") {
959        # check ecj, the standalone Eclipse compiler.
960        check_compiler($ecj, "Eclipse ecj", which("ecj"), "-g -preserveAllLocals -nowarn -source 1.5 -target 1.5");
961
962        my $javac_candidate;
963        my $javah_candidate;
964        my $jar_candidate;
965        my $javadoc_candidate;
966        my $vendor;
967        if ($jdk_home) {
968                $javac_candidate = "$jdk_home/bin/javac";
969                $javah_candidate = "$jdk_home/bin/javah";
970                $jar_candidate = "$jdk_home/bin/jar";
971                $javadoc_candidate = "$jdk_home/bin/javadoc";
972                $vendor = "Specified";
973        } else {
974                $javac_candidate = which("javac");
975                $javah_candidate = which("javah");
976                $jar_candidate = which("jar");
977                $javadoc_candidate = which("javadoc");
978                $vendor = "System";
979        }
980        check_compiler($javac, "$vendor javac", $javac_candidate, "-g");
981
982        check_jar($jar, "$vendor jar", $jar_candidate, "");
983        check_javadoc($javadoc, "$vendor javadoc", $javadoc_candidate, "");
984} elsif ($os eq "solaris") {
985        check_compiler($ecj, "Eclipse ecj", which("ecj"), "-g -preserveAllLocals -nowarn -source 1.5 -target 1.5");
986
987        my $javac_candidate;
988        my $javah_candidate;
989        my $jar_candidate;
990        my $javadoc_candidate;
991        my $vendor;
992        if ($jdk_home) {
993                $javac_candidate   = "$jdk_home/bin/javac";
994                $javah_candidate   = "$jdk_home/bin/javah";
995                $jar_candidate     = "$jdk_home/bin/jar";
996                $javadoc_candidate = "$jdk_home/bin/javadoc";
997                $vendor            = "Specified";
998        } else {
999                $javac_candidate   = "/usr/java/bin/javac";
1000                $javah_candidate   = "/usr/java/bin/javah";
1001                $jar_candidate     = "/usr/java/bin/jar";
1002                $javadoc_candidate = "/usr/java/bin/javadoc";
1003                $vendor            = "Sun";
1004        }
1005        check_compiler($javac, "$vendor javac", $javac_candidate, "-g");
1006
1007        # check for kaffe's compiler
1008        check_compiler($kaffec, "Kaffe javac", which("kaffec"), "");
1009
1010        check_jar($jar, "$vendor jar", $jar_candidate, "");
1011        check_javadoc($javadoc, "$vendor javadoc", $javadoc_candidate, "");
1012} else {
1013        bail "failed!", "This OS not configured with a workable Java compiler checks!\nTHIS IS AN INTERNAL ERROR, PLEASE FILE A BUG.";
1014}
1015
1016output "\n";
1017
1018# --------------------------------------------------------------------
1019# Check runtimes
1020# --------------------------------------------------------------------
1021
1022output "Check Java virtual machines:\n";
1023
1024# runtimes we will check for:
1025my $java;
1026my $kaffe;
1027my $cacao;
1028my $jamvm;
1029
1030if ($os eq "gentoo") {
1031        # check java (the one specified by Gentoo's java-config tool)
1032        # Is there any actual scenario where the javac would be from one
1033        # vendor's JDK and the java from anther's JRE? I can't imagine, but
1034        # do the $vendor check again. It's only cosmetic in any event.
1035        my $java_candidate;
1036        my $vendor;
1037
1038        if ($jdk_home) {
1039                $java_candidate = "$jdk_home/bin/java";
1040        } else {
1041                $java_candidate = `java-config --java`;
1042        }
1043
1044        if ($java_candidate =~ /sun/i) {
1045                $vendor = "Sun";
1046        } elsif ($java_candidate =~ /blackdown/i) {
1047                $vendor = "Blackdown";
1048        } elsif ($java_candidate =~ /ibm/i) {
1049                $vendor = "IBM";
1050        } else {
1051                $vendor = "System";
1052        }
1053        check_runtime($java, "$vendor java VM", $java_candidate, "-client -ea");
1054
1055        # check kaffe
1056        check_runtime($kaffe, "kaffe VM", which("kaffe"), "");
1057
1058        # check jamvm (an elegant bytecode interpreter used by many in the
1059        # CLASSPATH project to test new releases)
1060        my $jamvm_candidate;
1061        if ($jamvm_bin) {
1062                $jamvm_candidate = "$jamvm_bin";
1063        } else {
1064                $jamvm_candidate = "/usr/bin/jamvm";
1065        }
1066        check_runtime($jamvm, "JamVM VM", $jamvm_candidate, "");
1067
1068        my $cacao_candidate;
1069        if ($cacao_bin) {
1070                $cacao_candidate = "$cacao_bin";
1071        } else {
1072                $cacao_candidate = "/usr/bin/cacao";
1073        }
1074        check_runtime($cacao, "CACAO VM", $cacao_candidate, "");
1075} elsif ($os eq "debian") {
1076        # check for a proper JDK/JRE java Virtual Machine (presumably either
1077        # blackdown, or the real thing from Sun or IBM, as installed by the
1078        # user).  NOTE that this does *NOT* mean Sable VM or kaffe (so, if the
1079        # Debian alternatives system can say that's what's providing
1080        # java-runtime, then we need to take advantage of that. This is for a
1081        # real JRE only, ie java -> /opt/sun-jdk-1.4.2.02/bin/java, not for
1082        # java -> kaffe.
1083        my $java_candidate;
1084        my $vendor;
1085
1086        if ($jdk_home) {
1087                $java_candidate = "$jdk_home/bin/java";
1088                $vendor = "Specified";
1089        } else {
1090                $java_candidate = which("java");
1091                $vendor = "System";
1092        }
1093        check_runtime($java, "$vendor java VM", $java_candidate, "-client -ea");
1094
1095        # check kaffe. Don't take it personally, but kaffe is not meant as a
1096        # robust production ready VM.  It's a research tool (so described on
1097        # their home page) but given the progress in GNU classpath lately it
1098        # *may* work, so we do check for it  - we just don't pick it by
1099        # preference.
1100        check_runtime($kaffe, "Kaffe VM", "/usr/lib/kaffe/bin/java", "");
1101
1102        # check jamvm (an elegant bytecode interpreter used by many in the
1103        # CLASSPATH project to test new releases)
1104        my $jamvm_candidate;
1105        if ($jamvm_bin) {
1106                $jamvm_candidate = "$jamvm_bin";
1107        } else {
1108                $jamvm_candidate = "/usr/bin/jamvm";
1109        }
1110        check_runtime($jamvm, "JamVM VM", $jamvm_candidate, "");
1111
1112        my $cacao_candidate;
1113        if ($cacao_bin) {
1114                $cacao_candidate = "$cacao_bin";
1115        } else {
1116                $cacao_candidate = "/usr/bin/cacao";
1117        }
1118        check_runtime($cacao, "CACAO VM", $cacao_candidate, "");
1119} elsif ($os eq "fedora") {
1120        # check for a proper JDK/JRE java Virtual Machine. Red Hat is using
1121        # the alternatives system symlinks to select JVMs, and then *again*
1122        # to select versions. All the symlinks end up back in /usr/lib/jvm with
1123        # predictable names, which makes this workable.
1124        my $java_candidate;
1125        my $vendor;
1126        if ($jdk_home) {
1127                $java_candidate = "$jdk_home/bin/java";
1128                $vendor         = "Specified";
1129        } else {
1130                $java_candidate = "/usr/bin/java";
1131                $vendor         = "System Default";
1132        }
1133        check_runtime($java, "$vendor java VM", $java_candidate, "-client -ea");
1134
1135        # check kaffe. See the comment about Kaffe above in the Debian block.
1136        check_runtime($kaffe, "Kaffe VM", which("kaffe"), "");
1137
1138        # check jamvm (an elegant bytecode interpreter used by many in the
1139        # CLASSPATH project to test new releases)
1140        my $jamvm_candidate;
1141        if ($jamvm_bin) {
1142                $jamvm_candidate = "$jamvm_bin";
1143        } else {
1144                $jamvm_candidate = "/usr/bin/jamvm";
1145        }
1146        check_runtime($jamvm, "JamVM VM", $jamvm_candidate, "");
1147
1148        my $cacao_candidate;
1149        if ($cacao_bin) {
1150                $cacao_candidate = "$cacao_bin";
1151        } else {
1152                $cacao_candidate = "/usr/bin/cacao";
1153        }
1154        check_runtime($cacao, "CACAO VM", $cacao_candidate, "");
1155} elsif ($os eq "suse") {
1156        # check for a proper JDK/JRE java Virtual Machine.
1157        my $java_candidate;
1158        my $vendor;
1159        if ($jdk_home) {
1160                $java_candidate = "$jdk_home/bin/java";
1161                $vendor = "Specified";
1162        } else {
1163                $java_candidate = "/usr/lib/jvm/java/bin/java";
1164                $vendor = "Sun";
1165        }
1166        check_runtime($java, "$vendor java VM", $java_candidate, "-client -ea");
1167
1168        # check kaffe. See the comment about Kaffe above in the Debian block.
1169        check_runtime($kaffe, "Kaffe VM", which("kaffe"), "");
1170
1171        # check jamvm (an elegant bytecode interpreter used by many in the
1172        # CLASSPATH project to test new releases)
1173        my $jamvm_candidate;
1174        if ($jamvm_bin) {
1175                $jamvm_candidate = "$jamvm_bin";
1176        } else {
1177                $jamvm_candidate = "/usr/bin/jamvm";
1178        }
1179        check_runtime($jamvm, "JamVM VM", $jamvm_candidate, "");
1180
1181        my $cacao_candidate;
1182        if ($cacao_bin) {
1183                $cacao_candidate = "$cacao_bin";
1184        } else {
1185                $cacao_candidate = "/usr/bin/cacao";
1186        }
1187        check_runtime($cacao, "CACAO VM", $cacao_candidate, "");
1188} elsif ($os eq "mandriva") {
1189        my $java_candidate;
1190        my $vendor;
1191
1192        if ($jdk_home) {
1193                $java_candidate = "$jdk_home/bin/java";
1194                $vendor = "Specified";
1195        } else {
1196                $java_candidate = which("java");
1197                $vendor = "System";
1198        }
1199
1200        check_runtime($java, "$vendor java VM", $java_candidate, "-client -ea");
1201
1202        # check jamvm (an elegant bytecode interpreter used by many in the
1203        # CLASSPATH project to test new releases)
1204        my $jamvm_candidate;
1205        if ($jamvm_bin) {
1206                $jamvm_candidate = "$jamvm_bin";
1207        } else {
1208                $jamvm_candidate = "/usr/bin/jamvm";
1209        }
1210        check_runtime($jamvm, "JamVM VM", $jamvm_candidate, "");
1211
1212        my $cacao_candidate;
1213        if ($cacao_bin) {
1214                $cacao_candidate = "$cacao_bin";
1215        } else {
1216                $cacao_candidate = "/usr/bin/cacao";
1217        }
1218        check_runtime($cacao, "CACAO VM", $cacao_candidate, "");
1219} elsif ($os eq "arch") {
1220        # check for a proper JDK/JRE java Virtual Machine. Red Hat is using
1221        # the alternatives system symlinks to select JVMs, and then *again*
1222        # to select versions. All the symlinks end up back in /usr/lib/jvm with
1223        # predictable names, which makes this workable.
1224        my $java_candidate;
1225        my $vendor;
1226        if ($jdk_home) {
1227                $java_candidate = "$jdk_home/bin/java";
1228                $vendor         = "Specified";
1229        } else {
1230                $java_candidate = "/opt/java/bin/java";
1231                $vendor         = "IBM";
1232        }
1233        check_runtime($java, "$vendor java VM", $java_candidate, "-client -ea");
1234
1235        # check kaffe. See the comment about Kaffe above in the Debian block.
1236        check_runtime($kaffe, "Kaffe VM", which("kaffe"), "");
1237
1238        # check jamvm (an elegant bytecode interpreter used by many in the
1239        # CLASSPATH project to test new releases)
1240        my $jamvm_candidate;
1241        if ($jamvm_bin) {
1242                $jamvm_candidate = "$jamvm_bin";
1243        } else {
1244                $jamvm_candidate = "/usr/bin/jamvm";
1245        }
1246        check_runtime($jamvm, "JamVM VM", $jamvm_candidate, "");
1247
1248        my $cacao_candidate;
1249        if ($cacao_bin) {
1250                $cacao_candidate = "$cacao_bin";
1251        } else {
1252                $cacao_candidate = "/usr/bin/cacao";
1253        }
1254        check_runtime($cacao, "CACAO VM", $cacao_candidate, "");
1255} elsif ($os eq "solaris") {
1256        # check for a JDK/JRE java Virtual Machine, allowing an alternate to be set
1257        # (no reason to disable that)
1258        my $java_candidate;
1259        if ($jdk_home) {
1260                $java_candidate = "$jdk_home/bin/java";
1261        } else {
1262                $java_candidate = "/usr/java/bin/java";
1263        }
1264
1265        check_runtime($java, "Sun java VM", $java_candidate, "-client -ea");
1266
1267        # check kaffe
1268        check_runtime($kaffe, "kaffe VM", which("kaffe"), "");
1269
1270        # check jamvm (an elegant bytecode interpreter used by many in the
1271        # CLASSPATH project to test new releases)
1272        my $jamvm_candidate;
1273        if ($jamvm_bin) {
1274                $jamvm_candidate = "$jamvm_bin";
1275        } else {
1276                $jamvm_candidate = "/usr/bin/jamvm";
1277        }
1278        check_runtime($jamvm, "JamVM VM", $jamvm_candidate, "");
1279
1280        my $cacao_candidate;
1281        if ($cacao_bin) {
1282                $cacao_candidate = "$cacao_bin";
1283        } else {
1284                $cacao_candidate = "/usr/bin/cacao";
1285        }
1286        check_runtime($cacao, "CACAO VM", $cacao_candidate, "");
1287} else {
1288        bail "failed!", "This OS not configured with appropriate Java VM checks!\nTHIS IS AN INTERNAL ERROR, PLEASE FILE A BUG.";
1289}
1290
1291output "\n";
1292
1293print CONFIG <<HERE ;
1294
1295# the JAVAC variable contains the path to the java source compiler,
1296# the JAVA variable contains the path to the java runtime virtual
1297# machine. In both cases, the _CMD variable is for the terse output
1298# when make commands are running.
1299
1300HERE
1301
1302output "Select compiler:";
1303
1304if ($compiler) {
1305        # if overridden, check override...
1306        if ($compiler eq "javac") {
1307                bail "bad override", "javac specified but not detected as a workable compiler." unless $javac;
1308        } elsif ($compiler eq "ecj") {
1309                bail "bad override", "ecj specified but not detected as a workable compiler." unless $ecj;
1310        } else {
1311                bail "bad override", <<HERE ;
1312You specified compiler=$compiler on the command line, but that's not an option.
1313Valid choices are ecj, javac - but of course that compiler must be
1314installed (and detected!) in order to be able to specify it.
1315HERE
1316        }
1317} else {
1318        # otherwise, pick a compiler.
1319        if ($ecj) {
1320                $compiler = "ecj";
1321        } elsif ($javac) {
1322                $compiler = "javac";
1323        } else {
1324                bail "failed", "No java compiler was detected.";
1325        }
1326}
1327
1328if ($compiler eq "javac") {
1329        print CONFIG "JAVAC=$javac\n";
1330        print CONFIG "JAVAC_CMD=JAVAC\n";
1331} elsif ($compiler eq "ecj") {
1332        print CONFIG "JAVAC=$ecj\n";
1333        print CONFIG "JAVAC_CMD=ECJ\n";
1334} else {
1335        bail "failed", "INTERNAL ERROR no compiler selected.";
1336}
1337
1338print CONFIG <<HERE ;
1339
1340# the JAVAH, JAR, and JAVADOC variables simply contains a usable jar
1341# and javah executable, respectively, while the JAVAH_CMD, JAR_CMD,
1342# and JAVADOC_CMD variables is for display purposes, matching the
1343# pattern above.
1344
1345HERE
1346
1347if ($jar) {
1348        print CONFIG "JAR=$jar\n";
1349        print CONFIG "JAR_CMD=JAR\n";
1350} else {
1351        bail "failed", "No Java archive tool detected.";
1352}
1353if ($javadoc) {
1354        print CONFIG "JAVADOC=$javadoc\n";
1355        print CONFIG "JAVADOC_CMD=JAVADOC\n";
1356} else {
1357        bail "failed", "No JavaDoc tool detected.";
1358}
1359
1360output "$compiler\n";
1361
1362output "Select runtime:";
1363
1364if ($runtime) {
1365        # if overridden, check override...
1366        if ($runtime eq "java")  {
1367                bail "bad override", "java specified but not detected." unless $java;
1368        } elsif ($runtime eq "kaffe") {
1369                bail "bad override", "kaffe specified but not detected." unless $kaffe;
1370        } elsif ($runtime eq "cacao") {
1371                bail "bad override", "cacao specified but not detected." unless $cacao;
1372        } elsif ($runtime eq "jamvm") {
1373                bail "bad override", "jamvm specified but not detected." unless $jamvm;
1374        } else {
1375                bail "bad override", <<HERE ;
1376You specified runtime=$runtime on the command line, but that's not an option.
1377Valid choices are java, jamvm, cacao, or kaffe - but of course that virtual
1378machine must be installed (and detected!) before you can specify it.
1379HERE
1380        }
1381} else {
1382        if ($java) {
1383                $runtime = "java";
1384        } elsif ($jamvm) {
1385                $runtime = "jamvm";
1386        } elsif ($cacao) {
1387                $runtime = "cacao";
1388        } elsif ($kaffe) {
1389                $runtime = "kaffe";
1390        } else {
1391                bail "failed", "No usable Java runtime environment was detected.";
1392        }
1393}
1394
1395my $JAVA;
1396
1397if ($runtime eq "java") {
1398        print CONFIG "JAVA=$java\n";
1399        print CONFIG "JAVA_CMD=JAVA\n";
1400        $JAVA=$java;
1401} elsif ($runtime eq "kaffe") {
1402        print CONFIG "JAVA=$kaffe\n";
1403        print CONFIG "JAVA_CMD=KAFFE\n";
1404        $JAVA=$kaffe
1405} elsif ($runtime eq "cacao") {
1406        print CONFIG "JAVA=$cacao\n";
1407        print CONFIG "JAVA_CMD=CACAO\n";
1408        $JAVA=$cacao
1409} elsif ($runtime eq "jamvm") {
1410        print CONFIG "JAVA=$jamvm\n";
1411        print CONFIG "JAVA_CMD=JAMVM\n";
1412        $JAVA=$jamvm
1413} else {
1414        bail "failed", "INTERNAL ERROR no virtual machine selected";
1415}
1416output "$runtime\n";
1417output "\n";
1418
1419`rm -f Hello.java Hello.class Hello.o Hello Hello.c Hello.jar`;
1420
1421print CONFIG <<HERE ;
1422
1423# the install prefix. This *only* affects the location that installed
1424# files are sent to during the `make install` step.
1425
1426HERE
1427
1428if (!$prefix) {
1429        $prefix = "/usr/local";
1430}
1431print CONFIG "PREFIX=$prefix\n";
1432if (!$libdir) {
1433        $libdir = "$prefix/lib";
1434}
1435print CONFIG "LIBDIR=$libdir\n";
1436if (!$jardir) {
1437        $jardir = "$prefix/share/java";
1438}
1439print CONFIG "JARDIR=$jardir\n";
1440
1441# --------------------------------------------------------------------
1442# Get version constant
1443# --------------------------------------------------------------------
1444
1445my $version;
1446
1447open SOURCE, "src/org/gnome/split/config/Constants.java";
1448while (<SOURCE>) {
1449        chomp;
1450        if (/.* PROGRAM_VERSION = \"([\d\.\-rcdev]+)\";/) {
1451                $version = $1;
1452        }
1453}
1454close SOURCE;
1455
1456if (!$version) {
1457        bail("", "Couldn't find the release version");
1458}
1459
1460print CONFIG <<HERE ;
1461
1462# finally, we extract the version strings from the source code, for
1463# use in naming the target library files.
1464
1465HERE
1466
1467print CONFIG "VERSION=$version\n";
1468
1469# --------------------------------------------------------------------
1470# Done! Create .config file
1471# --------------------------------------------------------------------
1472
1473output "Write .config file:";
1474close CONFIG;
1475system "mv .config.tmp .config";
1476
1477output "ok\n";
1478
1479# --------------------------------------------------------------------
1480# Create in-place launcher file
1481# --------------------------------------------------------------------
1482
1483# We need to support specifying an alternative location for the installed
1484# gnome-split.jar file. For now it is hard coded as follows:
1485
1486my $JAVAGNOME_JAR   = join(":", @java_gnome_jar);
1487my $DBUSJAVA_JAR    = join(":", @dbus_java_jar);
1488my $DEBUGDIS_JAR    = join(":", @debug_disable_jar);
1489my $DEBUGENA_JAR    = join(":", @debug_enable_jar);
1490my $HEXDUMP_JAR     = join(":", @hexdump_jar);
1491my $UNIXSOCK_JAR    = join(":", @unix_jar);
1492my $GNOME_SPLIT_JAR = "$prefix/share/java/gnome-split-$version.jar";
1493
1494output "Write launcher files:";
1495
1496mkdir "tmp/";
1497mkdir "tmp/launcher";
1498
1499open LAUNCHER, ">tmp/launcher/gnome-split-local";
1500
1501print LAUNCHER "#!/bin/sh\n";
1502print LAUNCHER join (" ",
1503        "exec java",
1504        "-client",
1505        "-ea",
1506        "-Dprogram='gnome-split'",
1507        "-Djava.awt.headless=true",
1508        "-Djava.library.path=$libdir",
1509        "-classpath tmp/classes:$JAVAGNOME_JAR:$DBUSJAVA_JAR:$DEBUGDIS_JAR:$DEBUGENA_JAR:$HEXDUMP_JAR:$UNIXSOCK_JAR",
1510        "org.gnome.split.GnomeSplit",
1511        "\"\$@\"") . "\n";
1512
1513close LAUNCHER;
1514
1515# --------------------------------------------------------------------
1516# Create as-installed launcher file
1517# --------------------------------------------------------------------
1518
1519open LAUNCHER, ">tmp/launcher/gnome-split-install";
1520
1521print LAUNCHER "#!/bin/sh\n";
1522print LAUNCHER "cd $prefix\n";
1523print LAUNCHER join (" ",
1524        "exec java",
1525        "-client",
1526        "-ea",
1527        "-Dprogram='gnome-split'",
1528        "-Djava.awt.headless=true",
1529        "-Djava.library.path=$libdir",
1530        "-classpath $GNOME_SPLIT_JAR:$JAVAGNOME_JAR:$DBUSJAVA_JAR:$DEBUGDIS_JAR:$DEBUGENA_JAR:$HEXDUMP_JAR:$UNIXSOCK_JAR",
1531        "org.gnome.split.GnomeSplit",
1532        "\"\$@\"") . "\n";
1533
1534close LAUNCHER;
1535
1536open DESKTOP, ">tmp/launcher/gnome-split.desktop";
1537
1538print DESKTOP <<HERE ;
1539[Desktop Entry]
1540Version=$version
1541Type=Application
1542Name=GNOME Split
1543GenericName="Files splitter"
1544GenericName[fr]="Découpeur de fichiers"
1545Comment=Split and assemble files easily
1546Comment[fr]=Découpage et assemblage de fichiers
1547Categories=GNOME;GTK;Utility;
1548Path=$prefix
1549Exec=$prefix/bin/gnome-split
1550Icon=$prefix/share/pixmaps/gnome-split.png
1551MimeType=application/x-extension-xtm;application/x-extension-gsp;application/x-extension-yct;application/x-extension-kk;application/x-generic-chunk
1552HERE
1553
1554close DESKTOP;
1555
1556open MIMETYPE, ">tmp/launcher/gnome-split.xml";
1557
1558print MIMETYPE <<HERE;
1559<?xml version="1.0" encoding="UTF-8"?>
1560<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
1561  <mime-type type="application/x-extension-xtm">
1562    <comment>Xtremsplit file</comment>
1563    <glob pattern="*.xtm"/>
1564  </mime-type>
1565  <mime-type type="application/x-extension-gsp">
1566    <comment>GNOME Split file</comment>
1567    <glob pattern="*.gsp"/>
1568  </mime-type>
1569  <mime-type type="application/x-extension-yct">
1570    <comment>YoyoCut file</comment>
1571    <glob pattern="*.yct"/>
1572  </mime-type>
1573  <mime-type type="application/x-extension-kk">
1574    <comment>KFK file</comment>
1575    <glob pattern="*.kk*"/>
1576  </mime-type>
1577  <mime-type type="application/x-generic-chunk">
1578    <comment>First chunk of a split file</comment>
1579    <glob pattern="*.000"/>
1580    <glob pattern="*.001"/>
1581  </mime-type>
1582</mime-info>
1583HERE
1584
1585output "ok\n";
1586output "\n";
Note: See TracBrowser for help on using the browser.