Postfix – compilation

MyszaPostfix does not have a configure script, so you need to add proper paths and libraries when you creating Makefiles (make makefiles). I must admit, that Postfix code is one of the least problematic code to compile on differents systems. To make my compilations reproducible, I wrote a script and set proper options for compilation.

#!/bin/sh
#

# for GCC:
#CC=gcc
#CFLAGS="-O2 -mcpu=v9"
#MAKE=gmake
#
# for Sun Studio
CC=cc
CXX=CC
CFLAGS="-fast -xautopar"
CXXFLAGS=$CFLAGS
CPPFLAGS="-I/usr/local/include"
LDFLAGS="-L/usr/local/lib -R/usr/local/lib"
#LDFLAGS="-L/usr/local/lib -R/usr/local/lib -L/usr/ucblib -R/usr/ucblib"
#LIBS=
MAKE=dmake
#DMAKE_MODE=serial

export CC CFLAGS CPPFLAGS MAKE DMAKE_MODE
export CXX CXXFLAGS LDFLAGS LIBS

# $CC -v
$CC -V
set|grep PATH
set|grep FLAGS

KAT="postfix"
VER="2.9.3"

cd $KAT-$VER

tn="n"
echo "============================================="
echo "$MAKE clean [y|n] ?"
read tn
if [ "$tn" = "Y" ] || [ "$tn" = "y" ]; then
  $MAKE distclean || $MAKE realclean || $MAKE clean

  rm -f config.status
  rm -f config.log
fi;

tn="n"
echo "============================================="
echo "$MAKE makefiles [y|n] ?"
read tn
if [ "$tn" = "Y" ] || [ "$tn" = "y" ]; then
	$MAKE makefiles CC="$CC $CFLAGS" CCARGS="-DUSE_SASL_AUTH -DDEF_SASL_SERVER=\"dovecot\" -DHAS_SSL -DUSE_TLS -I/usr/local/ssl/include -DHAS_LDAP -I/usr/local/openldap/include -DHAS_DB -I/usr/local/BerkeleyDB.5.1/include -DHAS_PCRE -I/usr/local/include" AUXLIBS="-R/usr/local/ssl/lib -L/usr/local/ssl/lib -lssl -lcrypto -R/usr/local/openldap/lib -L/usr/local/openldap/lib -lldap -R/usr/local/openldap/lib -L/usr/local/openldap/lib -llber -R/usr/local/BerkeleyDB.5.1/lib -L/usr/local/BerkeleyDB.5.1/lib -ldb -L/usr/local/lib -R/usr/local/lib -lpcre"
fi;

tn="n"
echo "============================================="
echo "$MAKE [y|n] ?"
read tn
if [ "$tn" = "Y" ] || [ "$tn" = "y" ]; then
  $MAKE && echo "Compilation successful"
fi;

After unpacking sources downloaded from Postfix site, I run a script:

./drf_postfix-2.9.3_conf

cc: Sun C 5.10 SunOS_sparc 2009/06/03
usage: cc [ options] files.  Use 'cc -flags' for details
MANPATH=/usr/local/share/man:/usr/local/man:/usr/share/man
PATH=/usr/local/bin:/usr/bin:/usr/ccs/bin
CFLAGS=-fast -xautopar
CPPFLAGS=-I/usr/local/include
CXXFLAGS=-fast -xautopar
LDFLAGS=-L/usr/local/lib -R/usr/local/lib
=============================================
dmake clean [y|n] ?
n
=============================================
dmake makefiles [y|n] ?
y
dmake -f Makefile.in MAKELEVEL= Makefiles
(echo "# Do not edit -- this file documents how Postfix was built for your machine."; /bin/sh makedefs) >makedefs.tmp
set +e; if cmp makedefs.tmp conf/makedefs.out; then rm makedefs.tmp; \
else mv makedefs.tmp conf/makedefs.out; fi >/dev/null 2>/dev/null
set -e; for i in src/util src/global src/dns src/tls src/xsasl src/milter src/master  src/postfix src/fsstone src/smtpstone  src/sendmail src/error src/pickup src/cleanup src/smtpd src/local  src/trivial-rewrite src/qmgr src/oqmgr src/smtp src/bounce  src/pipe src/showq src/postalias src/postcat src/postconf src/postdrop  src/postkick src/postlock src/postlog src/postmap src/postqueue  src/postsuper src/qmqpd src/spawn src/flush src/verify  src/virtual src/proxymap src/anvil src/scache src/discard src/tlsmgr  src/postmulti src/postscreen src/dnsblog src/tlsproxy; do \
 (set -e; echo "[$i]"; cd $i; rm -f Makefile; \
 dmake -f Makefile.in Makefile MAKELEVEL=) || exit 1; \
done;
...

Compilation:

dmake [y|n] ?
y
rm -f libexec/post-install && ln -f conf/post-install libexec/post-install
rm -f libexec/postfix-files && ln -f conf/postfix-files libexec/postfix-files
rm -f libexec/postfix-script && ln -f conf/postfix-script libexec/postfix-script
rm -f libexec/postfix-wrapper && ln -f conf/postfix-wrapper libexec/postfix-wrapper
rm -f libexec/main.cf && ln -f conf/main.cf libexec/main.cf
rm -f libexec/master.cf && ln -f conf/master.cf libexec/master.cf
...

cc -fast -xautopar -DUSE_SASL_AUTH -DDEF_SASL_SERVER="dovecot" -DHAS_SSL -DUSE_TLS -I/usr/local/ssl/include -DHAS_LDAP -I/usr/local/openldap/include -DHAS_DB -I/usr/local/BerkeleyDB.5.1/include -DHAS_PCRE -I/usr/local/include -Dstrcasecmp=fix_strcasecmp 		  -Dstrncasecmp=fix_strncasecmp -g -O -I. -I../../include -DSUNOS5 -o tlsproxy tlsproxy.o tlsproxy_state.o ../../lib/libtls.a ../../lib/libmaster.a ../../lib/libglobal.a  ../../lib/libutil.a -R/usr/local/ssl/lib -L/usr/local/ssl/lib -lssl -lcrypto -R/usr/local/openldap/lib -L/usr/local/openldap/lib -lldap -R/usr/local/openldap/lib -L/usr/local/openldap/lib -llber -R/usr/local/BerkeleyDB.5.1/lib -L/usr/local/BerkeleyDB.5.1/lib -ldb -L/usr/local/lib -R/usr/local/lib -lpcre -lresolv -lsocket -lnsl
cp tlsproxy ../../libexec
Compilation successful

Installation after su root or sudo, but when you already have Postfix installed, you can do make upgrade to the same directory. You can upgrade Postfix without shutting down, but I always do a restart Postfix after upgrade.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.