4 # Licensed to the Apache Software Foundation (ASF) under one
5 # or more contributor license agreements. See the NOTICE file
6 # distributed with this work for additional information
7 # regarding copyright ownership. The ASF licenses this file
8 # to you under the Apache License, Version 2.0 (the
9 # "License"); you may not use this file except in compliance
10 # with the License. You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing,
15 # software distributed under the License is distributed on an
16 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 # KIND, either express or implied. See the License for the
18 # specific language governing permissions and limitations
23 # gen-make.py -- generate makefiles for building Subversion
31 my_getopt = getopt.gnu_getopt
32 except AttributeError:
33 my_getopt = getopt.getopt
39 import ConfigParser as configparser
41 # for the generator modules
42 sys.path.insert(0, os.path.join('build', 'generator'))
45 sys.path.insert(1, 'build')
48 'make' : ('gen_make', 'Makefiles for POSIX systems'),
49 'dsp' : ('gen_msvc_dsp', 'MSVC 6.x project files'),
50 'vcproj' : ('gen_vcnet_vcproj', 'VC.Net project files'),
53 def main(fname, gentype, verfname=None,
54 skip_depends=0, other_options=None):
56 verfname = os.path.join('subversion', 'include', 'svn_version.h')
58 gen_module = __import__(gen_modules[gentype][0])
60 generator = gen_module.Generator(fname, verfname, other_options)
63 generator.compute_hdr_deps()
66 generator.write_sqlite_headers()
68 if ('--debug', '') in other_options:
69 for dep_type, target_dict in generator.graph.deps.items():
70 sorted_targets = list(target_dict.keys()); sorted_targets.sort()
71 for target in sorted_targets:
72 print(dep_type + ": " + _objinfo(target))
73 for source in target_dict[target]:
74 print(" " + _objinfo(source))
76 gen_keys = sorted(generator.__dict__.keys())
78 value = generator.__dict__[name]
79 if isinstance(value, list):
82 print(" " + _objinfo(i))
87 if isinstance(o, str):
90 t = o.__class__.__name__
91 n = getattr(o, 'name', '-')
92 f = getattr(o, 'filename', '-')
93 return "%s: %s %s" % (t,n,f)
96 def _usage_exit(err=None):
97 "print ERR (if any), print usage, then exit the script"
99 print("ERROR: %s\n" % (err))
100 print("USAGE: gen-make.py [options...] [conf-file]")
101 print(" -s skip dependency generation")
102 print(" --debug print lots of stuff only developers care about")
103 print(" --release release mode")
104 print(" --reload reuse all options from the previous invocation")
105 print(" of the script, except -s, -t, --debug and --reload")
106 print(" -t TYPE use the TYPE generator; can be one of:")
107 items = sorted(gen_modules.items())
108 for name, (module, desc) in items:
109 print(' %-12s %s' % (name, desc))
111 print(" The default generator type is 'make'")
113 print(" Makefile-specific options:")
115 print(" --assume-shared-libs")
116 print(" omit dependencies on libraries, on the assumption that")
117 print(" shared libraries will be built, so that it is unnecessary")
118 print(" to relink executables when the libraries that they depend")
119 print(" on change. This is an option for developers who want to")
120 print(" increase the speed of frequent rebuilds.")
121 print(" *** Do not use unless you understand the consequences. ***")
123 print(" UNIX-specific options:")
125 print(" --installed-libs")
126 print(" Comma-separated list of Subversion libraries to find")
127 print(" pre-installed instead of building (probably only")
128 print(" useful for packagers)")
130 print(" Windows-specific options:")
132 print(" --with-apr=DIR")
133 print(" the APR sources are in DIR")
135 print(" --with-apr-util=DIR")
136 print(" the APR-Util sources are in DIR")
138 print(" --with-apr-iconv=DIR")
139 print(" the APR-Iconv sources are in DIR")
141 print(" --with-berkeley-db=DIR")
142 print(" look for Berkeley DB headers and libs in")
145 print(" --with-serf=DIR")
146 print(" the Serf sources are in DIR")
148 print(" --with-httpd=DIR")
149 print(" the httpd sources and binaries required")
150 print(" for building mod_dav_svn are in DIR;")
151 print(" implies --with-apr{-util, -iconv}, but")
152 print(" you can override them")
154 print(" --with-libintl=DIR")
155 print(" look for GNU libintl headers and libs in DIR;")
156 print(" implies --enable-nls")
158 print(" --with-openssl=DIR")
159 print(" tell serf to look for OpenSSL headers")
160 print(" and libs in DIR")
162 print(" --with-zlib=DIR")
163 print(" tell Subversion to look for ZLib headers and")
164 print(" libs in DIR")
166 print(" --with-jdk=DIR")
167 print(" look for the java development kit here")
169 print(" --with-junit=DIR")
170 print(" look for the junit jar here")
171 print(" junit is for testing the java bindings")
173 print(" --with-swig=DIR")
174 print(" look for the swig program in DIR")
176 print(" --with-sqlite=DIR")
177 print(" look for sqlite in DIR")
179 print(" --with-sasl=DIR")
180 print(" look for the sasl headers and libs in DIR")
182 print(" --enable-pool-debug")
183 print(" turn on APR pool debugging")
185 print(" --enable-purify")
186 print(" add support for Purify instrumentation;")
187 print(" implies --enable-pool-debug")
189 print(" --enable-quantify")
190 print(" add support for Quantify instrumentation")
192 print(" --enable-nls")
193 print(" add support for gettext localization")
195 print(" --enable-bdb-in-apr-util")
196 print(" configure APR-Util to use Berkeley DB")
198 print(" --enable-ml")
199 print(" enable use of ML assembler with zlib")
201 print(" --disable-shared")
202 print(" only build static libraries")
204 print(" --with-static-apr")
205 print(" Use static apr and apr-util")
207 print(" --with-static-openssl")
208 print(" Use static openssl")
210 print(" --vsnet-version=VER")
211 print(" generate for VS.NET version VER (2002, 2003, 2005, 2008, 2010 or 2012)")
212 print(" [only valid in combination with '-t vcproj']")
214 print(" --with-apr_memcache=DIR")
215 print(" the apr_memcache sources are in DIR")
224 def add(self, opt, val):
226 self.list[self.dict[opt]] = (opt, val)
228 self.dict[opt] = len(self.list)
229 self.list.append((opt, val))
231 if __name__ == '__main__':
233 opts, args = my_getopt(sys.argv[1:], 'st:',
237 'assume-shared-libs',
252 'with-apr_memcache=',
254 'with-static-openssl',
259 'enable-bdb-in-apr-util',
265 # Keep distributions that help by adding a path
266 # working. On unix this would be filtered by
267 # configure, but on Windows gen-make.py is used
273 _usage_exit("Too many arguments")
274 except getopt.GetoptError, e:
285 # First merge options with previously saved to gen-make.opts if --reload
287 for opt, val in opts:
288 if opt == '--reload':
289 prev_conf = configparser.ConfigParser()
290 prev_conf.read('gen-make.opts')
291 for opt, val in prev_conf.items('options'):
295 elif opt == '--with-neon' or opt == '--without-neon':
296 # Provide a warning that we ignored these arguments
297 print("Ignoring no longer supported argument '%s'" % opt)
302 for opt, val in rest.list:
308 if opt == '--with-httpd':
309 rest.add('--with-apr', os.path.join(val, 'srclib', 'apr'))
310 rest.add('--with-apr-util', os.path.join(val, 'srclib', 'apr-util'))
311 rest.add('--with-apr-iconv', os.path.join(val, 'srclib', 'apr-iconv'))
313 # Remember all options so that --reload and other scripts can use them
314 opt_conf = open('gen-make.opts', 'w')
315 opt_conf.write('[options]\n')
316 for opt, val in rest.list:
317 opt_conf.write(opt + ' = ' + val + '\n')
320 if gentype not in gen_modules.keys():
321 _usage_exit("Unknown module type '%s'" % (gentype))
323 main(conf, gentype, skip_depends=skip, other_options=rest.list)