beatbox-puredata/purest_json/manual/Compilation.html

496 lines
17 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>
Compilation
</title>
<style>
/* Page tweaks */
.preview-page {
margin-top: 64px;
margin-bottom: 21px;
}
/* User-content tweaks */
.timeline-comment-wrapper > .timeline-comment:after,
.timeline-comment-wrapper > .timeline-comment:before {
content: none;
}
/* User-content overrides */
.discussion-timeline.wide {
width: 920px;
}
</style>
<link href="style.css" rel="stylesheet"/>
</head>
<body>
<div class="page">
<div class="preview-page" data-autorefresh-url="" id="preview-page">
<main id="js-repo-pjax-container">
<div class="clearfix new-discussion-timeline container-xl px-3 px-md-4 px-lg-5">
<div class="repository-content">
<div class="clearfix">
<div class="Layout Layout--flowRow-until-md Layout--sidebarPosition-end Layout--sidebarPosition-flowRow-end">
<div class="Layout-main">
<div class="Box md Box--responsive" id="readme">
<div class="Box-header d-flex border-bottom-0 flex-items-center flex-justify-between color-bg-default rounded-top-2">
<div class="d-flex flex-items-center">
<h2 class="Box-title">
Compilation
</h2>
</div>
</div>
<div class="Box-body px-5 pb-5">
<article class="markdown-body entry-content container-lg" id="grip-content">
<p>
Compilation should be working on Linux, Windows with MinGW and Mac OS X. You will need header files of Puredata, as well as
<a href="http://curl.haxx.se/" rel="nofollow">
libcurl
</a>
,
<a href="https://github.com/json-c/json-c">
json-c
</a>
, and
<a href="http://liboauth.sourceforge.net/" rel="nofollow">
liboauth
</a>
.
</p>
<p>
The package build script uses the Makefile template from
<a href="https://github.com/pure-data/pd-lib-builder">
pd-lib-builder
</a>
.
</p>
<p>
To enable multi-instance support, add
<code>
multi=true
</code>
to the make command.
</p>
<p>
If you have gotten the source code from git, you will first have to init the
<a href="http://troydhanson.github.io/uthash/" rel="nofollow">
uthash
</a>
and pd-lib-builder submodule by running
<code>
git submodule update --init
</code>
.
</p>
<p>
OS X and Linux build scripts do not include dependencies in the resulting pd_linux or pd_darwin files. For making a distributable version of the library, there is a collection of bash scripts for the different platforms.
</p>
<p>
The manual is generated from the
<a href="https://github.com/residuum/PuRestJson/wiki">
Github wiki
</a>
. To generate it as well, a copy of the wiki is necessary (get it via
<code>
git clone https://github.com/residuum/PuRestJson.wiki.git
</code>
). The python script is called
<code>
create_manual.py
</code>
and needs
<a href="https://github.com/joeyespo/grip">
grip
</a>
and
<a href="https://pypi.python.org/pypi/BeautifulSoup" rel="nofollow">
BeautifulSoup
</a>
. Install those via
<code>
pip install grip beautifulsoup lxml
</code>
.
</p>
<h2>
<a aria-hidden="true" class="anchor" href="#circle-ci-builds---general-information" id="user-content-circle-ci-builds---general-information">
<span aria-hidden="true" class="octicon octicon-link">
</span>
</a>
Circle CI Builds - General Information
</h2>
<p>
PuREST JSON is configured to build on
<a href="https://app.circleci.com/pipelines/github/residuum/PuRestJson" rel="nofollow">
Circle CI
</a>
. The bash scripts in the folder
<code>
circleci-scripts
</code>
may serve as secondary documentation for building:
</p>
<ul>
<li>
<code>
*/before_install.sh
</code>
sets up the build environment
</li>
<li>
<code>
*/script.sh
</code>
is the command to build the binaries
</li>
<li>
<code>
*/pack.sh
</code>
generates the manual and creates deken packages
</li>
<li>
<code>
upload.sh
</code>
uploads the resulting package to my personal ownCloud instance
</li>
</ul>
<h2>
<a aria-hidden="true" class="anchor" href="#linux" id="user-content-linux">
<span aria-hidden="true" class="octicon octicon-link">
</span>
</a>
Linux
</h2>
<p>
As a guideline, look at the scripts in the
<code>
circleci-scripts/linux-amd64
</code>
folder, as the scripts in forder
<code>
linux-i386
</code>
are used to build 32 bit i386 packages on a 64 bit amd64 system.
</p>
<ol>
<li>
You need build-essentials, header files for puredata, libjson-c, libcurl4, liboauth. If you have Debian or a derivative (e.g. Ubuntu, Linux Mint), you can install the build utils and needed headers with
<code>
apt-get install build-essential puredata-dev libjson-c-dev libcurl4-openssl-dev liboauth-dev
</code>
. If you are not root, prefix the command with
<code>
sudo
</code>
.
</li>
<li>
Drop the sources in a directory and run
<code>
make
</code>
. You will get files with a suffix of pd_linux for each object (json-decode.pd_linux, json-encode.pd_linux, rest.pd_linux, oauth.pd_linux). These are needed to use the library.
</li>
<li>
(optional) To create a distributable version, you have to install patchelf, e.g.
<code>
apt-get install patchelf
</code>
. Run
<code>
bash dependencies/linux.sh *.pdlinux
</code>
. This will copy dependencies to the current folder and rewrite linking information in the files to point to these dependencies.
</li>
</ol>
<h3>
<a aria-hidden="true" class="anchor" href="#building-for-different-architectures" id="user-content-building-for-different-architectures">
<span aria-hidden="true" class="octicon octicon-link">
</span>
</a>
Building for Different Architectures
</h3>
<p>
Building for different architectures is possible. I will outline a way to do it on Debian based systems, e.g. Ubuntu.
</p>
<ol>
<li>
Install debootstrap, e.g. via
<code>
apt-get install debootstrap
</code>
.
</li>
<li>
Set up a directory as the root for your new chroot, e.g. for
<code>
/tmp/buildroot
</code>
on Ubuntu Trusty for i386 with
</li>
</ol>
<pre><code> sudo debootstrap \
--variant=buildd \
--include=build-essential \
--arch=i386 \
trusty /tmp/buildroot http://archive.ubuntu.com/ubuntu/
</code></pre>
<ol start="3">
<li>
Install the basic build system in that directory, and install the necessary dependencies for that architecture e.g. with
</li>
</ol>
<pre><code> echo deb http://archive.ubuntu.com/ubuntu/ \
$DIST restricted universe multiverse \
| sudo tee -a /tmp/buildroot/etc/apt/sources.list
sudo chroot /tmp/buildroot bash -c "apt-get update"
sudo chroot /tmp/buildroot bash -c "apt-get install -qq -y build-essential \
puredata-dev libjson-c-dev libcurl4-nss-dev liboauth-dev"
</code></pre>
<ol start="4">
<li>
Copy the files to a subfolder in the chroot folder, e.g.
<code>
/tmp/buildroot/PuRestJson
</code>
</li>
<li>
Run
<code>
make
</code>
via chroot:
</li>
</ol>
<pre><code> sudo chroot /tmp/buildroot bash -c "cd PuRestJson &amp;&amp; make"
</code></pre>
<ol start="6">
<li>
(optional) To create a distributable version, you have to install patchelf, e.g.
<code>
sudo chroot /tmp/buildroot bash -c "apt-get install patchelf"
</code>
. Run
<code>
sudo chroot ${CHROOTDIR} bash -c "cd PuRestJson &amp;&amp; bash ./dependencies/linux.sh *.pd_linux"
</code>
. This will copy dependencies to the /tmp/buildroot and rewrite linking information in the files to point to these dependencies.
</li>
</ol>
<h2>
<a aria-hidden="true" class="anchor" href="#windows-with-mingw" id="user-content-windows-with-mingw">
<span aria-hidden="true" class="octicon octicon-link">
</span>
</a>
Windows with MinGW
</h2>
<p>
This is possible, but I have given up on it, and only cross-compile the library with MXE.
</p>
<h2>
<a aria-hidden="true" class="anchor" href="#compilation-on-mac-os-x" id="user-content-compilation-on-mac-os-x">
<span aria-hidden="true" class="octicon octicon-link">
</span>
</a>
Compilation on Mac OS X
</h2>
<p>
As a guideline, look at the scripts in the
<code>
circleci-scripts/osx
</code>
folder.
</p>
<ol>
<li>
Install
<a href="https://developer.apple.com/xcode/" rel="nofollow">
XCode
</a>
, and
<a href="http://stackoverflow.com/a/9353468/124983" rel="nofollow">
install the command line tools
</a>
to get
<code>
gcc
</code>
and
<code>
otool
</code>
.
</li>
<li>
Install
<a href="http://brew.sh/" rel="nofollow">
Homebrew
</a>
to later install the dependencies.
</li>
<li>
Install dependencies via Homebrew:
</li>
</ol>
<pre><code> brew update
brew install json-c curl liboauth --universal
</code></pre>
<ol start="4">
<li>
Find the path to Pd.
</li>
<li>
Drop the sources in a directory and run
<code>
make pdincludepath=/path/to/pd/Contents/Resources/src
</code>
</li>
<li>
(optional) You are now able to use the library on a machine, if the dependencies are installed via Homebrew. To move the necessary dylibs to the current directory and change the links of the pd_darwin files, run
<code>
./dependencies/osx.sh
</code>
. This makes the whole folder distributable.
</li>
</ol>
<h2>
<a aria-hidden="true" class="anchor" href="#cross-compilation-for-windows-on-unix-like-systems-linux--bsd--mac-os-x-with-mxe" id="user-content-cross-compilation-for-windows-on-unix-like-systems-linux--bsd--mac-os-x-with-mxe">
<span aria-hidden="true" class="octicon octicon-link">
</span>
</a>
Cross-compilation for Windows on UNIX-like systems (Linux / *BSD / Mac OS X) with MXE
</h2>
<p>
As a guideline, look at the scripts in the
<code>
circleci-scripts/windows32
</code>
folder.
</p>
<ol>
<li>
Get the development version of MXE from
<a href="https://github.com/mxe/mxe">
their Github repository
</a>
and setup MXE, so that the cross compilation tools are in your PATH environmental variable.
</li>
<li>
Build the required libraries by running
<code>
make curl json-c liboauth pthreads
</code>
.
</li>
<li>
Download the Windows version of Pd and unzip it in a folder. You should have the following structure of files:
</li>
</ol>
<pre><code> pd/src/(source files including m_pd.h)
pd/bin/pd.dll
</code></pre>
<ol start="4">
<li>
Run
<code>
make
</code>
with some environmental variables to tell the compiler to use the cross compiler, and where to find the Pd source and pd.dll. Here is an example from my setup:
</li>
</ol>
<pre><code> #!/bin/bash
MXE_DIR=/usr/lib/mxe
MXE_GCC=${MXE_DIR}/usr/bin/i686-w64-mingw32.static-gcc
PD_DIR=/tmp/pd
make \
system=Windows \
machine=i386 \
uname=MINGW \
pdincludepath=${PD_DIR}/src \
pdbinpath=${PD_DIR}/bin \
CC=${MXE_GCC} \
arch.c.flags='-march=pentium4 -msse -msse2 -mfpmath=sse -I \
"/usr/lib/mxe/usr/i686-w64-mingw32.static/include"' \
ldflags='-L "/usr/lib/mxe/usr/i686-w64-mingw32.static/lib"'
</code></pre>
</article>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
<script>
function showCanonicalImages() {
var images = document.getElementsByTagName('img');
if (!images) {
return;
}
for (var index = 0; index < images.length; index++) {
var image = images[index];
if (image.getAttribute('data-canonical-src') && image.src !== image.getAttribute('data-canonical-src')) {
image.src = image.getAttribute('data-canonical-src');
}
}
}
function scrollToHash() {
if (location.hash && !document.querySelector(':target')) {
var element = document.getElementById('user-content-' + location.hash.slice(1));
if (element) {
element.scrollIntoView();
}
}
}
function autorefreshContent(eventSourceUrl) {
var initialTitle = document.title;
var contentElement = document.getElementById('grip-content');
var source = new EventSource(eventSourceUrl);
var isRendering = false;
source.onmessage = function(ev) {
var msg = JSON.parse(ev.data);
if (msg.updating) {
isRendering = true;
document.title = '(Rendering) ' + document.title;
} else {
isRendering = false;
document.title = initialTitle;
contentElement.innerHTML = msg.content;
showCanonicalImages();
}
}
source.onerror = function(e) {
if (e.readyState === EventSource.CLOSED && isRendering) {
isRendering = false;
document.title = initialTitle;
}
}
}
window.onhashchange = function() {
scrollToHash();
}
window.onload = function() {
scrollToHash();
}
showCanonicalImages();
var autorefreshUrl = document.getElementById('preview-page').getAttribute('data-autorefresh-url');
if (autorefreshUrl) {
autorefreshContent(autorefreshUrl);
}
</script>
</body>
</html>