This document describes how to build a completely self-contained, statically linked "althttpd" binary for Linux (or similar unix-like operating systems).
What You Need
- The
althttpd.c
source code file from this website. - A tarball of the latest OpenSSL release.
- The usual unix build tools, "make", "gcc", and friends.
- The OpenSSL build requires Perl.
Build Steps
- Compiling a static OpenSSL library.
- Unpack the OpenSSL tarball. Rename the top-level directory to "openssl".
- CD into the openssl directory.
- Run these commands:
./config no-ssl3 no-weak-ssl-ciphers no-shared no-threads --openssldir=/usr/lib/ssl CFLAGS=-Os make -e
- Fix a cup of tea while OpenSSL builds....
- Compiling
althttpd
- CD back up into the top-level directory where the
althttpd.c
source file lives. - Run:
gcc -I./openssl/include -Os -Wall -Wextra -DENABLE_TLS \ -o althttpd althttpd.c -L./openssl -lssl -lcrypto -ldl
- The command in the previous bullet builds a binary that is statically
linked against OpenSSL, but is still dynamically linked against
system libraries. To make the binary completely static, add the
-static
option. - To the
gcc
command above, you may optionally add-DALTHTTPD_VERSION='...'
where the quoted text is the version number of althttpd that will be reported to CGI scripts.
- CD back up into the top-level directory where the
Using The Binary
The above is all you need to do. After compiling, simply move the resulting binary into the /usr/bin directory of your server.