diff --git a/buildDarwin.sh b/buildDarwin.sh
index 0cb687a..6435657 100755
--- a/buildDarwin.sh
+++ b/buildDarwin.sh
@@ -1,57 +1,68 @@
 #!/bin/bash
+#  Kompiluje bibliotekę i buduje paczki dystrybucyjne zawierające
+#  Morfeusza i słowniki SGJP i Polimorf
+#
+# Założenia:
+# • kod źródłowy Morfeusza jest w MORFEUSZ_SRC
+# • słowniki są już skompilowane w katalogu DICT_DIR
+# • kompilacja odbędzie się w katalogu BUILD_DIR (który zostanie skasowany i utworzony)
+# • wyniki zostaną umieszczone w TARGET_DIR
 
-set -e -o pipefail
+#set -ex -o pipefail
+set -x
 
-if [ "$#" -ne 4 ]; then
-    echo "Must provide exactly 4 arguments: <CROSSMORFEUSZ_ROOT> <INPUT_DICTIONARIES> <DEFAULT_DICT_NAME> <DICT_VERSION>"
+if [ "$#" -ne 3 ]; then
+    echo "Expected arguments: ‹DICT_NAME› ‹DICT_VERSION› ‹64/32›"
     exit 1
 fi
 
-export CROSSMORFEUSZ_ROOT="$1"
-export INPUT_DICTIONARIES="$2"
-export DEFAULT_DICT_NAME="$3"
-export DICT_VERSION="$4"
-export ANALYZER_DICTIONARY_CPP=`mktemp`.cpp
-export GENERATOR_DICTIONARY_CPP=`mktemp`.cpp
-export DICT_DIR=`mktemp -d`
+export DICT_NAME="$1"
+export DICT_VERSION="$2"
+export BITS=$3
+
+
+export MORFEUSZ_SRC=`pwd`/Morfeusz
+export DICT_DIR=`pwd`/dicts
+export CROSSMORFEUSZ_ROOT=$HOME/crossmorfeusz
+export ANALYZER_DICTIONARY_CPP=$DICT_DIR/$DICT_NAME-a.cpp
+export GENERATOR_DICTIONARY_CPP=$DICT_DIR/$DICT_NAME-s.cpp
+
+
+export BUILD_ROOT=`pwd`/build/$1
+export TARGET_ROOT=`pwd`/target
+
 
-function buildDictionaries {
-    
-    INPUT_TAGSET=input/morfeusz-sgjp.tagset
-    SEGMENT_RULES_FILE=input/segmenty.dat
-    
-    python fsabuilder/morfeusz_builder \
-        --input-files="$INPUT_DICTIONARIES" \
-        --tagset-file="$INPUT_TAGSET" \
-        --segments-file="$SEGMENT_RULES_FILE" \
-        --analyzer-cpp="$ANALYZER_DICTIONARY_CPP" \
-        --generator-cpp="$GENERATOR_DICTIONARY_CPP" \
-        --dict="$DEFAULT_DICT_NAME" \
-        --dict-dir="$DICT_DIR"
-    
-    echo "DONE building dictionaries" >&2
-}
 
 function build {
     set -e -o pipefail
     os=$1
-    arch=$2
+    bity=$2
     embedded=$3
-    shift
-    shift
-    shift
+    python_ver=$4
+    shift 4
     targets=$@
+
+    if [ "$bity" = "64" ]; then
+	arch=amd64
+    else
+	arch=i386
+    fi
+
+    toolchain=$MORFEUSZ_SRC/toolchains/Toolchain-$os-$arch.cmake
+
+    buildDir=$BUILD_ROOT/$os-$bity-$embedded
+    targetDir=$TARGET_ROOT/$os/$bity
+
+#    rm -rf $buildDir || true
+    mkdir -p $buildDir
+
     
-    srcDir=`pwd`
-    buildDir=buildall/$os-$arch-$embedded
-    targetDir=$srcDir/target
-    toolchain=$srcDir/toolchains/Toolchain-$os-$arch.cmake
-    
-    echo "Will use $toolchain toolchain"
+#    echo "Will use $toolchain toolchain"
 
-    rm -rf $buildDir
+    # rm -rf $buildDir
     #~ rm -rf $targetDir
     mkdir -p $buildDir
+    rm -f $buildDir/CMakeCache.txt
     mkdir -p $targetDir
     cd $buildDir
     
@@ -66,62 +77,209 @@ function build {
             -D TARGET_DIR=$targetDir \
             -D ANALYZER_DICTIONARY_CPP=$ANALYZER_DICTIONARY_CPP \
             -D GENERATOR_DICTIONARY_CPP=$GENERATOR_DICTIONARY_CPP \
-            -D DEFAULT_DICT_NAME=$DEFAULT_DICT_NAME \
+            -D DEFAULT_DICT_NAME=$DICT_NAME \
             -D SKIP_DICTIONARY_BUILDING=1 \
             -D EMBEDDED_DEFAULT_DICT=1 \
-            -D DICT_VERSION=$DICT_VERSION"
+            -D DICT_VERSION=$DICT_VERSION "
         if [ "$CPACK_GENERATOR" != "" ]
         then
             CMAKE_ARGS="$CMAKE_ARGS -D CPACK_GENERATOR=$CPACK_GENERATOR"
         fi
     else
-        echo "setting default ACL to prevent control-file-has-bad-permissions lintian error"
-        setfacl -R -d -m o::rx -m g::rx -m u::rwx .
+        # "setting default ACL to prevent control-file-has-bad-permissions lintian error"
+        #setfacl -R -d -m o::rx -m g::rx -m u::rwx .
         
         CMAKE_ARGS="-D CROSSMORFEUSZ_ROOT=$CROSSMORFEUSZ_ROOT \
             -D CMAKE_TOOLCHAIN_FILE=$toolchain \
             -D TARGET_DIR=$targetDir \
             -D DEFAULT_DICT_DIR=$DICT_DIR \
-            -D DEFAULT_DICT_NAME=$DEFAULT_DICT_NAME \
+            -D DEFAULT_DICT_NAME=$DICT_NAME \
             -D SKIP_DICTIONARY_BUILDING=1 \
             -D CPACK_GENERATOR=DEB \
-            -D DICT_VERSION=$DICT_VERSION"
+            -D DICT_VERSION=$DICT_VERSION "
     fi
-    cmake $CMAKE_ARGS $srcDir 2>&1
-    echo "building $toolchain" >&2
-    make
+    CMAKE_ARGS="$CMAKE_ARGS -D PY=$python_ver"
+    cmake $CMAKE_ARGS $MORFEUSZ_SRC 2>&1
+    echo "building for $os-$arch" >&2
+#    make
     make $targets
 
-    for f in `find "$targetDir" -name "*-Linux-*.deb"`
-    do 
-        mv "$f" "`echo $f | sed -r 's/Linux-amd64.deb$/amd64.deb/' | sed -r 's/Linux-i386.deb/i386.deb/'`"
-    done
+    # for f in `find "$targetDir" -name "*-Linux-*.deb"`
+    # do 
+    #     mv "$f" "`echo $f | sed -r 's/Linux-amd64.deb$/amd64.deb/' | sed -r 's/Linux-i386.deb/i386.deb/'`"
+    # done
+
+    # for f in `find "$targetDir" -name "*-Linux-*.egg"`
+    # do 
+    #     mv "$f" "`echo $f | sed -r 's/Linux-amd64.egg$/linux-x86_64.egg/' | sed -r 's/Linux-i386.egg$/linux-i686.egg/'`"
+    # done
 
-    cd "$srcDir"
 }
+export -f build
+
+function buildegg {
+    os=$1
+    bity=$2
+    embedded=$3
+    python_ver=$4
+
+    if [ "$bity" = "64" ]; then
+	arch=amd64
+    else
+	arch=i386
+    fi
+
+    buildDir=$BUILD_ROOT/$os-$bity-$embedded/morfeusz/wrappers/python${python_ver:0:1}
+    if [[ "$python_ver" =~ 2.* ]]
+    then
+        eggName=morfeusz2-0.4.0-py2.7
+        eggDir=$buildDir/$eggName
+        pythonIncl=python27
+        if [ "$os-$arch" == "Windows-amd64" ]
+        then
+            pythonDir=$CROSSMORFEUSZ_ROOT/windows64/Python27
+        elif [ "$os-$arch" == "Windows-i386" ]
+        then
+            pythonDir=$CROSSMORFEUSZ_ROOT/windows32/Python27
+        elif [ "$os-$arch" == "Linux-i386" ]
+        then
+            pythonDir=$CROSSMORFEUSZ_ROOT/linux32/python/include/python2.7
+        elif [ "$os-$arch" == "Darwin-amd64" ]
+        then
+            pythonIncl=python2.7
+            pythonDir=$CROSSMORFEUSZ_ROOT/darwin64/Python.framework/Headers
+            pythonLib=$CROSSMORFEUSZ_ROOT/darwin64/Python.framework/Versions/2.7/lib
+        fi
+    else
+        if [ "$os-$arch" == "Windows-amd64" ]
+        then
+            if [ "$python_ver" == "3.6" ]
+            then
+                pythonDir=$CROSSMORFEUSZ_ROOT/windows64/Python36
+                eggName=morfeusz2-0.4.0-py3.6
+                eggDir=$buildDir/$eggName
+                pythonIncl=python36
+            elif [ "$python_ver" == "3.7" ]
+            then
+                pythonDir=$CROSSMORFEUSZ_ROOT/windows64/Python37
+                eggName=morfeusz2-0.4.0-py3.7
+                eggDir=$buildDir/$eggName
+                pythonIncl=python37
+            fi
+        else
+            eggName=morfeusz2-0.4.0-py3.6
+            eggDir=$buildDir/$eggName
+            pythonIncl=python36
+            if [ "$os-$arch" == "Windows-i386" ]
+            then
+                pythonDir=$CROSSMORFEUSZ_ROOT/windows32/Python36-32
+            elif [ "$os-$arch" == "Linux-i386" ]
+            then
+                pythonDir=$CROSSMORFEUSZ_ROOT/linux32/python3/include/python3.4m
+            elif [ "$os-$arch" == "Darwin-amd64" ]
+            then
+                pythonIncl=python3.6m
+                pythonDir=$CROSSMORFEUSZ_ROOT/darwin64/anaconda3.6-macos/include/python3.6m
+                pythonLib=$CROSSMORFEUSZ_ROOT/darwin64/anaconda3.6-macos/lib
+                # pythonDir=$CROSSMORFEUSZ_ROOT/darwin64/Python3.framework/Versions/3.6/Headers
+                # pythonLib=$CROSSMORFEUSZ_ROOT/darwin64/Python3.framework/Versions/3.6/lib
+            fi
+        fi
+    fi
+
+    targetDir=$TARGET_ROOT/$os/$bity
+    echo "src_dir: $MORFEUSZ_SRC"
+    echo "python_build_dir: $buildDir"
+    echo "egg_dir: $eggDir"
+    echo "python_lib_dir: $pythonDir"
+    if [ "$os-$arch" == "Windows-amd64" ]
+    then
+        gcc_command="x86_64-w64-mingw32-gcc -pthread -static-libgcc -static-libstdc++ -std=c++98 -DNDEBUG -DMS_WIN64 -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -fPIC -I$MORFEUSZ_SRC/morfeusz -I$buildDir/../../.. -I$pythonDir/include -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
+        echo "$gcc_command"
+        eval $gcc_command
+        gpp_command="x86_64-w64-mingw32-g++ -pthread -static-libgcc -static-libstdc++ -DMS_WIN64 -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security $buildDir/swigPYTHON.o -L$buildDir/../.. -L$pythonDir/libs -lmorfeusz2 -l$pythonIncl -o $eggDir/_morfeusz2.pyd"
+        echo "$gpp_command"
+        eval $gpp_command
+    elif [ "$os-$arch" == "Windows-i386" ]
+    then
+        gcc_command="i686-w64-mingw32-gcc -pthread -static-libgcc -static-libstdc++ -std=c++98 -DNDEBUG -DMS_WIN64 -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -fPIC -I$MORFEUSZ_SRC/morfeusz -I$buildDir/../../.. -I$pythonDir/include -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
+        echo "$gcc_command"
+        eval $gcc_command
+        gpp_command="i686-w64-mingw32-g++ -pthread -static-libgcc -static-libstdc++ -DMS_WIN64 -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security $buildDir/swigPYTHON.o -L$buildDir/../.. -L$pythonDir/libs -lmorfeusz2 -l$pythonIncl -o $eggDir/_morfeusz2.pyd"
+        echo "$gpp_command"
+        eval $gpp_command
+    elif [ "$os-$arch" == "Linux-i386" ]
+    then
+        gcc_command="x86_64-linux-gnu-gcc -m32 -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I$MORFEUSZ_SRC/morfeusz -I$buildDir/../../.. -I$pythonDir -I$pythonDir/.. -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
+        echo "$gcc_command"
+        eval $gcc_command
+        gpp_command="x86_64-linux-gnu-g++ -m32 -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 $buildDir/swigPYTHON.o -L$buildDir/../.. -lmorfeusz2 -o $eggDir/_morfeusz2.so"
+        echo "$gpp_command"
+        eval $gpp_command
+    elif [ "$os-$arch" == "Darwin-amd64" ]
+    then
+        gcc_command="/usr/x86_64-apple-darwin9/bin/x86_64-apple-darwin9-gcc -std=c++98 -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -Wformat -D_FORTIFY_SOURCE=2 -fPIC -I$MORFEUSZ_SRC/morfeusz -I$buildDir/../../.. -I$pythonDir -I$pythonDir/.. -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
+        eval $gcc_command
+        gpp_command="/usr/x86_64-apple-darwin9/bin/x86_64-apple-darwin9-g++ -std=c++98 -Wall -O3 -DNDEBUG -dynamiclib -Wl,-headerpad_max_install_names -install_name _morfeusz2.so $buildDir/swigPYTHON.o -L$buildDir/../.. -L$pythonLib -lmorfeusz2 -l$pythonIncl -o $eggDir/_morfeusz2.so"
+        eval $gpp_command
+	INSTALL_NAME_TOOL=/usr/x86_64-apple-darwin9/bin/x86_64-apple-darwin9-install_name_tool
+	${INSTALL_NAME_TOOL} -change /usr/x86_64-apple-darwin9/x86_64-apple-darwin9/lib/libstdc++.6.dylib /usr/lib/libstdc++.6.dylib $eggDir/_morfeusz2.so
+	${INSTALL_NAME_TOOL} -change libmorfeusz2.dylib @loader_path/libmorfeusz2.dylib $eggDir/_morfeusz2.so
+	# ${INSTALL_NAME_TOOL} -change libmorfeusz2.dylib @executable_path/../bin/libmorfeusz2.dylib $eggDir/_morfeusz2.so
+    fi
+
+
+    if [ "$os" == "Windows" ]
+    then
+        cp $buildDir/../../morfeusz2.dll $eggDir/
+    elif  [ "$os" == "Linux" ]
+    then
+        cp $buildDir/../../libmorfeusz2.so $eggDir/
+    elif  [ "$os" == "Darwin" ]
+    then
+        cp $buildDir/../../libmorfeusz2.dylib $eggDir/
+    fi
+
+    cp $buildDir/morfeusz2.py $eggDir/
+    if [ -d "$buildDir/$eggName" ]; then
+        cd $buildDir/$eggName
+        if [ "$os-$arch" == "Windows-amd64" ]
+        then
+            zip -r $eggName-win-amd64.zip ./*
+            cp $eggName-win-amd64.zip $targetDir/$eggName-win-amd64.egg
+        elif [ "$os-$arch" == "Windows-i386" ]
+        then
+            zip -r $eggName-win32.zip ./*
+            cp $eggName-win32.zip $targetDir/$eggName-win32.egg
+        elif [ "$os-$arch" == "Linux-i386" ]
+        then
+            zip -r $eggName-linux-i686.zip ./*
+            cp $eggName-linux-i686.zip $targetDir/$eggName-linux-i686.egg
+        elif [ "$os-$arch" == "Darwin-amd64" ]
+        then
+            zip -r $eggName-macosx-10.9-x86_64.zip ./*
+            cp $eggName-macosx-10.9-x86_64.zip $targetDir/$eggName-macosx-10.9-x86_64.egg
+        fi
+    fi
+
+}
+export -f buildegg
 
 function log {
     os=$1
     arch=$2
-    stdbuf -oL sed -e $"s/^/$os-$arch:\t/" | tee "log/$os-$arch.out"
+    stdbuf -oL sed -e $"s/^/$os-$arch:\t/" | tee -a "log/$os-$arch.out"
 }
-
-export -f build
 export -f log
 
-rm -rf log target
-mkdir -p log
-
-buildDictionaries 2>&1 | log All all
-
-{
-    #echo "build Linux amd64 true package package-java package-python package-builder 2>&1 | log Linux-tgz amd64"
-    #echo "build Linux amd64 false package 2>&1 | log Linux-deb amd64"
-    #echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true package package-java 2>&1 | log Linux-tgz i386"
-    #echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 false package 2>&1 | log Linux-deb i386"
-    #echo "build Windows amd64 true package package-java 2>&1 | log Windows amd64"
-    #echo "build Windows i386 true package package-java 2>&1 | log Windows i386"
-    echo "build Darwin amd64 true package package-java 2>&1 | log Darwin amd64"
-} | xargs -n1 -P2 -d$'\n' bash -c
+##??? rm -rf log $BUILD_ROOT
+mkdir -p log 
 
+build Darwin $BITS true 2 package package-java gui-dmg 2>&1 | log Darwin $BITS; 
+build Darwin $BITS true 2 py2morfeusz 2>&1 | log Darwin $BITS; 
+buildegg Darwin $BITS true 2 2>&1 | log Darwin $BITS; 
+build Darwin $BITS true 3 py3morfeusz 2>&1 | log Darwin $BITS; 
+buildegg Darwin $BITS true 3 2>&1 | log Darwin $BITS
+#build Darwin $BITS true 2 package package-java py2morfeusz 2>&1 | log Darwin $BITS
+#buildegg Darwin $BITS true 2 2>&1 | log Darwin $BITS
 
diff --git a/buildDict.sh b/buildDict.sh
new file mode 100755
index 0000000..1e4240c
--- /dev/null
+++ b/buildDict.sh
@@ -0,0 +1,67 @@
+#! /bin/bash
+#  Buduje postać binarną i pliki .cpp zawierające słowniki SGJP i Polimorf
+#
+# Założenia:
+# • kod źródłowy Morfeusza jest w MORFEUSZ_SRC
+# • słowniki źródłowe są w katalogu SRC_DICT_DIR i nazywają się ‹słownik›-‹data›.tab
+# • wynik kompilacji zostanie umieszczony w katalogu DICT_DIR (który zostanie skasowany i utworzony)
+# • kompilacja odbędzie się w katalogu BUILD_DIR (który zostanie skasowany i utworzony)
+
+
+set -ex -o pipefail
+
+if [ "$#" -ne 1 ]; then
+    echo "Exactly 1 argument needed: ‹DICT_VERSION›"
+    exit 1
+fi
+
+export MORFEUSZ_SRC=`pwd`/Morfeusz
+export DICT_DIR=`pwd`/dicts
+export SRC_DICT_DIR=$DICT_DIR
+export BUILD_DIR=`pwd`/build/dicts
+
+rm -rf $BUILD_DIR || true
+
+mkdir -p $BUILD_DIR $DICT_DIR
+
+cd $BUILD_DIR
+cmake $MORFEUSZ_SRC
+
+
+export DICT_VERSION="$1"
+
+# argument: nazwa słownika
+function buildDictionary {
+    set -x
+    DICT_NAME=$1
+
+    MAIN_DICT=$SRC_DICT_DIR/$DICT_NAME-$DICT_VERSION.tab
+    INPUT_DICTIONARIES="$MAIN_DICT,$MORFEUSZ_SRC/input/dodatki.tab"
+    INPUT_TAGSET=$MORFEUSZ_SRC/input/morfeusz-sgjp.tagset
+    SEGMENT_RULES_FILE=$MORFEUSZ_SRC/input/segmenty.dat
+    ANALYZER_DICTIONARY_CPP=$DICT_DIR/$DICT_NAME-a.cpp
+    GENERATOR_DICTIONARY_CPP=$DICT_DIR/$DICT_NAME-s.cpp
+    
+    fsabuilder/morfeusz_builder \
+        --input-files="$INPUT_DICTIONARIES" \
+        --tagset-file="$INPUT_TAGSET" \
+        --segments-file="$SEGMENT_RULES_FILE" \
+        --analyzer-cpp="$ANALYZER_DICTIONARY_CPP" \
+        --generator-cpp="$GENERATOR_DICTIONARY_CPP" \
+        --dict="$DICT_NAME" \
+        --dict-dir="$DICT_DIR"
+    
+    echo "DONE building dictionaries" >&2
+
+    DICT_PACKAGE=morfeusz2-dictionary-${DICT_NAME}-${DICT_VERSION}.tgz
+    (cd $DICT_DIR; tar czvf $DICT_PACKAGE $DICT_NAME-a.dict $DICT_NAME-s.dict )
+    gzip "$MAIN_DICT"
+}
+
+export -f buildDictionary
+
+
+{
+    echo "buildDictionary sgjp"
+    echo "buildDictionary polimorf"
+} | xargs -n1 -P6 -d$'\n' bash -c
diff --git a/buildLinux.sh b/buildLinux.sh
new file mode 100755
index 0000000..dfce9be
--- /dev/null
+++ b/buildLinux.sh
@@ -0,0 +1,161 @@
+#!/bin/bash
+#  Kompiluje bibliotekę i buduje paczki dystrybucyjne zawierające
+# Morfeusza i słowniki SGJP i Polimorf
+#
+# Założenia:
+# • kod źródłowy Morfeusza jest w MORFEUSZ_SRC
+# • słowniki są już skompilowane w katalogu DICT_DIR
+# • kompilacja odbędzie się w katalogu BUILD_DIR (który zostanie skasowany i utworzony)
+# • wyniki zostaną umieszczone w TARGET_DIR
+
+#set -ex -o pipefail
+set -x
+
+if [ "$#" -ne 4 ]; then
+    echo "Expected arguments: ‹DICT_NAME› ‹DICT_VERSION› ‹BUILD_ENV› ‹64/32›"
+    exit 1
+fi
+
+export DICT_NAME="$1"
+export DICT_VERSION="$2"
+
+export MORFEUSZ_SRC=`pwd`/Morfeusz
+export DICT_DIR=`pwd`/dicts
+export ANALYZER_DICTIONARY_CPP=$DICT_DIR/$DICT_NAME-a.cpp
+export GENERATOR_DICTIONARY_CPP=$DICT_DIR/$DICT_NAME-s.cpp
+
+# Wersja środowiska kompilacyjnego (znaczy pod którym Ubuntu budujemy: 14.04, 16.04, 18.04, 19.04 …):
+# Staje się debianowym numerem subwersji: morfeusz…_1.9.27-18.04_amd64.deb
+export BUILD_ENV=$3
+
+export BITS=$4
+
+export BUILD_ROOT=`pwd`/build/$1
+export TARGET_ROOT=`pwd`/target
+
+
+
+function build {
+    set -e -o pipefail
+    os=$1
+    arch=$2
+    embedded=$3
+    python_ver=$4
+    shift 4
+    targets=$@
+    
+#    toolchain=$MORFEUSZ_SRC/toolchains/Toolchain-$os-$arch.cmake
+    toolchain=$MORFEUSZ_SRC/toolchains/Toolchain-Linux-native.cmake
+    if [ "$os" = "Linux" ]; then
+	buildDir=$BUILD_ROOT/$os-$BUILD_ENV-$arch-$embedded
+	targetDir=$TARGET_ROOT/$os/$BUILD_ENV/$arch
+    else
+	buildDir=$BUILD_ROOT/$os-$arch-$embedded
+	targetDir=$TARGET_ROOT/$os/$arch
+    fi
+#    rm -rf $buildDir || true
+    mkdir -p $buildDir
+
+    
+#    echo "Will use $toolchain toolchain"
+
+    # rm -rf $buildDir
+    #~ rm -rf $targetDir
+    mkdir -p $buildDir
+    rm -f $buildDir/CMakeCache.txt
+    mkdir -p $targetDir
+    cd $buildDir
+    
+    if [ "$embedded" = true ]
+    then
+        if [ "$os" == "Linux" ]
+        then
+            CPACK_GENERATOR=TGZ
+        fi
+        CMAKE_ARGS="-D CMAKE_TOOLCHAIN_FILE=$toolchain \
+            -D TARGET_DIR=$targetDir \
+            -D ANALYZER_DICTIONARY_CPP=$ANALYZER_DICTIONARY_CPP \
+            -D GENERATOR_DICTIONARY_CPP=$GENERATOR_DICTIONARY_CPP \
+            -D DEFAULT_DICT_NAME=$DICT_NAME \
+            -D SKIP_DICTIONARY_BUILDING=1 \
+            -D EMBEDDED_DEFAULT_DICT=1 \
+            -D DICT_VERSION=$DICT_VERSION \
+	    -D BUILT_ON=$BUILD_ENV "
+        if [ "$CPACK_GENERATOR" != "" ]
+        then
+            CMAKE_ARGS="$CMAKE_ARGS -D CPACK_GENERATOR=$CPACK_GENERATOR"
+        fi
+    else
+        # "setting default ACL to prevent control-file-has-bad-permissions lintian error"
+        setfacl -R -d -m o::rx -m g::rx -m u::rwx .
+        
+        CMAKE_ARGS="-D CMAKE_TOOLCHAIN_FILE=$toolchain \
+            -D TARGET_DIR=$targetDir \
+            -D DEFAULT_DICT_DIR=$DICT_DIR \
+            -D DEFAULT_DICT_NAME=$DICT_NAME \
+            -D SKIP_DICTIONARY_BUILDING=1 \
+            -D CPACK_GENERATOR=DEB \
+            -D DICT_VERSION=$DICT_VERSION \
+	    -D BUILT_ON=$BUILD_ENV "
+    fi
+    CMAKE_ARGS="$CMAKE_ARGS -D PY=$python_ver"
+    cmake $CMAKE_ARGS $MORFEUSZ_SRC 2>&1
+    echo "building for $os-$arch ($BUILD_ENV)" >&2
+#    make
+    make $targets
+
+    # for f in `find "$targetDir" -name "*-Linux-*.deb"`
+    # do 
+    #     mv "$f" "`echo $f | sed -r 's/Linux-amd64.deb$/amd64.deb/' | sed -r 's/Linux-i386.deb/i386.deb/'`"
+    # done
+
+    # for f in `find "$targetDir" -name "*-Linux-*.egg"`
+    # do 
+    #     mv "$f" "`echo $f | sed -r 's/Linux-amd64.egg$/linux-x86_64.egg/' | sed -r 's/Linux-i386.egg$/linux-i686.egg/'`"
+    # done
+
+}
+export -f build
+
+function log {
+    os=$1
+    arch=$2
+    stdbuf -oL sed -e $"s/^/$os-$BUILD_ENV-$arch:\t/" | tee -a "log/$os-$BUILD_ENV-$arch.out"
+}
+export -f log
+
+##??? rm -rf log $BUILD_ROOT
+mkdir -p log 
+
+build Linux $BITS true 2.7 package package-java gui-tgz package-python2 2>&1 | log Linux-tgz2 $BITS;
+build Linux $BITS true 3.0 package-python3 package-builder 2>&1 | log Linux-tgz3 $BITS
+build Linux $BITS false 0 lib-deb bin-deb dev-deb dictionary-deb java-deb gui-deb 2>&1 | log Linux-deb $BITS
+
+
+# {
+#     echo "build Linux amd64 true 2.7 package package-java package-python2 package-builder 2>&1 | log Linux-tgz2 amd64; \
+#         build Linux amd64 true 3.0 package-python3 2>&1 | log Linux-tgz3 amd64"
+#     echo "build Linux amd64 false 0 lib-deb bin-deb dev-deb dictionary-deb java-deb 2>&1 | log Linux-deb amd64"
+#     echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true 2.7 package package-java py2morfeusz 2>&1 | log Linux-tgz i386; \
+#         buildegg Linux i386 true 2.7 2>&1 | log Linux i386; \
+#         LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true 3.0 py3morfeusz 2>&1 | log Linux-tgz i386; \
+#         buildegg Linux i386 true 3.0 2>&1 | log Linux i386"
+#     echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 false 0 lib-deb bin-deb java-deb 2>&1 | log Linux-deb i386"
+#     echo "build Windows amd64 true 2.7 package package-java py2morfeusz 2>&1 | log Windows amd64; \
+#         buildegg Windows amd64 true 2.7 2>&1 | log Windows amd64; \
+#         build Windows amd64 true 3.6 py3morfeusz 2>&1 | log Windows amd64; \
+#         buildegg Windows amd64 true 3.6 2>&1 | log Windows amd64; \
+#         build Windows amd64 true 3.7 py3morfeusz 2>&1 | log Windows amd64; \
+#         buildegg Windows amd64 true 3.7 2>&1 | log Windows amd64"
+#     echo "build Windows i386 true 2.7 package package-java py2morfeusz 2>&1 | log Windows i386; \
+#         buildegg Windows i386 true 2.7 2>&1 | log Windows i386; \
+#         build Windows i386 true 3.0 py3morfeusz 2>&1 | log Windows i386 \
+#         buildegg Windows i386 true 3.0 2>&1 | log Windows i386"
+#     echo "build Darwin amd64 true 2 package package-java py2morfeusz 2>&1 | log Darwin amd64; \
+#         buildegg Darwin amd64 true 2 2>&1 | log Darwin amd64; \
+#         build Darwin amd64 true 3 py3morfeusz 2>&1 | log Darwin amd64; \
+#         buildegg Darwin amd64 true 3 2>&1 | log Darwin amd64"
+#     echo "build Darwin amd64 true 2 package package-java py2morfeusz 2>&1 | log Darwin amd64"
+#     echo "buildegg Darwin amd64 true 2 2>&1 | log Darwin amd64"
+
+# } | xargs -n1 -P6 -d$'\n' bash -c
diff --git a/buildOtherDict.sh b/buildOtherDict.sh
new file mode 100755
index 0000000..6fc5cfc
--- /dev/null
+++ b/buildOtherDict.sh
@@ -0,0 +1,155 @@
+#!/bin/bash
+# Kompiluje pakiet debianowy z dodatkowym słownikiem dla Morfeusza
+# [Zrobione z myślą o Polimorfie, ale można użyć do innych.]
+#
+# Założenia:
+# • kod źródłowy Morfeusza jest w MORFEUSZ_SRC
+# • słowniki są już skompilowane w katalogu DICT_DIR
+# • kompilacja odbędzie się w katalogu BUILD_DIR (który zostanie skasowany i utworzony)
+# • wyniki zostaną umieszczone w TARGET_DIR
+
+#set -ex -o pipefail
+set -x
+
+if [ "$#" -ne 2 ]; then
+    echo "Expected arguments: ‹DICT_NAME› ‹DICT_VERSION›"
+    exit 1
+fi
+
+export DICT_NAME="$1"
+export DICT_VERSION="$2"
+
+export MORFEUSZ_SRC=`pwd`/Morfeusz
+export DICT_DIR=`pwd`/dicts
+export CROSSMORFEUSZ_ROOT=${HOME}/crossmorfeusz
+export ANALYZER_DICTIONARY_CPP=$DICT_DIR/$DICT_NAME-a.cpp
+export GENERATOR_DICTIONARY_CPP=$DICT_DIR/$DICT_NAME-s.cpp
+
+# Wersja środowiska kompilacyjnego (znaczy pod którym Ubuntu budujemy: 14.04, 16.04, 18.04, 19.04 …):
+# Staje się debianowym numerem subwersji: morfeusz…_1.9.27-18.04_amd64.deb
+export BUILD_ENV=18.04
+
+export BITS=64
+
+export BUILD_ROOT=`pwd`/build/$1
+export TARGET_ROOT=`pwd`/target
+
+
+
+function build {
+    set -e -o pipefail
+    os=$1
+    arch=$2
+    embedded=$3
+    python_ver=$4
+    shift 4
+    targets=$@
+    
+#    toolchain=$MORFEUSZ_SRC/toolchains/Toolchain-$os-$arch.cmake
+    toolchain=$MORFEUSZ_SRC/toolchains/Toolchain-Linux-native.cmake
+    buildDir=$BUILD_ROOT/$os-$BUILD_ENV-$arch-$embedded
+    targetDir=$TARGET_ROOT/$os/$BUILD_ENV/$arch
+#    rm -rf $buildDir || true
+    mkdir -p $buildDir
+
+    
+#    echo "Will use $toolchain toolchain"
+
+    # rm -rf $buildDir
+    #~ rm -rf $targetDir
+    mkdir -p $buildDir
+    rm -f $buildDir/CMakeCache.txt
+    mkdir -p $targetDir
+    cd $buildDir
+    
+    if [ "$embedded" = true ]
+    then
+        if [ "$os" == "Linux" ]
+        then
+            CPACK_GENERATOR=TGZ
+        fi
+        CMAKE_ARGS="-D CMAKE_TOOLCHAIN_FILE=$toolchain \
+            -D TARGET_DIR=$targetDir \
+            -D ANALYZER_DICTIONARY_CPP=$ANALYZER_DICTIONARY_CPP \
+            -D GENERATOR_DICTIONARY_CPP=$GENERATOR_DICTIONARY_CPP \
+            -D DEFAULT_DICT_NAME=$DICT_NAME \
+            -D SKIP_DICTIONARY_BUILDING=1 \
+            -D EMBEDDED_DEFAULT_DICT=1 \
+            -D DICT_VERSION=$DICT_VERSION \
+	    -D BUILT_ON=$BUILD_ENV "
+        if [ "$CPACK_GENERATOR" != "" ]
+        then
+            CMAKE_ARGS="$CMAKE_ARGS -D CPACK_GENERATOR=$CPACK_GENERATOR"
+        fi
+    else
+        # "setting default ACL to prevent control-file-has-bad-permissions lintian error"
+        setfacl -R -d -m o::rx -m g::rx -m u::rwx .
+        
+        CMAKE_ARGS="-D CMAKE_TOOLCHAIN_FILE=$toolchain \
+            -D TARGET_DIR=$targetDir \
+            -D DEFAULT_DICT_DIR=$DICT_DIR \
+            -D DEFAULT_DICT_NAME=$DICT_NAME \
+            -D SKIP_DICTIONARY_BUILDING=1 \
+            -D CPACK_GENERATOR=DEB \
+            -D DICT_VERSION=$DICT_VERSION \
+	    -D BUILT_ON=$BUILD_ENV "
+    fi
+    CMAKE_ARGS="$CMAKE_ARGS -D PY=$python_ver"
+    cmake $CMAKE_ARGS $MORFEUSZ_SRC 2>&1
+    echo "building $DICT_NAME for $os-$arch ($BUILD_ENV)" >&2
+#    make
+    make $targets
+
+    # for f in `find "$targetDir" -name "*-Linux-*.deb"`
+    # do 
+    #     mv "$f" "`echo $f | sed -r 's/Linux-amd64.deb$/amd64.deb/' | sed -r 's/Linux-i386.deb/i386.deb/'`"
+    # done
+
+    # for f in `find "$targetDir" -name "*-Linux-*.egg"`
+    # do 
+    #     mv "$f" "`echo $f | sed -r 's/Linux-amd64.egg$/linux-x86_64.egg/' | sed -r 's/Linux-i386.egg$/linux-i686.egg/'`"
+    # done
+
+}
+export -f build
+
+function log {
+    os=$1
+    arch=$2
+    stdbuf -oL sed -e $"s/^/$os-$BUILD_ENV-$arch:\t/" | tee "log/$os-$BUILD_ENV-$arch-$DICT_NAME.out"
+}
+export -f log
+
+##??? rm -rf log $BUILD_ROOT
+mkdir -p log 
+
+build Linux $BITS false 0 dictionary-deb 2>&1 | log Linux-deb $BITS
+
+
+# {
+#     echo "build Linux amd64 true 2.7 package package-java package-python2 package-builder 2>&1 | log Linux-tgz2 amd64; \
+#         build Linux amd64 true 3.0 package-python3 2>&1 | log Linux-tgz3 amd64"
+#     echo "build Linux amd64 false 0 lib-deb bin-deb dev-deb dictionary-deb java-deb 2>&1 | log Linux-deb amd64"
+#     echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true 2.7 package package-java py2morfeusz 2>&1 | log Linux-tgz i386; \
+#         buildegg Linux i386 true 2.7 2>&1 | log Linux i386; \
+#         LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true 3.0 py3morfeusz 2>&1 | log Linux-tgz i386; \
+#         buildegg Linux i386 true 3.0 2>&1 | log Linux i386"
+#     echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 false 0 lib-deb bin-deb java-deb 2>&1 | log Linux-deb i386"
+#     echo "build Windows amd64 true 2.7 package package-java py2morfeusz 2>&1 | log Windows amd64; \
+#         buildegg Windows amd64 true 2.7 2>&1 | log Windows amd64; \
+#         build Windows amd64 true 3.6 py3morfeusz 2>&1 | log Windows amd64; \
+#         buildegg Windows amd64 true 3.6 2>&1 | log Windows amd64; \
+#         build Windows amd64 true 3.7 py3morfeusz 2>&1 | log Windows amd64; \
+#         buildegg Windows amd64 true 3.7 2>&1 | log Windows amd64"
+#     echo "build Windows i386 true 2.7 package package-java py2morfeusz 2>&1 | log Windows i386; \
+#         buildegg Windows i386 true 2.7 2>&1 | log Windows i386; \
+#         build Windows i386 true 3.0 py3morfeusz 2>&1 | log Windows i386 \
+#         buildegg Windows i386 true 3.0 2>&1 | log Windows i386"
+#     echo "build Darwin amd64 true 2 package package-java py2morfeusz 2>&1 | log Darwin amd64; \
+#         buildegg Darwin amd64 true 2 2>&1 | log Darwin amd64; \
+#         build Darwin amd64 true 3 py3morfeusz 2>&1 | log Darwin amd64; \
+#         buildegg Darwin amd64 true 3 2>&1 | log Darwin amd64"
+#     echo "build Darwin amd64 true 2 package package-java py2morfeusz 2>&1 | log Darwin amd64"
+#     echo "buildegg Darwin amd64 true 2 2>&1 | log Darwin amd64"
+
+# } | xargs -n1 -P6 -d$'\n' bash -c
diff --git a/buildAll.sh b/buildWindows.sh
index 8c11421..e3ffff9 100755
--- a/buildAll.sh
+++ b/buildWindows.sh
@@ -1,60 +1,68 @@
 #!/bin/bash
+#  Kompiluje bibliotekę i buduje paczki dystrybucyjne zawierające
+#  Morfeusza i słowniki SGJP i Polimorf
+#
+# Założenia:
+# • kod źródłowy Morfeusza jest w MORFEUSZ_SRC
+# • słowniki są już skompilowane w katalogu DICT_DIR
+# • kompilacja odbędzie się w katalogu BUILD_DIR (który zostanie skasowany i utworzony)
+# • wyniki zostaną umieszczone w TARGET_DIR
 
-set -e -o pipefail
+#set -ex -o pipefail
+set -x
 
-if [ "$#" -ne 4 ]; then
-    echo "Must provide exactly 4 arguments: <CROSSMORFEUSZ_ROOT> <INPUT_DICTIONARIES> <DEFAULT_DICT_NAME> <DICT_VERSION>"
+if [ "$#" -ne 3 ]; then
+    echo "Expected arguments: ‹DICT_NAME› ‹DICT_VERSION› ‹64/32›"
     exit 1
 fi
 
-export CROSSMORFEUSZ_ROOT="$1"
-export INPUT_DICTIONARIES="$2"
-export DEFAULT_DICT_NAME="$3"
-export DICT_VERSION="$4"
-export ANALYZER_DICTIONARY_CPP=`mktemp`.cpp
-export GENERATOR_DICTIONARY_CPP=`mktemp`.cpp
-export DICT_DIR=`mktemp -d`
+export DICT_NAME="$1"
+export DICT_VERSION="$2"
+export BITS=$3
+
+
+export MORFEUSZ_SRC=`pwd`/Morfeusz
+export DICT_DIR=`pwd`/dicts
+export CROSSMORFEUSZ_ROOT=${HOME}/crosslibs
+export ANALYZER_DICTIONARY_CPP=$DICT_DIR/$DICT_NAME-a.cpp
+export GENERATOR_DICTIONARY_CPP=$DICT_DIR/$DICT_NAME-s.cpp
+
+
+export BUILD_ROOT=`pwd`/build/$1
+export TARGET_ROOT=`pwd`/target
+
 
-function buildDictionaries {
-    
-    INPUT_TAGSET=input/morfeusz-sgjp.tagset
-    SEGMENT_RULES_FILE=input/segmenty.dat
-    
-    python fsabuilder/morfeusz_builder \
-        --input-files="$INPUT_DICTIONARIES" \
-        --tagset-file="$INPUT_TAGSET" \
-        --segments-file="$SEGMENT_RULES_FILE" \
-        --analyzer-cpp="$ANALYZER_DICTIONARY_CPP" \
-        --generator-cpp="$GENERATOR_DICTIONARY_CPP" \
-        --dict="$DEFAULT_DICT_NAME" \
-        --dict-dir="$DICT_DIR"
-    
-    echo "DONE building dictionaries" >&2
-}
 
 function build {
     set -e -o pipefail
     os=$1
-    arch=$2
+    bity=$2
     embedded=$3
     python_ver=$4
-    shift
-    shift
-    shift
-    shift
+    shift 4
     targets=$@
+
+    if [ "$bity" = "64" ]; then
+	arch=amd64
+    else
+	arch=i386
+    fi
+
+    toolchain=$MORFEUSZ_SRC/toolchains/Toolchain-$os-$arch.cmake
+
+    buildDir=$BUILD_ROOT/$os-$bity-$embedded
+    targetDir=$TARGET_ROOT/$os/$bity
+
+#    rm -rf $buildDir || true
+    mkdir -p $buildDir
+
     
-    srcDir=`pwd`
-    buildDir=buildall/$os-$arch-$embedded
-    targetDir=$srcDir/target
-    toolchain=$srcDir/toolchains/Toolchain-$os-$arch.cmake
-    
-    echo "Will use $toolchain toolchain"
+#    echo "Will use $toolchain toolchain"
 
     # rm -rf $buildDir
     #~ rm -rf $targetDir
-    rm -f $buildDir/CMakeCache.txt
     mkdir -p $buildDir
+    rm -f $buildDir/CMakeCache.txt
     mkdir -p $targetDir
     cd $buildDir
     
@@ -69,64 +77,59 @@ function build {
             -D TARGET_DIR=$targetDir \
             -D ANALYZER_DICTIONARY_CPP=$ANALYZER_DICTIONARY_CPP \
             -D GENERATOR_DICTIONARY_CPP=$GENERATOR_DICTIONARY_CPP \
-            -D DEFAULT_DICT_NAME=$DEFAULT_DICT_NAME \
+            -D DEFAULT_DICT_NAME=$DICT_NAME \
             -D SKIP_DICTIONARY_BUILDING=1 \
             -D EMBEDDED_DEFAULT_DICT=1 \
-            -D DICT_VERSION=$DICT_VERSION"
+            -D DICT_VERSION=$DICT_VERSION "
         if [ "$CPACK_GENERATOR" != "" ]
         then
             CMAKE_ARGS="$CMAKE_ARGS -D CPACK_GENERATOR=$CPACK_GENERATOR"
         fi
     else
-        echo "setting default ACL to prevent control-file-has-bad-permissions lintian error"
-        setfacl -R -d -m o::rx -m g::rx -m u::rwx .
+        # "setting default ACL to prevent control-file-has-bad-permissions lintian error"
+        #setfacl -R -d -m o::rx -m g::rx -m u::rwx .
         
         CMAKE_ARGS="-D CROSSMORFEUSZ_ROOT=$CROSSMORFEUSZ_ROOT \
             -D CMAKE_TOOLCHAIN_FILE=$toolchain \
             -D TARGET_DIR=$targetDir \
             -D DEFAULT_DICT_DIR=$DICT_DIR \
-            -D DEFAULT_DICT_NAME=$DEFAULT_DICT_NAME \
+            -D DEFAULT_DICT_NAME=$DICT_NAME \
             -D SKIP_DICTIONARY_BUILDING=1 \
             -D CPACK_GENERATOR=DEB \
-            -D DICT_VERSION=$DICT_VERSION"
+            -D DICT_VERSION=$DICT_VERSION "
     fi
     CMAKE_ARGS="$CMAKE_ARGS -D PY=$python_ver"
-    cmake $CMAKE_ARGS $srcDir 2>&1
-    echo "building $toolchain" >&2
-    make
+    cmake $CMAKE_ARGS $MORFEUSZ_SRC 2>&1
+    echo "building for $os-$arch" >&2
+#    make
     make $targets
 
-    for f in `find "$targetDir" -name "*-Linux-*.deb"`
-    do 
-        mv "$f" "`echo $f | sed -r 's/Linux-amd64.deb$/amd64.deb/' | sed -r 's/Linux-i386.deb/i386.deb/'`"
-    done
+    # for f in `find "$targetDir" -name "*-Linux-*.deb"`
+    # do 
+    #     mv "$f" "`echo $f | sed -r 's/Linux-amd64.deb$/amd64.deb/' | sed -r 's/Linux-i386.deb/i386.deb/'`"
+    # done
 
-    for f in `find "$targetDir" -name "*-Linux-*.egg"`
-    do 
-        mv "$f" "`echo $f | sed -r 's/Linux-amd64.egg$/linux-x86_64.egg/' | sed -r 's/Linux-i386.egg$/linux-i686.egg/'`"
-    done
-
-    if [ "$os" = Linux -a "$embedded" = false ]; then
-        "$srcDir/createDictionaryDeb.sh" "$DICT_DIR" "${DEFAULT_DICT_NAME}" "${DICT_VERSION}" "${targetDir}"
-    fi
+    # for f in `find "$targetDir" -name "*-Linux-*.egg"`
+    # do 
+    #     mv "$f" "`echo $f | sed -r 's/Linux-amd64.egg$/linux-x86_64.egg/' | sed -r 's/Linux-i386.egg$/linux-i686.egg/'`"
+    # done
 
-    cd "$srcDir"
-}
-
-function log {
-    os=$1
-    arch=$2
-    stdbuf -oL sed -e $"s/^/$os-$arch:\t/" | tee "log/$os-$arch.out"
 }
+export -f build
 
 function buildegg {
     os=$1
-    arch=$2
+    bity=$2
     embedded=$3
     python_ver=$4
 
-    srcDir=`pwd`
-    buildDir=buildall/$os-$arch-$embedded/morfeusz/wrappers/python${python_ver:0:1}
+    if [ "$bity" = "64" ]; then
+	arch=amd64
+    else
+	arch=i386
+    fi
+
+    buildDir=$BUILD_ROOT/$os-$bity-$embedded/morfeusz/wrappers/python${python_ver:0:1}
     if [[ "$python_ver" =~ 2.* ]]
     then
         eggName=morfeusz2-0.4.0-py2.7
@@ -182,14 +185,14 @@ function buildegg {
         fi
     fi
 
-    targetDir=$srcDir/target
-    echo "$srcDir"
-    echo "$buildDir"
-    echo "$eggDir"
-    echo "$pythonDir"
+    targetDir=$TARGET_ROOT/$os/$bity
+    echo "src_dir: $MORFEUSZ_SRC"
+    echo "python_build_dir: $buildDir"
+    echo "egg_dir: $eggDir"
+    echo "python_lib_dir: $pythonDir"
     if [ "$os-$arch" == "Windows-amd64" ]
     then
-        gcc_command="x86_64-w64-mingw32-gcc -pthread -static-libgcc -static-libstdc++ -std=c++98 -DNDEBUG -DMS_WIN64 -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -fPIC -I$srcDir/morfeusz -I$buildDir/../../.. -I$pythonDir/include -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
+        gcc_command="x86_64-w64-mingw32-gcc -pthread -static-libgcc -static-libstdc++ -std=c++98 -DNDEBUG -DMS_WIN64 -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -fPIC -I$MORFEUSZ_SRC/morfeusz -I$buildDir/../../.. -I$pythonDir/include -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
         echo "$gcc_command"
         eval $gcc_command
         gpp_command="x86_64-w64-mingw32-g++ -pthread -static-libgcc -static-libstdc++ -DMS_WIN64 -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security $buildDir/swigPYTHON.o -L$buildDir/../.. -L$pythonDir/libs -lmorfeusz2 -l$pythonIncl -o $eggDir/_morfeusz2.pyd"
@@ -197,7 +200,7 @@ function buildegg {
         eval $gpp_command
     elif [ "$os-$arch" == "Windows-i386" ]
     then
-        gcc_command="i686-w64-mingw32-gcc -pthread -static-libgcc -static-libstdc++ -std=c++98 -DNDEBUG -DMS_WIN64 -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -fPIC -I$srcDir/morfeusz -I$buildDir/../../.. -I$pythonDir/include -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
+        gcc_command="i686-w64-mingw32-gcc -pthread -static-libgcc -static-libstdc++ -std=c++98 -DNDEBUG -DMS_WIN64 -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -fPIC -I$MORFEUSZ_SRC/morfeusz -I$buildDir/../../.. -I$pythonDir/include -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
         echo "$gcc_command"
         eval $gcc_command
         gpp_command="i686-w64-mingw32-g++ -pthread -static-libgcc -static-libstdc++ -DMS_WIN64 -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wdate-time -D_FORTIFY_SOURCE=2 -g -fno-stack-protector -Wformat -Werror=format-security $buildDir/swigPYTHON.o -L$buildDir/../.. -L$pythonDir/libs -lmorfeusz2 -l$pythonIncl -o $eggDir/_morfeusz2.pyd"
@@ -205,7 +208,7 @@ function buildegg {
         eval $gpp_command
     elif [ "$os-$arch" == "Linux-i386" ]
     then
-        gcc_command="x86_64-linux-gnu-gcc -m32 -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I$srcDir/morfeusz -I$buildDir/../../.. -I$pythonDir -I$pythonDir/.. -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
+        gcc_command="x86_64-linux-gnu-gcc -m32 -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I$MORFEUSZ_SRC/morfeusz -I$buildDir/../../.. -I$pythonDir -I$pythonDir/.. -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
         echo "$gcc_command"
         eval $gcc_command
         gpp_command="x86_64-linux-gnu-g++ -m32 -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 $buildDir/swigPYTHON.o -L$buildDir/../.. -lmorfeusz2 -o $eggDir/_morfeusz2.so"
@@ -213,7 +216,7 @@ function buildegg {
         eval $gpp_command
     elif [ "$os-$arch" == "Darwin-amd64" ]
     then
-        gcc_command="/home/zil/crossmorfeusz/darwin64/x86_64-apple-darwin9/bin/x86_64-apple-darwin9-gcc -std=c++98 -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -Wformat -D_FORTIFY_SOURCE=2 -fPIC -I$srcDir/morfeusz -I$buildDir/../../.. -I$pythonDir -I$pythonDir/.. -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
+        gcc_command="/home/zil/crossmorfeusz/darwin64/x86_64-apple-darwin9/bin/x86_64-apple-darwin9-gcc -std=c++98 -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -Wformat -D_FORTIFY_SOURCE=2 -fPIC -I$MORFEUSZ_SRC/morfeusz -I$buildDir/../../.. -I$pythonDir -I$pythonDir/.. -c $buildDir/swigPYTHON.cpp -o $buildDir/swigPYTHON.o"
         echo "$gcc_command"
         eval $gcc_command
         gpp_command="/home/zil/crossmorfeusz/darwin64/x86_64-apple-darwin9/bin/x86_64-apple-darwin9-g++ -std=c++98 -Wall -O3 -DNDEBUG -dynamiclib -Wl,-headerpad_max_install_names -install_name _morfeusz2.so $buildDir/swigPYTHON.o -L$buildDir/../.. -L$pythonLib -lmorfeusz2 -l$pythonIncl -o $eggDir/_morfeusz2.so"
@@ -256,54 +259,56 @@ function buildegg {
     fi
 
 }
+export -f buildegg
 
-export -f build
+function log {
+    os=$1
+    arch=$2
+    stdbuf -oL sed -e $"s/^/$os-$arch:\t/" | tee -a "log/$os-$arch.out"
+}
 export -f log
-export -f buildegg
 
-rm -rf log target buildall
-mkdir -p log buildall
-
-buildDictionaries 2>&1 | log All all
-
-{
-    echo "build Linux amd64 true 2.7 package package-java package-python2 package-builder 2>&1 | log Linux-tgz2 amd64; \
-        build Linux amd64 true 3.0 package-python3 2>&1 | log Linux-tgz3 amd64"
-    echo "build Linux amd64 false 0 lib-deb bin-deb dev-deb dictionary-deb java-deb 2>&1 | log Linux-deb amd64"
-    echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true 2.7 package package-java py2morfeusz 2>&1 | log Linux-tgz i386; \
-        buildegg Linux i386 true 2.7 2>&1 | log Linux i386; \
-        LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true 3.0 py3morfeusz 2>&1 | log Linux-tgz i386; \
-        buildegg Linux i386 true 3.0 2>&1 | log Linux i386"
-    echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 false 0 lib-deb bin-deb java-deb 2>&1 | log Linux-deb i386"
-    echo "build Windows amd64 true 2.7 package package-java py2morfeusz 2>&1 | log Windows amd64; \
-        buildegg Windows amd64 true 2.7 2>&1 | log Windows amd64; \
-        build Windows amd64 true 3.6 py3morfeusz 2>&1 | log Windows amd64; \
-        buildegg Windows amd64 true 3.6 2>&1 | log Windows amd64; \
-        build Windows amd64 true 3.7 py3morfeusz 2>&1 | log Windows amd64; \
-        buildegg Windows amd64 true 3.7 2>&1 | log Windows amd64"
-    echo "build Windows i386 true 2.7 package package-java py2morfeusz 2>&1 | log Windows i386; \
-        buildegg Windows i386 true 2.7 2>&1 | log Windows i386; \
-        build Windows i386 true 3.0 py3morfeusz 2>&1 | log Windows i386 \
-        buildegg Windows i386 true 3.0 2>&1 | log Windows i386"
-    echo "build Darwin amd64 true 2 package package-java py2morfeusz 2>&1 | log Darwin amd64; \
-        buildegg Darwin amd64 true 2 2>&1 | log Darwin amd64; \
-        build Darwin amd64 true 3 py3morfeusz 2>&1 | log Darwin amd64; \
-        buildegg Darwin amd64 true 3 2>&1 | log Darwin amd64"
-    echo "build Darwin amd64 true 2 package package-java py2morfeusz 2>&1 | log Darwin amd64"
-    echo "buildegg Darwin amd64 true 2 2>&1 | log Darwin amd64"
-
-} | xargs -n1 -P6 -d$'\n' bash -c
-
-srcDir=`pwd`
-targetDir=$srcDir/target
-
-for f in `find "$targetDir" -name "*-py3.6-linux-x86_64.egg"`
-do 
-    cp -f "$f" "`echo $f | sed -r 's/py3.6/py3.7/'`"
-done
-
-for f in `find "$targetDir" -name "*-py3.5-linux-x86_64.egg"`
-do 
-    cp -f "$f" "`echo $f | sed -r 's/py3.5/py3.6/'`"
-    cp -f "$f" "`echo $f | sed -r 's/py3.5/py3.7/'`"
-done
+##??? rm -rf log $BUILD_ROOT
+mkdir -p log 
+
+build Windows $BITS true 2.7 package package-java py2morfeusz 2>&1 | log Windows $BITS
+build Windows $BITS true 2.7 gui-installer 2>&1 | log Windows $BITS
+buildegg Windows $BITS true 2.7 2>&1 | log Windows $BITS
+build Windows $BITS true 3.6 py3morfeusz 2>&1 | log Windows $BITS
+buildegg Windows $BITS true 3.6 2>&1 | log Windows $BITS 
+build Windows $BITS true 3.7 py3morfeusz 2>&1 | log Windows $BITS
+buildegg Windows $BITS true 3.7 2>&1 | log Windows $BITS
+
+# build Windows $BITS true 2.7 package package-java py2morfeusz 2>&1 | log Windows $BITS
+# buildegg Windows $BITS true 2.7 2>&1 | log Windows $BITS
+# build Windows $BITS true 3.0 py3morfeusz 2>&1 | log Windows $BITS 
+# buildegg Windows $BITS true 3.0 2>&1 | log Windows $BITS
+
+
+# {
+#     echo "build Linux amd64 true 2.7 package package-java package-python2 package-builder 2>&1 | log Linux-tgz2 amd64; \
+#         build Linux amd64 true 3.0 package-python3 2>&1 | log Linux-tgz3 amd64"
+#     echo "build Linux amd64 false 0 lib-deb bin-deb dev-deb dictionary-deb java-deb 2>&1 | log Linux-deb amd64"
+#     echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true 2.7 package package-java py2morfeusz 2>&1 | log Linux-tgz i386; \
+#         buildegg Linux i386 true 2.7 2>&1 | log Linux i386; \
+#         LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true 3.0 py3morfeusz 2>&1 | log Linux-tgz i386; \
+#         buildegg Linux i386 true 3.0 2>&1 | log Linux i386"
+#     echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 false 0 lib-deb bin-deb java-deb 2>&1 | log Linux-deb i386"
+#     echo "build Windows amd64 true 2.7 package package-java py2morfeusz 2>&1 | log Windows amd64; \
+#         buildegg Windows amd64 true 2.7 2>&1 | log Windows amd64; \
+#         build Windows amd64 true 3.6 py3morfeusz 2>&1 | log Windows amd64; \
+#         buildegg Windows amd64 true 3.6 2>&1 | log Windows amd64; \
+#         build Windows amd64 true 3.7 py3morfeusz 2>&1 | log Windows amd64; \
+#         buildegg Windows amd64 true 3.7 2>&1 | log Windows amd64"
+#     echo "build Windows i386 true 2.7 package package-java py2morfeusz 2>&1 | log Windows i386; \
+#         buildegg Windows i386 true 2.7 2>&1 | log Windows i386; \
+#         build Windows i386 true 3.0 py3morfeusz 2>&1 | log Windows i386 \
+#         buildegg Windows i386 true 3.0 2>&1 | log Windows i386"
+#     echo "build Darwin amd64 true 2 package package-java py2morfeusz 2>&1 | log Darwin amd64; \
+#         buildegg Darwin amd64 true 2 2>&1 | log Darwin amd64; \
+#         build Darwin amd64 true 3 py3morfeusz 2>&1 | log Darwin amd64; \
+#         buildegg Darwin amd64 true 3 2>&1 | log Darwin amd64"
+#     echo "build Darwin amd64 true 2 package package-java py2morfeusz 2>&1 | log Darwin amd64"
+#     echo "buildegg Darwin amd64 true 2 2>&1 | log Darwin amd64"
+
+# } | xargs -n1 -P6 -d$'\n' bash -c
diff --git a/fsabuilder/CMakeLists.txt b/fsabuilder/CMakeLists.txt
index 23afe8b..320b48b 100644
--- a/fsabuilder/CMakeLists.txt
+++ b/fsabuilder/CMakeLists.txt
@@ -10,26 +10,26 @@ set (DEPS        "")
 configure_file (${SETUP_PY_IN} ${SETUP_PY})
 
 add_custom_command (OUTPUT ${SETUP_PY}
-                       COMMAND python
+                       COMMAND python3
                        ARGS setup.py build
                        DEPENDS ${DEPS})
 
 add_custom_target (builder-setup DEPENDS ${SETUP_PY})
 
 add_custom_target (install-builder
-    COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX}
+    COMMAND python3 ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX}
     DEPENDS builder-setup
 )
 #~ add_custom_target (package-builder-tgz
-    #~ COMMAND python ${SETUP_PY} bdist -d "${TARGET_DIR}" --plat-name='all'
+    #~ COMMAND python3 ${SETUP_PY} bdist -d "${TARGET_DIR}" --plat-name='all'
     #~ DEPENDS builder-setup
 #~ )
 add_custom_target (package-builder-egg
-    COMMAND python ${SETUP_PY} bdist_egg -d "${TARGET_DIR}"
+    COMMAND python3 ${SETUP_PY} bdist_egg -d "${TARGET_DIR}"
     DEPENDS builder-setup
 )
 add_custom_target (package-builder-sdist
-    COMMAND python ${SETUP_PY} sdist -d "${TARGET_DIR}"
+    COMMAND python3 ${SETUP_PY} sdist -d "${TARGET_DIR}"
     DEPENDS builder-setup
 )
 
@@ -38,12 +38,12 @@ set (PACKAGE_DEPENDS "package-builder-egg" "package-builder-sdist")
 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
   if (BUILT_ON)
     add_custom_target (package-builder-deb-sdist
-        COMMAND python ${SETUP_PY} --command-packages=stdeb.command sdist_dsc --package "${MORFEUSZBUILDER}" --depends "${CPACK_DEBIAN_PACKAGE_NAME}" --depends python-pyparsing --debian-version ${BUILT_ON}
+        COMMAND python3 ${SETUP_PY} --command-packages=stdeb.command sdist_dsc --package3 "${MORFEUSZBUILDER}" --depends "${CPACK_DEBIAN_PACKAGE_NAME}" --depends python-pyparsing --debian-version ${BUILT_ON}
         DEPENDS builder-setup
     )
   else ()
     add_custom_target (package-builder-deb-sdist
-        COMMAND python ${SETUP_PY} --command-packages=stdeb.command sdist_dsc --package "${MORFEUSZBUILDER}" --depends "${CPACK_DEBIAN_PACKAGE_NAME}" --depends python-pyparsing
+        COMMAND python3 ${SETUP_PY} --command-packages=stdeb.command sdist_dsc --package3 "${MORFEUSZBUILDER}" --depends "${CPACK_DEBIAN_PACKAGE_NAME}" --depends python-pyparsing
         DEPENDS builder-setup
     )
   endif ()