Index: builder.py
===================================================================
--- builder.py	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ builder.py	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -187,4 +187,5 @@
     data = re.sub('#include <bsd.h>',      '#include <rtems/bsd/bsd.h>', data)
     data = re.sub('#include <zerocopy.h>', '#include <rtems/bsd/zerocopy.h>', data)
+    data = re.sub('#include <modules.h>',  '#include <rtems/bsd/modules.h>', data)
     return data
 
Index: buildset/default.ini
===================================================================
--- buildset/default.ini	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ buildset/default.ini	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -1,4 +1,8 @@
 #
-# Default configuration.
+# Default configuration. Contains most features except for some big or slow ones
+# like WiFi or IPSec.
+#
+# At all developers: Please allways add all modules to this file and mark them
+# as explicitly "off" if they are not used.
 #
 
@@ -31,6 +35,6 @@
 dev_usb_serial = on
 dev_usb_storage = on
-dev_usb_wlan = on
-dev_wlan_rtwn = on
+dev_usb_wlan = off
+dev_wlan_rtwn = off
 dhcpcd = on
 dpaa = on
@@ -44,5 +48,5 @@
 mmc_ti = on
 net = on
-net80211 = on
+net80211 = off
 netinet = on
 netinet6 = on
@@ -54,5 +58,5 @@
 tty = on
 user_space = on
-user_space_wlanstats = on
+user_space_wlanstats = off
 usr_sbin_tcpdump = on
-usr_sbin_wpa_supplicant = on
+usr_sbin_wpa_supplicant = off
Index: buildset/everything.ini
===================================================================
--- buildset/everything.ini	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
+++ buildset/everything.ini	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -0,0 +1,15 @@
+#
+# This configuration has the target to provide all features of libbsd even the
+# big and slow ones.
+#
+
+[general]
+name = everything
+extends = default.ini
+
+[modules]
+dev_usb_wlan = on
+dev_wlan_rtwn = on
+net80211 = on
+user_space_wlanstats = on
+usr_sbin_wpa_supplicant = on
Index: buildset/minimal.ini
===================================================================
--- buildset/minimal.ini	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
+++ buildset/minimal.ini	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -0,0 +1,22 @@
+#
+# This configuration has the target to provide the smallest possible libbsd
+# during link time. It should disable everything that can be disabled without
+# loosing basic functionality. As a target, it should once only provide the
+# following functions:
+#
+# - basic IPv4 only networking
+# - basic USB support
+# - all device drivers that don't increase the application size without being
+#   explicitly linked in
+#
+# ATTENTION: This configuration will loose functionality in the future as soon
+# as it is possible to disable the functionality.
+#
+
+[general]
+name = minimal
+extends = default.ini
+
+[modules]
+crypto_openssl = off
+netinet6 = off
Index: ildset/sample.ini
===================================================================
--- buildset/sample.ini	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ 	(revision )
@@ -1,10 +1,0 @@
-#
-# Currently this is mostly a sample configuration.
-#
-
-[general]
-name = sample
-extends = default.ini
-
-[modules]
-dev_nic_broadcomm = off
Index: dhcpcd/config.h
===================================================================
--- dhcpcd/config.h	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ dhcpcd/config.h	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -15,4 +15,5 @@
 #include <stdint.h>
 #include "compat/pollts.h"
+#include <rtems/bsd/local/opt_inet6.h>
 uint32_t arc4random(void);
 static inline int dhcpcd_flock(int a, int b) { return -1; }
Index: dhcpcd/dhcp6.c
===================================================================
--- dhcpcd/dhcp6.c	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ dhcpcd/dhcp6.c	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -28,4 +28,8 @@
 /* TODO: We should decline dupliate addresses detected */
 
+#ifdef __rtems__
+#include <rtems/bsd/local/opt_inet6.h>
+#endif /* __rtems__ */
+#if defined(__rtems__) && defined(INET6)
 #include <sys/stat.h>
 #include <sys/utsname.h>
@@ -2810,2 +2814,3 @@
 	return n;
 }
+#endif /* defined(__rtems__) && defined(INET6) */
Index: dhcpcd/ipv6.c
===================================================================
--- dhcpcd/ipv6.c	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ dhcpcd/ipv6.c	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -26,4 +26,8 @@
  */
 
+#ifdef __rtems__
+#include <rtems/bsd/local/opt_inet6.h>
+#endif /* __rtems__ */
+#if defined(__rtems__) && defined(INET6)
 #include <sys/param.h>
 #include <sys/types.h>
@@ -1046,2 +1050,3 @@
 	routes = nrs;
 }
+#endif /* defined(__rtems__) && defined(INET6) */
Index: dhcpcd/ipv6.h
===================================================================
--- dhcpcd/ipv6.h	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ dhcpcd/ipv6.h	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -32,4 +32,7 @@
 
 #include <netinet/in.h>
+#ifdef __rtems__
+#include <rtems/bsd/local/opt_inet6.h>
+#endif /* __rtems__ */
 
 #define ALLROUTERS "ff02::2"
Index: dhcpcd/ipv6nd.c
===================================================================
--- dhcpcd/ipv6nd.c	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ dhcpcd/ipv6nd.c	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -26,4 +26,8 @@
  */
 
+#ifdef __rtems__
+#include <rtems/bsd/local/opt_inet6.h>
+#endif /* __rtems__ */
+#if defined(__rtems__) && defined(INET6)
 #include <sys/ioctl.h>
 #include <sys/param.h>
@@ -1834,2 +1838,3 @@
 	return 0;
 }
+#endif /* defined(__rtems__) && defined(INET6) */
Index: dhcpcd/platform.h
===================================================================
--- dhcpcd/platform.h	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ dhcpcd/platform.h	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -28,4 +28,7 @@
 #ifndef PLATFORM_H
 #define PLATFORM_H
+#ifdef __rtems__
+#include <rtems/bsd/local/opt_inet6.h>
+#endif /* __rtems__ */
 
 char *hardware_platform(void);
Index: freebsd/lib/libc/rpc/rpcb_clnt.c
===================================================================
--- freebsd/lib/libc/rpc/rpcb_clnt.c	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ freebsd/lib/libc/rpc/rpcb_clnt.c	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -32,5 +32,4 @@
 
 /* #ident	"@(#)rpcb_clnt.c	1.27	94/04/24 SMI" */
-
 
 #if defined(LIBC_SCCS) && !defined(lint)
Index: freebsd/sbin/ifconfig/ifconfig.c
===================================================================
--- freebsd/sbin/ifconfig/ifconfig.c	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ freebsd/sbin/ifconfig/ifconfig.c	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -55,4 +55,5 @@
 #include <machine/rtems-bsd-program.h>
 #include <machine/rtems-bsd-commands.h>
+#include <rtems/bsd/modules.h>
 #endif /* __rtems__ */
 #include <sys/param.h>
@@ -383,6 +384,10 @@
 	group_ctor();
 	ifmedia_ctor();
+#ifdef RTEMS_BSD_MODULE_IEEE80211
 	ieee80211_ctor();
+#endif
+#ifdef RTEMS_BSD_MODULE_NETINET6
 	inet6_ctor();
+#endif
 	inet_ctor();
 	lagg_ctor();
Index: freebsd/sbin/ping6/ping6.c
===================================================================
--- freebsd/sbin/ping6/ping6.c	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ freebsd/sbin/ping6/ping6.c	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -70,4 +70,5 @@
  */
 
+#if defined(__rtems__) && defined(INET6)
 #ifndef lint
 static const char copyright[] =
@@ -2836,2 +2837,3 @@
 	exit(1);
 }
+#endif /* defined(__rtems__) && defined(INET6) */
Index: libbsd.py
===================================================================
--- libbsd.py	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ libbsd.py	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -2562,5 +2562,5 @@
                 'lib/libc/db/recno/rec_utils.c',
             ],
-            mm.generator['source']('-D__DBINTERFACE_PRIVATE -DINET6')
+            mm.generator['source']('-D__DBINTERFACE_PRIVATE')
         )
         self.addRTEMSHeaderFiles(
@@ -2805,5 +2805,5 @@
                 'usr.sbin/arp/arp.c',
             ],
-            mm.generator['source'](['-DINET6', '-DINET'])
+            mm.generator['source'](['-DINET'])
         )
 
@@ -2830,5 +2830,5 @@
                 'lib/libbsdstat/bsdstat.c',
             ],
-            mm.generator['source'](['-DINET6', '-DINET'])
+            mm.generator['source']([])
         )
 
@@ -3841,5 +3841,4 @@
         cflags = ['-D__FreeBSD__=1',
                   '-DBSD=1',
-                  '-DINET6',
                   '-D_U_=__attribute__((unused))',
                   '-DHAVE_LIMITS_H=1',
@@ -4152,5 +4151,4 @@
             ],
             mm.generator['source'](['-D__FreeBSD__=1',
-                                    '-DINET6',
                                     '-D_U_=__attribute__((unused))',
                                     '-DHAVE_CONFIG_H=1',
@@ -4559,5 +4557,5 @@
                 'dhcpcd/crypt/hmac_md5.c',
             ],
-            mm.generator['source']('-D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6')
+            mm.generator['source']('-D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET')
         )
         self.addRTEMSSourceFiles(
Index: libbsd.txt
===================================================================
--- libbsd.txt	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ libbsd.txt	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -120,4 +120,12 @@
 The build system based on the Waf build system. To build with Waf please refer
 to the README.waf file.
+
+Note that the libbsd supports different buildsets. These can be selected with
+the `--buildset=xxx.ini` option during the configure phase. Take a look at the
+comments in `buildset/*.ini` to see which build sets are officially supported.
+
+You can also create and provide your own buildset configuration. But remember
+that it's quite easy to break something by disabling the wrong modules. Only the
+configurations in the `buildset` directory are officially maintained.
 
 ===== Example Configuration for Network Tests =====
@@ -1174,7 +1182,10 @@
 
 The libbsd provides a basic support for WLAN. Note that currently this support
-is still in an early state. The following gives a rough overview over the
-necessary steps to connect to an encrypted network with an RTL8188EU based WiFi
-dongle:
+is still in an early state. The WLAN support is _not_ enabled in the default
+buildset. You have to configure libbsd with the
+`--buildset=buildset/everything.ini` to enable that feature.
+
+The following gives a rough overview over the necessary steps to connect to an
+encrypted network with an RTL8188EU based WiFi dongle:
 
 - Reference all necessary module for your BSP. For some BSPs this is already
Index: rtemsbsd/include/machine/rtems-bsd-user-space.h
===================================================================
--- rtemsbsd/include/machine/rtems-bsd-user-space.h	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ rtemsbsd/include/machine/rtems-bsd-user-space.h	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -43,4 +43,5 @@
 #define __FreeBSD__ 1
 
+#include <rtems/bsd/local/opt_inet6.h>
 #include <machine/rtems-bsd-version.h>
 #include <sys/cdefs.h>
Index: rtemsbsd/include/rtems/bsd/local/opt_inet6.h
===================================================================
--- rtemsbsd/include/rtems/bsd/local/opt_inet6.h	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ rtemsbsd/include/rtems/bsd/local/opt_inet6.h	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -1,1 +1,4 @@
-#define INET6 1
+#include <rtems/bsd/modules.h>
+#ifdef RTEMS_BSD_MODULE_NETINET6
+  #define INET6 1
+#endif
Index: testsuite/commands01/test_main.c
===================================================================
--- testsuite/commands01/test_main.c	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ testsuite/commands01/test_main.c	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -41,4 +41,5 @@
 
 #include <rtems/libcsupport.h>
+#include <rtems/bsd/modules.h>
 
 #define TEST_NAME "LIBBSD COMMANDS 1"
@@ -109,4 +110,5 @@
 		NULL
 	};
+#ifdef RTEMS_BSD_MODULE_NETINET6
 	char *lo0_inet6[] = {
 		"ifconfig",
@@ -118,4 +120,5 @@
 		NULL
 	};
+#endif /* RTEMS_BSD_MODULE_NETINET6 */
 	char *status[] = {
 		"ifconfig",
@@ -124,4 +127,5 @@
 		NULL
 	};
+#ifdef RTEMS_BSD_MODULE_NETINET6
 	char *status_inet6[] = {
 		"ifconfig",
@@ -130,10 +134,13 @@
 		NULL
 	};
+#endif /* RTEMS_BSD_MODULE_NETINET6 */
 
 	exit_code = rtems_bsd_command_ifconfig(ARGC(lo0), lo0);
 	assert(exit_code == EX_OK);
 
+#ifdef RTEMS_BSD_MODULE_NETINET6
 	exit_code = rtems_bsd_command_ifconfig(ARGC(lo0_inet6), lo0_inet6);
 	assert(exit_code == EX_OK);
+#endif /* RTEMS_BSD_MODULE_NETINET6 */
 
 	rtems_resource_snapshot_take(&snapshot);
@@ -142,11 +149,15 @@
 	assert(exit_code == EX_OK);
 
+#ifdef RTEMS_BSD_MODULE_NETINET6
 	exit_code = rtems_bsd_command_ifconfig(ARGC(status_inet6), status_inet6);
 	assert(exit_code == EX_OK);
-
-	rtems_resource_snapshot_take(&snapshot);
-
+#endif /* RTEMS_BSD_MODULE_NETINET6 */
+
+	rtems_resource_snapshot_take(&snapshot);
+
+#ifdef RTEMS_BSD_MODULE_NETINET6
 	exit_code = rtems_bsd_command_ifconfig(ARGC(status_inet6), status_inet6);
 	assert(exit_code == EX_OK);
+#endif /* RTEMS_BSD_MODULE_NETINET6 */
 
 	assert(rtems_resource_snapshot_check(&snapshot));
@@ -196,4 +207,5 @@
 test_ping6(void)
 {
+#ifdef RTEMS_BSD_MODULE_NETINET6
 	rtems_resource_snapshot snapshot;
 	int exit_code;
@@ -215,4 +227,5 @@
 
 	assert(rtems_resource_snapshot_check(&snapshot));
+#endif
 }
 
@@ -261,4 +274,5 @@
 test_wlanstats(void)
 {
+#ifdef RTEMS_BSD_MODULE_USER_SPACE_WLANSTATS
 	rtems_resource_snapshot snapshot;
 	char *wlanstats[] = {
@@ -272,4 +286,5 @@
 	rtems_bsd_command_wlanstats(ARGC(wlanstats), wlanstats);
 	assert(rtems_resource_snapshot_check(&snapshot));
+#endif /* RTEMS_BSD_MODULE_USER_SPACE_WLANSTATS */
 }
 
Index: testsuite/include/rtems/bsd/test/default-network-init.h
===================================================================
--- testsuite/include/rtems/bsd/test/default-network-init.h	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ testsuite/include/rtems/bsd/test/default-network-init.h	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -48,4 +48,5 @@
 #include <rtems/stackchk.h>
 #include <rtems/bsd/bsd.h>
+#include <rtems/bsd/modules.h>
 
 #if defined(DEFAULT_NETWORK_DHCPCD_ENABLE) && \
@@ -328,5 +329,19 @@
 #include <rtems/netcmds-config.h>
 
+#ifdef RTEMS_BSD_MODULE_USER_SPACE_WLANSTATS
+  #define SHELL_WLANSTATS_COMMAND &rtems_shell_WLANSTATS_Command,
+#else
+  #define SHELL_WLANSTATS_COMMAND
+#endif
+
+#ifdef RTEMS_BSD_MODULE_USR_SBIN_WPA_SUPPLICANT
+  #define SHELL_WPA_SUPPLICANT_COMMAND &rtems_shell_WPA_SUPPLICANT_Command,
+#else
+  #define SHELL_WPA_SUPPLICANT_COMMAND
+#endif
+
 #define CONFIGURE_SHELL_USER_COMMANDS \
+  SHELL_WLANSTATS_COMMAND \
+  SHELL_WPA_SUPPLICANT_COMMAND \
   &bsp_interrupt_shell_command, \
   &rtems_shell_ARP_Command, \
@@ -338,7 +353,5 @@
   &rtems_shell_TCPDUMP_Command, \
   &rtems_shell_SYSCTL_Command, \
-  &rtems_shell_VMSTAT_Command, \
-  &rtems_shell_WLANSTATS_Command, \
-  &rtems_shell_WPA_SUPPLICANT_Command
+  &rtems_shell_VMSTAT_Command
 
 #define CONFIGURE_SHELL_COMMAND_CPUINFO
Index: testsuite/media01/test_main.c
===================================================================
--- testsuite/media01/test_main.c	(revision 4eb250246daa333f41d7f6cbfddf5e297f1cdee0)
+++ testsuite/media01/test_main.c	(revision 338f3005fc420b2c26f597ae6c0754f391c9fcca)
@@ -201,5 +201,14 @@
 #include <rtems/netcmds-config.h>
 
+#ifdef RTEMS_BSD_MODULE_USR_SBIN_WPA_SUPPLICANT
+  #define SHELL_WPA_SUPPLICANT_COMMANDS \
+    &rtems_shell_WPA_SUPPLICANT_Command, \
+    &rtems_shell_WPA_SUPPLICANT_FORK_Command,
+#else
+  #define SHELL_WPA_SUPPLICANT_COMMANDS
+#endif
+
 #define CONFIGURE_SHELL_USER_COMMANDS \
+  SHELL_WPA_SUPPLICANT_COMMANDS \
   &bsp_interrupt_shell_command, \
   &rtems_shell_ARP_Command, \
@@ -210,7 +219,5 @@
   &rtems_shell_SYSCTL_Command, \
   &rtems_shell_IFCONFIG_Command, \
-  &rtems_shell_VMSTAT_Command, \
-  &rtems_shell_WPA_SUPPLICANT_Command, \
-  &rtems_shell_WPA_SUPPLICANT_FORK_Command
+  &rtems_shell_VMSTAT_Command
 
 #define CONFIGURE_SHELL_COMMAND_CPUINFO
