Make a status test pass against old servers.
[svn.git] / gen-make.py
blob6fe722ce7f3a537b066070393fd17998417d5f58
1 #!/usr/bin/env python
3 # gen-make.py -- generate makefiles for building Subversion
7 import os
8 import sys
9 import getopt
10 try:
11 my_getopt = getopt.gnu_getopt
12 except AttributeError:
13 my_getopt = getopt.getopt
14 import ConfigParser
16 # for the generator modules
17 sys.path.insert(0, os.path.join('build', 'generator'))
19 # for getversion
20 sys.path.insert(1, 'build')
22 gen_modules = {
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):
30 if verfname is 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)
37 if not skip_depends:
38 generator.compute_hdr_deps()
40 generator.write()
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)
49 print "=" * 72
50 gen_keys = generator.__dict__.keys()
51 gen_keys.sort()
52 for name in gen_keys:
53 value = generator.__dict__[name]
54 if type(value) == type([]):
55 print name + ": "
56 for i in value:
57 print " " + _objinfo(i)
58 print "=" * 72
61 def _objinfo(o):
62 if type(o) == type(''):
63 return repr(o)
64 else:
65 t = o.__class__.__name__
66 n = getattr(o, 'name', '-')
67 f = getattr(o, 'filename', '-')
68 return "%s: %s %s" % (t,n,f)
71 def _usage_exit():
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()
81 items.sort()
82 for name, (module, desc) in items:
83 print ' %-12s %s' % (name, desc)
84 print
85 print " The default generator type is 'make'"
86 print
87 print " Makefile-specific options:"
88 print
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. ***"
96 print
97 print " UNIX-specific options:"
98 print
99 print " --installed-libs"
100 print " Comma-separated list of Subversion libraries to find"
101 print " pre-installed instead of building (probably only"
102 print " useful for packagers)"
103 print
104 print " Windows-specific options:"
105 print
106 print " --with-apr=DIR"
107 print " the APR sources are in DIR"
108 print
109 print " --with-apr-util=DIR"
110 print " the APR-Util sources are in DIR"
111 print
112 print " --with-apr-iconv=DIR"
113 print " the APR-Iconv sources are in DIR"
114 print
115 print " --with-berkeley-db=DIR"
116 print " look for Berkeley DB headers and libs in"
117 print " DIR"
118 print
119 print " --with-neon=DIR"
120 print " the Neon sources are in DIR"
121 print
122 print " --without-neon"
123 print " Don't build Neon sources (if present)"
124 print
125 print " --with-serf=DIR"
126 print " the Serf sources are in DIR"
127 print
128 print " --with-httpd=DIR"
129 print " the httpd sources and binaries required"
130 print " for building mod_dav_svn are in DIR;"
131 print " implies --with-apr{-util, -iconv}, but"
132 print " you can override them"
133 print
134 print " --with-libintl=DIR"
135 print " look for GNU libintl headers and libs in DIR;"
136 print " implies --enable-nls"
137 print
138 print " --with-openssl=DIR"
139 print " tell neon to look for OpenSSL headers"
140 print " and libs in DIR"
141 print
142 print " --with-zlib=DIR"
143 print " tell neon to look for ZLib headers and"
144 print " libs in DIR"
145 print
146 print " --with-junit=DIR"
147 print " look for the junit jar here"
148 print " junit is for testing the java bindings"
149 print
150 print " --with-swig=DIR"
151 print " look for the swig program in DIR"
152 print
153 print " --with-sasl=DIR"
154 print " look for the sasl headers and libs in DIR"
155 print
156 print " --enable-pool-debug"
157 print " turn on APR pool debugging"
158 print
159 print " --enable-purify"
160 print " add support for Purify instrumentation;"
161 print " implies --enable-pool-debug"
162 print
163 print " --enable-quantify"
164 print " add support for Quantify instrumentation"
165 print
166 print " --enable-nls"
167 print " add support for gettext localization"
168 print
169 print " --enable-bdb-in-apr-util"
170 print " configure APR-Util to use Berkeley DB"
171 print
172 print " --enable-ml"
173 print " enable use of ML assembler with zlib"
174 print
175 print " --disable-shared"
176 print " only build static libraries"
177 print
178 print " --vsnet-version=VER"
179 print " generate for VS.NET version VER (2002, 2003, 2005 or 2008)"
180 print " [only valid in combination with '-t vcproj']"
181 sys.exit(0)
184 class Options:
185 def __init__(self):
186 self.list = []
187 self.dict = {}
189 def add(self, opt, val):
190 if self.dict.has_key(opt):
191 self.list[self.dict[opt]] = (opt, val)
192 else:
193 self.dict[opt] = len(self.list)
194 self.list.append((opt, val))
196 if __name__ == '__main__':
197 try:
198 opts, args = my_getopt(sys.argv[1:], 'st:',
199 ['debug',
200 'release',
201 'reload',
202 'assume-shared-libs',
203 'with-apr=',
204 'with-apr-util=',
205 'with-apr-iconv=',
206 'with-berkeley-db=',
207 'with-neon=',
208 'without-neon',
209 'with-serf=',
210 'with-httpd=',
211 'with-libintl=',
212 'with-openssl=',
213 'with-zlib=',
214 'with-junit=',
215 'with-swig=',
216 'with-sasl=',
217 'enable-pool-debug',
218 'enable-purify',
219 'enable-quantify',
220 'enable-nls',
221 'enable-bdb-in-apr-util',
222 'enable-ml',
223 'disable-shared',
224 'installed-libs=',
225 'vsnet-version=',
227 if len(args) > 1:
228 _usage_exit()
229 except getopt.GetoptError:
230 _usage_exit()
232 conf = 'build.conf'
233 skip = 0
234 gentype = 'make'
235 rest = Options()
237 if args:
238 conf = args[0]
240 for opt, val in opts:
241 if opt == '-s':
242 skip = 1
243 elif opt == '-t':
244 gentype = val
245 elif opt == '--reload':
246 prev_conf = ConfigParser.ConfigParser()
247 prev_conf.read('gen-make.opts')
248 for opt, val in prev_conf.items('options'):
249 if opt != '--debug':
250 rest.add(opt, val)
251 del prev_conf
252 else:
253 rest.add(opt, val)
254 if opt == '--with-httpd':
255 rest.add('--with-apr', os.path.join(val, 'srclib', 'apr'))
256 rest.add('--with-apr-util', os.path.join(val, 'srclib', 'apr-util'))
257 rest.add('--with-apr-iconv', os.path.join(val, 'srclib', 'apr-iconv'))
259 # Remember all options so that --reload and other scripts can use them
260 opt_conf = open('gen-make.opts', 'w')
261 opt_conf.write('[options]\n')
262 for opt, val in rest.list:
263 opt_conf.write(opt + ' = ' + val + '\n')
264 opt_conf.close()
266 if gentype not in gen_modules.keys():
267 _usage_exit()
269 main(conf, gentype, skip_depends=skip, other_options=rest.list)
272 ### End of file.