[Xorp-hackers] [PATCH] xorp: rtrmgr: Fix compiling of lex and yacc on BSD OSs
igorm at etf.rs
igorm at etf.rs
Wed Mar 14 03:01:40 PDT 2012
From: Igor Maravic <igorm at etf.rs>
On BSD bison generates header files with .h suffix.
On other OSs it generates header files with .hh suffix.
Check which OS we use and include appropriate files.
Signed-off-by: Igor Maravic <igorm at etf.rs>
---
xorp/SConstruct | 3 +++
xorp/rtrmgr/SConscript | 9 +++++++--
xorp/rtrmgr/boot.ll | 5 +++++
xorp/rtrmgr/op_commands.ll | 5 +++++
xorp/rtrmgr/template.ll | 5 +++++
5 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/xorp/SConstruct b/xorp/SConstruct
index b60ab6a..7e6c7fd 100644
--- a/xorp/SConstruct
+++ b/xorp/SConstruct
@@ -632,6 +632,9 @@ if not env.GetOption('clean') and \
osname = sys.platform.upper()
conf.Define('HOST_OS_NAME', '"' + osname + '"')
+ #export osname - needed for lex and yacc
+ env['osname'] = osname
+
# toolchain
conf.Define('CPP_SUPPORTS_C99_VA_ARGS')
conf.Define('CPP_SUPPORTS_GNU_VA_ARGS')
diff --git a/xorp/rtrmgr/SConscript b/xorp/rtrmgr/SConscript
index ebe930c..7dccf32 100644
--- a/xorp/rtrmgr/SConscript
+++ b/xorp/rtrmgr/SConscript
@@ -55,9 +55,14 @@ libxorp_rtrmgr_env = env.Clone()
#Create yacc files
yacc_env = env.Clone()
-yacc_env.Replace(YACCHXXFILESUFFIX='.hh')
-yacc_env.AppendUnique(YACCFLAGS='-d')
+# bison on BSD generates headers files with .h suffix,
+# while on other OSs it generates header files with .hh suffix
+if (env['osname'] == "FreeBSD" or env['osname'] == "NetBSD"):
+ yacc_env.Replace(YACCHXXFILESUFFIX='.h')
+else:
+ yacc_env.Replace(YACCHXXFILESUFFIX='.hh')
+yacc_env.AppendUnique(YACCFLAGS='-d')
tplt_env_y = yacc_env.Clone()
tplt_env_y.AppendUnique(YACCFLAGS='-ptplt')
diff --git a/xorp/rtrmgr/boot.ll b/xorp/rtrmgr/boot.ll
index 3e639ef..d2a4064 100644
--- a/xorp/rtrmgr/boot.ll
+++ b/xorp/rtrmgr/boot.ll
@@ -12,7 +12,12 @@
#define YYSTYPE char*
#include "libxorp/xorp.h"
+
+#if defined(HOST_OS_FREEBSD) || defined(HOST_OS_NETBSD)
+#include "y.boot_tab.h"
+#else
#include "y.boot_tab.hh"
+#endif
#ifdef __xorp_unused
#define __unused __xorp_unused
diff --git a/xorp/rtrmgr/op_commands.ll b/xorp/rtrmgr/op_commands.ll
index 765cf6c..65b917a 100644
--- a/xorp/rtrmgr/op_commands.ll
+++ b/xorp/rtrmgr/op_commands.ll
@@ -12,7 +12,12 @@
#define YYSTYPE char*
#include "libxorp/xorp.h"
#include <string.h>
+
+#if defined(HOST_OS_FREEBSD) || defined(HOST_OS_NETBSD)
+#include "y.opcmd_tab.h"
+#else
#include "y.opcmd_tab.hh"
+#endif
#ifdef __xorp_unused
#define __unused __xorp_unused
diff --git a/xorp/rtrmgr/template.ll b/xorp/rtrmgr/template.ll
index fbe3ad7..bf9ca48 100644
--- a/xorp/rtrmgr/template.ll
+++ b/xorp/rtrmgr/template.ll
@@ -11,7 +11,12 @@
#define YYSTYPE char*
#include "libxorp/xorp.h"
+
+#if defined(HOST_OS_FREEBSD) || defined(HOST_OS_NETBSD)
+#include "y.tplt_tab.h"
+#else
#include "y.tplt_tab.hh"
+#endif
#ifdef __xorp_unused
#define __unused __xorp_unused
--
1.7.5.4
More information about the Xorp-hackers
mailing list