Remove no-longer-used svn_*_get_mergeinfo_for_tree APIs.
[svn.git] / gen-make.py
blobdab738337560368c108e0cf7ab464568232803f7
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 " Windows-specific options:"
98 print
99 print " --with-apr=DIR"
100 print " the APR sources are in DIR"
101 print
102 print " --with-apr-util=DIR"
103 print " the APR-Util sources are in DIR"
104 print
105 print " --with-apr-iconv=DIR"
106 print " the APR-Iconv sources are in DIR"
107 print
108 print " --with-berkeley-db=DIR"
109 print " look for Berkeley DB headers and libs in"
110 print " DIR"
111 print
112 print " --with-neon=DIR"
113 print " the Neon sources are in DIR"
114 print
115 print " --without-neon"
116 print " Don't build Neon sources (if present)"
117 print
118 print " --with-serf=DIR"
119 print " the Serf sources are in DIR"
120 print
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"
126 print
127 print " --with-libintl=DIR"
128 print " look for GNU libintl headers and libs in DIR;"
129 print " implies --enable-nls"
130 print
131 print " --with-openssl=DIR"
132 print " tell neon to look for OpenSSL headers"
133 print " and libs in DIR"
134 print
135 print " --with-zlib=DIR"
136 print " tell neon to look for ZLib headers and"
137 print " libs in DIR"
138 print
139 print " --with-junit=DIR"
140 print " look for the junit jar here"
141 print " junit is for testing the java bindings"
142 print
143 print " --with-swig=DIR"
144 print " look for the swig program in DIR"
145 print
146 print " --with-sqlite=DIR"
147 print " look for sqlite in DIR"
148 print
149 print " --with-sasl=DIR"
150 print " look for the sasl headers and libs in DIR"
151 print
152 print " --enable-pool-debug"
153 print " turn on APR pool debugging"
154 print
155 print " --enable-purify"
156 print " add support for Purify instrumentation;"
157 print " implies --enable-pool-debug"
158 print
159 print " --enable-quantify"
160 print " add support for Quantify instrumentation"
161 print
162 print " --enable-nls"
163 print " add support for gettext localization"
164 print
165 print " --enable-bdb-in-apr-util"
166 print " configure APR-Util to use Berkeley DB"
167 print
168 print " --enable-ml"
169 print " enable use of ML assembler with zlib"
170 print
171 print " --disable-shared"
172 print " only build static libraries"
173 print
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']"
177 sys.exit(0)
180 class Options:
181 def __init__(self):
182 self.list = []
183 self.dict = {}
185 def add(self, opt, val):
186 if self.dict.has_key(opt):
187 self.list[self.dict[opt]] = (opt, val)
188 else:
189 self.dict[opt] = len(self.list)
190 self.list.append((opt, val))
192 if __name__ == '__main__':
193 try:
194 opts, args = my_getopt(sys.argv[1:], 'st:',
195 ['debug',
196 'release',
197 'reload',
198 'assume-shared-libs',
199 'with-apr=',
200 'with-apr-util=',
201 'with-apr-iconv=',
202 'with-berkeley-db=',
203 'with-neon=',
204 'without-neon',
205 'with-serf=',
206 'with-httpd=',
207 'with-libintl=',
208 'with-openssl=',
209 'with-zlib=',
210 'with-junit=',
211 'with-swig=',
212 'with-sqlite=',
213 'with-sasl=',
214 'enable-pool-debug',
215 'enable-purify',
216 'enable-quantify',
217 'enable-nls',
218 'enable-bdb-in-apr-util',
219 'enable-ml',
220 'disable-shared',
221 'vsnet-version=',
223 if len(args) > 1:
224 _usage_exit()
225 except getopt.GetoptError:
226 _usage_exit()
228 conf = 'build.conf'
229 skip = 0
230 gentype = 'make'
231 rest = Options()
233 if args:
234 conf = args[0]
236 for opt, val in opts:
237 if opt == '-s':
238 skip = 1
239 elif opt == '-t':
240 gentype = val
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'):
245 if opt != '--debug':
246 rest.add(opt, val)
247 del prev_conf
248 else:
249 rest.add(opt, val)
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')
260 opt_conf.close()
262 if gentype not in gen_modules.keys():
263 _usage_exit()
265 main(conf, gentype, skip_depends=skip, other_options=rest.list)
268 ### End of file.