3 # gen-make.py -- generate makefiles for building Subversion
11 my_getopt
= getopt
.gnu_getopt
12 except AttributeError:
13 my_getopt
= getopt
.getopt
16 # for the generator modules
17 sys
.path
.insert(0, os
.path
.join('build', 'generator'))
20 sys
.path
.insert(1, 'build')
23 'make' : ('gen_make', 'Makefiles for POSIX systems'),
24 'dsp' : ('gen_msvc_dsp', 'MSVC 6.x project files'),
25 'vcproj' : ('gen_vcnet_vcproj', 'VC.Net project files'),
28 def main(fname
, gentype
, verfname
=None,
29 skip_depends
=0, other_options
=None):
31 verfname
= os
.path
.join('subversion', 'include', 'svn_version.h')
33 gen_module
= __import__(gen_modules
[gentype
][0])
35 generator
= gen_module
.Generator(fname
, verfname
, other_options
)
38 generator
.compute_hdr_deps()
42 if ('--debug', '') in other_options
:
43 for dep_type
, target_dict
in generator
.graph
.deps
.items():
44 sorted_targets
= target_dict
.keys(); sorted_targets
.sort()
45 for target
in sorted_targets
:
46 print dep_type
+ ": " + _objinfo(target
)
47 for source
in target_dict
[target
]:
48 print " " + _objinfo(source
)
50 gen_keys
= generator
.__dict
__.keys()
53 value
= generator
.__dict
__[name
]
54 if type(value
) == type([]):
57 print " " + _objinfo(i
)
62 if type(o
) == type(''):
65 t
= o
.__class
__.__name
__
66 n
= getattr(o
, 'name', '-')
67 f
= getattr(o
, 'filename', '-')
68 return "%s: %s %s" % (t
,n
,f
)
72 "print usage, exit the script"
73 print "USAGE: gen-make.py [options...] [conf-file]"
74 print " -s skip dependency generation"
75 print " --debug print lots of stuff only developers care about"
76 print " --release release mode"
77 print " --reload reuse all options from the previous invocation"
78 print " of the script, except -s, -t, --debug and --reload"
79 print " -t TYPE use the TYPE generator; can be one of:"
80 items
= gen_modules
.items()
82 for name
, (module
, desc
) in items
:
83 print ' %-12s %s' % (name
, desc
)
85 print " The default generator type is 'make'"
87 print " Makefile-specific options:"
89 print " --assume-shared-libs"
90 print " omit dependencies on libraries, on the assumption that"
91 print " shared libraries will be built, so that it is unnecessary"
92 print " to relink executables when the libraries that they depend"
93 print " on change. This is an option for developers who want to"
94 print " increase the speed of frequent rebuilds."
95 print " *** Do not use unless you understand the consequences. ***"
97 print " Windows-specific options:"
99 print " --with-apr=DIR"
100 print " the APR sources are in DIR"
102 print " --with-apr-util=DIR"
103 print " the APR-Util sources are in DIR"
105 print " --with-apr-iconv=DIR"
106 print " the APR-Iconv sources are in DIR"
108 print " --with-berkeley-db=DIR"
109 print " look for Berkeley DB headers and libs in"
112 print " --with-neon=DIR"
113 print " the Neon sources are in DIR"
115 print " --without-neon"
116 print " Don't build Neon sources (if present)"
118 print " --with-serf=DIR"
119 print " the Serf sources are in DIR"
121 print " --with-httpd=DIR"
122 print " the httpd sources and binaries required"
123 print " for building mod_dav_svn are in DIR;"
124 print " implies --with-apr{-util, -iconv}, but"
125 print " you can override them"
127 print " --with-libintl=DIR"
128 print " look for GNU libintl headers and libs in DIR;"
129 print " implies --enable-nls"
131 print " --with-openssl=DIR"
132 print " tell neon to look for OpenSSL headers"
133 print " and libs in DIR"
135 print " --with-zlib=DIR"
136 print " tell neon to look for ZLib headers and"
139 print " --with-junit=DIR"
140 print " look for the junit jar here"
141 print " junit is for testing the java bindings"
143 print " --with-swig=DIR"
144 print " look for the swig program in DIR"
146 print " --with-sqlite=DIR"
147 print " look for sqlite in DIR"
149 print " --with-sasl=DIR"
150 print " look for the sasl headers and libs in DIR"
152 print " --enable-pool-debug"
153 print " turn on APR pool debugging"
155 print " --enable-purify"
156 print " add support for Purify instrumentation;"
157 print " implies --enable-pool-debug"
159 print " --enable-quantify"
160 print " add support for Quantify instrumentation"
162 print " --enable-nls"
163 print " add support for gettext localization"
165 print " --enable-bdb-in-apr-util"
166 print " configure APR-Util to use Berkeley DB"
169 print " enable use of ML assembler with zlib"
171 print " --disable-shared"
172 print " only build static libraries"
174 print " --vsnet-version=VER"
175 print " generate for VS.NET version VER (2002, 2003, 2005 or 2008)"
176 print " [only valid in combination with '-t vcproj']"
185 def add(self
, opt
, val
):
186 if self
.dict.has_key(opt
):
187 self
.list[self
.dict[opt
]] = (opt
, val
)
189 self
.dict[opt
] = len(self
.list)
190 self
.list.append((opt
, val
))
192 if __name__
== '__main__':
194 opts
, args
= my_getopt(sys
.argv
[1:], 'st:',
198 'assume-shared-libs',
218 'enable-bdb-in-apr-util',
225 except getopt
.GetoptError
:
236 for opt
, val
in opts
:
241 elif opt
== '--reload':
242 prev_conf
= ConfigParser
.ConfigParser()
243 prev_conf
.read('gen-make.opts')
244 for opt
, val
in prev_conf
.items('options'):
250 if opt
== '--with-httpd':
251 rest
.add('--with-apr', os
.path
.join(val
, 'srclib', 'apr'))
252 rest
.add('--with-apr-util', os
.path
.join(val
, 'srclib', 'apr-util'))
253 rest
.add('--with-apr-iconv', os
.path
.join(val
, 'srclib', 'apr-iconv'))
255 # Remember all options so that --reload and other scripts can use them
256 opt_conf
= open('gen-make.opts', 'w')
257 opt_conf
.write('[options]\n')
258 for opt
, val
in rest
.list:
259 opt_conf
.write(opt
+ ' = ' + val
+ '\n')
262 if gentype
not in gen_modules
.keys():
265 main(conf
, gentype
, skip_depends
=skip
, other_options
=rest
.list)