chiark / gitweb /
core: if we cannot JOB_ISOLATE the default target JOB_REPLACE it instead
[elogind.git] / make-man-rules.py
index b88b43a..5415984 100644 (file)
@@ -21,6 +21,7 @@ from __future__ import print_function
 import xml.etree.ElementTree as tree
 import collections
 import sys
+import os
 
 SECTION = '''\
 MANPAGES += \\
@@ -40,10 +41,16 @@ endif
 
 HEADER = '''\
 # Do not edit. Generated by make-man-rules.py.
-# Regenerate with 'make update-man-list'.
+# Regenerate with 'make all update-man-list'.
 
 '''
 
+CLEANFILES = '''\
+
+CLEANFILES += \\
+       {cleanfiles}
+'''
+
 def man(page, number):
     return 'man/{}.{}'.format(page, number)
 
@@ -76,7 +83,7 @@ def create_rules(*xml_files):
 def mjoin(files):
     return ' \\\n\t'.join(sorted(files) or '#')
 
-def make_makefile(rules):
+def make_makefile(rules, cleanfiles):
     return HEADER + '\n'.join(
         (CONDITIONAL if conditional else SECTION).format(
             manpages=mjoin(set(rulegroup.values())),
@@ -85,8 +92,13 @@ def make_makefile(rules):
                             for k,v in sorted(rulegroup.items())
                             if k != v),
             conditional=conditional)
-        for conditional,rulegroup in sorted(rules.items()))
+        for conditional,rulegroup in sorted(rules.items())) + \
+        CLEANFILES.format(cleanfiles=mjoin(cleanfiles))
 
 if __name__ == '__main__':
-    rules = create_rules(*sys.argv[1:])
-    print(make_makefile(rules), end='')
+    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='')