Compiling ipsec-tools-0.7 in RedHat EL 4

Stock ipsec-tools v0.7 does not build in RedHat EL 4:

Making all in racoon
make[3]: Entering directory `/home/octeon/src/ipsec-tools-0.7/src/racoon’
if gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I./../libipsec -D_GNU_SOURCE -include ./src/include-glibc/glibc-bugs.h -I./src/include-glibc -I./src/include-glibc -I./../../src/racoon/missing -D_GNU_SOURCE -include ../../src/include-glibc/glibc-bugs.h -I../../src/include-glibc -I../../src/include-glibc -DSYSCONFDIR=\”/usr/local/etc\” -DADMINPORTDIR=\”/usr/local/var/racoon\” -g -O2 -Wall -Werror -Wno-unused -MT isakmp.o -MD -MP -MF “.deps/isakmp.Tpo” -c -o isakmp.o isakmp.c; \
then mv -f “.deps/isakmp.Tpo” “.deps/isakmp.Po”; else rm -f “.deps/isakmp.Tpo”; exit 1; fi
In file included from ../../src/include-glibc/linux/ip.h:26,
from isakmp.c:115:
/usr/include/asm/byteorder.h:6:2: #warning using private kernel header; include <endian.h> instead!
In file included from /usr/include/asm/byteorder.h:35,
from ../../src/include-glibc/linux/ip.h:26,
from isakmp.c:115:
../../src/include-glibc/linux/byteorder/little_endian.h:43: error: syntax error before “__cpu_to_le64p”
../../src/include-glibc/linux/byteorder/little_endian.h: In function `__cpu_to_le64p’:
../../src/include-glibc/linux/byteorder/little_endian.h:45: error: `__le64′ undeclared (first use in this function)

…and so on.
/usr/include/asm/byteorder.h really is a private kernel header in this distro. Does not look like a feature – at least it is fixed in RHEL 5!. But what if I can’t upgrade right now. Here is a really dirty fix to src/include-glibc/linux/ip.h in the ipsec-tools source tree (and it is a symlink to real kernel header, so make a backup), assuming that you are on little-endian machine. Replace the line #include <asm/byteorder.h> with #define __LITTLE_ENDIAN_BITFIELD.
Or, not to forget about the change when you stump into problems with this pernicious hack:

/* Uncomment the next line to compile ipsec-tools-0.7 */
/* #define WE_COMPILE_IPSEC_TOOLS */

#ifdef WE_COMPILE_IPSEC_TOOLS
#define __LITTLE_ENDIAN_BITFIELD
#else
#include <asm/byteorder.h>
#endif /* WE_COMPILE_IPSEC_TOOLS */

I wish I knew if there is a better way to fix this – short of upgrading to RHEL 5.

Leave a Reply

Your email address will not be published. Required fields are marked *