]> git.lyx.org Git - lyx.git/blobdiff - lib/configure.py
* lib/lyx2lyx/lyx_1_4.py:
[lyx.git] / lib / configure.py
index f841da37983bb85c1da511bec64a96e1033e0e44..7d9c3b91c812c6cf54136e0bb09d5c89affb31a3 100644 (file)
@@ -183,12 +183,21 @@ def checkViewer(description, progs, rc_entry = [], path = []):
     return checkProg(description, progs, rc_entry, path, not_found = 'auto')
 
 
-def checkLatex():
-    ''' Check latex, return lyx_check_config '''
+def checkDTLtools():
+    ''' Check whether DTL tools are available (Windows only) '''
     # Find programs! Returned path is not used now
     if ((os.name == 'nt' or sys.platform == 'cygwin') and
             checkProg('DVI to DTL converter', ['dv2dt']) != ['', ''] and
             checkProg('DTL to DVI converter', ['dt2dv']) != ['', '']):
+        dtl_tools = True
+    else:
+        dtl_tools = False
+    return dtl_tools
+
+
+def checkLatex(dtl_tools):
+    ''' Check latex, return lyx_check_config '''
+    if dtl_tools:
         # Windows only: DraftDVI
         converter_entry = r'''\converter latex      dvi2       "%%"    "latex"
 \converter dvi2       dvi        "python -tt $$s/scripts/clean_dvi.py $$i $$o" ""'''
@@ -217,7 +226,7 @@ def checkLatex():
     return ''
 
 
-def checkFormatEntries():  
+def checkFormatEntries(dtl_tools):  
     ''' Check all formats (\Format entries) '''
     checkViewer('a Tgif viewer and editor', ['tgif'],
         rc_entry = [r'\Format tgif       obj     Tgif                   "" "%%"        "%%"    "vector"'])
@@ -254,6 +263,7 @@ def checkFormatEntries():
 \Format docbook    sgml    DocBook                B  ""        "%%"    "document"
 \Format docbook-xml xml   "Docbook (XML)"         "" ""        "%%"    "document"
 \Format literate   nw      NoWeb                  N  ""        "%%"    "document"
+\Format lilypond   ly     "LilyPond music"        "" ""        "%%"    "vector"
 \Format latex      tex    "LaTeX (plain)"         L  ""        "%%"    "document"
 \Format linuxdoc   sgml    LinuxDoc               x  ""        "%%"    "document"
 \Format pdflatex   tex    "LaTeX (pdflatex)"      "" ""        "%%"    "document"
@@ -277,9 +287,7 @@ def checkFormatEntries():
     #
     checkViewer('a DVI previewer', ['xdvi', 'kdvi'],
         rc_entry = [r'\Format dvi        dvi     DVI                    D  "%%"        ""      "document,vector"'])
-    if ((os.name == 'nt' or sys.platform == 'cygwin') and
-            checkProg('DVI to DTL converter', ['dv2dt']) != ['', ''] and
-            checkProg('DTL to DVI converter', ['dt2dv']) != ['', '']):
+    if dtl_tools:
         # Windows only: DraftDVI
         addToRC(r'\Format dvi2       dvi     DraftDVI               "" ""      "document,vector"')
     #
@@ -408,6 +416,24 @@ def checkConverterEntries():
         'latex2html -no_subdir -split 0 -show_section_numbers $$i', 'hevea -s $$i'],
         rc_entry = [ r'\converter latex      html       "%%"   "originaldir,needaux"' ])
     #
+    path, lilypond = checkProg('a LilyPond -> EPS/PDF/PNG converter', ['lilypond'])
+    if (lilypond != ''):
+        version_string = cmdOutput("lilypond --version")
+        match = re.match('GNU LilyPond (\S+)', version_string)
+        if match:
+            version_number = match.groups()[0]
+            version = version_number.split('.')
+            if int(version[0]) > 2 or (len(version) > 1 and int(version[0]) == 2 and int(version[1]) >= 6):
+                addToRC(r'''\converter lilypond   eps        "lilypond -b eps --ps $$i"        ""
+\converter lilypond   png        "lilypond -b eps --png $$i"   ""''')
+                if int(version[0]) > 2 or (len(version) > 1 and int(version[0]) == 2 and int(version[1]) >= 9):
+                    addToRC(r'\converter lilypond   pdf        "lilypond -b eps --pdf $$i"     ""')
+                print '+  found LilyPond version %s.' % version_number
+            else:
+                print '+  found LilyPond, but version %s is too old.' % version_number
+        else:
+            print '+  found LilyPond, but could not extract version number.'
+    #
     # FIXME: no rc_entry? comment it out
     # checkProg('Image converter', ['convert $$i $$o'])
     #
@@ -737,6 +763,7 @@ Options:
     setEnviron()
     createDirectories()
     windows_style_tex_paths = checkTeXPaths()
+    dtl_tools = checkDTLtools()
     ## Write the first part of outfile
     writeToFile(outfile, '''# This file has been automatically generated by LyX' lib/configure.py
 # script. It contains default settings that have been determined by
@@ -746,8 +773,8 @@ Options:
 # override the values given here.
 ''')
     # check latex
-    LATEX = checkLatex()
-    checkFormatEntries()
+    LATEX = checkLatex(dtl_tools)
+    checkFormatEntries(dtl_tools)
     checkConverterEntries()
     (chk_linuxdoc, bool_linuxdoc, linuxdoc_cmd) = checkLinuxDoc()
     (chk_docbook, bool_docbook, docbook_cmd) = checkDocBook()