# along with systemd; If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
-import xml.etree.ElementTree as tree
import collections
import sys
-import os
+from xml_helper import *
SECTION = '''\
MANPAGES += \\
'''
-CLEANFILES = '''\
-
-CLEANFILES += \\
- {cleanfiles}
-'''
-
HTML_ALIAS_RULE = '''\
{}.html: {}.html
$(html-alias)
return 'man/{}.{}'.format(page, number)
def add_rules(rules, name):
- xml = tree.parse(name)
+ xml = xml_parse(name)
# print('parsing {}'.format(name), file=sys.stderr)
conditional = xml.getroot().get('conditional') or ''
rulegroup = rules[conditional]
def mjoin(files):
return ' \\\n\t'.join(sorted(files) or '#')
-def make_makefile(rules, cleanfiles):
+def make_makefile(rules):
return HEADER + '\n'.join(
(CONDITIONAL if conditional else SECTION).format(
manpages=mjoin(set(rulegroup.values())),
for k,v in sorted(rulegroup.items())
if k != v),
conditional=conditional)
- for conditional,rulegroup in sorted(rules.items())) + \
- CLEANFILES.format(cleanfiles=mjoin(cleanfiles))
+ for conditional,rulegroup in sorted(rules.items()))
if __name__ == '__main__':
- sources = set(sys.argv[1:])
- basenames = [os.path.basename(source) for source in sources]
- spares = set([source for source in sources
- if os.path.basename(source) + '.in' in basenames])
- rules = create_rules(*(sources - spares))
- print(make_makefile(rules, spares), end='')
+ rules = create_rules(*sys.argv[1:])
+ print(make_makefile(rules), end='')