Fix mistakes in cptest asserts
[oweals/dinit.git] / BUILD.txt
index 08de0596c85a8bb6693c422968d67f910cc08461..6ce4c6899ba9f0b0016b9edec79f7633ec59e621 100644 (file)
--- a/BUILD.txt
+++ b/BUILD.txt
@@ -4,17 +4,19 @@ Building Dinit
 Building Dinit should be a straight-forward process. It requires GNU make and a C++11 compiler
 (GCC version 4.9 and later, or Clang ~5.0 and later, should be fine)
 
-Edit the "mconfig" file to choose appropriate values for the configuration variables defined
-within. In particular:
+On the directly supported operating systems - Linux, OpenBSD, FreeBSD and Darwin (macOS) - a
+suitable build configuration is provided and will be used automatically if no manual configuration
+is supplied. For other systems, or to fine tune or correct the configuration, create and edit the
+"mconfig" file (start by copying one for a particular OS from the "configs" directory) to choose
+appropriate values for the configuration variables defined within. In particular:
 
   CXX : should be set to the name of the C++ compiler (and link driver)
   CXXOPTS :  are options passed to the compiler during compilation (see note for GCC below)
   LDFLAGS :  are any extra flags required for linking; should not normally be needed
              (FreeBSD requires -lrt).
 
-Suitable defaults for a number of systems are provided. Note that the "eg++" or "clang++" package
-must be installed on OpenBSD as the default "g++" compiler is too old. Clang is part of the base
-system in recent releases.
+Note that the "eg++" or "clang++" package must be installed on OpenBSD as the default "g++"
+compiler is too old. Clang is part of the base system in recent releases.
 
 Then, change into the "src" directory, and run "make" (or "gmake" if the system make is not
 GNU make, such as on most BSD systems):
@@ -27,6 +29,57 @@ utility. Use "make install" to install; you can specify an alternate installatio
 setting the "DESTDIR" variable, eg "make DESTDIR=/tmp/temporary-install-path install".
 
 
+Recommended Compiler options
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+
+Dinit should generally build fine with no additional options, other than:
+ -std=c++11 :  may be required to select correct C++ standard.
+ -D_GLIBCXX_USE_CXX11_ABI=1 :   see "Special note for GCC/Libstdc++", below. Not needed for
+                                most modern systems.
+
+Recommended options, supported by at least GCC and Clang, are:
+ -Os       : optimise for size
+ -fno-rtti : disable RTTI (run-time type information), it is not required by Dinit.
+             However, on some platforms such as Mac OS (and historically FreeBSD, IIRC), this
+             prevents exceptions working correctly.
+ -fno-plt  : enables better code generation for non-static builds, but may cause unit test
+             failures on some older versions of FreeBSD (11.2-RELEASE-p4 with clang++ 6.0.0).
+ -flto     : perform link-time optimisation (option required at compile and link).
+
+Consult compiler documentation for further information on the above options.
+
+
+Other configuration variables
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+There are a number of other variables you can set in the mconfig file which affect the build:
+
+SBINDIR=...
+    Where the "/sbin" directory is. Executables will be installed here.
+MANDIR=...
+    Where the "man" directory is. Man pages will be installed here.
+SYSCONTROLSOCKET=...
+    Default full path to the control socket, for when Dinit runs as system service manager.
+BUILD_SHUTDOWN=yes|no
+    Whether to build the "shutdown" (and "halt" etc) utilities. These are only useful
+    if dinit is the system init (i.e. the PID 1 process). You probably don't want this
+    unless building for Linux.
+SHUTDOWN_PREFIX=...
+    Name prefix for "shutdown", "halt" and "reboot" commands (if they are built). This affects
+    both the output, and what command dinit will execute as part of system shutdown.
+    If you want to install Dinit alongside another init system with its own shutdown/halt/reboot
+    commands, set this (for eg. to "dinit-").
+USE_UTMPX=1|0
+    Whether to build support for manipulating the utmp/utmpx database via the related POSIX
+    functions. This may be required (along with appropriate service configuration) for utilities
+    like "who" to work correctly (the service configuration items "inittab-id" and "inittab-line"
+    have no effect if this is disabled). If not set to any value, support is enabled for certain
+    systems automatically and disabled for all others.
+SANITIZE_OPTS=...
+    Any options to enable run-time sanitizers or additional safety checks. This will be used
+    only when building tests. It can safely be left blank.
+
+
 Running test suite
 =-=-=-=-=-=-=-=-=-
 
@@ -51,6 +104,13 @@ If you get this, either disable the address sanitizer or make sure you have over
 
 Any test failures will abort the test suite run immediately.
 
+To run the integration tests:
+
+    make check-igr
+    
+(The integration tests are more fragile than the unit tests, but give a better indication that
+Dinit will actually work correctly on your system).
+
 In addition to the standard test suite, there is experimental support for fuzzing the control
 protocol handling using LLVM/clang's fuzzer (libFuzzer). Change to the `src/tests/cptests`
 directory and build the "fuzz" target: