Index: app/TODO
===================================================================
--- app/TODO	(revision 20b4e44e7537762f6aceb72b039f6e8f8a50e201)
+++ app/TODO	(revision 389de9abcbd0bbec63c04912b2d253b58dc5145c)
@@ -8,13 +8,13 @@
 * mar nie obsluguje plikow konfiguracyjnych [JW]
 
-* compiledic - plik tymczasowe [PK]
+* DONE compiledic - plik tymczasowe [PK]
 
 * ser i grp - parametr tags (zeby bral wskazany program tag2re) [TO]
 
-* lista zaleznosci dla komend system w perlu [PK]
+* DONE lista zaleznosci dla komend system w perlu [PK]
 
 * polaczyc sen'y [TO]
 
-* poprawic utt_make_conf (wykrywanie slownikow) [PK]
+* DONE poprawic utt_make_conf (wykrywanie slownikow) [PK]
 
 * generowanie i sprawdzanie zaleznosci dla tarballa [PK]
Index: app/dist/common/utt_make_config.pl
===================================================================
--- app/dist/common/utt_make_config.pl	(revision d593c5e768abb663835cfc216a133cf5ce86c8c6)
+++ app/dist/common/utt_make_config.pl	(revision 389de9abcbd0bbec63c04912b2d253b58dc5145c)
@@ -12,4 +12,6 @@
 
 prepareUttUsrHome($usr_home);
+conf_utt(catfile($usr_home, 'utt.conf'), $sys_home);
+
 conf_cor(catfile($usr_home, 'cor.conf'), $sys_home);
 conf_grp(catfile($usr_home, 'grp.conf'), $sys_home);
@@ -17,5 +19,4 @@
 conf_lem(catfile($usr_home, 'lem.conf'), $sys_home);
 conf_ser(catfile($usr_home, 'ser.conf'), $sys_home);
-conf_utt(catfile($usr_home, 'utt.conf'), $sys_home);
 
 print "UTT user configuration created in $usr_home\n";
@@ -27,15 +28,17 @@
     my $dir = shift;
 
-	if(-d $dir) {
-		print "Old configuration will be deleted!\n";
-		my $cnt = unlink <$dir/*>;
-		print "$cnt files deleted.\n";
+    print "Preparing user configuration.\n";
+
+    if(-d $dir) {
+	print "Old configuration detected. ";
+	my $cnt = unlink <$dir/*>;
+	print "($cnt files deleted)\n";
+    }
+    else {
+	print "Creating directory $dir\n";
+	if(1 != mkdir $dir) {
+	    die "Unable to create UTT user configuration!\n";
 	}
-	else {
-		print "Creating directory $dir\n";
-		if(1 != mkdir $dir) {
-		  die "Unable to create UTT user configuration!\n";
-		}
-	}
+    }
 }
 
@@ -114,11 +117,38 @@
 	my $utt_file = shift;
 	my $utthome = shift;
+
+	my $lang = getUserLanguage(abs_path(catdir($utthome, "share/utt")));
+
   open(FILE, ">$utt_file");
 
   print FILE makeConfigHeader();
-  print FILE "# user locale\n";
-  print FILE "language=", findLocale(), "\n";
+  print FILE "# user locale (dictionary)\n";
+  print FILE "language=", $lang, "\n";
 
   close FILE;
+}
+
+sub getUserLanguage() {
+    my $dict_dir = shift;
+
+    print "Setup dictionaries.\n";
+    
+    opendir(DIR, $dict_dir) || die "Install dictionary first!\n";
+    @files = grep(/[^\.{1,2}]/ && -d "$dict_dir/$_", readdir(DIR));
+    closedir DIR;
+    my $cnt = scalar @files;
+    print "$cnt dictionary(ies) found.\n";
+    if(0 == $cnt) {
+	die("Install dictionary first!\n");
+    }
+
+    foreach my $file (@files) {
+	print "Do you select dictionary $file [yes/no]? ";
+	my $ans = <STDIN>;
+	if($ans =~ /y(es)?/i) {
+	    return $file;
+	}
+    }
+    die "No dictionary selected - setup failed!\n";
 }
 
Index: app/src/compiledic/compiledic
===================================================================
--- app/src/compiledic/compiledic	(revision 20b4e44e7537762f6aceb72b039f6e8f8a50e201)
+++ app/src/compiledic/compiledic	(revision 389de9abcbd0bbec63c04912b2d253b58dc5145c)
@@ -11,4 +11,5 @@
 use File::Basename;
 use File::Temp;
+use File::Copy;
 use Getopt::Long;
 
@@ -51,27 +52,28 @@
 `lexmakelab $symfilenoext`;
 
-# Analiza pliku s³ownika
+# Tworzymy katalog tymczasowy, gdzie wszystko bedzie umieszczane.
+$tmp_root = tempdir( CLEANUP => 1 );
 
-print "preparing file...........................................";
 
-`sed -r "s/([[:punct:]])/\[\\1\]/g" < $file > temp1`;
+# Analiza pliku slownika
 
-`cp temp1 temp2`;
+print "preparing file...........................................\n";
+print "... sed section .....\n";
+(undef, my $file_sed) = File::Temp::tempfile( DIR => $tmp_root, SUFFIX => ".sed" );
+`sed -r "s/([[:punct:]])/\[\\1\]/g" < $file > $file_sed`;
 
 print "OK\n";
 
-#dzielimy plik na wiele czê¶ci, uruchamiamy lexcomplex dla ka¿dej
-#czê¶ci osobno, nastêpnie ³±czymy to za pomoc± programu fsmunion
+#dzielimy plik na wiele czesci, uruchamiamy lexcomplex dla kazdej
+#czesci osobno, nastepnie laczymy to za pomoca programu fsmunion
 
-#print "Dzielê s³ownik na mniejsze czê¶ci...";
+#print "Dziele slownik na mniejsze czesci...";
 
-open(IN, "./temp2");
+open(IN, $file_sed);
 
 $lineCount = 0;
 $fileCount = 0;
 
-`mkdir LemTEMP`;
-
-open(FILE, ">LemTEMP/slo_0");
+open(FILE, ">$tmp_root/slo_$fileCount");
 
 while (<IN>) {
@@ -82,6 +84,6 @@
 
 	close(FILE);
-#	print "Tworzê nowy plik tymczasowy: slo_".$fileCount."\n";
-	open(FILE, ">LemTEMP/slo_".$fileCount);
+#	print "Tworze nowy plik tymczasowy: slo_".$fileCount."\n";
+	open(FILE, ">$tmp_root/slo_".$fileCount);
     }
 
@@ -107,7 +109,5 @@
     $files++;
 
-    $command = "lexcomplex -l $labfile -S $sclfile < LemTEMP/slo_".$i." > LemTEMP/slownik_".$i.".fsm";
-
-    `$command`;
+    `lexcomplex -l $labfile -S $sclfile < $tmp_root/slo_$i > $tmp_root/slownik_$i.fsm`;
 
 }
@@ -120,5 +120,5 @@
 print "OK\n";
 
-`rm LemTEMP/slo_*`;
+unlink <$tmp_root/slo_*>;
 
 print "building final automaton";
@@ -130,5 +130,5 @@
 $dots=0;
 
-`cp LemTEMP/slownik_0.fsm slownik1.fsm`;
+copy("$tmp_root/slownik_0.fsm", "$tmp_root/slownik1.fsm");
 
 for ($i=1; $i<=$filecount; $i++) {
@@ -141,9 +141,7 @@
     $files++;
 
-    $command = "fsmunion LemTEMP/slownik_".$i." slownik1.fsm > slownik2.fsm";
+    `fsmunion $tmp_root/slownik_$i slownik1.fsm > $tmp_file/slownik2.fsm`;
 
-    `$command`;
-
-    `mv slownik2.fsm slownik1.fsm`;
+    move("$tmp_root/slownik2.fsm", "$tmp_root/slownik1.fsm") || die "Unable to move $tmp_root/slownik2.fsm!\n";
 }
 
@@ -154,5 +152,5 @@
 }
 
-`fsmunion LemTEMP/* > slownik1.fsm`;
+`fsmunion $tmp_root/* > $tmp_root/slownik1.fsm`;
 
 print "OK\n";
@@ -160,7 +158,7 @@
 print "removing epsilon-transitions.............................";
 
-`fsmrmepsilon slownik1.fsm > slownik2.fsm`;
+`fsmrmepsilon $tmp_root/slownik1.fsm > $tmp_root/slownik2.fsm`;
 
-`rm slownik1.fsm`;
+unlink ("$tmp_root/slownik1.fsm");
 
 print "OK\n";
@@ -168,7 +166,7 @@
 print "determinizing automaton..................................";
 
-`fsmdeterminize slownik2.fsm > slownik1.fsm`;
+`fsmdeterminize $tmp_root/slownik2.fsm > $tmp_root/slownik1.fsm`;
 
-`rm slownik2.fsm`;
+unlink ("$tmp_root/slownik2.fsm");
 
 print "OK\n";
@@ -176,5 +174,5 @@
 print "minimizing automaton.....................................";
 
-`fsmminimize slownik1.fsm > slownik.fsm`;
+`fsmminimize $tmp_root/slownik1.fsm > $tmp_root/slownik.fsm`;
 
 #`rm slownik1.fsm`;
@@ -184,9 +182,9 @@
 print "converting fsm format to bin.............................";
 
-`fsmprint -i $labfile slownik.fsm > slownik.txt`;
+`fsmprint -i $labfile $tmp_root/slownik.fsm > $tmp_root/slownik.txt`;
 
-`fsm2aut slownik.txt > slownik.aut`;
+`fsm2aut $tmp_root/slownik.txt > $tmp_root/slownik.aut`;
 
-`aut2fsa < slownik.aut > $filenameprefix.bin`;
+`aut2fsa < $tmp_root/slownik.aut > $filenameprefix.bin`;
 
 print "OK\n";
@@ -194,11 +192,6 @@
 print "removing temporary files.................................";
 
-`rm LemTEMP/*`;
-`rmdir LemTEMP`;
-`rm temp2`;
-`rm slownik.fsm`;
-`rm slownik.txt`;
-`rm slownik.aut`;
-`rm labels.*`;
+unlink <$tmp_root/*>;
+unlink ($tmp_root);
 
 print "OK\n";
Index: app/src/ser/ser
===================================================================
--- app/src/ser/ser	(revision 20b4e44e7537762f6aceb72b039f6e8f8a50e201)
+++ app/src/ser/ser	(revision 389de9abcbd0bbec63c04912b2d253b58dc5145c)
@@ -156,9 +156,8 @@
 
 
-system "m4 \"--define=PATTERN=$flexpattern\" \"--define=DEFAULTACTION=$defaultaction\" $flextemplate > $tmpfile_l";
+`m4 "--define=PATTERN=$flexpattern" "--define=DEFAULTACTION=$defaultaction" $flextemplate > $tmpfile_l`;
 
 if($flex)
 {
-	#system "cat $tmpfile_l";
 	if(open(FLEX, $tmpfile_l)) {
 		while(<FLEX>) {
@@ -173,11 +172,9 @@
 }
 
-system "flex -o$tmpfile_c $tmpfile_l";
-system "cc -O3 -o $tmpfile_x $tmpfile_c -lfl";
-system "$tmpfile_x";
+`flex -o$tmpfile_c $tmpfile_l`;
+`cc -O3 -o $tmpfile_x $tmpfile_c -lfl`;
+`$tmpfile_x`;
 
-#system "rm -f $tmpfile_l $tmpfile_c $tmpfile_x";
 unlink $tmpfile_l;
 unlink $tmpfile_c;
 unlink $tmpfile_x;
-
