]> git.lyx.org Git - lyx.git/blobdiff - lib/doc/depend.py
merge booktabs branch
[lyx.git] / lib / doc / depend.py
index 8fdb70c3de718381492f071c666b920752e68f5c..50df48a9056dee010ec9539b5dcb9882be3ff419 100644 (file)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -tt
 # -*- coding: iso-8859-1 -*-
 # This file is part of the LyX Documentation
 # Copyright (C) 2004 José Matos <jamatos@lyx.org>
@@ -31,12 +31,14 @@ from glob import glob
 possible_documents = ("Intro", "FAQ", "Tutorial", "UserGuide", "Extended", "Customization")
 lang_pattern = re.compile('^([a-z]{2})_')
 
-def documents(prefix):
+def documents(srcdir, prefix):
     result = []
     for file in possible_documents:
-        fname = prefix + file + '.lyx'
+        fname = srcdir + '/' + prefix + file + '.lyx'
         if os.access(fname, os.F_OK):
             result.append(fname)
+        else:
+            result.append(srcdir + '/' + file + '.lyx')
     return result
 
 
@@ -46,11 +48,13 @@ def main(argv):
 #
 # First come the rules for each xx_TOC.lyx file. Then comes the
 # TOCs target, which prints all the TOC files.
-""" % argv[0]
+""" % os.path.basename(argv[0])
 
     # What are the languages available? And its documents?
     languages = {}
-    for file in glob('*'):
+    srcdir = os.path.dirname(argv[0])
+    for file in glob(srcdir + '/*'):
+        file = os.path.basename(file)
         lang = lang_pattern.match(file)
         if lang:
             if lang.group(1) not in languages:
@@ -63,8 +67,8 @@ def main(argv):
     langs.sort()
 
     # The default language is english and doesn't need any prefix
-    print 'TOC.lyx:', '.lyx '.join(possible_documents) + '.lyx'
-    print '\tpython doc_toc.py'
+    print 'TOC.lyx: $(srcdir)/' + '.lyx $(srcdir)/'.join(possible_documents) + '.lyx'
+    print '\tPYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py'
     print
     tocs = ['TOC.lyx']
 
@@ -73,15 +77,16 @@ def main(argv):
         toc_name = lang + '_TOC.lyx'
         tocs.append(toc_name)
 
-        languages[lang].remove(toc_name)
+        if toc_name in languages[lang]:
+            languages[lang].remove(toc_name)
+        languages[lang].sort()
 
-        print toc_name + ':', ' '.join(languages[lang])
-        print '\tpython doc_toc.py %s' % lang
+        print toc_name + ': $(srcdir)/' + ' $(srcdir)/'.join(languages[lang])
+        print '\tPYTHONPATH=$(top_builddir)/lib/lyx2lyx python -tt $(srcdir)/doc_toc.py %s' % lang
         print
 
     # Write meta-rule to call all the other rules
-    print 'TOCs:', ' '.join(tocs)
-    print '\t@echo Made TOCs succesfully.'
+    print 'tocfiles =', ' '.join(tocs)
 
 
 if __name__ == "__main__":