Index: app/src/ser/ser
===================================================================
--- app/src/ser/ser	(revision 25ae32e4c2354e0ed6756bbe1de83f39cd814652)
+++ app/src/ser/ser	(revision 754d2a3af45fbb9ef2f650ef3c85a6cce1d960f9)
@@ -7,7 +7,10 @@
 use strict;
 use Getopt::Long;
+use File::Temp;
 
-my $SHARE_DIR="/usr/share/utt";
-my $USER_DIR="$ENV{HOME}/.utt/share";
+my $LIB_DIR="/usr/local/lib/utt";
+
+my $systemconfigfile='/usr/local/etc/utt/ser.conf';
+my $userconfigfile="$ENV{'HOME'}/.utt/ser.conf";
 
 #use lib "$ENV{HOME}/.utt/lib/perl";
@@ -25,10 +28,7 @@
 my $morfield='lem';
 
-my $configfile1="../../conf/ser.conf";
-my $configfile2="../conf/ser.conf";
-
 #read configuration files###########################
 my $file;
-foreach $file ($configfile1, $configfile2){
+foreach $file ($systemconfigfile, $userconfigfile){
   if(open(CONFIG, $file)){
   	while (<CONFIG>) {
@@ -51,5 +51,5 @@
 			$no_markers=1;
     		}
-    		elsif($name eq "define"){
+    		elsif($name eq "macros"){
 			$macros=$value;
     		}
@@ -74,5 +74,5 @@
 	   "only-matching|m" => \$only_matching,
            "no-markers|M" => \$no_markers,
-	   "define=s" => \$macros,
+	   "macros=s" => \$macros,
 	   "flex-template=s" => \$flextemplate,
 	   "flex" => \$flex,
@@ -88,5 +88,5 @@
    --pattern=PATTERN -e	PATTERN   Search pattern.
    --morph=STRING                 Field containing morphological information (default 'lem').
-   --define=FILE                  Read macrodefinitions from FILE.
+   --macros=FILE                  Read macrodefinitions from FILE.
    --flex-template=FILE           Read flex code template from FILE.
    --only-matching -m		  Print only fragments matching PATTERN.
@@ -102,11 +102,9 @@
 die("$0: flex template file not found") unless
     $flextemplate or
-    -e "$USER_DIR/ser.l.template" and $flextemplate="$USER_DIR/ser.l.template" or
-    -e "$SHARE_DIR/ser.l.template" and $flextemplate="$SHARE_DIR/ser.l.template";
+    -e "$LIB_DIR/ser.l.template" and $flextemplate="$LIB_DIR/ser.l.template";
 
 die("$0: macro file not found") unless
     $macros or
-    -e "$USER_DIR/terms.m4" and $macros="$USER_DIR/terms.m4" or
-    -e "$SHARE_DIR/terms.m4" and $macros="$SHARE_DIR/terms.m4";
+    -e "$LIB_DIR/terms.m4" and $macros="$LIB_DIR/terms.m4";
 
 
@@ -120,4 +118,5 @@
 # discarding spaces
 $pattern =~ s/\s+/\\`'/g; #` 
+
 
 my $flexpattern = `echo \"$pattern\" | m4 --define=ENDOFSEGMENT=\\\\n --define=MORFIELD=$morfield $macros - 2>/dev/null`;
@@ -153,16 +152,21 @@
 # docelowo posrednie pliki powinny byc w jakims tempie !!!
 
-system "m4 \"--define=PATTERN=$flexpattern\" \"--define=DEFAULTACTION=$defaultaction\" $flextemplate > $USER_DIR/ser.l";
+(undef, my $tmpfile_l) = File::Temp::tempfile(SUFFIX=>'.l');
+(undef, my $tmpfile_c) = File::Temp::tempfile(SUFFIX=>'.c');
+(undef, my $tmpfile_x) = File::Temp::tempfile();
+
+
+system "m4 \"--define=PATTERN=$flexpattern\" \"--define=DEFAULTACTION=$defaultaction\" $flextemplate > $tmpfile_l";
 
 if($flex)
 {
-    system "cat $USER_DIR/ser.l";
+    system "cat $tmpfile_l";
     exit 0;
 }
 
-system "flex -o$USER_DIR/ser.c $USER_DIR/ser.l";
-system "cc -O3 -o $USER_DIR/ser.executable $USER_DIR/ser.c -lfl";
-system "$USER_DIR/ser.executable";
+system "flex -o$tmpfile_c $tmpfile_l";
+system "cc -O3 -o $tmpfile_x $tmpfile_c -lfl";
+system "$tmpfile_x";
 
-system "rm -f $USER_DIR/ser.{l,c,executable}";
+system "rm -f $tmpfile_l $tmpfile_c $tmpfile_x";
 
