diff --git a/README.md b/README.md
index 91d63ad..19b0818 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,12 @@ URTrator executable contains everything we need. Just download
approriate binary and launch it! :) The only thing is to make
sure you have GTK2 and sqlite3 installed.
+## Distro-and-OS specific instructions
+
+* [MacOS](/doc/installation/macos/)
+* Windows (to be written)
+* Nixes: read below.
+
## Development version
URTrator written in Go and GTK2, so you should have them installed.
diff --git a/doc/installation/macos/README.md b/doc/installation/macos/README.md
new file mode 100644
index 0000000..ee0373f
--- /dev/null
+++ b/doc/installation/macos/README.md
@@ -0,0 +1,25 @@
+# MacOS installation
+
+For proper application bundle building you have to:
+
+* Install Homebrew (http://brew.sh)
+* Install Golang:
+
+```
+brew install go
+```
+
+* Install GTK+2:
+
+```
+brew install gtk+
+```
+
+* Install dylibbundler:
+
+```
+brew install dylibbundler
+```
+
+* Execute ``make-app.sh`` script from current directory. If everything
+went fine - you will see URTrator.app right in this directory.
diff --git a/doc/installation/macos/make-app.sh b/doc/installation/macos/make-app.sh
old mode 100755
new mode 100644
index efe98bc..43fef55
--- a/doc/installation/macos/make-app.sh
+++ b/doc/installation/macos/make-app.sh
@@ -39,9 +39,9 @@ if [ $? -ne 0 ]; then
fi
echo "Creating app bundle..."
-mkdir -p /Applications/URTrator.app/Contents/{MacOS,Library,Resources}
-cp $GOPATH/bin/urtrator /Applications/URTrator.app/Contents/MacOS/
-cp $GOPATH/src/github.com/pztrn/urtrator/artwork/urtrator.icns /Applications/URTrator.app/Contents/Resources/
+mkdir -p URTrator.app/Contents/{MacOS,Framework,Resources}
+cp $GOPATH/bin/urtrator URTrator.app/Contents/MacOS/
+cp $GOPATH/src/github.com/pztrn/urtrator/artwork/urtrator.icns URTrator.app/Contents/Resources/
#####################################################################
# APP BUNDLE INFO.PLIST
@@ -53,7 +53,7 @@ INFOPLIST='
CFBundleGetInfoString
URTrator
CFBundleExecutable
- urtrator
+ urtrator.sh
CFBundleIdentifier
name.pztrn.urtrator
CFBundleName
@@ -73,20 +73,28 @@ INFOPLIST='
'
-echo ${INFOPLIST} > /Applications/URTrator.app/Contents/Info.plist
+echo ${INFOPLIST} > URTrator.app/Contents/Info.plist
+echo -e '#!/bin/bash\ncd "${0%/*}"\n./urtrator' > ./URTrator.app/Contents/MacOS/urtrator.sh
+chmod +x ./URTrator.app/Contents/MacOS/urtrator.sh
#####################################################################
# Libraries works.
+# First iteration - main libraries.
echo "Copying libraries..."
-LIBS_TO_COPY=$(otool -L urtrator | awk {' print $1 '} | grep "/usr/local")
+dylibbundler -of -b -x ./URTrator.app/Contents/MacOS/urtrator -d ./URTrator.app/Contents/Framework/ -p @executable_path/../Framework/
-for lib in ${LIBS_TO_COPY[@]}; do
- cp ${lib} /Applications/URTrator.app/Contents/Library
+# Fix shit for dylibbundler. By this moment we should have everything
+# we needed in Framework directory.
+for lib in $(ls ./URTrator.app/Contents/Framework); do
libname=$(echo ${lib} | awk -F"/" {' print $NF '})
- install_name_tool -change ${lib} @executable_path/../Library/${libname} /Applications/URTrator.app/Contents/MacOS/urtrator
+ DEPS=$(otool -L ./URTrator.app/Contents/Framework/${lib} | grep "/usr/local")
+ for dep in ${DEPS[@]}; do
+ dep_name=$(echo ${dep} | awk -F"/" {' print $NF '})
+ install_name_tool -change ${dep} @executable_path/../Framework/${dep_name} ./URTrator.app/Contents/Framework/${libname}
+ done
done
echo "Finishing..."
-echo "URTrator is ready! Launch from Applications!"
+echo "URTrator is ready! Copy URTrator.app bundle to Applications and launch it!"