Fix compiler warning due to missing function prototype.
[svn.git] / doc / tools / bin / find-xsl.py
blobcaba8a0c66035c71e94ccea43ec8c6065a31c135
1 #!/usr/bin/env python
3 import sys
4 import os
5 import glob
7 #######################################################
8 candidate_xsldirs = (
9 # Fedora
10 '/usr/share/sgml/docbook/xsl-stylesheets',
11 # Cygwin
12 '/usr/share/docbook-xsl',
13 # Debian
14 '/usr/share/xml/docbook/stylesheet/nwalsh',
15 # SUSE
16 '/usr/share/xml/docbook/stylesheet/nwalsh/current',
17 # FreeBSD
18 '/usr/local/share/xsl/docbook',
19 # Gentoo
20 '/usr/share/sgml/docbook/xsl-stylesheets-*',
21 # Please add your OS's location here if not listed!
23 #######################################################
25 tools_bin_dir = os.path.dirname(sys.argv[0])
26 xsl_dir = os.path.join(tools_bin_dir, '..', 'xsl')
28 if os.path.exists(xsl_dir):
29 print "XSL directory %s already exists" % (xsl_dir,)
30 sys.exit(0)
32 for i in candidate_xsldirs:
33 globs = glob.glob(i)
34 # Crude method of preferring the highest version, when multiple exist
35 globs.sort()
36 globs.reverse()
37 for j in globs:
38 if os.path.exists(os.path.join(j, 'html', 'docbook.xsl')):
39 os.symlink(j, xsl_dir)
40 print "Found and linked %s" % (j,)
41 sys.exit(0)
43 sys.stderr.write('ERROR: Failed to find a DocBook XSL directory\n')
44 sys.exit(1)