summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2016-04-23 17:37:27 +1000
committerChris Johns <chrisj@rtems.org>2016-04-23 17:37:27 +1000
commite1e10cddee4be72c2a66218c2bc0393e578a7fdc (patch)
treebe28236f336ed07b491020c3ebf3cd0ed08e9373
parentwaf: Move the generated content to libbsd_waf.py. (diff)
downloadrtems-libbsd-e1e10cddee4be72c2a66218c2bc0393e578a7fdc.tar.bz2
waf: Add the ability to set FreeBSD options on the configure command line.
Add --freebsd-options to add specific FreeBSD compile time options to the build. This is a developer tool.
-rw-r--r--README.waf20
-rw-r--r--freebsd/sys/kern/init_main.c5
-rw-r--r--freebsd/sys/sys/systm.h6
-rw-r--r--libbsd_waf.py72
-rwxr-xr-xwaf_generator.py16
-rw-r--r--wscript8
6 files changed, 86 insertions, 41 deletions
diff --git a/README.waf b/README.waf
index 1e806b52..39f078b8 100644
--- a/README.waf
+++ b/README.waf
@@ -106,7 +106,6 @@ Steps
one time with different tool sets or configurations you can easly move
between them safe in the knowledge that one build will not infect another.
-
Updating RTEMS Waf Support
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -136,3 +135,22 @@ versions:
$ git pull
$ cd ..
$ git commit -m "Update rtems_waf" rtems_waf
+
+FreeBSD Developer Support
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The --freebsd-option provides a tool you can set special kernel options. This
+is a developer tool and should only be used if you are familiar with the
+internals of the FreeBSD kernel and what these options do.
+
+The options are listed in:
+
+ https://github.com/freebsd/freebsd/blob/master/sys/conf/NOTES
+
+An example to turn on a verbose kernel boot, verbose sysinit and bus debugging
+configure with:
+
+ --freebsd-options=bootverbose,verbose_sysinit,bus_debug
+
+The LibBSD waf support splits the options and converts them to uppercase and
+adds them -D options on the compiler command line.
diff --git a/freebsd/sys/kern/init_main.c b/freebsd/sys/kern/init_main.c
index 8e65b5f4..7311bb02 100644
--- a/freebsd/sys/kern/init_main.c
+++ b/freebsd/sys/kern/init_main.c
@@ -161,6 +161,11 @@ sysinit_add(struct sysinit **set, struct sysinit **set_end)
newsysinit_end = newset + count;
}
#else /* __rtems__ */
+#ifdef BOOTVERBOSE
+int bootverbose = 1;
+SYSCTL_INT(_debug, OID_AUTO, bootverbose, CTLFLAG_RW, &bootverbose, 0,
+ "Control the output of verbose kernel messages");
+#endif
RWSET_DECLARE(sysinit_set, struct sysinit);
#endif /* __rtems__ */
diff --git a/freebsd/sys/sys/systm.h b/freebsd/sys/sys/systm.h
index 6ac0491d..36b3f59f 100644
--- a/freebsd/sys/sys/systm.h
+++ b/freebsd/sys/sys/systm.h
@@ -73,7 +73,11 @@ extern int boothowto; /* reboot flags, from console subsystem */
#ifndef __rtems__
extern int bootverbose; /* nonzero to print verbose messages */
#else /* __rtems__ */
-#define bootverbose 0 /* XXX RTEMS doesn't support verbose */
+#ifdef BOOTVERBOSE
+extern int bootverbose; /* nonzero to print verbose messages */
+#else
+#define bootverbose 0 /* Remove all verbose code for the standard RTEMS build */
+#endif /* BOOTVERBOSE */
#endif /* __rtems__ */
diff --git a/libbsd_waf.py b/libbsd_waf.py
index 33784ead..689a72c3 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -39,6 +39,11 @@ def build(bld):
cflags = ['-std=gnu11'] + common_flags
cxxflags = ['-std=gnu++11'] + common_flags
+ # Defines
+ defines = []
+ for o in bld.env.FREEBSD_OPTIONS.split(","):
+ defines += ["%s=1" % (o.strip().upper())]
+
# Include paths
includes = []
for i in ['-Irtemsbsd/@CPU@/include', '-Ifreebsd/sys/@CPU@/include']:
@@ -136,18 +141,6 @@ def build(bld):
# Lex
if bld.env.AUTO_REGEN:
- bld(target = "freebsd/lib/libc/net/nslexer.c",
- source = "freebsd/lib/libc/net/nslexer.l",
- rule = "${LEX} -P _nsyy -t ${SRC} | sed -e '/YY_BUF_SIZE/s/16384/1024/' > ${TGT}")
- bld.objects(target = "lex__nsyy",
- features = "c",
- cflags = cflags,
- includes = [] + includes,
- defines = [],
- source = "freebsd/lib/libc/net/nslexer.c")
- libbsd_use += ["lex__nsyy"]
-
- if bld.env.AUTO_REGEN:
bld(target = "freebsd/contrib/libpcap/scanner.c",
source = "freebsd/contrib/libpcap/scanner.l",
rule = "${LEX} -P pcap -t ${SRC} | sed -e '/YY_BUF_SIZE/s/16384/1024/' > ${TGT}")
@@ -155,11 +148,23 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
- defines = ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1', 'NEED_YYPARSE_WRAPPER=1', 'yylval=pcap_lval'],
+ defines = defines + ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1', 'NEED_YYPARSE_WRAPPER=1', 'yylval=pcap_lval'],
source = "freebsd/contrib/libpcap/scanner.c")
libbsd_use += ["lex_pcap"]
if bld.env.AUTO_REGEN:
+ bld(target = "freebsd/lib/libc/net/nslexer.c",
+ source = "freebsd/lib/libc/net/nslexer.l",
+ rule = "${LEX} -P _nsyy -t ${SRC} | sed -e '/YY_BUF_SIZE/s/16384/1024/' > ${TGT}")
+ bld.objects(target = "lex__nsyy",
+ features = "c",
+ cflags = cflags,
+ includes = [] + includes,
+ defines = defines + [],
+ source = "freebsd/lib/libc/net/nslexer.c")
+ libbsd_use += ["lex__nsyy"]
+
+ if bld.env.AUTO_REGEN:
bld(target = "freebsd/lib/libipsec/policy_token.c",
source = "freebsd/lib/libipsec/policy_token.l",
rule = "${LEX} -P __libipsecyy -t ${SRC} | sed -e '/YY_BUF_SIZE/s/16384/1024/' > ${TGT}")
@@ -167,7 +172,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
- defines = [],
+ defines = defines + [],
source = "freebsd/lib/libipsec/policy_token.c")
libbsd_use += ["lex___libipsecyy"]
@@ -180,21 +185,10 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
- defines = ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1', 'NEED_YYPARSE_WRAPPER=1', 'yylval=pcap_lval'],
+ defines = defines + ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1', 'NEED_YYPARSE_WRAPPER=1', 'yylval=pcap_lval'],
source = "freebsd/contrib/libpcap/grammar.c")
libbsd_use += ["yacc_pcap"]
if bld.env.AUTO_REGEN:
- bld(target = "freebsd/lib/libipsec/policy_parse.c",
- source = "freebsd/lib/libipsec/policy_parse.y",
- rule = "${YACC} -b __libipsecyy -d -p __libipsecyy ${SRC} && sed -e '/YY_BUF_SIZE/s/16384/1024/' < __libipsecyy.tab.c > ${TGT} && rm -f __libipsecyy.tab.c && mv __libipsecyy.tab.h freebsd/lib/libipsec/y.tab.h")
- bld.objects(target = "yacc___libipsecyy",
- features = "c",
- cflags = cflags,
- includes = [] + includes,
- defines = [],
- source = "freebsd/lib/libipsec/policy_parse.c")
- libbsd_use += ["yacc___libipsecyy"]
- if bld.env.AUTO_REGEN:
bld(target = "freebsd/lib/libc/net/nsparser.c",
source = "freebsd/lib/libc/net/nsparser.y",
rule = "${YACC} -b _nsyy -d -p _nsyy ${SRC} && sed -e '/YY_BUF_SIZE/s/16384/1024/' < _nsyy.tab.c > ${TGT} && rm -f _nsyy.tab.c && mv _nsyy.tab.h freebsd/lib/libc/net/nsparser.h")
@@ -202,9 +196,20 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
- defines = [],
+ defines = defines + [],
source = "freebsd/lib/libc/net/nsparser.c")
libbsd_use += ["yacc__nsyy"]
+ if bld.env.AUTO_REGEN:
+ bld(target = "freebsd/lib/libipsec/policy_parse.c",
+ source = "freebsd/lib/libipsec/policy_parse.y",
+ rule = "${YACC} -b __libipsecyy -d -p __libipsecyy ${SRC} && sed -e '/YY_BUF_SIZE/s/16384/1024/' < __libipsecyy.tab.c > ${TGT} && rm -f __libipsecyy.tab.c && mv __libipsecyy.tab.h freebsd/lib/libipsec/y.tab.h")
+ bld.objects(target = "yacc___libipsecyy",
+ features = "c",
+ cflags = cflags,
+ includes = [] + includes,
+ defines = defines + [],
+ source = "freebsd/lib/libipsec/policy_parse.c")
+ libbsd_use += ["yacc___libipsecyy"]
# Objects built with different CFLAGS
objs01_source = ['freebsd/bin/hostname/hostname.c',
@@ -349,7 +354,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
- defines = ['INET6'],
+ defines = defines + ['INET6'],
source = objs01_source)
libbsd_use += ["objs01"]
@@ -358,7 +363,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
- defines = ['NO_SSL', 'NO_POPEN', 'NO_CGI', 'USE_WEBSOCKET'],
+ defines = defines + ['NO_SSL', 'NO_POPEN', 'NO_CGI', 'USE_WEBSOCKET'],
source = objs02_source)
libbsd_use += ["objs02"]
@@ -390,7 +395,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
- defines = ['__DBINTERFACE_PRIVATE', 'INET6'],
+ defines = defines + ['__DBINTERFACE_PRIVATE', 'INET6'],
source = objs03_source)
libbsd_use += ["objs03"]
@@ -420,7 +425,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
- defines = ['__FreeBSD__', 'THERE_IS_NO_FORK', 'MASTER_ONLY', 'INET', 'INET6'],
+ defines = defines + ['__FreeBSD__', 'THERE_IS_NO_FORK', 'MASTER_ONLY', 'INET', 'INET6'],
source = objs04_source)
libbsd_use += ["objs04"]
@@ -441,7 +446,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
- defines = ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1'],
+ defines = defines + ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1'],
source = objs05_source)
libbsd_use += ["objs05"]
@@ -592,7 +597,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = ['freebsd/contrib/tcpdump', 'freebsd/usr.sbin/tcpdump/tcpdump'] + includes,
- defines = ['__FreeBSD__=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_CONFIG_H=1', 'HAVE_NET_PFVAR_H=1'],
+ defines = defines + ['__FreeBSD__=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_CONFIG_H=1', 'HAVE_NET_PFVAR_H=1'],
source = objs06_source)
libbsd_use += ["objs06"]
@@ -1066,6 +1071,7 @@ def build(bld):
cflags = cflags,
cxxflags = cxxflags,
includes = includes,
+ defines = defines,
source = source,
use = libbsd_use)
diff --git a/waf_generator.py b/waf_generator.py
index 9c65ebc5..9d5939a8 100755
--- a/waf_generator.py
+++ b/waf_generator.py
@@ -294,6 +294,11 @@ class ModuleManager(builder.ModuleManager):
self.add(' cflags = %r + common_flags' % (builder.cflags()))
self.add(' cxxflags = %r + common_flags' % (builder.cxxflags()))
self.add('')
+ self.add(' # Defines')
+ self.add(' defines = []')
+ self.add(' for o in bld.env.FREEBSD_OPTIONS.split(","):')
+ self.add(' defines += ["%s=1" % (o.strip().upper())]')
+ self.add('')
self.add(' # Include paths')
self.add(' includes = []')
self.add(' for i in %r:' % (builder.cpu_includes()))
@@ -409,7 +414,7 @@ class ModuleManager(builder.ModuleManager):
if 'lex' in data:
lexes = data['lex']
self.add(' # Lex')
- for l in lexes:
+ for l in sorted(lexes.keys()):
lex = lexes[l]['all']
if 'cflags' in lex:
lex_defines = [d[2:] for d in lex['cflags']]
@@ -428,7 +433,7 @@ class ModuleManager(builder.ModuleManager):
self.add(' features = "c",')
self.add(' cflags = cflags,')
self.add(' includes = %r + includes,' % (lex_includes))
- self.add(' defines = %r,' % (lex_defines))
+ self.add(' defines = defines + %r,' % (lex_defines))
self.add(' source = "%s.c")' % (lex['file'][:-2]))
self.add(' libbsd_use += ["lex_%s"]' % (lex['sym']))
self.add('')
@@ -436,7 +441,7 @@ class ModuleManager(builder.ModuleManager):
if 'yacc' in data:
yaccs = data['yacc']
self.add(' # Yacc')
- for y in yaccs:
+ for y in sorted(yaccs.keys()):
yacc = yaccs[y]['all']
yacc_file = yacc['file']
if yacc['sym'] is not None:
@@ -462,7 +467,7 @@ class ModuleManager(builder.ModuleManager):
self.add(' features = "c",')
self.add(' cflags = cflags,')
self.add(' includes = %r + includes,' % (yacc_includes))
- self.add(' defines = %r,' % (yacc_defines))
+ self.add(' defines = defines + %r,' % (yacc_defines))
self.add(' source = "%s.c")' % (yacc_file[:-2]))
self.add(' libbsd_use += ["yacc_%s"]' % (yacc_sym))
self.add('')
@@ -496,7 +501,7 @@ class ModuleManager(builder.ModuleManager):
self.add(' features = "c",')
self.add(' cflags = cflags,')
self.add(' includes = %r + includes,' % (includes))
- self.add(' defines = %r,' % (defines))
+ self.add(' defines = defines + %r,' % (defines))
self.add(' source = objs%02d_source)' % objs)
self.add(' libbsd_use += ["objs%02d"]' % (objs))
self.add('')
@@ -518,6 +523,7 @@ class ModuleManager(builder.ModuleManager):
self.add(' cflags = cflags,')
self.add(' cxxflags = cxxflags,')
self.add(' includes = includes,')
+ self.add(' defines = defines,')
self.add(' source = source,')
self.add(' use = libbsd_use)')
self.add('')
diff --git a/wscript b/wscript
index e4ae9b8b..5dba56ba 100644
--- a/wscript
+++ b/wscript
@@ -63,6 +63,11 @@ def options(opt):
default = "config.inc",
dest = "net_config",
help = "Network test configuration.")
+ opt.add_option("--freebsd-options",
+ action = "store",
+ default = "",
+ dest = "freebsd_options",
+ help = "Set FreeBSD options (developer option).")
libbsd_waf.options(opt)
def bsp_configure(conf, arch_bsp):
@@ -82,8 +87,9 @@ def configure(conf):
conf.env.AUTO_REGEN = conf.options.auto_regen
conf.env.WARNINGS = conf.options.warnings
conf.env.NET_CONFIG = conf.options.net_config
+ conf.env.FREEBSD_OPTIONS =conf.options.freebsd_options
rtems.configure(conf, bsp_configure)
- libbsd_waf.configure(conf, arch_bsp)
+ libbsd_waf.configure(conf)
def build(bld):
rtems.build(bld)