The attached patch (due to my laziness it is in two parts as I just maintan it 
in this way, apply both in order)
changes scid so it complies to the typical Linux way of organising data files 
(data files are separate from
the binary, all paths in use are set-able by ./configure switches) - but it 
keeps windows behaviour (data files
under binary dir) as it is.

The result: after you run 
   ./configure BINDIR=/usr/local/bin SHAREDIR=/usr/local/share/scid
   make
   make install
the binaries will be installed to /usr/local/bin and books, eco files, 
databases etc
to the given share directory

Of course you can still run
  ./configure BINDIR=$HOME/scid SHAREDIR=$HOME/scid
and install everything in one place.

Details of what is changed:

- Makefile.conf is rewritten, so instead of hardcoded destination directory, 
SHAREDIR configurable
  is used to install all the data files and BINDIR to install binaries and 
scripts

- configure is patched, so it generates tiny bit of TCL (config.tcl.conf -> 
config.tcl), setting all
  the data paths there instead of hardcoding them (on windows it just sets data 
path to scidExeDir)

- TCL code is patched, so instead of generating paths to books or bases 
according to the scid binary
  location, it uses the constants defined in config.tcl

I haven't tested in on windows so it requires taking a look, but I believe that 
there should not be any problems.

Note: I did not touch pocket, maybe there sth similar could be also considered. 
Or maybe not.

Wywalone mnóstwo śmieci

diff --git a/Makefile.conf b/Makefile.conf
--- a/Makefile.conf
+++ b/Makefile.conf
@@ -16,7 +16,6 @@ COMPILE = @COMPILE@
 COMPILE = @COMPILE@
 CC = @CC@
 LINK = @LINK@
-DESTDIR = /usr/local/bin/
 
 # BINDIR: where the Scid programs are copied for "make install".
 #
@@ -229,37 +228,38 @@ toga:
 #   for all users, and put extra files in $SHAREDIR, type "make install".
 #
 install: all
-	install -m 755 -d $(DESTDIR)
-	install -m 755 scid $(SCRIPTS) $(EXECS) $(DESTDIR)
-	install -m 644 -p scid.eco spelling.ssp $(DESTDIR)
-	install -m 755 -d $(DESTDIR)/engines
-	install -m 755 -d $(DESTDIR)/engines/crafty-20.14
-	install ./engines/crafty-20.14/crafty $(DESTDIR)/engines/crafty-20.14/
-	install ./engines/crafty-20.14/book*.bin $(DESTDIR)/engines/crafty-20.14/
-	install -m 755 -d $(DESTDIR)/engines/Phalanx-XXII
-	install ./engines/Phalanx-XXII/phalanx $(DESTDIR)/engines/Phalanx-XXII
-	install -m 755 -d $(DESTDIR)/engines/togaII1.2.1a
-	install ./engines/togaII1.2.1a/src/fruit $(DESTDIR)/engines/togaII1.2.1a/
-	install -m 755 -d $(DESTDIR)/books
-	install -m 666 ./books/* $(DESTDIR)/books/
-	install -m 755 -d $(DESTDIR)/bases
-	install -m 666 ./bases/* $(DESTDIR)/bases/
-	install -m 755 -d $(DESTDIR)/html
-	cp -r ./html/* $(DESTDIR)/html/
-	chmod -R 0777 $(DESTDIR)/html/*
+	install -m 755 -d $(BINDIR)
+	install -m 755 -d $(SHAREDIR)
+	install -m 755 scid $(SCRIPTS) $(EXECS) $(BINDIR)
+	install -m 644 -p scid.eco spelling.ssp $(SHAREDIR)/data/
+	install -m 755 -d $(SHAREDIR)/engines
+	install -m 755 -d $(SHAREDIR)/engines/crafty-20.14
+	install ./engines/crafty-20.14/crafty $(SHAREDIR)/engines/crafty-20.14/
+	install ./engines/crafty-20.14/book*.bin $(SHAREDIR)/engines/crafty-20.14/
+	install -m 755 -d $(SHAREDIR)/engines/Phalanx-XXII
+	install ./engines/Phalanx-XXII/phalanx $(SHAREDIR)/engines/Phalanx-XXII
+	install -m 755 -d $(SHAREDIR)/engines/togaII1.2.1a
+	install ./engines/togaII1.2.1a/src/fruit $(SHAREDIR)/engines/togaII1.2.1a/
+	install -m 755 -d $(SHAREDIR)/books
+	install -m 666 ./books/* $(SHAREDIR)/books/
+	install -m 755 -d $(SHAREDIR)/bases
+	install -m 666 ./bases/* $(SHAREDIR)/bases/
+	install -m 755 -d $(SHAREDIR)/html
+	cp -r ./html/* $(SHAREDIR)/html/
+	chmod -R 0777 $(SHAREDIR)/html/*
 
 uninstall:
-	rm -rf $(DESTDIR)/engines
-	rm -rf $(DESTDIR)/books
-	rm -rf $(DESTDIR)/bases
-	rm -f $(DESTDIR)/scid.eco $(DESTDIR)/spelling.ssp
-	rm -f $(DESTDIR)/scid $(DESTDIR)/sc_addmove $(DESTDIR)/sc_epgn
-	rm -f $(DESTDIR)/sc_spell $(DESTDIR)/sc_eco $(DESTDIR)/sc_import
-	rm -f $(DESTDIR)/sc_remote $(DESTDIR)/sc_tree $(DESTDIR)/scidpgn
-	rm -f $(DESTDIR)/pgnfix $(DESTDIR)/spliteco
-	rm -f $(DESTDIR)/pgnscid $(DESTDIR)/tkscid $(DESTDIR)/tcscid
-	rm -f $(DESTDIR)/scmerge $(DESTDIR)/scidlet
-	rm -rf $(DESTDIR)/html
+	rm -rf $(SHAREDIR)/engines
+	rm -rf $(SHAREDIR)/books
+	rm -rf $(SHAREDIR)/bases
+	rm -f $(SHAREDIR)/data/scid.eco $(SHAREDIR)/data/spelling.ssp
+	rm -f $(BINDIR)/scid $(BINDIR)/sc_addmove $(BINDIR)/sc_epgn
+	rm -f $(BINDIR)/sc_spell $(BINDIR)/sc_eco $(BINDIR)/sc_import
+	rm -f $(BINDIR)/sc_remote $(BINDIR)/sc_tree $(BINDIR)/scidpgn
+	rm -f $(BINDIR)/pgnfix $(BINDIR)/spliteco
+	rm -f $(BINDIR)/pgnscid $(BINDIR)/tkscid $(BINDIR)/tcscid
+	rm -f $(BINDIR)/scmerge $(BINDIR)/scidlet
+	rm -rf $(SHAREDIR)/html
 	
 old-install: all
 	chmod 755 scid $(SCRIPTS) $(EXECS)
Kolejna próba ustawienia config.tcl w sensownym miejscu

diff --git a/Makefile.conf b/Makefile.conf
--- a/Makefile.conf
+++ b/Makefile.conf
@@ -170,6 +170,7 @@ OBJS= @OBJS@
 #
 TCLS= \
   tcl/start.tcl \
+  tcl/config.tcl \
   tcl/bitmaps.tcl \
   tcl/language.tcl \
   tcl/utils.tcl \
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -327,11 +327,12 @@ proc checkZlib {} {
     }
 }
 
-# writeMakefile:
+# writeMakefileAndConf:
 #    Creates the Makefile using Makefile.conf and the configured
 #    settings.
-#
-proc writeMakefile {{type ""}} {
+#    Also creates tcl/config.tcl
+#
+proc writeMakefileAndConf {{type ""}} {
     global var defaultVar
     set default 0
     set success 0
@@ -386,15 +387,52 @@ proc writeMakefile {{type ""}} {
 
     close $from
     close $to
+
+    # Writing tcl/config.tcl
+
+    if {[catch {set from [open "tcl/config.tcl.conf" r]}]} {
+       puts "Error opening file for reading: tcl/config.tcl.conf"
+       exit 1
+    }
+    if {[catch {set to [open "tcl/config.tcl" w]}]} {
+       puts "Error opening file for writing: tcl/config.tcl"
+       exit 1
+    }
+
+    set line [gets $from]
+    while {1} {
+        set line [gets $from]
+        if {[eof $from]} { break }
+        foreach sub [array names var] {
+            set first [string first "@$sub@" $line]
+            if {$first >= 0} {
+                set last [expr $first + [string length $sub] + 1]
+                set pre [string range $line 0 [expr $first - 1]]
+                set post [string range $line [expr $last + 1] end]
+                set line $pre
+                append line $var($sub)
+                append line $post
+            }
+        }
+        if {[string compare "!" [string index $line 0]]} {
+            puts $to $line
+        }
+    }
+
+    close $from
+    close $to
+
+    # Summary info
+
     if {$default} {
-        puts {The default Makefile was written.}
+        puts {The default Makefile and tcl/config.tcl were written.}
     } elseif {$success} {
-        puts {The Makefile configured for your system was written.}
+        puts {The Makefile and tcl/config.tcl configured for your system were written.}
         puts {Now just type "make" to compile Scid.}
     } else {
         puts {Not all settings could be determined!}
-        puts {The default Makefile was written.}
-        puts {You will need to edit it before you can compile Scid.}
+        puts {The default Makefile and tcl/config.tcl were written.}
+        puts {You will need to edit those before you can compile Scid.}
     }
 }
 
@@ -455,7 +493,7 @@ foreach arg $argv {
 }
 
 if {$default} {
-    writeMakefile default
+    writeMakefileAndConf default
     exit 0
 }
 
@@ -470,6 +508,6 @@ puts "    Tcl/Tk version: $tclv"
 puts "    Tcl/Tk version: $tclv"
 puts "    Your operating system is: $tcl_platform(os) $tcl_platform(osVersion)"
 
-writeMakefile
+writeMakefileAndConf
 
 ### End of configure script ###
diff --git a/tcl/config.tcl.conf b/tcl/config.tcl.conf
new file mode 100644
--- /dev/null
+++ b/tcl/config.tcl.conf
@@ -0,0 +1,23 @@
+###################
+# config.tcl: Some embedded configuration for Scid
+
+namespace eval ::config {}
+
+if {$windowsOS} {
+  set scidShareDir $scidExeDir
+} else {
+  set scidShareDir "@SHAREDIR@"
+}
+
+set scidBooksDir [file nativename [file join $scidShareDir "books"]]
+set scidBasesDir [file nativename [file join $scidShareDir "bases"]]
+
+# ecoFile: the ECO file for opening classification. Scid will try to load
+# this first, and if that fails, it will try to load  "scid.eco" in the
+# current directory.
+if {$windowsOS} {
+  set ecoFile [file join $scidDataDir "scid.eco"]
+} else {
+  set ecoFile [file join [file join $scidShareDir "data"] "scid.eco"]
+}
+
diff --git a/tcl/start.tcl b/tcl/start.tcl
--- a/tcl/start.tcl
+++ b/tcl/start.tcl
@@ -94,6 +94,7 @@ foreach ns {
     ::tb ::optable
   ::board ::move
   ::tacgame ::sergame ::opening ::tactics ::uci
+  ::config
 } {
   namespace eval $ns {}
 }
@@ -120,15 +121,6 @@ set scidConfigDir [file nativename [file
 set scidConfigDir [file nativename [file join $scidUserDir "config"]]
 set scidDataDir [file nativename [file join $scidUserDir "data"]]
 set scidLogDir [file nativename [file join $scidUserDir "log"]]
-
-# ecoFile: the ECO file for opening classification. Scid will try to load
-# this first, and if that fails, it will try to load  "scid.eco" in the
-# current directory.
-if {$windowsOS} {
-  set ecoFile [file join $scidDataDir "scid.eco"]
-} else {
-  set ecoFile "/usr/local/share/scid/scid.eco"
-}
 
 # boardSizes: a list of the available board sizes.
 set boardSizes [list 25 30 35 40 45 50 55 60 65 70]
diff --git a/tcl/tools/analysis.tcl b/tcl/tools/analysis.tcl
--- a/tcl/tools/analysis.tcl
+++ b/tcl/tools/analysis.tcl
@@ -660,7 +660,7 @@ proc configAnnotation {} {
   addHorizontalRule $w
   checkbutton $w.cbBook  -text $::tr(UseBook) -variable ::useAnalysisBook
   # load book names
-  set bookPath [file nativename [file join [file dirname [info nameofexecutable]] "books" ]]
+  set bookPath $::scidBooksDir
   ::combobox::combobox $w.comboBooks -editable false -width 12
   set bookList [  lsort -dictionary [ glob -nocomplain -directory $bookPath *.bin ] ]
   foreach file  $bookList {
@@ -725,7 +725,7 @@ proc bookAnnotation { {n 1} } {
   if {$::annotateMode && $::useAnalysisBook} {
     
     set prevbookmoves ""
-    set bn [ file join [file nativename [file join [file dirname [info nameofexecutable]] "books" ]] $::useAnalysisBookName ]
+    set bn [ file join $::scidBooksDir $::useAnalysisBookName ]
     sc_book load $bn $::analysisBookSlot
     
     set bookmoves [sc_book moves $::analysisBookSlot]
diff --git a/tcl/tools/sergame.tcl b/tcl/tools/sergame.tcl
--- a/tcl/tools/sergame.tcl
+++ b/tcl/tools/sergame.tcl
@@ -89,7 +89,7 @@ namespace eval sergame {
     
     # load book names
     checkbutton $w.fbook.cbUseBook -text $::tr(UseBook) -variable ::sergame::useBook
-    set bookPath [file nativename [file join [file dirname [info nameofexecutable]] "books" ]]
+    set bookPath $::scidBooksDir
     ::combobox::combobox $w.fbook.combo -editable false -width 12
     set bookList [ lsort -dictionary [ glob -nocomplain -directory $bookPath *.bin ] ]
     set i 0
diff --git a/tcl/tools/tactics.tcl b/tcl/tools/tactics.tcl
--- a/tcl/tools/tactics.tcl
+++ b/tcl/tools/tactics.tcl
@@ -14,7 +14,7 @@ namespace eval tactics {
   
   set infoEngineLabel ""
   
-  set basePath [file nativename [file join [file dirname [info nameofexecutable]] "bases" ]]
+  set basePath $::scidBasesDir
   set baseList {}
   set solved "problem solved"
   set failed "problem failed"
diff --git a/tcl/windows/book.tcl b/tcl/windows/book.tcl
--- a/tcl/windows/book.tcl
+++ b/tcl/windows/book.tcl
@@ -37,7 +37,7 @@ namespace eval book {
       set ::book::currentTuningBook $name
     }
     
-    set bn [ file join [file nativename [file join [file dirname [info nameofexecutable]] "books" ]] $name ]
+    set bn [ file join $::scidBooksDir $name ]
     sc_book load $bn $slot
   }
   
@@ -88,7 +88,7 @@ namespace eval book {
     
     frame $w.f
     # load book names
-    set bookPath [file nativename [file join [file dirname [info nameofexecutable]] "books" ]]
+    set bookPath $::scidBooksDir
     ::combobox::combobox $w.f.combo -editable false -width 12
     set bookList [  lsort -dictionary [ glob -nocomplain -directory $bookPath *.bin ] ]
     set i 0
@@ -201,7 +201,7 @@ namespace eval book {
     frame $w.fcombo
     frame $w.f
     # load book names
-    set bookPath [file nativename [file join [file dirname [info nameofexecutable]] "books" ]]
+    set bookPath $::scidBooksDir
     ::combobox::combobox $w.fcombo.combo -editable false -width 0
     pack $w.fcombo.combo -expand yes -fill x
     set bookList [  lsort -dictionary [ glob -nocomplain -directory $bookPath *.bin ] ]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Scid-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scid-users

Reply via email to