Postfix port fails with NO_RELAY_AGENT undeclared

Build system: FreeBSD 6.1, ports updated from cvs 07 october 2006. For some weird reason mail/postfix port build with default options (PCRE selected in make config) fails with:

trace.c:118: error: `NO_RELAY_AGENT' undeclared (first use in this function)

cc -DHAS_PCRE -I/usr/local/include -O2 -fno-strict-aliasing -pipe -I. -I../../include -DFREEBSD6 -c trace.c
trace.c: In function `trace_append':
trace.c:118: error: `NO_RELAY_AGENT' undeclared (first use in this function)
trace.c:118: error: (Each undeclared identifier is reported only once
trace.c:118: error: for each function it appears in.)
trace.c:124: error: `BOUNCE_CMD_APPEND' undeclared (first use in this function)
trace.c:133: error: `DEL_REQ_FLAG_USR_VRFY' undeclared (first use in this function)
trace.c: In function `trace_flush':
trace.c:148: error: `BOUNCE_CMD_TRACE' undeclared (first use in this function)
*** Error code 1

Stop in /home/obj/usr/ports/mail/postfix/work/postfix-2.3.3/src/global.
*** Error code 1

Stop in /home/obj/usr/ports/mail/postfix/work/postfix-2.3.3.
*** Error code 1

Stop in /usr/ports/mail/postfix.
*** Error code 1
However, it builds fine with PCRE disabled (actually all options cleared in make config). Looking at the build process you can see, that when PCRE is enabled (or some other options, like LDAP), make includes compiler option "-I/usr/local/include" and in this path there is a trace.h, an include file with the same name as in postfix sources:
14:07@zaibas:postfix-2.3.3# v /usr/local/include/trace.h
-r--r--r--  1 root  wheel  312 Sep 21  2003 /usr/local/include/trace.h

14:07@zaibas:postfix-2.3.3# v src/global/trace.h
-rw-r--r--  1 root  wheel  712 Nov  1  2005 src/global/trace.h
Turns out that trace.h in /usr/local/include comes from another port science/hdf:
14:13@zaibas:postfix-2.3.3# pkg_info -L hdf-4.1r5|grep trace.h
/usr/local/include/trace.h
Two solutions from here:
  • upgrade science/hdf port to latest version (it has no trace.h in /usr/local/include anymore in version hdf-4.2r1_1)
     
  • or if required to keep the existing hdf port, then use attached small patch to fix postfix build process (it renames -I/usr/local/include to -isystem /usr/local/include which tells compiler to reorder include files, and first take -I files, then -isystem files.
AttachmentSize
patch-makedefs2313 bytes