Browse Source

fix build

Namdak Tonpa 6 years ago
parent
commit
00f8b7dfcf

+ 0 - 1
doc/book.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/book.tex

+ 16 - 0
doc/book.tex

@@ -0,0 +1,16 @@
+% copyright (c) 2013 Synrc Research Center
+
+\documentclass[8pt,twoside]{article}
+\input{synrc.tex}
+\begin{document}
+\titleMAD
+\tableofcontents
+\include{index}
+\include{setup}
+\include{config}
+\include{commands}
+\include{scripts}
+\include{deps}
+\include{bundles}
+\include{ports}
+\end{document}

+ 0 - 1
doc/bundles.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/bundles.tex

+ 155 - 0
doc/bundles.tex

@@ -0,0 +1,155 @@
+\section{Container Bundles}
+
+\subsection{ESCRIPT Bundles}
+
+The key feature of mad is ability to create single-file bundled web sites.
+Thus making dream to boot simpler than node.js come true.
+This bundle target is ready to run on Windows, Linux and Mac.
+
+To make this possible we implemented a zip filesytem inside escript.
+mad packages priv directories along with ebin and configs.
+You can redefine each file in zip fs inside target
+escript by creation the copy with same path locally near escript.
+After launch all files are copied to ETS.
+N2O also comes with custom cowboy static handler that is able to
+read static files from this cached ETS filesystem.
+Also bundle are compatible with active online realoading and recompilation.
+
+E.g. you main create a single file site with:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    # mad bundle app_name
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+app\_name shoul be the same as a valid Erlang module, with app\_module:main/1
+function defined, which will boot up the bundle. This function could be like that:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+     -module(app_name).
+     main(Params) -> mad_repl:sh(Params).
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{BEAM ERTS Releases}
+
+As you may know you can create OTP releases with
+reltool (rebar generate) or systools (relx). mad creates releases boot
+script with systools and pack tra by itself.
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    # mad release beam sample
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{LING Unikernels}
+
+Sample rebar.config for your application you want to go unikernel:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    {deps_dir,"deps"}.
+    {deps, [{ling,"master"},{sh,"1.9"}]}.
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+Now you should build LING/posix:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    $ mad dep
+    $ cd deps/ling
+    $ ARCH=posix make
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+Now pack vmling.o, your OTP apps and rest static to single-file LING bundle with VM inside.
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    $ mad release ling mad
+    Ling Params: []
+    ARCH: posix_x86
+    Bundle Name: mad
+    System: [compiler,syntax_tools,sasl,tools,mnesia,reltool,xmerl,crypto,kernel,
+             stdlib,wx,webtool,ssl,runtime_tools,public_key,observer,inets,asn1,
+             et,eunit,hipe,os_mon]
+    Apps: [kernel,stdlib,sh,mad]
+    Overlay: ["crypto.beam","9p.beam","9p_auth.beam","9p_info.beam",
+              "9p_mounter.beam","9p_server.beam","9p_tcp.beam","9p_zero.beam",
+              "disk.beam","disk_server.beam","embedded_export.beam",
+              "goo_export.beam","goofs.beam","hipe_unified_loader.beam",
+              "inet_config.beam","kernel.beam","ling_bifs.beam","ling_code.beam",
+              "ling_disasm.beam","ling_iops.beam","ling_iopvars.beam",
+              "ling_lib.beam","net_vif.beam","os.beam","prim_file.beam",
+              "user_drv.beam","os_mon.beam","dets.beam","filename.beam",
+              "maps.beam","unicode.beam","zlib.beam"]
+    Bucks: [{boot,"/boot",2},
+            {os_mon,"/erlang/lib/os_mon/ebin",1},
+            {crypto,"/erlang/lib/crypto/ebin",1},
+            {kernel,"/erlang/lib/kernel/ebin",90},
+            {stdlib,"/erlang/lib/stdlib/ebin",85},
+            {sh,"/erlang/lib/sh/ebin",6},
+            {mad,"/erlang/lib/mad/ebin",43}]
+    Initializing EMBED.FS:
+    Mount View:
+     /boot /boot
+    /erlang/lib/os_mon/ebin /os_mon
+    /erlang/lib/crypto/ebin /crypto
+    /erlang/lib/kernel/ebin /kernel
+    /erlang/lib/stdlib/ebin /stdlib
+    /erlang/lib/sh/ebin /sh
+    /erlang/lib/mad/ebin /mad
+    Creating EMBED.FS C file: ...ok
+    Compilation of Filesystem object: ...ok
+    Linking Image: ok
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+Run it:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    $ rlwrap ./image.img
+    Erlang [ling-0.5]
+
+    Eshell V6.3  (abort with ^G)
+    1> application:which_applications().
+    [{mad,"MAD VXZ Build Tool","2.2"},
+     {sh,"VXZ SH Executor","0.9"},
+     {stdlib,"ERTS  CXC 138 10","2.2"},
+     {kernel,"ERTS  CXC 138 10","3.0.3"}]
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{Docker-compatible RUNC Containers}
+
+Creating runc-complatible container is simple:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    # mad release runc sample
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{Makefiles with OTP.MK}
+
+OTP.MK is a tiny 50 lines Makefile that allows to start your set
+of application using run\_erl and to\_erl tools from OTP distribution.
+We use that way in poduction. This is the best option also in
+development mode because all directory structure is open and mutable,
+so you can reload modified files and perform recompilation on the fly.
+
+It uses the original code to fast resolve dependencies into the right
+boot sequence to start. If you want more powerful Makefile-based erlang
+package management you may take a look onto ERLANG.MK by Nine Nines.
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    # make console
+\end{lstlisting}
+\vspace{1\baselineskip}
+

+ 0 - 1
doc/commands.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/commands.tex

+ 111 - 0
doc/commands.tex

@@ -0,0 +1,111 @@
+\section{Commands}
+
+Synrc mad has a simple interface as follows:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+  MAD Container Tool version b547fa
+
+      invoke = mad params
+      params = [] | command [ options  ] params
+     command = app     | deps  | clean | compile | up
+             | release [ beam  | ling  | script  | runc ]
+             | deploy  | start | stop  | attach  | sh
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+It seems to us more natural, you can specify random
+commands set with different specifiers (options).
+
+\subsection{deps, dep}
+
+In rebar-like managers we are selecting deps from rebar.config:
+\vspace{1\baselineskip}
+\begin{lstlisting}
+  {sub_dirs,["apps"]}.
+  {deps_dir,"deps"}.
+  {deps, [active,{nitro,"2.9"},{n2o,"2.9"}]}.
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+The search sequence for dependecies is follows. First mad will try to
+reach global package repository at \footahref{http://synrc.com/apps/index.txt}{http://synrc.com/apps/index.txt},
+this address is configurable. No application server is required for mad
+package management, only static files with OTP application format.
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+  {application,bpe,
+      [{description,"BPE SRC Business Process Engine"},
+       {vsn,"1.9"},
+       {registered,[]},
+       {applications,[kernel,stdlib,kvs,n2o]},
+       {dependencies,[kernel,stdlib,fs,ranch,crypto,mnesia,
+                      gproc,cowlib,kvs,cowboy,n2o,active,
+                      jsone,mad,nitro,sh,bpe]},
+       {mod,{bpe_app,[]}},
+       {env,[]},
+       {modules,[bpe,bpe_app,bpe_date,bpe_event,bpe_metainfo,bpe_proc,
+                 bpe_sup,bpe_task,default_railing,log_allow,routes,
+                 sampleproc,sampleproc_process]}]}.
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+If no file is found or server is unavailable then application registry will
+be taken from mad built-in index.txt. If no luck then the name of application,
+e.g. "spawnproc/rete" will be interpreted as github repository address.
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+   $ mad dep active n2o kvs ling "spawnproc/rete"
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{compile, com}
+Performs compilation of all known compilations backends in complilation profile of mad:
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    app — app.src erlang templating
+    dtl — DTL compiler
+    erl — BEAM compiler
+    c/c++ — for gcc cland and other native compilation
+    script — .script file used in projects like gproc
+    yrl/xrl — DSL language parser compilers
+    upl — UPL compiler
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{release, rel, bundle, bun}
+Taking all dependecies and resolve boot sequence according to dependecy order.
+Storing this value in .applist. If release type is not defined ({\bf beam} in following example),
+then {\bf script} release will be taken as a default.
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    $ mad release beam sample
+    Ordered: [kernel,stdlib,fs,ranch,crypto,compiler,syntax_tools,
+              gproc,cowlib,cowboy,n2o,sample,active,erlydtl,jsone,
+              mad,nitro,sh]
+    *WARNING* : Missing application sasl. Can not upgrade with this release
+    sample.boot: ok
+    OK:  "sample"
+
+    $ mad rel mad
+    Ordered: [kernel,stdlib,inets,sh,mad]
+    OK:  "mad"
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+MAD supports several releasing backends:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    script — script bundles, like mad itself
+    beam — ERTS releases with systools
+    ling — LING portable unikernels
+    runc — Docker-compatible containers
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{sh, repl, rep}
+
+Start REPL shell session.

+ 0 - 1
doc/config.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/config.tex

+ 70 - 0
doc/config.tex

@@ -0,0 +1,70 @@
+\section{Configuration File}
+
+\subsection{rebar.config}
+
+mad uses {\bf rebar.config} filename to load mad configuration.
+Despite mad is no fully rebar compatible (e.g. it can't uses
+rebar plugins, ports compilation is rather different, etc),
+it uses its name to achive certail level of compatibility.
+
+\subsection{deps}
+
+deps is the core option of mad. It says which OTP applications
+shold be used and where they could be found. Yoy may also specify
+versions. Here is simpliest example:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}[caption=deps Option]
+    {deps, [
+             {kvs,   ".*", {git,"git://github.com/synrc/kvs"}},
+             {forms, ".*", {git,"git://github.com/synrc/forms"}}
+    ]}.
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{deps\_dir}
+
+To specify where deps should be stored after fetching inside
+your application you use deps\_dir option:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}[caption=deps\_dir Option]
+    {deps_dir, "deps"}.
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{sub\_dirs}
+
+If your application consist of more than one src
+directory, you may specify all of the sub-applications.
+Each sub-application should be valid OTP application
+with its own rebar.config configuration file.
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    {sub_dirs,["apps"]}.
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{lib\_dirs}
+
+To use include directive across your sub-applications
+you should specify the {\bf lib\_dirs} directories
+which will be settled as include directories during compilation.
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    {lib_dirs,["apps"]}.
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+E.g. you have my\_app and my\_server applications
+inside apps directory and you including HRL file
+from my\_server application from ap\_app application:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    -module(my_app).
+    -include_lib("my_server/include/my_server.hrl").
+\end{lstlisting}
+\vspace{1\baselineskip}

+ 0 - 1
doc/deps.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/deps.tex

+ 65 - 0
doc/deps.tex

@@ -0,0 +1,65 @@
+\section{Dependencies}
+
+\subsection{OTP Compliant}
+
+mad supports app files inside ebin, priv static folder and c_src ports directories points.
+Specifically two kinds of directory layouts:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}[caption=Solution]
+    +-- apps
+    +-- deps
+    +-- rebar.config
+    +-- sys.config
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\vspace{1\baselineskip}
+\begin{lstlisting}[caption=OTP Application]
+    +-- deps
+    +-- ebin
+    +-- include
+    +-- priv
+    +-- src
+    +-- rebar.config
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{Application Depot}
+
+As you may know you can create OTP releases systools from sasl application.
+mad currently creates releases with systools, but manually manages binary access:
+from local erlang or public applcation depot.
+
+To bundle binary BEAM or LING along with synrc spplications MAD can use
+global repository statically avaliable at Github Pages:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+
+  $ curl -X GET http://synrc.com/apps/index.txt
+  [ {bin,[beam],     ["7.0.3"]},
+    {lib,[active],   ["0.9"]},
+    {lib,[compiler], ["6.0"]},
+    {lib,[cowboy],   ["1.0.1"]},
+    {lib,[cowlib],   ["1.0.0"]},
+    {lib,[crypto],   ["3.6"]},
+    {lib,[erlydtl],  ["0.8.0"]},
+    {lib,[fs],       ["1.9"]},
+    {lib,[gproc],    ["0.3"]},
+    {lib,[jsone],    ["v0.3.3"]},
+    {lib,[kernel],   ["4.0"]},
+    {lib,[stdlib],   ["2.5"]},
+    {lib,[kvs],      ["2.9"]},
+    {lib,[mad],      ["2.9"]},
+    {lib,[mnesia],   ["4.13"]},
+    {lib,[n2o],      ["2.10"]},
+    {lib,[nitro],    ["0.9"]},
+    {lib,[ranch],    ["1.0.0"]},
+    {lib,[rest],     ["2.9"]},
+    {lib,[review],   ["2.9"]},
+    {lib,[sh],       ["1.9"]},
+    {lib,[syntax_tools], ["1.7"]} ].
+
+\end{lstlisting}
+\vspace{1\baselineskip}

+ 0 - 1
doc/hevea.sty

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/hevea.sty

+ 90 - 0
doc/hevea.sty

@@ -0,0 +1,90 @@
+% hevea  : hevea.sty
+% This is a very basic style file for latex document to be processed
+% with hevea. It contains definitions of LaTeX environment which are
+% processed in a special way by the translator. 
+%  Mostly :
+%     - latexonly, not processed by hevea, processed by latex.
+%     - htmlonly , the reverse.
+%     - rawhtml,  to include raw HTML in hevea output.
+%     - toimage, to send text to the image file.
+% The package also provides hevea logos, html related commands (ahref
+% etc.), void cutting and image commands.
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{hevea}[2002/01/11]
+\RequirePackage{comment}
+\newif\ifhevea\heveafalse
+\@ifundefined{ifimagen}{\newif\ifimagen\imagenfalse}
+\makeatletter%
+\newcommand{\heveasmup}[2]{%
+\raise #1\hbox{$\m@th$%
+  \csname S@\f@size\endcsname
+  \fontsize\sf@size 0%
+  \math@fontsfalse\selectfont
+#2%
+}}%
+\DeclareRobustCommand{\hevea}{H\kern-.15em\heveasmup{.2ex}{E}\kern-.15emV\kern-.15em\heveasmup{.2ex}{E}\kern-.15emA}%
+\DeclareRobustCommand{\hacha}{H\kern-.15em\heveasmup{.2ex}{A}\kern-.15emC\kern-.1em\heveasmup{.2ex}{H}\kern-.15emA}%
+\DeclareRobustCommand{\html}{\protect\heveasmup{0.ex}{HTML}}
+%%%%%%%%% Hyperlinks hevea style
+\newcommand{\ahref}[2]{{#2}}
+\newcommand{\ahrefloc}[2]{{#2}}
+\newcommand{\aname}[2]{{#2}}
+\newcommand{\ahrefurl}[1]{\texttt{#1}}
+\newcommand{\footahref}[2]{#2\footnote{\texttt{#1}}}
+\newcommand{\mailto}[1]{\texttt{#1}}
+\newcommand{\imgsrc}[2][]{}
+\newcommand{\home}[1]{\protect\raisebox{-.75ex}{\char126}#1}
+\AtBeginDocument
+{\@ifundefined{url}
+{%url package is not loaded
+\let\url\ahref\let\oneurl\ahrefurl\let\footurl\footahref}
+{}}
+%% Void cutting instructions
+\newcounter{cuttingdepth}
+\newcommand{\tocnumber}{}
+\newcommand{\notocnumber}{}
+\newcommand{\cuttingunit}{}
+\newcommand{\cutdef}[2][]{}
+\newcommand{\cuthere}[2]{}
+\newcommand{\cutend}{}
+\newcommand{\htmlhead}[1]{}
+\newcommand{\htmlfoot}[1]{}
+\newcommand{\htmlprefix}[1]{}
+\newenvironment{cutflow}[1]{}{}
+\newcommand{\cutname}[1]{}
+\newcommand{\toplinks}[3]{}
+\newcommand{\setlinkstext}[3]{}
+\newcommand{\flushdef}[1]{}
+\newcommand{\footnoteflush}[1]{}
+%%%% Html only
+\excludecomment{rawhtml}
+\newcommand{\rawhtmlinput}[1]{}
+\excludecomment{htmlonly}
+%%%% Latex only
+\newenvironment{latexonly}{}{}
+\newenvironment{verblatex}{}{}
+%%%% Image file stuff
+\def\toimage{\endgroup}
+\def\endtoimage{\begingroup\def\@currenvir{toimage}}
+\def\verbimage{\endgroup}
+\def\endverbimage{\begingroup\def\@currenvir{verbimage}}
+\newcommand{\imageflush}[1][]{}
+%%% Bgcolor definition
+\newsavebox{\@bgcolorbin}
+\newenvironment{bgcolor}[2][]
+  {\newcommand{\@mycolor}{#2}\begin{lrbox}{\@bgcolorbin}\vbox\bgroup}
+  {\egroup\end{lrbox}%
+   \begin{flushleft}%
+   \colorbox{\@mycolor}{\usebox{\@bgcolorbin}}%
+   \end{flushleft}}
+%%% Style sheets macros, defined as no-ops
+\newcommand{\newstyle}[2]{}
+\newcommand{\addstyle}[1]{}
+\newcommand{\setenvclass}[2]{}
+\newcommand{\getenvclass}[1]{}
+\newcommand{\loadcssfile}[1]{}
+\newenvironment{divstyle}[1]{}{}
+\newenvironment{cellstyle}[2]{}{}
+\newif\ifexternalcss
+%%% Postlude
+\makeatother

+ 0 - 1
doc/index.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/index.tex

+ 75 - 0
doc/index.tex

@@ -0,0 +1,75 @@
+\section{MAD: Erlang Containers}
+
+\subsection{Purpose}
+We were trying to make something minimalistic that fits out \footahref{https://github.com/synrc}{application stack}.
+The main idea of mad is to provide clean and simple rebar-like fast dependency manager that
+is able to build several types of packages and provides interface of containered deployments
+to virtualiezed environments.
+
+\subsection{Several Types of Packaging}
+The key feature of mad is ability to create single-file bundled web sites.
+This target escript is ready to run on Windows, Linux and Mac.
+
+\subsection{Deployment Options}
+As a deploy tool mad is also supposed to launch, start, stop and manage containers, locally or remote.
+You can make containers from different type of packages, like making runc container with beam release.
+
+\subsection{OTP Compliant}
+Mad supports ERTS boot files generation with systools and erlang application format used by OTP.
+This is the main format of application repository. Also boot files are suported on both LING and BEAM.
+
+\subsection{Tiny Size}
+And the good part:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+                      Sources        Binary
+    mad               967 LOC        52 KB
+    rebar             7717 LOC       181 KB
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\subsection{History}
+
+We came to conclusion that no matter how perfect your libraries are,
+the comfort and ease come mostly from developing tools.
+Everything got started when \footahref{https://github.com/proger}{Vladimir~Kirillov} decided to
+replace Rusty's sync beam reloader. As you know sync uses
+filesystem polling which is neither energy-efficient nor elegant. Also
+sync is only able to recompile separate modules while
+common use-case in N2O is to recompile DTL templates
+and LESS/SCSS stylesheets. That is why we need to recompile
+the whole project. That's the story how \footahref{https://github.com/synrc/active}{active} emerged.
+Under the hood active is a client subscriber
+of \footahref{https://github.com/synrc/fs}{fs} library, native filesystem listener for Linux, Windows and Mac.
+
+De-facto standard in Erlang world is rebar.
+We love rebar interface despite its implementation.
+First we plugged rebar into active and then decided to drop its support,
+it was slow, especially in cold recompilation.
+It was designed to be a stand-alone tool, so it has some
+glitches while using as embedded library.
+Later we switched to Makefile-based build tool \footahref{https://github.com/synrc/otp.mk}{otp.mk}.
+
+The idea to build rebar replacement was up in the air for a long time.
+The best minimal approach was picked up by \footahref{https://github.com/s1n4}{Sina~Samavati},
+who implemented the first prototype called 'mad'. Initially mad
+was able to compile DTL templates, YECC files, escript (like
+bundled in gproc), also it had support for caching with side-effects.
+In a month I forked mad and took over the development under the same name.
+
+\vspace{1\baselineskip}
+\begin{lstlisting}[caption=Example of building N2O sample]
+                                   Cold       Hot
+    rebar get-deps compile         53.156s    4.714s
+    mad deps compile               54.097s    0.899s
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+\vspace{1\baselineskip}
+\begin{lstlisting}[caption=Example of building Cowboy]
+                                   Hot
+    make (erlang.mk)               2.588s
+    mad compile                    2.521s
+\end{lstlisting}
+\vspace{1\baselineskip}

+ 0 - 1
doc/setup.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/setup.tex

+ 68 - 0
doc/setup.tex

@@ -0,0 +1,68 @@
+\section{Setup}
+
+\subsection{Installing Binary}
+
+Fresh version of mad included as a binary in its primary github repository:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    # curl -fsSL https://raw.github.com/synrc/mad/master/mad > mad \
+              && chmod +x mad \
+              && sudo cp /usr/local/bin
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+Or you may want to add mad to your PATH.
+
+\subsection{Compiling Sources}
+
+If you want you can compile mad by yourself:
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    # git clone http://github.com/synrc/mad \
+             && cd mad \
+             && make
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+Note that mad uses mad to build mad. It's mad.
+
+\subsection{Creating a sample N2O project}
+
+mad also comes with N2O templates. So you can bootstrap a N2O-based site
+just having a single copy of mad binary.
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    # mad app sample
+    # cd sample
+    # mad deps compile release sample
+\end{lstlisting}
+\vspace{1\baselineskip}
+
+After that you can just run escript web\_app under Windows, Linux and
+Mac and open \footahref{http://localhost:8000}{http://localhost:8000}.
+
+\vspace{1\baselineskip}
+\begin{lstlisting}
+    C:\> escript sample
+    Applications: [kernel,stdlib,crypto,cowlib,ranch,
+                   cowboy,compiler,syntax_tools,
+                   erlydtl,gproc,xmerl,n2o,sample,
+                   fs,active,mad,sh]
+    Configuration: [{n2o,[{port,8000},
+                          {route,routes}]},
+                    {kvs,[{dba,store_mnesia},
+                          {schema,[kvs_user,
+                                   kvs_acl,
+                                   kvs_feed,
+                                   kvs_subscription]}]}]
+    Erlang/OTP 17 [erts-6.0] [64-bit] [smp:4:4]
+                  [async-threads:10] [kernel-poll:false]
+
+    Eshell V6.0  (abort with ^G)
+    1>
+\end{lstlisting}
+\vspace{1\baselineskip}
+

+ 0 - 1
doc/synrc.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/synrc.tex

+ 137 - 0
doc/synrc.tex

@@ -0,0 +1,137 @@
+% Copyright (c) 2010 Synrc Research Center
+
+\usepackage{afterpage}
+
+\usepackage{hevea}
+\usepackage[english]{babel}
+\usepackage{palatino}
+\usepackage{graphicx}
+\usepackage{tocloft}
+\usepackage{cite}
+\usepackage[utf8]{inputenc}
+\usepackage{moreverb}
+\usepackage{listings}
+\usepackage[none]{hyphenat}
+\usepackage{caption}
+\usepackage[usenames,dvipsnames]{color}
+\usepackage[top=18mm, bottom=25.4mm,
+            inner=16mm,outer=18mm,
+            paperwidth=142mm, paperheight=200mm]{geometry}
+
+%left=18mm, right=18mm,
+
+% \usepackage[hmarginratio=3:2]{geometry}
+
+\hyphenation{framework nitrogen javascript facebook streaming JavaScript micro-frameworks}
+
+\setlength{\cftsubsecnumwidth}{2.5em}
+
+% include image for HeVeA and LaTeX
+
+\makeatletter
+\def\@seccntformat#1{\llap{\csname the#1\endcsname\hskip0.7em\relax}}
+\makeatother
+
+\newcommand{\includeimage}[2]
+{\ifhevea
+    {\imgsrc{#1}}
+\else{
+    \begin{figure}[h!]
+    \centering
+    \includegraphics[width=\textwidth]{#1}
+    \caption{#2}
+    \end{figure}}
+\fi}
+
+% HeVeA header
+
+{\ifhevea
+  \let\oldmeta=\@meta
+  \renewcommand{\@meta}{%
+  \oldmeta
+  \begin{rawhtml}
+  <meta name="Author" content="Maxim Sokhatsky">
+  <meta http-equiv="expires" content="Tue, 01 Jan 2020 1:00:00 GMT" />
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=IE10,chrome=1" />
+  \end{rawhtml}}
+
+  \htmlhead{\rawhtmlinput{templates/head-hevea.htx}}
+  \htmlfoot{\rawhtmlinput{templates/foot.htx}}
+  \footerfalse
+\fi}
+
+% title page for N2O
+
+\newcommand*{\titleMAD}
+{
+    \begingroup
+   \thispagestyle{empty}
+    \hbox{
+        \hspace*{0.2\textwidth}
+        \rule{1pt}{\textheight}
+        \hspace*{0.05\textwidth}
+        \parbox[b]{0.75\textwidth}
+        {
+            {\noindent\Huge \bfseries MAD}\\[2\baselineskip]
+            {\LARGE \textsc{
+                Small and Fast\\[0.5\baselineskip]
+                Build Tool\\[0.5\baselineskip]
+                for Erlang Apps}}\\[4\baselineskip]
+            \vspace{0.5\textheight}
+%            {\Large \textit{Maxim Sokhatsky}}\\[2\baselineskip]
+%            {\large {\bf {\color{Blue}syn}{\color{OrangeRed}rc} research center}
+%            {\copyright} 2013-2014}\\[1\baselineskip]
+        }
+    }
+    \endgroup
+}
+
+% define images store
+
+\graphicspath{{./images/}}
+
+% start each section from new page
+
+\let\stdsection\section
+\renewcommand\section{\newpage\stdsection}
+
+% define style for code listings
+
+\lstset{
+    backgroundcolor=\color{white},
+    keywordstyle=\color{blue},
+    basicstyle=\bf\ttfamily\footnotesize,
+    columns=fixed}
+
+%\headsep = 0cm
+%\voffset = -1.5cm
+%\hoffset = -0.7cm
+%\topmargin = 0cm
+%\textwidth = 12cm
+%\textheight = 17.5cm
+%\footskip = 1cm
+%\parindent = 0cm
+
+\hyphenpenalty=5000
+  \tolerance=1000
+
+\newenvironment{dedication}
+{
+   \thispagestyle{empty}
+   \cleardoublepage
+   \thispagestyle{empty}
+   \vspace*{\stretch{1}}
+   \hfill\begin{minipage}[t]{0.66\textwidth}
+   \raggedright
+}%
+{
+   \end{minipage}
+   \vspace*{\stretch{3}}
+   \clearpage
+}
+
+\newcommand\blankpage{
+    \null
+    \thispagestyle{empty}
+    \newpage}

+ 0 - 1
doc/web/bundles.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/web/bundles.tex

+ 17 - 0
doc/web/bundles.tex

@@ -0,0 +1,17 @@
+\input{../../../../synrc.hva}
+%HEVEA \loadcssfile{../../../../synrc.css}
+\renewcommand{\images}{http://synrc.com/apps/mad/doc/images}
+\begin{document}
+\title{MAD Bundles}
+\author{Maxim Sokhatsky}
+%HEVEA \begin{divstyle}{nonselectedwrapper}
+%HEVEA \begin{divstyle}{article}
+\input{toc}
+%HEVEA \begin{divstyle}{articlecol}
+\include{../bundles}
+%HEVEA \rawhtmlinput{templates/disqus.htx}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \begin{divstyle}{clear}{~}\end{divstyle}
+\end{document}

+ 0 - 1
doc/web/commands.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/web/commands.tex

+ 17 - 0
doc/web/commands.tex

@@ -0,0 +1,17 @@
+\input{../../../../synrc.hva}
+%HEVEA \loadcssfile{../../../../synrc.css}
+\renewcommand{\images}{http://synrc.com/apps/mad/doc/images}
+\begin{document}
+\title{MAD Commands}
+\author{Maxim Sokhatsky}
+%HEVEA \begin{divstyle}{nonselectedwrapper}
+%HEVEA \begin{divstyle}{article}
+\input{toc}
+%HEVEA \begin{divstyle}{articlecol}
+\include{../commands}
+%HEVEA \rawhtmlinput{templates/disqus.htx}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \begin{divstyle}{clear}{~}\end{divstyle}
+\end{document}

+ 0 - 1
doc/web/config.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/web/config.tex

+ 17 - 0
doc/web/config.tex

@@ -0,0 +1,17 @@
+\input{../../../../synrc.hva}
+%HEVEA \loadcssfile{../../../../synrc.css}
+\renewcommand{\images}{http://synrc.com/apps/mad/doc/images}
+\begin{document}
+\title{MAD Config}
+\author{Maxim Sokhatsky}
+%HEVEA \begin{divstyle}{nonselectedwrapper}
+%HEVEA \begin{divstyle}{article}
+\input{toc}
+%HEVEA \begin{divstyle}{articlecol}
+\include{../config}
+%HEVEA \rawhtmlinput{templates/disqus.htx}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \begin{divstyle}{clear}{~}\end{divstyle}
+\end{document}

+ 0 - 1
doc/web/deps.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/web/deps.tex

+ 17 - 0
doc/web/deps.tex

@@ -0,0 +1,17 @@
+\input{../../../../synrc.hva}
+%HEVEA \loadcssfile{../../../../synrc.css}
+\renewcommand{\images}{http://synrc.com/apps/mad/doc/images}
+\begin{document}
+\title{MAD Deps}
+\author{Maxim Sokhatsky}
+%HEVEA \begin{divstyle}{nonselectedwrapper}
+%HEVEA \begin{divstyle}{article}
+\input{toc}
+%HEVEA \begin{divstyle}{articlecol}
+\include{../deps}
+%HEVEA \rawhtmlinput{templates/disqus.htx}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \begin{divstyle}{clear}{~}\end{divstyle}
+\end{document}

+ 0 - 1
doc/web/index.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/web/index.tex

+ 18 - 0
doc/web/index.tex

@@ -0,0 +1,18 @@
+\input{../../../../synrc.hva}
+%HEVEA \loadcssfile{../../../../synrc.css}
+\renewcommand{\images}{http://synrc.com/apps/mad/doc/images}
+\begin{document}
+\title{MAD}
+\author{Maxim Sokhatsky}
+%HEVEA \begin{divstyle}{nonselectedwrapper}
+%HEVEA \begin{divstyle}{article}
+\input{toc}
+%HEVEA \begin{divstyle}{articlecol}
+\include{../index}
+%HEVEA \rawhtmlinput{templates/mad-comments.htx}
+%HEVEA \rawhtmlinput{templates/disqus.htx}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \begin{divstyle}{clear}{~}\end{divstyle}
+\end{document}

+ 0 - 1
doc/web/setup.tex

@@ -1 +0,0 @@
-/Users/maxim/depot/synrc/mad/doc/web/setup.tex

+ 17 - 0
doc/web/setup.tex

@@ -0,0 +1,17 @@
+\input{../../../../synrc.hva}
+%HEVEA \loadcssfile{../../../../synrc.css}
+\renewcommand{\images}{http://synrc.com/apps/mad/doc/images}
+\begin{document}
+\title{MAD Setup}
+\author{Maxim Sokhatsky}
+%HEVEA \begin{divstyle}{nonselectedwrapper}
+%HEVEA \begin{divstyle}{article}
+\input{toc}
+%HEVEA \begin{divstyle}{articlecol}
+\include{../setup}
+%HEVEA \rawhtmlinput{templates/disqus.htx}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \end{divstyle}
+%HEVEA \begin{divstyle}{clear}{~}\end{divstyle}
+\end{document}