Make world

From Segfault
Jump to navigation Jump to search

CFLAGS

If possible, try to add some hardening flags becore compiling:

export   CFLAGS="-g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fpie -Wl,-z,defs -Wl,-z,now -Wl,-z,relro"
export CXXFLAGS="${CFLAGS}"
export CPPFLAGS="-D_FORTIFY_SOURCE=2"
export  LDFLAGS="-Wl,-z,relro,-z,now,-z,noexecstack -fPIC -fPIE"

cURL

Building cURL is pretty straightforward:

sudo apt-get install autoconf automake libtool libssl-dev zlib1g-dev
git clone https://github.com/bagder/curl.git curl-git
cd curl-git
./buildconf && ./configure --prefix=/opt/curl && make
sudo make install

Building it statically requires some more options:

LDFLAGS="-static" PKG_CONFIG="pkg-config --static" \
 ./configure --disable-shared --enable-static && make curl_LDFLAGS="-all-static"

cryptsetup

Check out cryptsetup:

git clone https://code.google.com/p/cryptsetup/ cryptsetup-git
cd cryptsetup-git

sudo yum install autoconf automake gettext-devel libtool pkgconfig libgcrypt-devel libuuid-devel device-mapper-devel popt-devel
./autogen.sh --prefix=/opt/cryptsetup
make && sudo make install

DVD::RIP

sudo apt-get install libevent-execflow-perl anyevent-perl libevent-rpc-perl \
                      libevent-perl libintl-xs-perl libintl-perl
cvs -z3 -d :pserver:cvs@cvs.exit1.org:/cvs login
cvs -z3 -d :pserver:cvs@cvs.exit1.org:/cvs checkout dvdrip
cd dvdrip
perl Makefile.PL
make test
sudo make install

Encoder

MJPEG

Dunno when we're gonna need this one, but for the sake of completeness:

cvs -d:pserver:anonymous@mjpeg.cvs.sourceforge.net:/cvsroot/mjpeg login
cvs -z3 -d:pserver:anonymous@mjpeg.cvs.sourceforge.net:/cvsroot/mjpeg co -P mjpeg_play
./autogen.sh
./configure --prefix=/opt/mjpeg --enable-simd-accel
make
sudo make install

TwoLAME

sudo apt-get install libsndfile1-dev
git clone git://github.com/njh/twolame.git twolame-git
cd twolame-git
./autogen.sh
./configure --prefix=/opt/twolame
make
sudo make install

Transcode

sudo apt-get install libdvdread-dev libmpeg2-4-dev libao-dev libavifile-0.7-dev ogmtools \
                     libbz2-dev liblzo-dev libmpeg3-dev libpostproc-dev libquicktime-dev \
                     libmagick9-dev libtheora-dev libvorbis-dev libogg-dev libxml2-dev \
                     libavcodec-dev liba52-dev libjpeg-dev
cvs -z3 -d :pserver:cvs@cvs.exit1.org:/cvstc login
cvs -z3 -d :pserver:cvs@cvs.exit1.org:/cvstc co -r HEAD transcode
./autogen.sh
./configure --prefix=/opt/transcode --enable-ogg --enable-theora --enable-vorbis --enable-lame \
            --with-lame-prefix=/opt/lame --enable-libdvdread --enable-libmpeg2 --enable-libavcodec \
            --disable-libjpeg --disable-lzo --disable-libquicktime
make
sudo make install

Xvid

 wget http://downloads.xvid.org/downloads/xvid_latest.tar.gz -O - | tar -xzf -
 cd xvid_*/xvidcore/build/generic
 ./bootstrap.sh
 ./configure --prefix=/opt/xvid
 make
 sudo make install

This is a good time to check/adjust LIBRARY_PATH:

 export LIBRARY_PATH=$LIBRARY_PATH:/opt/lame/lib:/opt/xvid/lib

or edit ld.so.conf:

$ cat /etc/ld.so.conf.d/opt.conf
/opt/lame/lib
/opt/xvid/lib

Kernel

Install prerequisites:

apt install ...                                                                              # ?
dnf install make flex bison perl-Getopt-Long  elfutils-libelf-devel openssl-devel rpm-build

Clone the kernel source:

git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-git
cd $_
make -j4 O=$DIR help

...and continue as needed.

Mutt on Solaris

Prerequisites:

 hg clone http://dev.mutt.org/hg/mutt
 export LDFLAGS=-L$HOME/opt/gdbm/lib
 export CPPFLAGS="-I$HOME/opt/gdbm/include -I$HOME/opt/iconv/include"
 ./configure --prefix=$HOME/opt/mutt --enable-hcache --enable-imap --with-ssl=$HOME/opt/openssl
 make && make install

However, mutt wouldn't start after the build was complete, `libgdbm.so.3` was not found. Being too lazy to fiddle out the *right* configure settings, I just set an alias for mutt:

 alias mutt='LD_LIBRARY_PATH=$HOME/opt/gdbm/lib $HOME/opt/mutt/bin/mutt'

GNU/parted

sudo apt-get install gettext cvs libtool curl automake autoconf uuid-dev libreadline-dev texinfo
git clone http://git.debian.org/git/parted/parted.git
cd parted
./bootstrap
./configure --prefix=/opt/parted --enable-fs && make
sudo make install

PHP

Stable releases can be downloaded from php.net. Development release can be checked out via Git:

git clone https://github.com/php/php-src.git php-src-git
cd $_

Note: Use --includedir as shown below only if you're only copying' the resulting libphp5.so to the Apache directory. For a full-blown PHP5-installation you should set --prefix instead of --includedir.

./configure --with-apxs2=/usr/bin/apxs2 --includedir=/usr/share/php \
            --with-openssl --with-mysql --with-gd --with-ldap --with-zlib-dir=/usr/include
make
sudo make install

Mcrypt

If the php-pecl-mcrypt is not available from the package manager, we can install it manually.

macOS

Although deprecated[1], many applications still use the mcrypt extension. Here's how to install the extension with an already existing PHP installation:

port install libmcrypt                                                                  # for MacPorts
brew install mcrypt                                                                     # for Homebrew

Check the locally installed PHP version:

$ php -v | head -1
PHP 5.5.38 (cli) (built: Oct 29 2017 20:49:07) 

...and checkout the source package of the same version:

curl -OL https://github.com/php/php-src/archive/php-5.5.38.tar.gz
tar -xzf php*.tar.gz php-src-php*/ext/mcrypt/
cd php-src-php*/ext/mcrypt/
phpize
./configure --with-mcrypt=/usr/local/include/                                           # Where mcrypt.h is located
make && make test
sudo install -m0755 -o root -g wheel modules/mcrypt.so /usr/local/lib/

Now PHP can be started with the mcrypt extension:

php -d extension=/usr/local/lib/mcrypt.so  -S localhost:8080 -t /var/www

Linux

On Linux we may have PEAR installed:

sudo dnf install php-devel php-pear libmcrypt-devel gcc
sudo apt install php-dev   php-pear libmcrypt-dev   gcc

With that we can install mcrypt:

sudo pear config-set temp_dir /var/tmp                                                  # Needed if /tmp is mounted with noexec[2]
sudo pecl install channel://pecl.php.net/mcrypt-1.0.4

Or, with some hardening options set:

sudo CFLAGS="-g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fpie -Wl,-z,now -Wl,-z,relro" \
     LDFLAGS="-Wl,-z,relro,-z,now,-z,noexecstack -fPIC -fPIE" \
     pecl install channel://pecl.php.net/mcrypt-1.0.4

With that, mcrypt should already be installed:

$ php -i | grep -m1 ^extension_dir
extension_dir => /usr/lib/php/20190902 => /usr/lib/php/20190902

$ ldd /usr/lib/php/20190902/mcrypt.so 
       linux-vdso.so.1 (0x00007ffee8159000)
       libmcrypt.so.4 => /usr/lib/libmcrypt.so.4 (0x00007f9f62d30000)
       libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9f62b6b000)
       /lib64/ld-linux-x86-64.so.2 (0x00007f9f62d7c000)

We could also install directly from source:

wget --content-disposition https://pecl.php.net/get/mcrypt                              # curl -O --remote-header-name should have the same effect.
tar -xzf mcrypt*.tgz && cd mcrypt*/
phpize && ./configure --with-php-config=/usr/bin/php-config && make

Install with:

$ grep ^EXTENSION_DIR Makefile
EXTENSION_DIR = /usr/lib/php/20180731

$ sudo make install

APC

APC appears to be discontinued[3] and has been superseded by APCu.

Get the stable version via:

wget --content-disposition https://pecl.php.net/get/APCu                         # curl -O --remote-header-name should have the same effect.

Or check out the development version:

git clone https://github.com/krakjoe/apcu.git apcu-git
cd $_

phpize
./configure --enable-apc --enable-apc-mmap --with-php-config=/usr/bin/php-config5

Install:

$ grep ^EXTENSION_DIR Makefile
EXTENSION_DIR = /usr/lib/php5/20060613

$ make && sudo make install

eAccelerator

Checkout eAccelerator from its Git repository: -- The project appears to be have been discontinued.

git clone https://github.com/eaccelerator/eaccelerator.git eaccelerator-git
cd $_

phpize
./configure -enable-eaccelerator=shared --with-php-config=/usr/bin/php-config5

Install:

$ grep ^EXTENSION_DIR Makefile
EXTENSION_DIR = /usr/lib/php5/20060613

$ make && sudo make install

pixz

sudo dnf install autoconf automake libarchive-devel xz-devel

git clone https://github.com/vasi/pixz.git pixz-git
cd pixz-git

./autogen.sh && A2X=/bin/true ./configure
make -ki 
sudo install -o root -g root -v src/pixz /usr/local/bin/pixz

QEMU

 cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/qemu co qemu
 cd qemu
 mkdir .tmp
 TMPDIR=.tmp ./configure --prefix=/opt/qemu --enable-system --enable-linux-user --disable-gfx-check \
                         --target-list=i386-linux-user,sparc-linux-user,ppc-linux-user,i386-softmmu,\
                                       ppc-softmmu,sparc-softmmu
 make
 sudo make install

SHC

shc is a shell compiler[4]. Unfortunately it has been removed[5] from the Debian archive. So let's compile it from source:

wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9.tgz
tar -xzf shc-3.8.9.tgz 
cd shc-3.8.9
make
sudo mkdir -p /usr/local/man/man1/
sudo make install

Let's try:

$ cat test.ksh 
#!/usr/bin/ksh
echo "hello world"

$ shc -f test.ksh 
$ file test.ksh* | cut -c-80
test.ksh:     a /usr/bin/ksh script, ASCII text executable
test.ksh.x:   ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically l
test.ksh.x.c: C source, ASCII text

$ ./test.ksh.x 
hello world

Yay :-)

The expiration date feature is nice too:

$ shc -e 01/01/1970 -m "Bababui bababui!" -f test.ksh 
$ ./test.ksh.x 
./test.ksh.x: has expired!
Bababui bababui!

ssldump

ssldump hasn't seen an update in years, but may still come in handy:

sudo apt-get install libpcap0.8-dev                        # Debian, Ubuntu

cvs -d:pserver:anonymous@ssldump.cvs.sourceforge.net:/cvsroot/ssldump login
cvs -z3 -d:pserver:anonymous@ssldump.cvs.sourceforge.net:/cvsroot/ssldump co -P ssldump
mv ssldump ssldump-cvs
cd ssldump-cvs

Even for a x86-64 host, we have to configure for i686:

./configure --prefix=/opt/ssldump --with-pcap-lib=/usr/lib/x86_64-linux-gnu i686-linux-gnu
make && sudo make install

Note: try to pass e.g. CFLAGS="-g3" to gcc, just in case ssldump dumps core :-\

UNFS3

The Userspace NFSv3 server.

apt-get install cvs autoconf libc6-dev bison flex
cvs -d:pserver:anonymous@cvs.lysator.liu.se:/cvsroot/unfs3 login          # Press ENTER
cvs -d:pserver:anonymous@cvs.lysator.liu.se:/cvsroot/unfs3 co unfs3

./bootstrap
./configure --prefix=/opt/unfs3
make
sudo make install

ViM on Solaris

hg clone https://vim.googlecode.com/hg/ vim
cd vim
./configure --prefix=/opt/vim
make && make install

...should be the easy part. Now ViM is "Vi Enhanced" and thus has syntax and color support:

  • Add "syntax on" to your ~/.vimrc to enable syntax highlighting.
  • To enable color-support, a few more steps must be taken:
export TERM=xterm               # our terminal supports colors
export TERMINFO=$HOME/.terminfo # where to find the TERM definitions (see below)

Now ViM should start with color support.

The terminfo definitions can be downloaded from Fefe. When your Xterm background is dark (say, black), you might want to "set background=dark" in your ~/.vimrc.

Webinject

Webinject is missing a README, so let's cobble something together:

git clone https://github.com/sni/Webinject webinject-git
cd webinject-git/Webinject

sudo dnf install perl-Module-Install    perl-Module-Install-ReadmeFromPod    perl-libwww-perl perl-LWP-Protocol-https perl-XML-Simple    perl-XML-Parser     # Fedora
sudo apt install libmodule-install-perl libmodule-install-readmefrompod-perl libwww-perl liblwp-protocol-https-perl   libxml-simple-perl libxml-parser-perl  # Debian
cpan install Module::Install Module::Install::ReadmeFromPod                                                                                                  # System agnostic

perl Makefile.PL
make
sudo make install

Wordcloud

Build a wordcloud generator:

git clone https://github.com/amueller/word_cloud.git word_cloud-git
cd $_

sudo apt-get install libfreetype6-dev libpng-dev python-numpy libagg-dev libqhull-dev

export PYTHONPATH=$HOME/opt/lib/python2.7/site-packages
mkdir -p "$PYTHONPATH"

python setup.py install --prefix=$HOME/opt

Xar

xar, the "eXtensible ARchiver" is often used in MacOS X to extract disk images.

sudo apt-get install gcc make libssl-dev libxml2-dev                         # Debian

git clone git://github.com/mackyle/xar xar-git                               # May not work without patching configure.ac[6]
cd xar-git/xar
./autogen.sh --prefix=/opt/xar
make && sudo make install

Xgas

One of these old X11 programs that were moved to contrib/ once but now resides in unsupported. So, to download and compile this thing:

mkdir xgas && cd $_
wget --mirror --no-parent --no-directories https://www.x.org/releases/unsupported/programs/xgas/
rm -f index.html*

We need to create a Makefile[7] from the Imakefile[8] first:

$ TMPDIR=`pwd` xmkmf 
imake -DUseInstalled -I/usr/lib/X11/config

$ make
$ sudo install -m 0755 -o root -g root ./xgas /usr/local/games/xgas
$ sudo make install.man MANPATH=/usr/local/share/man

Now xgas should be installed and ready to use:

$ ldd `which xgas`
       linux-vdso.so.1 (0x00007ffd587fc000)
       libXaw.so.7 => /usr/lib/x86_64-linux-gnu/libXaw.so.7 (0x00007fbd433c4000)
       libXmu.so.6 => /usr/lib/x86_64-linux-gnu/libXmu.so.6 (0x00007fbd431ab000)
       libXt.so.6 => /usr/lib/x86_64-linux-gnu/libXt.so.6 (0x00007fbd42f41000)
       libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007fbd42d39000)
       libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007fbd42b1c000)
       libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fbd42909000)
       libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fbd425c6000)
       libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbd422c5000)
       libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbd41f19000)
       libXpm.so.4 => /usr/lib/x86_64-linux-gnu/libXpm.so.4 (0x00007fbd41d07000)
       libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fbd41b02000)
       libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fbd418df000)
       libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fbd416db000)
       /lib64/ld-linux-x86-64.so.2 (0x0000562182018000)
       libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fbd414d6000)
       libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fbd412d1000)

Note: not every distribution will be able to provide all needed development headers and we may have to get those from a Debian system instead:

apt-get download libxt-dev libx11-dev x11proto-core-dev libxaw7-dev libxmu-headers libsm-dev libice-dev libxext-dev libxaw7 libxmu-dev libxmu6 libxcb1
for p in *deb; do dpkg -x $p x; done

Transfer the x directory to the development machine and try:

$ make CFLAGS="-I${PWD}/x/usr/include/" USRLIBDIR="${PWD}/x/usr/lib/x86_64-linux-gnu/"
rm -f xgas
gcc -o xgas -O2 -fno-strength-reduce -fno-strict-aliasing      -L/usr/local/src/xgas/x/usr/lib/x86_64-linux-gnu/ \
  main.o dynamics.o chamber.o timestep.o molecule.o util.o help.o Gas.o doc.o quick.o man.o \
  -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 -lXt -lSM -lICE -lXext -lX11   -lm   
/usr/bin/ld: /usr/local/src/xgas/x/usr/lib/x86_64-linux-gnu//libX11.a(OpenDis.o): undefined reference to symbol 'xcb_get_setup'
/usr/lib64/libxcb.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:1053: xgas] Error 1

Almost :-\

Xine

Pre-requisites:

sudo apt-get install xorg-dev libaa1-dev libcaca-dev libflac-dev libmng-dev libogg-dev libtheora-dev \
                     libvorbis-dev libc6-dev-i386 g++ libcurl3-openssl-dev libpng12-dev libreadline-dev \
                     libtool autoconf autotools-dev automake1.9

First we have to compile xine-lib (migrated to Mercurial recently)

hg clone http://hg.debian.org/hg/xine-lib/xine-lib/
cd xine-lib
hg update
./autogen.sh
./configure --prefix=/opt/xine --enable-altivec --enable-vidix --enable-a52dec --enable-mad \
            --enable-musepack --enable-asf --enable-faad --enable-aalib --with-caca --with-vorbis \
            --with-theora --with-alsa
make
sudo make install

Now we go on to compile xine-ui:

cd ../
cvs -z3 -d:pserver:anonymous@xine.cvs.sourceforge.net:/cvsroot/xine co -P xine-ui
cd xine-ui
cvs update
export PKG_CONFIG_PATH="/opt/xine/lib/pkgconfig"
export CFLAGS="-I/opt/xine/include"
export LDFLAGS="-L/opt/xine/lib"
./autogen.sh
./configure --prefix=/opt/xine --with-caca --with-aalib
make
sudo make install

Zulip

Zulip is some kind of chat client. Don't ask. But if you have to build it, here is how:

sudo apt-get install cmake libqjson-dev qt4-qmake libqt4-dev libqtwebkit-dev libphonon-dev phonon-backend-gstreamer 

git clone https://github.com/zulip/zulip-desktop.git zulip-desktop-git
mkdir zulip-desktop-git/build && cd $_
cmake ..
make
sudo make install DESTDIR=/opt/zulip                                  # Adjust DESTDIR[9] accordingly

Start with:

LD_LIBRARY_PATH=/opt/zulip/usr/local/lib /opt/zulip/usr/local/bin/zulip --site https://zulip.example.org

References