OSDN Git Service

2009-04-26 Matthias Klose <doko@ubuntu.com>
[pf3gnuchains/gcc-fork.git] / libjava / contrib / aot-compile.in
1 #!/usr/bin/env python
2
3 ## Copyright (C) 2006 Free Software Foundation
4 ## Written by Gary Benson <gbenson@redhat.com>
5 ##
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 2 of the License, or
9 ## (at your option) any later version.
10 ##
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ## GNU General Public License for more details.
15
16 import sys
17 sys.path.append("@python_mod_dir_expanded@")
18 import aotcompile
19 import getopt
20 import os
21
22 usage = """\
23 Usage: %s [OPTION...] SRCDIR DSTDIR
24 AOT-compile all Java bytecode in SRCDIR into DSTDIR.
25
26 Options:
27   -M, --make=PATH        make executable to use (%s)
28   -C, --gcj=PATH         gcj executable to use (%s)
29   -D, --dbtool=PATH      gcj-dbtool executable to use (%s)
30   -m, --makeflags=FLAGS  flags to pass to make during build
31   -c, --gcjflags=FLAGS   flags to pass to gcj during compilation
32                            in addition to %s
33   -l, --ldflags=FLAGS    flags to pass to gcj during linking
34                            in addition to %s
35   -e, --exclude=PATH     do not compile PATH
36
37 Extra flags may also be passed using the AOT_MAKEFLAGS, AOT_GCJFLAGS
38 and AOT_LDFLAGS environment variables.""" % (
39     os.path.basename(sys.argv[0]),
40     aotcompile.PATHS["make"],
41     aotcompile.PATHS["gcj"],
42     aotcompile.PATHS["dbtool"],
43     repr(" ".join(aotcompile.GCJFLAGS)),
44     repr(" ".join(aotcompile.LDFLAGS)))
45
46 try:
47     if os.environ.has_key("RPM_PACKAGE_NAME"):
48         raise aotcompile.Error, "not for use within rpm specfiles"
49
50     try:
51         opts, args = getopt.getopt(
52             sys.argv[1:],
53             "M:C:D:m:c:l:e:",
54             ["make=", "gcj=", "dbtool=",
55              "makeflags=" "gcjflags=", "ldflags=",
56              "exclude="])
57         srcdir, dstdir = args
58     except:
59         print >>sys.stderr, usage
60         sys.exit(1)
61
62     compiler = aotcompile.Compiler(srcdir, dstdir)
63     for o, a in opts:
64         if o in ("-M", "--make"):
65             aotcompile.PATHS["make"] = a
66         if o in ("-C", "--gcj"):
67             aotcompile.PATHS["gcj"] = a
68         if o in ("-D", "--dbtool"):
69             aotcompile.PATHS["dbtool"] = a
70         if o in ("-m", "--makeflags"):
71             compiler.makeflags[0:0] = a.split()
72         if o in ("-c", "--gcjflags"):
73             compiler.gcjflags[0:0] = a.split()
74         if o in ("-l", "--ldflags"):
75             compiler.ldflags[0:0] = a.split()
76         if o in ("-e", "--exclude"):
77             compiler.exclusions.append(a)
78     
79     compiler.makeflags[0:0] = os.environ.get("AOT_MAKEFLAGS", "").split() 
80     compiler.gcjflags[0:0] = os.environ.get("AOT_GCJFLAGS", "").split() 
81     compiler.ldflags[0:0] = os.environ.get("AOT_LDFLAGS", "").split() 
82
83     compiler.compile()
84
85 except aotcompile.Error, e:
86     print >>sys.stderr, "%s: error: %s" % (
87         os.path.basename(sys.argv[0]), e)
88     sys.exit(1)