Page MenuHomeFreeBSD

No OneTemporary

Index: stable/11/share/man/man5/src.conf.5
===================================================================
--- stable/11/share/man/man5/src.conf.5 (revision 322581)
+++ stable/11/share/man/man5/src.conf.5 (revision 322582)
@@ -1,1545 +1,1550 @@
.\" DO NOT EDIT-- this file is generated by tools/build/options/makeman.
.\" $FreeBSD$
-.Dd August 5, 2017
+.Dd August 16, 2017
.Dt SRC.CONF 5
.Os
.Sh NAME
.Nm src.conf
.Nd "source build options"
.Sh DESCRIPTION
The
.Nm
file contains settings that will apply to every build involving the
.Fx
source tree; see
.Xr build 7 .
.Pp
The
.Nm
file uses the standard makefile syntax.
However,
.Nm
should not specify any dependencies to
.Xr make 1 .
Instead,
.Nm
is to set
.Xr make 1
variables that control the aspects of how the system builds.
.Pp
The default location of
.Nm
is
.Pa /etc/src.conf ,
though an alternative location can be specified in the
.Xr make 1
variable
.Va SRCCONF .
Overriding the location of
.Nm
may be necessary if the system-wide settings are not suitable
for a particular build.
For instance, setting
.Va SRCCONF
to
.Pa /dev/null
effectively resets all build controls to their defaults.
.Pp
The only purpose of
.Nm
is to control the compilation of the
.Fx
source code, which is usually located in
.Pa /usr/src .
As a rule, the system administrator creates
.Nm
when the values of certain control variables need to be changed
from their defaults.
.Pp
In addition, control variables can be specified
for a particular build via the
.Fl D
option of
.Xr make 1
or in its environment; see
.Xr environ 7 .
.Pp
The environment of
.Xr make 1
for the build can be controlled via the
.Va SRC_ENV_CONF
variable, which defaults to
.Pa /etc/src-env.conf .
Some examples that may only be set in this file are
.Va WITH_DIRDEPS_BUILD ,
and
.Va WITH_META_MODE
as they are environment-only variables.
Note that
.Va MAKEOBJDIRPREFIX
may be set here only when using
.Va WITH_DIRDEPS_BUILD .
.Pp
The values of variables are ignored regardless of their setting;
even if they would be set to
.Dq Li FALSE
or
.Dq Li NO .
The presence of an option causes
it to be honored by
.Xr make 1 .
.Pp
This list provides a name and short description for variables
that can be used for source builds.
.Bl -tag -width indent
.It Va WITHOUT_ACCT
Set to not build process accounting tools such as
.Xr accton 8
and
.Xr sa 8 .
.It Va WITHOUT_ACPI
Set to not build
.Xr acpiconf 8 ,
.Xr acpidump 8
and related programs.
.It Va WITHOUT_AMD
Set to not build
.Xr amd 8 ,
and related programs.
.It Va WITHOUT_APM
Set to not build
.Xr apm 8 ,
.Xr apmd 8
and related programs.
.It Va WITHOUT_ASSERT_DEBUG
Set to compile programs and libraries without the
.Xr assert 3
checks.
.It Va WITHOUT_AT
Set to not build
.Xr at 1
and related utilities.
.It Va WITHOUT_ATM
Set to not build
programs and libraries related to ATM networking.
.It Va WITHOUT_AUDIT
Set to not build audit support into system programs.
.It Va WITHOUT_AUTHPF
Set to not build
.Xr authpf 8 .
.It Va WITHOUT_AUTOFS
Set to not build
.Xr autofs 5
related programs, libraries, and kernel modules.
.It Va WITH_AUTO_OBJ
Enable automatic creation of objdirs.
.Pp
This must be set in the environment, make command line, or
.Pa /etc/src-env.conf ,
not
.Pa /etc/src.conf .
.It Va WITHOUT_BHYVE
Set to not build or install
.Xr bhyve 8 ,
associated utilities, and examples.
.Pp
This option only affects amd64/amd64.
.It Va WITHOUT_BINUTILS
Set to not build or install binutils (as, ld, objcopy, and objdump ) as part
of the normal system build.
The resulting system cannot build programs from source.
.Pp
This is a default setting on
arm64/aarch64.
.It Va WITH_BINUTILS
Set to build and install binutils (as, ld, objcopy, and objdump) as part
of the normal system build.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITHOUT_BINUTILS_BOOTSTRAP
Set to not build binutils (as, ld, objcopy and objdump)
as part of the bootstrap process.
.Bf -symbolic
The option does not work for build targets unless some alternative
toolchain is provided.
.Ef
.Pp
This is a default setting on
arm64/aarch64.
.It Va WITH_BINUTILS_BOOTSTRAP
Set build binutils (as, ld, objcopy and objdump)
as part of the bootstrap process.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITHOUT_BLACKLIST
Set this if you do not want to build
.Xr blacklistd 8
and
.Xr blacklistctl 8 .
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_BLACKLIST_SUPPORT
.El
.It Va WITHOUT_BLACKLIST_SUPPORT
Set to build some programs without
.Xr libblacklist 3
support, like
.Xr fingerd 8 ,
.Xr ftpd 8 ,
.Xr rlogind 8 ,
.Xr rshd 8 ,
and
.Xr sshd 8 .
.It Va WITHOUT_BLUETOOTH
Set to not build Bluetooth related kernel modules, programs and libraries.
.It Va WITHOUT_BOOT
Set to not build the boot blocks and loader.
.It Va WITHOUT_BOOTPARAMD
Set to not build or install
.Xr bootparamd 8 .
.It Va WITHOUT_BOOTPD
Set to not build or install
.Xr bootpd 8 .
.It Va WITHOUT_BSDINSTALL
Set to not build
.Xr bsdinstall 8 ,
.Xr sade 8 ,
and related programs.
.It Va WITHOUT_BSD_CPIO
Set to not build the BSD licensed version of cpio based on
.Xr libarchive 3 .
.It Va WITH_BSD_GREP
Install BSD-licensed grep as '[ef]grep' instead of GNU grep.
+.It Va WITHOUT_BSD_GREP_FASTMATCH
+Set this option to exclude the fastmatch implementation from
+.Xr bsdgrep 1 ,
+instead using only
+.Xr regex 3 .
.It Va WITHOUT_BSNMP
Set to not build or install
.Xr bsnmpd 1
and related libraries and data files.
.It Va WITHOUT_BZIP2
Set to not build contributed bzip2 software as a part of the base system.
.Bf -symbolic
The option has no effect yet.
.Ef
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_BZIP2_SUPPORT
.El
.It Va WITHOUT_BZIP2_SUPPORT
Set to build some programs without optional bzip2 support.
.It Va WITHOUT_CALENDAR
Set to not build
.Xr calendar 1 .
.It Va WITHOUT_CAPSICUM
Set to not build Capsicum support into system programs.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_CASPER
.El
.It Va WITHOUT_CASPER
Set to not build Casper program and related libraries.
.It Va WITH_CCACHE_BUILD
Set to use
.Xr ccache 1
for the build.
No configuration is required except to install the
.Sy devel/ccache
package.
When using with
.Xr distcc 1 ,
set
.Sy CCACHE_PREFIX=/usr/local/bin/distcc .
The default cache directory of
.Pa $HOME/.ccache
will be used, which can be overridden by setting
.Sy CCACHE_DIR .
The
.Sy CCACHE_COMPILERCHECK
option defaults to
.Sy content
when using the in-tree bootstrap compiler,
and
.Sy mtime
when using an external compiler.
The
.Sy CCACHE_CPP2
option is used for Clang but not GCC.
.Pp
Sharing a cache between multiple work directories requires using a layout
similar to
.Pa /some/prefix/src
.Pa /some/prefix/obj
and an environment such as:
.Bd -literal -offset indent
CCACHE_BASEDIR='${SRCTOP:H}' MAKEOBJDIRPREFIX='${SRCTOP:H}/obj'
.Ed
.Pp
See
.Xr ccache 1
for more configuration options.
.It Va WITHOUT_CCD
Set to not build
.Xr geom_ccd 4
and related utilities.
.It Va WITHOUT_CDDL
Set to not build code licensed under Sun's CDDL.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_CTF
.It
.Va WITHOUT_ZFS
.El
.It Va WITHOUT_CLANG
Set to not build the Clang C/C++ compiler during the regular phase of the build.
.Pp
This is a default setting on
sparc64/sparc64.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_CLANG_EXTRAS
.It
.Va WITHOUT_CLANG_FULL
.El
.It Va WITH_CLANG
Set to build the Clang C/C++ compiler during the normal phase of the build.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc and powerpc/powerpc64.
.It Va WITHOUT_CLANG_BOOTSTRAP
Set to not build the Clang C/C++ compiler during the bootstrap phase of
the build.
To be able to build the system, either gcc or clang bootstrap must be
enabled unless an alternate compiler is provided via XCC.
.Pp
This is a default setting on
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITH_CLANG_BOOTSTRAP
Set to build the Clang C/C++ compiler during the bootstrap phase of the build.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm64/aarch64, i386/i386 and pc98/i386.
.It Va WITH_CLANG_EXTRAS
Set to build additional clang and llvm tools, such as bugpoint.
.It Va WITHOUT_CLANG_FULL
Set to avoid building the ARCMigrate, Rewriter and StaticAnalyzer components of
the Clang C/C++ compiler.
.Pp
This is a default setting on
sparc64/sparc64.
.It Va WITH_CLANG_FULL
Set to build the ARCMigrate, Rewriter and StaticAnalyzer components of the
Clang C/C++ compiler.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc and powerpc/powerpc64.
.It Va WITHOUT_CLANG_IS_CC
Set to install the GCC compiler as
.Pa /usr/bin/cc ,
.Pa /usr/bin/c++
and
.Pa /usr/bin/cpp .
.Pp
This is a default setting on
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITH_CLANG_IS_CC
Set to install the Clang C/C++ compiler as
.Pa /usr/bin/cc ,
.Pa /usr/bin/c++
and
.Pa /usr/bin/cpp .
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm64/aarch64, i386/i386 and pc98/i386.
.It Va WITHOUT_CPP
Set to not build
.Xr cpp 1 .
.It Va WITHOUT_CROSS_COMPILER
Set to not build any cross compiler in the cross-tools stage of buildworld.
When compiling a different version of
.Fx
than what is installed on the system, provide an alternate
compiler with XCC to ensure success.
When compiling with an identical version of
.Fx
to the host, this option may be safely used.
This option may also be safe when the host version of
.Fx
is close to the sources being built, but all bets are off if there have
been any changes to the toolchain between the versions.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_BINUTILS_BOOTSTRAP
.It
.Va WITHOUT_CLANG_BOOTSTRAP
.It
.Va WITHOUT_ELFTOOLCHAIN_BOOTSTRAP
.It
.Va WITHOUT_GCC_BOOTSTRAP
.El
.It Va WITHOUT_CRYPT
Set to not build any crypto code.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_KERBEROS
.It
.Va WITHOUT_KERBEROS_SUPPORT
.It
.Va WITHOUT_OPENSSH
.It
.Va WITHOUT_OPENSSL
.El
.Pp
When set, these options are also in effect:
.Pp
.Bl -inset -compact
.It Va WITHOUT_GSSAPI
(unless
.Va WITH_GSSAPI
is set explicitly)
.El
.It Va WITH_CTF
Set to compile with CTF (Compact C Type Format) data.
CTF data encapsulates a reduced form of debugging information
similar to DWARF and the venerable stabs and is required for DTrace.
.It Va WITHOUT_CTM
Set to not build
.Xr ctm 1
and related utilities.
.It Va WITHOUT_CUSE
Set to not build CUSE-related programs and libraries.
.It Va WITHOUT_CXGBETOOL
Set to not build
.Xr cxgbetool 8
.Pp
This is a default setting on
arm/arm, arm/armeb, arm/armv6, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32 and powerpc/powerpc.
.It Va WITH_CXGBETOOL
Set to build
.Xr cxgbetool 8
.Pp
This is a default setting on
amd64/amd64, arm64/aarch64, i386/i386, pc98/i386, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITHOUT_CXX
Set to not build
.Xr c++ 1
and related libraries.
It will also prevent building of
.Xr gperf 1
and
.Xr devd 8 .
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_CLANG
.It
.Va WITHOUT_CLANG_EXTRAS
.It
.Va WITHOUT_CLANG_FULL
.It
.Va WITHOUT_GNUCXX
.It
.Va WITHOUT_GROFF
.El
.It Va WITHOUT_DEBUG_FILES
Set to avoid building or installing standalone debug files for each
executable binary and shared library.
.It Va WITHOUT_DIALOG
Set to not build
.Xr dialog 1 ,
.Xr dialog 3 ,
.Xr dpv 1 ,
and
.Xr dpv 3 .
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_BSDINSTALL
.El
.It Va WITHOUT_DICT
Set to not build the Webster dictionary files.
.It Va WITH_DIRDEPS_BUILD
This is an experimental build system.
For details see
http://www.crufty.net/sjg/docs/freebsd-meta-mode.htm.
Build commands can be seen from the top-level with:
.Dl make show-valid-targets
The build is driven by dirdeps.mk using
.Va DIRDEPS
stored in
Makefile.depend files found in each directory.
.Pp
The build can be started from anywhere, and behaves the same.
The initial instance of
.Xr make 1
recursively reads
.Va DIRDEPS
from
.Pa Makefile.depend ,
computing a graph of tree dependencies from the current origin.
Setting
.Va NO_DIRDEPS
skips checking dirdep dependencies and will only build in the current
and child directories.
.Va NO_DIRDEPS_BELOW
skips building any dirdeps and only build the current directory.
.Pp
This also utilizes the
.Va WITH_META_MODE
logic for incremental builds.
.Pp
The build hides commands executed unless
.Va NO_SILENT
is defined.
.Pp
Note that there is currently no mass install feature for this.
.Pp
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITH_INSTALL_AS_USER
.El
.Pp
When set, these options are also in effect:
.Pp
.Bl -inset -compact
.It Va WITHOUT_SYSTEM_COMPILER
(unless
.Va WITH_SYSTEM_COMPILER
is set explicitly)
.It Va WITH_AUTO_OBJ
(unless
.Va WITHOUT_AUTO_OBJ
is set explicitly)
.It Va WITH_META_MODE
(unless
.Va WITHOUT_META_MODE
is set explicitly)
.It Va WITH_STAGING
(unless
.Va WITHOUT_STAGING
is set explicitly)
.It Va WITH_STAGING_MAN
(unless
.Va WITHOUT_STAGING_MAN
is set explicitly)
.It Va WITH_STAGING_PROG
(unless
.Va WITHOUT_STAGING_PROG
is set explicitly)
.It Va WITH_SYSROOT
(unless
.Va WITHOUT_SYSROOT
is set explicitly)
.El
.Pp
This must be set in the environment, make command line, or
.Pa /etc/src-env.conf ,
not
.Pa /etc/src.conf .
.It Va WITH_DIRDEPS_CACHE
Cache result of dirdeps.mk which can save significant time
for subsequent builds.
Depends on
.Va WITH_DIRDEPS_BUILD .
.Pp
This must be set in the environment, make command line, or
.Pa /etc/src-env.conf ,
not
.Pa /etc/src.conf .
.It Va WITHOUT_DMAGENT
Set to not build dma Mail Transport Agent.
.It Va WITHOUT_DOCCOMPRESS
Set to not install compressed system documentation.
Only the uncompressed version will be installed.
.It Va WITH_DTRACE_TESTS
Set to build and install the DTrace test suite in
.Pa /usr/tests/cddl/usr.sbin/dtrace .
This test suite is considered experimental on architectures other than
amd64/amd64 and running it may cause system instability.
.It Va WITHOUT_DYNAMICROOT
Set this if you do not want to link
.Pa /bin
and
.Pa /sbin
dynamically.
.It Va WITHOUT_ED_CRYPTO
Set to build
.Xr ed 1
without support for encryption/decryption.
.It Va WITHOUT_EE
Set to not build and install
.Xr edit 1 ,
.Xr ee 1 ,
and related programs.
.It Va WITHOUT_EFI
Set not to build
.Xr efivar 3
and
.Xr efivar 8 .
.Pp
This is a default setting on
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITH_EFI
Set to build
.Xr efivar 3
and
.Xr efivar 8 .
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm64/aarch64, i386/i386 and pc98/i386.
.It Va WITH_EISA
Set to build EISA kernel modules.
.It Va WITHOUT_ELFCOPY_AS_OBJCOPY
Set to build and install
.Xr objcopy 1
from GNU Binutils, instead of the one from ELF Tool Chain.
This option is provided as a transition aid and will be removed in due time.
.It Va WITHOUT_ELFTOOLCHAIN_BOOTSTRAP
Set to not build ELF Tool Chain tools
(addr2line, nm, size, strings and strip)
as part of the bootstrap process.
.Bf -symbolic
An alternate bootstrap tool chain must be provided.
.Ef
.It Va WITHOUT_EXAMPLES
Set to avoid installing examples to
.Pa /usr/share/examples/ .
.It Va WITH_EXTRA_TCP_STACKS
Set to build extra TCP stack modules.
.It Va WITHOUT_FDT
Set to not build Flattened Device Tree support as part of the base system.
This includes the device tree compiler (dtc) and libfdt support library.
.It Va WITHOUT_FILE
Set to not build
.Xr file 1
and related programs.
.It Va WITHOUT_FINGER
Set to not build or install
.Xr finger 1
and
.Xr fingerd 8 .
.It Va WITHOUT_FLOPPY
Set to not build or install programs
for operating floppy disk driver.
.It Va WITHOUT_FMTREE
Set to not build and install
.Pa /usr/sbin/fmtree .
.It Va WITHOUT_FORMAT_EXTENSIONS
Set to not enable
.Fl fformat-extensions
when compiling the kernel.
Also disables all format checking.
.It Va WITHOUT_FORTH
Set to build bootloaders without Forth support.
.It Va WITHOUT_FP_LIBC
Set to build
.Nm libc
without floating-point support.
.It Va WITHOUT_FREEBSD_UPDATE
Set to not build
.Xr freebsd-update 8 .
.It Va WITHOUT_FTP
Set to not build or install
.Xr ftp 1
and
.Xr ftpd 8 .
.It Va WITHOUT_GAMES
Set to not build games.
.It Va WITHOUT_GCC
Set to not build and install gcc and g++ as part of the normal build process.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm64/aarch64, i386/i386 and pc98/i386.
.It Va WITH_GCC
Set to build and install gcc and g++.
.Pp
This is a default setting on
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITHOUT_GCC_BOOTSTRAP
Set to not build gcc and g++ as part of the bootstrap process.
You must enable either gcc or clang bootstrap to be able to build the system,
unless an alternative compiler is provided via
XCC.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm64/aarch64, i386/i386 and pc98/i386.
.It Va WITH_GCC_BOOTSTRAP
Set to build gcc and g++ as part of the bootstrap process.
.Pp
This is a default setting on
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITHOUT_GCOV
Set to not build the
.Xr gcov 1
tool.
.It Va WITHOUT_GDB
Set to not build
.Xr gdb 1 .
.Pp
This is a default setting on
arm64/aarch64.
.It Va WITH_GDB
Set to build
.Xr gdb 1 .
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITHOUT_GNU
Set to not build contributed GNU software as a part of the base system.
This option can be useful if the system built must not contain any code
covered by the GNU Public License due to legal reasons.
.Bf -symbolic
The option has no effect yet.
.Ef
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_GNU_SUPPORT
.El
.It Va WITHOUT_GNUCXX
Do not build the GNU C++ stack (g++, libstdc++).
This is the default on platforms where clang is the system compiler.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm64/aarch64, i386/i386 and pc98/i386.
.It Va WITH_GNUCXX
Build the GNU C++ stack (g++, libstdc++).
This is the default on platforms where gcc is the system compiler.
.Pp
This is a default setting on
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITHOUT_GNU_GREP_COMPAT
Set this option to omit the gnu extensions to grep from being included in
BSD grep.
.It Va WITHOUT_GNU_SUPPORT
Set to build some programs without optional GNU support.
.It Va WITHOUT_GPIO
Set to not build
.Xr gpioctl 8
as part of the base system.
.It Va WITHOUT_GPL_DTC
Set to build the BSD licensed version of the device tree compiler rather
than the GPLed one from elinux.org.
.It Va WITHOUT_GROFF
Set to not build
.Xr groff 1
and
.Xr vgrind 1 .
You should consider installing the textproc/groff port to not break
.Xr man 1 .
.It Va WITHOUT_GSSAPI
Set to not build libgssapi.
.It Va WITHOUT_HAST
Set to not build
.Xr hastd 8
and related utilities.
.It Va WITH_HESIOD
Set to build Hesiod support.
.It Va WITHOUT_HTML
Set to not build HTML docs.
.It Va WITHOUT_HYPERV
Set to not build or install HyperV utilities.
.It Va WITHOUT_ICONV
Set to not build iconv as part of libc.
.It Va WITHOUT_INCLUDES
Set to not install header files.
This option used to be spelled
.Va NO_INCS .
.Bf -symbolic
The option does not work for build targets.
.Ef
.It Va WITHOUT_INET
Set to not build programs and libraries related to IPv4 networking.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_INET_SUPPORT
.El
.It Va WITHOUT_INET6
Set to not build
programs and libraries related to IPv6 networking.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_INET6_SUPPORT
.El
.It Va WITHOUT_INET6_SUPPORT
Set to build libraries, programs, and kernel modules without IPv6 support.
.It Va WITHOUT_INETD
Set to not build
.Xr inetd 8 .
.It Va WITHOUT_INET_SUPPORT
Set to build libraries, programs, and kernel modules without IPv4 support.
.It Va WITHOUT_INSTALLLIB
Set this if to not install optional libraries.
For example, when creating a
.Xr nanobsd 8
image.
.Bf -symbolic
The option does not work for build targets.
.Ef
.It Va WITH_INSTALL_AS_USER
Set to make install targets succeed for non-root users by installing
files with owner and group attributes set to that of the user running
the
.Xr make 1
command.
The user still must set the
.Va DESTDIR
variable to point to a directory where the user has write permissions.
.It Va WITHOUT_IPFILTER
Set to not build IP Filter package.
.It Va WITHOUT_IPFW
Set to not build IPFW tools.
.It Va WITHOUT_IPSEC_SUPPORT
Set to not build the kernel with
.Xr ipsec 4
support.
This option is needed for
.Xr ipsec 4
and
.Xr tcpmd5 4 .
.It Va WITHOUT_ISCSI
Set to not build
.Xr iscid 8
and related utilities.
.It Va WITHOUT_JAIL
Set to not build tools for the support of jails; e.g.,
.Xr jail 8 .
.It Va WITHOUT_KDUMP
Set to not build
.Xr kdump 1
and
.Xr truss 1 .
.It Va WITHOUT_KERBEROS
Set this to not build Kerberos 5 (KTH Heimdal).
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_KERBEROS_SUPPORT
.El
.Pp
When set, these options are also in effect:
.Pp
.Bl -inset -compact
.It Va WITHOUT_GSSAPI
(unless
.Va WITH_GSSAPI
is set explicitly)
.El
.It Va WITHOUT_KERBEROS_SUPPORT
Set to build some programs without Kerberos support, like
.Xr ssh 1 ,
.Xr telnet 1 ,
.Xr sshd 8 ,
and
.Xr telnetd 8 .
.It Va WITHOUT_KERNEL_SYMBOLS
Set to not install kernel symbol files.
.Bf -symbolic
This option is recommended for those people who have small root partitions.
.Ef
.It Va WITHOUT_KVM
Set to not build the
.Nm libkvm
library as a part of the base system.
.Bf -symbolic
The option has no effect yet.
.Ef
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_KVM_SUPPORT
.El
.It Va WITHOUT_KVM_SUPPORT
Set to build some programs without optional
.Nm libkvm
support.
.It Va WITHOUT_LDNS
Setting this variable will prevent the LDNS library from being built.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_LDNS_UTILS
.It
.Va WITHOUT_UNBOUND
.El
.It Va WITHOUT_LDNS_UTILS
Setting this variable will prevent building the LDNS utilities
.Xr drill 1
and
.Xr host 1 .
.It Va WITHOUT_LEGACY_CONSOLE
Set to not build programs that support a legacy PC console; e.g.,
.Xr kbdcontrol 1
and
.Xr vidcontrol 1 .
.It Va WITHOUT_LIB32
On 64-bit platforms, set to not build 32-bit library set and a
.Nm ld-elf32.so.1
runtime linker.
.It Va WITHOUT_LIBCPLUSPLUS
Set to avoid building libcxxrt and libc++.
.It Va WITHOUT_LIBPTHREAD
Set to not build the
.Nm libpthread
providing library,
.Nm libthr .
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_LIBTHR
.El
.It Va WITH_LIBSOFT
On armv6 only, set to enable soft float ABI compatibility libraries.
This option is for transitioning to the new hard float ABI.
.It Va WITHOUT_LIBTHR
Set to not build the
.Nm libthr
(1:1 threading)
library.
.It Va WITHOUT_LLD
Set to not build LLVM's lld linker.
.Pp
This is a default setting on
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITH_LLD
Set to build LLVM's lld linker.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm64/aarch64, i386/i386 and pc98/i386.
.It Va WITHOUT_LLDB
Set to not build the LLDB debugger.
.Pp
This is a default setting on
arm/arm, arm/armeb, arm/armv6, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITH_LLDB
Set to build the LLDB debugger.
.Pp
This is a default setting on
amd64/amd64 and arm64/aarch64.
.It Va WITHOUT_LLD_BOOTSTRAP
Set to not build the LLD linker during the bootstrap phase of
the build.
To be able to build the system, either Binutils or LLD bootstrap must be
enabled unless an alternate linker is provided via XLD.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITH_LLD_BOOTSTRAP
Set to build the LLD linker during the bootstrap phase of the build.
.Pp
This is a default setting on
arm64/aarch64.
.It Va WITHOUT_LLD_IS_LD
Set to use GNU binutils ld as the system linker, instead of LLVM's LLD.
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITH_LLD_IS_LD
Set to use LLVM's LLD as the system linker, instead of GNU binutils ld.
.Pp
This is a default setting on
arm64/aarch64.
.It Va WITHOUT_LLVM_LIBUNWIND
Set to use GCC's stack unwinder (instead of LLVM's libunwind).
.Pp
This is a default setting on
amd64/amd64, arm/arm, arm/armeb, arm/armv6, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, pc98/i386, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
.It Va WITH_LLVM_LIBUNWIND
Set to use LLVM's libunwind stack unwinder (instead of GCC's unwinder).
.Pp
This is a default setting on
arm64/aarch64.
.It Va WITHOUT_LOCALES
Set to not build localization files; see
.Xr locale 1 .
.It Va WITHOUT_LOCATE
Set to not build
.Xr locate 1
and related programs.
.It Va WITHOUT_LPR
Set to not build
.Xr lpr 1
and related programs.
.It Va WITHOUT_LS_COLORS
Set to build
.Xr ls 1
without support for colors to distinguish file types.
.It Va WITHOUT_LZMA_SUPPORT
Set to build some programs without optional lzma compression support.
.It Va WITHOUT_MAIL
Set to not build any mail support (MUA or MTA).
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_DMAGENT
.It
.Va WITHOUT_MAILWRAPPER
.It
.Va WITHOUT_SENDMAIL
.El
.It Va WITHOUT_MAILWRAPPER
Set to not build the
.Xr mailwrapper 8
MTA selector.
.It Va WITHOUT_MAKE
Set to not install
.Xr make 1
and related support files.
.It Va WITHOUT_MAN
Set to not build manual pages.
When set, these options are also in effect:
.Pp
.Bl -inset -compact
.It Va WITHOUT_MAN_UTILS
(unless
.Va WITH_MAN_UTILS
is set explicitly)
.El
.It Va WITHOUT_MANCOMPRESS
Set to not to install compressed man pages.
Only the uncompressed versions will be installed.
.It Va WITHOUT_MANDOCDB
Use the version of
.Xr makewhatis 1
introduced in
.Fx 2.1 ,
instead of the
.Xr makewhatis 8
database and utilities from
.Xr mandoc 1 .
.It Va WITHOUT_MAN_UTILS
Set to not build utilities for manual pages,
.Xr apropos 1 ,
.Xr catman 1 ,
.Xr makewhatis 1 ,
.Xr man 1 ,
.Xr whatis 1 ,
.Xr manctl 8 ,
and related support files.
.It Va WITH_META_MODE
Create
.Xr make 1
meta files when building, which can provide a reliable incremental build when
using
.Xr filemon 4 .
The meta file is created in OBJDIR as
.Pa target.meta .
These meta files track the command that was executed, its output, and the
current directory.
The
.Xr filemon 4
module is required unless
.Va NO_FILEMON
is defined.
When the module is loaded, any files used by the commands executed are
tracked as dependencies for the target in its meta file.
The target is considered out-of-date and rebuilt if any of these
conditions are true compared to the last build:
.Bl -bullet -compact
.It
The command to execute changes.
.It
The current working directory changes.
.It
The target's meta file is missing.
.It
The target's meta file is missing filemon data when filemon is loaded
and a previous run did not have it loaded.
.It
[requires
.Xr filemon 4 ]
Files read, executed or linked to are newer than the target.
.It
[requires
.Xr filemon 4 ]
Files read, written, executed or linked are missing.
.El
The meta files can also be useful for debugging.
.Pp
The build hides commands that are executed unless
.Va NO_SILENT
is defined.
Errors cause
.Xr make 1
to show some of its environment for further debugging.
.Pp
The build operates as it normally would otherwise.
This option originally invoked a different build system but that was renamed
to
.Va WITH_DIRDEPS_BUILD .
.Pp
Currently this also enforces
.Va WITHOUT_SYSTEM_COMPILER .
When set, these options are also in effect:
.Pp
.Bl -inset -compact
.It Va WITHOUT_SYSTEM_COMPILER
(unless
.Va WITH_SYSTEM_COMPILER
is set explicitly)
.El
.Pp
This must be set in the environment, make command line, or
.Pa /etc/src-env.conf ,
not
.Pa /etc/src.conf .
.It Va WITH_NAND
Set to build the NAND Flash components.
.It Va WITHOUT_NDIS
Set to not build programs and libraries
related to NDIS emulation support.
.It Va WITHOUT_NETCAT
Set to not build
.Xr nc 1
utility.
.It Va WITHOUT_NETGRAPH
Set to not build applications to support
.Xr netgraph 4 .
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_ATM
.It
.Va WITHOUT_BLUETOOTH
.It
.Va WITHOUT_NETGRAPH_SUPPORT
.El
.It Va WITHOUT_NETGRAPH_SUPPORT
Set to build libraries, programs, and kernel modules without netgraph support.
.It Va WITHOUT_NIS
Set to not build
.Xr NIS 8
support and related programs.
If set, you might need to adopt your
.Xr nsswitch.conf 5
and remove
.Sq nis
entries.
.It Va WITHOUT_NLS
Set to not build NLS catalogs.
.It Va WITHOUT_NLS_CATALOGS
Set to not build NLS catalog support for
.Xr csh 1 .
.It Va WITHOUT_NS_CACHING
Set to disable name caching in the
.Pa nsswitch
subsystem.
The generic caching daemon,
.Xr nscd 8 ,
will not be built either if this option is set.
.It Va WITHOUT_NTP
Set to not build
.Xr ntpd 8
and related programs.
.It Va WITH_OFED
Set to build the
.Dq "OpenFabrics Enterprise Distribution"
Infiniband software stack.
.It Va WITH_OPENLDAP
Enable building openldap support for kerberos.
.It Va WITHOUT_OPENSSH
Set to not build OpenSSH.
.It Va WITHOUT_OPENSSL
Set to not build OpenSSL.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_KERBEROS
.It
.Va WITHOUT_KERBEROS_SUPPORT
.It
.Va WITHOUT_OPENSSH
.El
.Pp
When set, these options are also in effect:
.Pp
.Bl -inset -compact
.It Va WITHOUT_GSSAPI
(unless
.Va WITH_GSSAPI
is set explicitly)
.El
.It Va WITHOUT_PAM
Set to not build PAM library and modules.
.Bf -symbolic
This option is deprecated and does nothing.
.Ef
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_PAM_SUPPORT
.El
.It Va WITHOUT_PAM_SUPPORT
Set to build some programs without PAM support, particularly
.Xr ftpd 8
and
.Xr ppp 8 .
.It Va WITHOUT_PC_SYSINSTALL
Set to not build
.Xr pc-sysinstall 8
and related programs.
.It Va WITHOUT_PF
Set to not build PF firewall package.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_AUTHPF
.El
.It Va WITHOUT_PKGBOOTSTRAP
Set to not build
.Xr pkg 7
bootstrap tool.
.It Va WITHOUT_PMC
Set to not build
.Xr pmccontrol 8
and related programs.
.It Va WITHOUT_PORTSNAP
Set to not build or install
.Xr portsnap 8
and related files.
.It Va WITHOUT_PPP
Set to not build
.Xr ppp 8
and related programs.
.It Va WITHOUT_PROFILE
Set to not build profiled libraries for use with
.Xr gprof 8 .
.It Va WITHOUT_QUOTAS
Set to not build
.Xr quota 1
and related programs.
.It Va WITHOUT_RADIUS_SUPPORT
Set to not build radius support into various applications, like
.Xr pam_radius 8
and
.Xr ppp 8 .
.It Va WITHOUT_RBOOTD
Set to not build or install
.Xr rbootd 8 .
.It Va WITHOUT_RCMDS
Disable building of the
.Bx
r-commands.
This includes
.Xr rlogin 1 ,
.Xr rsh 1 ,
etc.
.It Va WITHOUT_RCS
Set to not build
.Xr rcs 1 ,
.Xr etcupdate 8 ,
and related utilities.
.It Va WITH_REPRODUCIBLE_BUILD
Set to exclude build metadata (such as the build time, user, or host)
from the kernel, boot loaders, and uname output, so that builds produce
bit-for-bit identical output.
.It Va WITHOUT_RESCUE
Set to not build
.Xr rescue 8 .
.It Va WITHOUT_ROUTED
Set to not build
.Xr routed 8
utility.
.It Va WITH_RPCBIND_WARMSTART_SUPPORT
Set to build
.Xr rpcbind 8
with warmstart support.
.It Va WITHOUT_SENDMAIL
Set to not build
.Xr sendmail 8
and related programs.
.It Va WITHOUT_SETUID_LOGIN
Set this to disable the installation of
.Xr login 1
as a set-user-ID root program.
.It Va WITHOUT_SHAREDOCS
Set to not build the
.Bx 4.4
legacy docs.
.It Va WITH_SHARED_TOOLCHAIN
Set to build the toolchain binaries shared.
The set includes
.Xr cc 1 ,
.Xr make 1
and necessary utilities like assembler, linker and library archive manager.
.It Va WITH_SORT_THREADS
Set to enable threads in
.Xr sort 1 .
.It Va WITHOUT_SOURCELESS
Set to not build kernel modules that include sourceless code (either microcode or native code for host CPU).
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_SOURCELESS_HOST
.It
.Va WITHOUT_SOURCELESS_UCODE
.El
.It Va WITHOUT_SOURCELESS_HOST
Set to not build kernel modules that include sourceless native code for host CPU.
.It Va WITHOUT_SOURCELESS_UCODE
Set to not build kernel modules that include sourceless microcode.
.It Va WITHOUT_SSP
Set to not build world with propolice stack smashing protection.
.It Va WITH_STAGING
Enable staging of files to a stage tree.
This can be best thought of as auto-install to
.Va DESTDIR
with some extra meta data to ensure dependencies can be tracked.
Depends on
.Va WITH_DIRDEPS_BUILD .
When set, these options are also in effect:
.Pp
.Bl -inset -compact
.It Va WITH_STAGING_MAN
(unless
.Va WITHOUT_STAGING_MAN
is set explicitly)
.It Va WITH_STAGING_PROG
(unless
.Va WITHOUT_STAGING_PROG
is set explicitly)
.El
.Pp
This must be set in the environment, make command line, or
.Pa /etc/src-env.conf ,
not
.Pa /etc/src.conf .
.It Va WITH_STAGING_MAN
Enable staging of man pages to stage tree.
.It Va WITH_STAGING_PROG
Enable staging of PROGs to stage tree.
.It Va WITH_STALE_STAGED
Check staged files are not stale.
.It Va WITH_SVN
Set to install
.Xr svnlite 1
as
.Xr svn 1 .
.It Va WITHOUT_SVNLITE
Set to not build
.Xr svnlite 1
and related programs.
.It Va WITHOUT_SYMVER
Set to disable symbol versioning when building shared libraries.
.It Va WITHOUT_SYSCONS
Set to not build
.Xr syscons 4
support files such as keyboard maps, fonts, and screen output maps.
.It Va WITH_SYSROOT
Enable use of sysroot during build.
Depends on
.Va WITH_DIRDEPS_BUILD .
.Pp
This must be set in the environment, make command line, or
.Pa /etc/src-env.conf ,
not
.Pa /etc/src.conf .
.It Va WITHOUT_SYSTEM_COMPILER
Set to not opportunistically skip building a cross-compiler during the
bootstrap phase of the build.
Normally, if the currently installed compiler matches the planned bootstrap
compiler type and revision, then it will not be built.
This does not prevent a compiler from being built for installation though,
only for building one for the build itself.
The
.Va WITHOUT_CLANG
and
.Va WITHOUT_GCC
options control those.
.It Va WITHOUT_TALK
Set to not build or install
.Xr talk 1
and
.Xr talkd 8 .
.It Va WITHOUT_TCP_WRAPPERS
Set to not build or install
.Xr tcpd 8 ,
and related utilities.
.It Va WITHOUT_TCSH
Set to not build and install
.Pa /bin/csh
(which is
.Xr tcsh 1 ) .
.It Va WITHOUT_TELNET
Set to not build
.Xr telnet 1
and related programs.
.It Va WITHOUT_TESTS
Set to not build nor install the
.Fx
Test Suite in
.Pa /usr/tests/ .
See
.Xr tests 7
for more details.
This also disables the build of all test-related dependencies, including ATF.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_DTRACE_TESTS
.It
.Va WITHOUT_TESTS_SUPPORT
.El
.It Va WITHOUT_TESTS_SUPPORT
Set to disables the build of all test-related dependencies, including ATF.
.It Va WITHOUT_TEXTPROC
Set to not build
programs used for text processing.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_GROFF
.El
.It Va WITHOUT_TFTP
Set to not build or install
.Xr tftp 1
and
.Xr tftpd 8 .
.It Va WITHOUT_TIMED
Set to not build or install
.Xr timed 8 .
.It Va WITHOUT_TOOLCHAIN
Set to not install header or
programs used for program development,
compilers, debuggers etc.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_BINUTILS
.It
.Va WITHOUT_CLANG
.It
.Va WITHOUT_CLANG_EXTRAS
.It
.Va WITHOUT_CLANG_FULL
.It
.Va WITHOUT_GCC
.It
.Va WITHOUT_GDB
.It
.Va WITHOUT_INCLUDES
.It
.Va WITHOUT_LLD
.It
.Va WITHOUT_LLDB
.El
.It Va WITHOUT_UNBOUND
Set to not build
.Xr unbound 8
and related programs.
.It Va WITHOUT_USB
Set to not build USB-related programs and libraries.
.It Va WITHOUT_USB_GADGET_EXAMPLES
Set to not build USB gadget kernel modules.
.It Va WITHOUT_UTMPX
Set to not build user accounting tools such as
.Xr last 1 ,
.Xr users 1 ,
.Xr who 1 ,
.Xr ac 8 ,
.Xr lastlogin 8
and
.Xr utx 8 .
.It Va WITHOUT_VI
Set to not build and install vi, view, ex and related programs.
.It Va WITHOUT_VT
Set to not build
.Xr vt 4
support files (fonts and keymaps).
.It Va WITHOUT_WARNS
Set this to not add warning flags to the compiler invocations.
Useful as a temporary workaround when code enters the tree
which triggers warnings in environments that differ from the
original developer.
.It Va WITHOUT_WIRELESS
Set to not build programs used for 802.11 wireless networks; especially
.Xr wpa_supplicant 8
and
.Xr hostapd 8 .
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_WIRELESS_SUPPORT
.El
.It Va WITHOUT_WIRELESS_SUPPORT
Set to build libraries, programs, and kernel modules without
802.11 wireless support.
.It Va WITHOUT_WPA_SUPPLICANT_EAPOL
Build
.Xr wpa_supplicant 8
without support for the IEEE 802.1X protocol and without
support for EAP-PEAP, EAP-TLS, EAP-LEAP, and EAP-TTLS
protocols (usable only via 802.1X).
.It Va WITHOUT_ZFS
Set to not build ZFS file system.
.It Va WITHOUT_ZONEINFO
Set to not build the timezone database.
When set, it enforces these options:
.Pp
.Bl -item -compact
.It
.Va WITHOUT_ZONEINFO_LEAPSECONDS_SUPPORT
.It
.Va WITHOUT_ZONEINFO_OLD_TIMEZONES_SUPPORT
.El
.It Va WITH_ZONEINFO_LEAPSECONDS_SUPPORT
Set to build leapsecond information in to the timezone database.
.It Va WITH_ZONEINFO_OLD_TIMEZONES_SUPPORT
Set to build backward compatibility timezone aliases in to the timezone
database.
.El
.Sh FILES
.Bl -tag -compact -width Pa
.It Pa /etc/src.conf
.It Pa /etc/src-env.conf
.It Pa /usr/share/mk/bsd.own.mk
.El
.Sh SEE ALSO
.Xr make 1 ,
.Xr make.conf 5 ,
.Xr build 7 ,
.Xr ports 7
.Sh HISTORY
The
.Nm
file appeared in
.Fx 7.0 .
.Sh AUTHORS
This manual page was autogenerated by
.An tools/build/options/makeman .
Index: stable/11/share/mk/src.opts.mk
===================================================================
--- stable/11/share/mk/src.opts.mk (revision 322581)
+++ stable/11/share/mk/src.opts.mk (revision 322582)
@@ -1,466 +1,467 @@
# $FreeBSD$
#
# Option file for FreeBSD /usr/src builds.
#
# Users define WITH_FOO and WITHOUT_FOO on the command line or in /etc/src.conf
# and /etc/make.conf files. These translate in the build system to MK_FOO={yes,no}
# with sensible (usually) defaults.
#
# Makefiles must include bsd.opts.mk after defining specific MK_FOO options that
# are applicable for that Makefile (typically there are none, but sometimes there
# are exceptions). Recursive makes usually add MK_FOO=no for options that they wish
# to omit from that make.
#
# Makefiles must include bsd.mkopt.mk before they test the value of any MK_FOO
# variable.
#
# Makefiles may also assume that this file is included by src.opts.mk should it
# need variables defined there prior to the end of the Makefile where
# bsd.{subdir,lib.bin}.mk is traditionally included.
#
# The old-style YES_FOO and NO_FOO are being phased out. No new instances of them
# should be added. Old instances should be removed since they were just to
# bridge the gap between FreeBSD 4 and FreeBSD 5.
#
# Makefiles should never test WITH_FOO or WITHOUT_FOO directly (although an
# exception is made for _WITHOUT_SRCONF which turns off this mechanism
# completely inside bsd.*.mk files).
#
.if !target(__<src.opts.mk>__)
__<src.opts.mk>__:
.include <bsd.own.mk>
#
# Define MK_* variables (which are either "yes" or "no") for users
# to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the
# make(1) environment.
# These should be tested with `== "no"' or `!= "no"' in makefiles.
# The NO_* variables should only be set by makefiles for variables
# that haven't been converted over.
#
# These options are used by src the builds
__DEFAULT_YES_OPTIONS = \
ACCT \
ACPI \
AMD \
APM \
AT \
ATM \
AUDIT \
AUTHPF \
AUTOFS \
BHYVE \
BINUTILS \
BINUTILS_BOOTSTRAP \
BLACKLIST \
BLUETOOTH \
BOOT \
BOOTPARAMD \
BOOTPD \
BSD_CPIO \
+ BSD_GREP_FASTMATCH \
BSDINSTALL \
BSNMP \
BZIP2 \
CALENDAR \
CAPSICUM \
CASPER \
CCD \
CDDL \
CPP \
CROSS_COMPILER \
CRYPT \
CTM \
CUSE \
CXX \
DIALOG \
DICT \
DMAGENT \
DYNAMICROOT \
ED_CRYPTO \
EE \
ELFCOPY_AS_OBJCOPY \
EFI \
ELFTOOLCHAIN_BOOTSTRAP \
EXAMPLES \
FDT \
FILE \
FINGER \
FLOPPY \
FMTREE \
FORTH \
FP_LIBC \
FREEBSD_UPDATE \
FTP \
GAMES \
GCOV \
GDB \
GNU \
GNU_GREP_COMPAT \
GPIO \
GPL_DTC \
GROFF \
HAST \
HTML \
HYPERV \
ICONV \
INET \
INET6 \
INETD \
IPFILTER \
IPFW \
ISCSI \
JAIL \
KDUMP \
KVM \
LDNS \
LDNS_UTILS \
LEGACY_CONSOLE \
LIB32 \
LIBPTHREAD \
LIBTHR \
LOCALES \
LOCATE \
LPR \
LS_COLORS \
LZMA_SUPPORT \
MAIL \
MAILWRAPPER \
MAKE \
MANDOCDB \
NDIS \
NETCAT \
NETGRAPH \
NLS_CATALOGS \
NS_CACHING \
NTP \
OPENSSL \
PAM \
PC_SYSINSTALL \
PF \
PKGBOOTSTRAP \
PMC \
PORTSNAP \
PPP \
QUOTAS \
RADIUS_SUPPORT \
RCMDS \
RBOOTD \
RCS \
RESCUE \
ROUTED \
SENDMAIL \
SETUID_LOGIN \
SHAREDOCS \
SOURCELESS \
SOURCELESS_HOST \
SOURCELESS_UCODE \
SVNLITE \
SYSCONS \
SYSTEM_COMPILER \
TALK \
TCP_WRAPPERS \
TCSH \
TELNET \
TESTS \
TEXTPROC \
TFTP \
TIMED \
UNBOUND \
USB \
UTMPX \
VI \
VT \
WIRELESS \
WPA_SUPPLICANT_EAPOL \
ZFS \
ZONEINFO
__DEFAULT_NO_OPTIONS = \
BSD_GREP \
CLANG_EXTRAS \
DTRACE_TESTS \
EISA \
HESIOD \
LIBSOFT \
NAND \
OFED \
OPENLDAP \
REPRODUCIBLE_BUILD \
RPCBIND_WARMSTART_SUPPORT \
SHARED_TOOLCHAIN \
SORT_THREADS \
SVN \
ZONEINFO_LEAPSECONDS_SUPPORT \
ZONEINFO_OLD_TIMEZONES_SUPPORT \
#
# Default behaviour of some options depends on the architecture. Unfortunately
# this means that we have to test TARGET_ARCH (the buildworld case) as well
# as MACHINE_ARCH (the non-buildworld case). Normally TARGET_ARCH is not
# used at all in bsd.*.mk, but we have to make an exception here if we want
# to allow defaults for some things like clang to vary by target architecture.
# Additional, per-target behavior should be rarely added only after much
# gnashing of teeth and grinding of gears.
#
.if defined(TARGET_ARCH)
__T=${TARGET_ARCH}
.else
__T=${MACHINE_ARCH}
.endif
.if defined(TARGET)
__TT=${TARGET}
.else
__TT=${MACHINE}
.endif
.include <bsd.compiler.mk>
# If the compiler is not C++11 capable, disable Clang and use GCC instead.
# This means that architectures that have GCC 4.2 as default can not
# build Clang without using an external compiler.
.if ${COMPILER_FEATURES:Mc++11} && (${__T} == "aarch64" || \
${__T} == "amd64" || ${__TT} == "arm" || ${__T} == "i386")
# Clang is enabled, and will be installed as the default /usr/bin/cc.
__DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC LLD
__DEFAULT_NO_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
.elif ${COMPILER_FEATURES:Mc++11} && ${__T} != "riscv64" && ${__T} != "sparc64"
# If an external compiler that supports C++11 is used as ${CC} and Clang
# supports the target, then Clang is enabled but GCC is installed as the
# default /usr/bin/cc.
__DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL GCC GCC_BOOTSTRAP GNUCXX
__DEFAULT_NO_OPTIONS+=CLANG_BOOTSTRAP CLANG_IS_CC LLD
.else
# Everything else disables Clang, and uses GCC instead.
__DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
__DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC LLD
.endif
# In-tree binutils/gcc are older versions without modern architecture support.
.if ${__T} == "aarch64" || ${__T} == "riscv64"
BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB
__DEFAULT_YES_OPTIONS+=LLVM_LIBUNWIND
.else
__DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND
.endif
.if ${__T} == "riscv64"
BROKEN_OPTIONS+=PROFILE # "sorry, unimplemented: profiler support for RISC-V"
BROKEN_OPTIONS+=TESTS # "undefined reference to `_Unwind_Resume'"
BROKEN_OPTIONS+=CXX # "libcxxrt.so: undefined reference to `_Unwind_Resume_or_Rethrow'"
.endif
.if ${__T} == "aarch64"
__DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
.else
__DEFAULT_NO_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
.endif
.if ${__T} == "aarch64" || ${__T} == "amd64"
__DEFAULT_YES_OPTIONS+=LLDB
.else
__DEFAULT_NO_OPTIONS+=LLDB
.endif
# LLVM lacks support for FreeBSD 64-bit atomic operations for ARMv4/ARMv5
.if ${__T} == "arm" || ${__T} == "armeb"
BROKEN_OPTIONS+=LLDB
.endif
# Only doing soft float API stuff on armv6
.if ${__T} != "armv6"
BROKEN_OPTIONS+=LIBSOFT
.endif
.if ${__T:Mmips*} || ${__T:Mpowerpc*} || ${__T:Msparc64} || ${__T:Mriscv*}
BROKEN_OPTIONS+=EFI
.endif
.if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \
${__T} == "powerpc64" || ${__T} == "sparc64"
__DEFAULT_YES_OPTIONS+=CXGBETOOL
.else
__DEFAULT_NO_OPTIONS+=CXGBETOOL
.endif
.include <bsd.mkopt.mk>
#
# MK_* options that default to "yes" if the compiler is a C++11 compiler.
#
.for var in \
LIBCPLUSPLUS
.if !defined(MK_${var})
.if ${COMPILER_FEATURES:Mc++11}
.if defined(WITHOUT_${var})
MK_${var}:= no
.else
MK_${var}:= yes
.endif
.else
.if defined(WITH_${var})
MK_${var}:= yes
.else
MK_${var}:= no
.endif
.endif
.endif
.endfor
#
# Force some options off if their dependencies are off.
# Order is somewhat important.
#
.if ${MK_CAPSICUM} == "no"
MK_CASPER:= no
.endif
.if ${MK_LIBPTHREAD} == "no"
MK_LIBTHR:= no
.endif
.if ${MK_LDNS} == "no"
MK_LDNS_UTILS:= no
MK_UNBOUND:= no
.endif
.if ${MK_SOURCELESS} == "no"
MK_SOURCELESS_HOST:= no
MK_SOURCELESS_UCODE:= no
.endif
.if ${MK_CDDL} == "no"
MK_ZFS:= no
MK_CTF:= no
.endif
.if ${MK_CRYPT} == "no"
MK_OPENSSL:= no
MK_OPENSSH:= no
MK_KERBEROS:= no
.endif
.if ${MK_CXX} == "no"
MK_CLANG:= no
MK_GROFF:= no
MK_GNUCXX:= no
.endif
.if ${MK_DIALOG} == "no"
MK_BSDINSTALL:= no
.endif
.if ${MK_MAIL} == "no"
MK_MAILWRAPPER:= no
MK_SENDMAIL:= no
MK_DMAGENT:= no
.endif
.if ${MK_NETGRAPH} == "no"
MK_ATM:= no
MK_BLUETOOTH:= no
.endif
.if ${MK_OPENSSL} == "no"
MK_OPENSSH:= no
MK_KERBEROS:= no
.endif
.if ${MK_PF} == "no"
MK_AUTHPF:= no
.endif
.if ${MK_TESTS} == "no"
MK_DTRACE_TESTS:= no
.endif
.if ${MK_TEXTPROC} == "no"
MK_GROFF:= no
.endif
.if ${MK_ZONEINFO} == "no"
MK_ZONEINFO_LEAPSECONDS_SUPPORT:= no
MK_ZONEINFO_OLD_TIMEZONES_SUPPORT:= no
.endif
.if ${MK_CROSS_COMPILER} == "no"
MK_BINUTILS_BOOTSTRAP:= no
MK_CLANG_BOOTSTRAP:= no
MK_ELFTOOLCHAIN_BOOTSTRAP:= no
MK_GCC_BOOTSTRAP:= no
.endif
.if ${MK_META_MODE} == "yes"
MK_SYSTEM_COMPILER:= no
.endif
.if ${MK_TOOLCHAIN} == "no"
MK_BINUTILS:= no
MK_CLANG:= no
MK_GCC:= no
MK_GDB:= no
MK_INCLUDES:= no
MK_LLD:= no
MK_LLDB:= no
.endif
.if ${MK_CLANG} == "no"
MK_CLANG_EXTRAS:= no
MK_CLANG_FULL:= no
.endif
#
# MK_* options whose default value depends on another option.
#
.for vv in \
GSSAPI/KERBEROS \
MAN_UTILS/MAN
.if defined(WITH_${vv:H})
MK_${vv:H}:= yes
.elif defined(WITHOUT_${vv:H})
MK_${vv:H}:= no
.else
MK_${vv:H}:= ${MK_${vv:T}}
.endif
.endfor
#
# Set defaults for the MK_*_SUPPORT variables.
#
#
# MK_*_SUPPORT options which default to "yes" unless their corresponding
# MK_* variable is set to "no".
#
.for var in \
BLACKLIST \
BZIP2 \
GNU \
INET \
INET6 \
KERBEROS \
KVM \
NETGRAPH \
PAM \
TESTS \
WIRELESS
.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
MK_${var}_SUPPORT:= no
.else
MK_${var}_SUPPORT:= yes
.endif
.endfor
.if !${COMPILER_FEATURES:Mc++11}
MK_LLDB:= no
.endif
# gcc 4.8 and newer supports libc++, so suppress gnuc++ in that case.
# while in theory we could build it with that, we don't want to do
# that since it creates too much confusion for too little gain.
# XXX: This is incomplete and needs X_COMPILER_TYPE/VERSION checks too
# to prevent Makefile.inc1 from bootstrapping unneeded dependencies
# and to support 'make delete-old' when supplying an external toolchain.
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800
MK_GNUCXX:=no
MK_GCC:=no
.endif
.endif # !target(__<src.opts.mk>__)
Index: stable/11/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH
===================================================================
--- stable/11/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH (nonexistent)
+++ stable/11/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH (revision 322582)
@@ -0,0 +1,5 @@
+.\" $FreeBSD$
+Set this option to exclude the fastmatch implementation from
+.Xr bsdgrep 1 ,
+instead using only
+.Xr regex 3 .
Property changes on: stable/11/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+FreeBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: stable/11/usr.bin/grep/Makefile
===================================================================
--- stable/11/usr.bin/grep/Makefile (revision 322581)
+++ stable/11/usr.bin/grep/Makefile (revision 322582)
@@ -1,95 +1,99 @@
# $NetBSD: Makefile,v 1.4 2011/02/16 01:31:33 joerg Exp $
# $FreeBSD$
# $OpenBSD: Makefile,v 1.6 2003/06/25 15:00:04 millert Exp $
.include <src.opts.mk>
.if ${MK_BSD_GREP} == "yes"
PROG= grep
.else
PROG= bsdgrep
CLEANFILES+= bsdgrep.1
bsdgrep.1: grep.1
${CP} ${.ALLSRC} ${.TARGET}
.endif
SRCS= file.c grep.c queue.c util.c
-# Extra files ported backported form some regex improvements
+.if ${MK_BSD_GREP_FASTMATCH} == "yes"
+# Extra files ported backported for some regex improvements
.PATH: ${.CURDIR}/regex
SRCS+= fastmatch.c hashtable.c tre-compile.c tre-fastmatch.c
CFLAGS+=-I${.CURDIR}/regex
+.else
+CFLAGS+= -DWITHOUT_FASTMATCH
+.endif
CFLAGS.gcc+= --param max-inline-insns-single=500
.if ${MK_BSD_GREP} == "yes"
LINKS= ${BINDIR}/grep ${BINDIR}/egrep \
${BINDIR}/grep ${BINDIR}/fgrep \
${BINDIR}/grep ${BINDIR}/rgrep \
${BINDIR}/grep ${BINDIR}/zgrep \
${BINDIR}/grep ${BINDIR}/zegrep \
${BINDIR}/grep ${BINDIR}/zfgrep
MLINKS= grep.1 egrep.1 \
grep.1 fgrep.1 \
grep.1 rgrep.1 \
grep.1 zgrep.1 \
grep.1 zegrep.1 \
grep.1 zfgrep.1
.endif
LIBADD= z
.if ${MK_LZMA_SUPPORT} != "no"
LIBADD+= lzma
.if ${MK_BSD_GREP} == "yes"
LINKS+= ${BINDIR}/${PROG} ${BINDIR}/xzgrep \
${BINDIR}/${PROG} ${BINDIR}/xzegrep \
${BINDIR}/${PROG} ${BINDIR}/xzfgrep \
${BINDIR}/${PROG} ${BINDIR}/lzgrep \
${BINDIR}/${PROG} ${BINDIR}/lzegrep \
${BINDIR}/${PROG} ${BINDIR}/lzfgrep
MLINKS+= grep.1 xzgrep.1 \
grep.1 xzegrep.1 \
grep.1 xzfgrep.1 \
grep.1 lzgrep.1 \
grep.1 lzegrep.1 \
grep.1 lzfgrep.1
.endif
.else
CFLAGS+= -DWITHOUT_LZMA
.endif
.if ${MK_BZIP2_SUPPORT} != "no"
LIBADD+= bz2
.if ${MK_BSD_GREP} == "yes"
LINKS+= ${BINDIR}/grep ${BINDIR}/bzgrep \
${BINDIR}/grep ${BINDIR}/bzegrep \
${BINDIR}/grep ${BINDIR}/bzfgrep
MLINKS+= grep.1 bzgrep.1 \
grep.1 bzegrep.1 \
grep.1 bzfgrep.1
.endif
.else
CFLAGS+= -DWITHOUT_BZIP2
.endif
.if ${MK_GNU_GREP_COMPAT} != "no"
CFLAGS+= -I${DESTDIR}/usr/include/gnu
LIBADD+= gnuregex
.endif
.if ${MK_NLS} != "no"
.include "${.CURDIR}/nls/Makefile.inc"
.else
CFLAGS+= -DWITHOUT_NLS
.endif
.if ${MK_TESTS} != "no"
SUBDIR+= tests
.endif
.include <bsd.prog.mk>
Index: stable/11/usr.bin/grep/grep.c
===================================================================
--- stable/11/usr.bin/grep/grep.c (revision 322581)
+++ stable/11/usr.bin/grep/grep.c (revision 322582)
@@ -1,761 +1,770 @@
/* $NetBSD: grep.c,v 1.6 2011/04/18 03:48:23 joerg Exp $ */
/* $FreeBSD$ */
/* $OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
* Copyright (C) 2008-2009 Gabor Kovesdan <gabor@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <sys/types.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
#include <libgen.h>
#include <locale.h>
#include <stdbool.h>
#define _WITH_GETLINE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#ifndef WITHOUT_FASTMATCH
#include "fastmatch.h"
+#endif
#include "grep.h"
#ifndef WITHOUT_NLS
#include <nl_types.h>
nl_catd catalog;
#endif
/*
* Default messags to use when NLS is disabled or no catalogue
* is found.
*/
const char *errstr[] = {
"",
/* 1*/ "(standard input)",
/* 2*/ "cannot read bzip2 compressed file",
/* 3*/ "unknown %s option",
/* 4*/ "usage: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]]\n",
/* 5*/ "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n",
/* 6*/ "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n",
/* 7*/ "\t[--null] [pattern] [file ...]\n",
/* 8*/ "Binary file %s matches\n",
/* 9*/ "%s (BSD grep) %s\n",
};
/* Flags passed to regcomp() and regexec() */
int cflags = REG_NOSUB;
int eflags = REG_STARTEND;
/* Shortcut for matching all cases like empty regex */
bool matchall;
/* Searching patterns */
unsigned int patterns;
static unsigned int pattern_sz;
struct pat *pattern;
regex_t *r_pattern;
+#ifndef WITHOUT_FASTMATCH
fastmatch_t *fg_pattern;
+#endif
/* Filename exclusion/inclusion patterns */
unsigned int fpatterns, dpatterns;
static unsigned int fpattern_sz, dpattern_sz;
struct epat *dpattern, *fpattern;
/* For regex errors */
char re_error[RE_ERROR_BUF + 1];
/* Command-line flags */
unsigned long long Aflag; /* -A x: print x lines trailing each match */
unsigned long long Bflag; /* -B x: print x lines leading each match */
bool Hflag; /* -H: always print file name */
bool Lflag; /* -L: only show names of files with no matches */
bool bflag; /* -b: show block numbers for each match */
bool cflag; /* -c: only show a count of matching lines */
bool hflag; /* -h: don't print filename headers */
bool iflag; /* -i: ignore case */
bool lflag; /* -l: only show names of files with matches */
bool mflag; /* -m x: stop reading the files after x matches */
long long mcount; /* count for -m */
long long mlimit; /* requested value for -m */
char fileeol; /* indicator for eol */
bool nflag; /* -n: show line numbers in front of matching lines */
bool oflag; /* -o: print only matching part */
bool qflag; /* -q: quiet mode (don't output anything) */
bool sflag; /* -s: silent mode (ignore errors) */
bool vflag; /* -v: only show non-matching lines */
bool wflag; /* -w: pattern must start and end on word boundaries */
bool xflag; /* -x: pattern must match entire line */
bool lbflag; /* --line-buffered */
bool nullflag; /* --null */
char *label; /* --label */
const char *color; /* --color */
int grepbehave = GREP_BASIC; /* -EFGP: type of the regex */
int binbehave = BINFILE_BIN; /* -aIU: handling of binary files */
int filebehave = FILE_STDIO; /* -JZ: normal, gzip or bzip2 file */
int devbehave = DEV_READ; /* -D: handling of devices */
int dirbehave = DIR_READ; /* -dRr: handling of directories */
int linkbehave = LINK_READ; /* -OpS: handling of symlinks */
bool dexclude, dinclude; /* --exclude-dir and --include-dir */
bool fexclude, finclude; /* --exclude and --include */
enum {
BIN_OPT = CHAR_MAX + 1,
COLOR_OPT,
HELP_OPT,
MMAP_OPT,
LINEBUF_OPT,
LABEL_OPT,
NULL_OPT,
R_EXCLUDE_OPT,
R_INCLUDE_OPT,
R_DEXCLUDE_OPT,
R_DINCLUDE_OPT
};
static inline const char *init_color(const char *);
/* Housekeeping */
bool first = true; /* flag whether we are processing the first match */
bool prev; /* flag whether or not the previous line matched */
int tail; /* lines left to print */
bool file_err; /* file reading error */
/*
* Prints usage information and returns 2.
*/
static void
usage(void)
{
fprintf(stderr, getstr(4), getprogname());
fprintf(stderr, "%s", getstr(5));
fprintf(stderr, "%s", getstr(6));
fprintf(stderr, "%s", getstr(7));
exit(2);
}
static const char *optstr = "0123456789A:B:C:D:EFGHIJMLOPSRUVZabcd:e:f:hilm:nopqrsuvwxXyz";
static const struct option long_options[] =
{
{"binary-files", required_argument, NULL, BIN_OPT},
{"help", no_argument, NULL, HELP_OPT},
{"mmap", no_argument, NULL, MMAP_OPT},
{"line-buffered", no_argument, NULL, LINEBUF_OPT},
{"label", required_argument, NULL, LABEL_OPT},
{"null", no_argument, NULL, NULL_OPT},
{"color", optional_argument, NULL, COLOR_OPT},
{"colour", optional_argument, NULL, COLOR_OPT},
{"exclude", required_argument, NULL, R_EXCLUDE_OPT},
{"include", required_argument, NULL, R_INCLUDE_OPT},
{"exclude-dir", required_argument, NULL, R_DEXCLUDE_OPT},
{"include-dir", required_argument, NULL, R_DINCLUDE_OPT},
{"after-context", required_argument, NULL, 'A'},
{"text", no_argument, NULL, 'a'},
{"before-context", required_argument, NULL, 'B'},
{"byte-offset", no_argument, NULL, 'b'},
{"context", optional_argument, NULL, 'C'},
{"count", no_argument, NULL, 'c'},
{"devices", required_argument, NULL, 'D'},
{"directories", required_argument, NULL, 'd'},
{"extended-regexp", no_argument, NULL, 'E'},
{"regexp", required_argument, NULL, 'e'},
{"fixed-strings", no_argument, NULL, 'F'},
{"file", required_argument, NULL, 'f'},
{"basic-regexp", no_argument, NULL, 'G'},
{"no-filename", no_argument, NULL, 'h'},
{"with-filename", no_argument, NULL, 'H'},
{"ignore-case", no_argument, NULL, 'i'},
{"bz2decompress", no_argument, NULL, 'J'},
{"files-with-matches", no_argument, NULL, 'l'},
{"files-without-match", no_argument, NULL, 'L'},
{"max-count", required_argument, NULL, 'm'},
{"lzma", no_argument, NULL, 'M'},
{"line-number", no_argument, NULL, 'n'},
{"only-matching", no_argument, NULL, 'o'},
{"quiet", no_argument, NULL, 'q'},
{"silent", no_argument, NULL, 'q'},
{"recursive", no_argument, NULL, 'r'},
{"no-messages", no_argument, NULL, 's'},
{"binary", no_argument, NULL, 'U'},
{"unix-byte-offsets", no_argument, NULL, 'u'},
{"invert-match", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{"word-regexp", no_argument, NULL, 'w'},
{"line-regexp", no_argument, NULL, 'x'},
{"xz", no_argument, NULL, 'X'},
{"null-data", no_argument, NULL, 'z'},
{"decompress", no_argument, NULL, 'Z'},
{NULL, no_argument, NULL, 0}
};
/*
* Adds a searching pattern to the internal array.
*/
static void
add_pattern(char *pat, size_t len)
{
/* Do not add further pattern is we already match everything */
if (matchall)
return;
/* Check if we can do a shortcut */
if (len == 0) {
matchall = true;
for (unsigned int i = 0; i < patterns; i++) {
free(pattern[i].pat);
}
pattern = grep_realloc(pattern, sizeof(struct pat));
pattern[0].pat = NULL;
pattern[0].len = 0;
patterns = 1;
return;
}
/* Increase size if necessary */
if (patterns == pattern_sz) {
pattern_sz *= 2;
pattern = grep_realloc(pattern, ++pattern_sz *
sizeof(struct pat));
}
if (len > 0 && pat[len - 1] == '\n')
--len;
/* pat may not be NUL-terminated */
pattern[patterns].pat = grep_malloc(len + 1);
memcpy(pattern[patterns].pat, pat, len);
pattern[patterns].len = len;
pattern[patterns].pat[len] = '\0';
++patterns;
}
/*
* Adds a file include/exclude pattern to the internal array.
*/
static void
add_fpattern(const char *pat, int mode)
{
/* Increase size if necessary */
if (fpatterns == fpattern_sz) {
fpattern_sz *= 2;
fpattern = grep_realloc(fpattern, ++fpattern_sz *
sizeof(struct epat));
}
fpattern[fpatterns].pat = grep_strdup(pat);
fpattern[fpatterns].mode = mode;
++fpatterns;
}
/*
* Adds a directory include/exclude pattern to the internal array.
*/
static void
add_dpattern(const char *pat, int mode)
{
/* Increase size if necessary */
if (dpatterns == dpattern_sz) {
dpattern_sz *= 2;
dpattern = grep_realloc(dpattern, ++dpattern_sz *
sizeof(struct epat));
}
dpattern[dpatterns].pat = grep_strdup(pat);
dpattern[dpatterns].mode = mode;
++dpatterns;
}
/*
* Reads searching patterns from a file and adds them with add_pattern().
*/
static void
read_patterns(const char *fn)
{
struct stat st;
FILE *f;
char *line;
size_t len;
ssize_t rlen;
if ((f = fopen(fn, "r")) == NULL)
err(2, "%s", fn);
if ((fstat(fileno(f), &st) == -1) || (S_ISDIR(st.st_mode))) {
fclose(f);
return;
}
len = 0;
line = NULL;
while ((rlen = getline(&line, &len, f)) != -1) {
if (line[0] == '\0')
continue;
add_pattern(line, line[0] == '\n' ? 0 : (size_t)rlen);
}
free(line);
if (ferror(f))
err(2, "%s", fn);
fclose(f);
}
static inline const char *
init_color(const char *d)
{
char *c;
c = getenv("GREP_COLOR");
return (c != NULL && c[0] != '\0' ? c : d);
}
int
main(int argc, char *argv[])
{
char **aargv, **eargv, *eopts;
char *ep;
const char *pn;
unsigned long long l;
unsigned int aargc, eargc, i;
int c, lastc, needpattern, newarg, prevoptind;
setlocale(LC_ALL, "");
#ifndef WITHOUT_NLS
catalog = catopen("grep", NL_CAT_LOCALE);
#endif
/* Check what is the program name of the binary. In this
way we can have all the funcionalities in one binary
without the need of scripting and using ugly hacks. */
pn = getprogname();
if (pn[0] == 'b' && pn[1] == 'z') {
filebehave = FILE_BZIP;
pn += 2;
} else if (pn[0] == 'x' && pn[1] == 'z') {
filebehave = FILE_XZ;
pn += 2;
} else if (pn[0] == 'l' && pn[1] == 'z') {
filebehave = FILE_LZMA;
pn += 2;
} else if (pn[0] == 'r') {
dirbehave = DIR_RECURSE;
Hflag = true;
} else if (pn[0] == 'z') {
filebehave = FILE_GZIP;
pn += 1;
}
switch (pn[0]) {
case 'e':
grepbehave = GREP_EXTENDED;
break;
case 'f':
grepbehave = GREP_FIXED;
break;
}
lastc = '\0';
newarg = 1;
prevoptind = 1;
needpattern = 1;
fileeol = '\n';
eopts = getenv("GREP_OPTIONS");
/* support for extra arguments in GREP_OPTIONS */
eargc = 0;
if (eopts != NULL && eopts[0] != '\0') {
char *str;
/* make an estimation of how many extra arguments we have */
for (unsigned int j = 0; j < strlen(eopts); j++)
if (eopts[j] == ' ')
eargc++;
eargv = (char **)grep_malloc(sizeof(char *) * (eargc + 1));
eargc = 0;
/* parse extra arguments */
while ((str = strsep(&eopts, " ")) != NULL)
if (str[0] != '\0')
eargv[eargc++] = grep_strdup(str);
aargv = (char **)grep_calloc(eargc + argc + 1,
sizeof(char *));
aargv[0] = argv[0];
for (i = 0; i < eargc; i++)
aargv[i + 1] = eargv[i];
for (int j = 1; j < argc; j++, i++)
aargv[i + 1] = argv[j];
aargc = eargc + argc;
} else {
aargv = argv;
aargc = argc;
}
while (((c = getopt_long(aargc, aargv, optstr, long_options, NULL)) !=
-1)) {
switch (c) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
if (newarg || !isdigit(lastc))
Aflag = 0;
else if (Aflag > LLONG_MAX / 10) {
errno = ERANGE;
err(2, NULL);
}
Aflag = Bflag = (Aflag * 10) + (c - '0');
break;
case 'C':
if (optarg == NULL) {
Aflag = Bflag = 2;
break;
}
/* FALLTHROUGH */
case 'A':
/* FALLTHROUGH */
case 'B':
errno = 0;
l = strtoull(optarg, &ep, 10);
if (((errno == ERANGE) && (l == ULLONG_MAX)) ||
((errno == EINVAL) && (l == 0)))
err(2, NULL);
else if (ep[0] != '\0') {
errno = EINVAL;
err(2, NULL);
}
if (c == 'A')
Aflag = l;
else if (c == 'B')
Bflag = l;
else
Aflag = Bflag = l;
break;
case 'a':
binbehave = BINFILE_TEXT;
break;
case 'b':
bflag = true;
break;
case 'c':
cflag = true;
break;
case 'D':
if (strcasecmp(optarg, "skip") == 0)
devbehave = DEV_SKIP;
else if (strcasecmp(optarg, "read") == 0)
devbehave = DEV_READ;
else
errx(2, getstr(3), "--devices");
break;
case 'd':
if (strcasecmp("recurse", optarg) == 0) {
Hflag = true;
dirbehave = DIR_RECURSE;
} else if (strcasecmp("skip", optarg) == 0)
dirbehave = DIR_SKIP;
else if (strcasecmp("read", optarg) == 0)
dirbehave = DIR_READ;
else
errx(2, getstr(3), "--directories");
break;
case 'E':
grepbehave = GREP_EXTENDED;
break;
case 'e':
{
char *token;
char *string = optarg;
while ((token = strsep(&string, "\n")) != NULL)
add_pattern(token, strlen(token));
}
needpattern = 0;
break;
case 'F':
grepbehave = GREP_FIXED;
break;
case 'f':
read_patterns(optarg);
needpattern = 0;
break;
case 'G':
grepbehave = GREP_BASIC;
break;
case 'H':
Hflag = true;
break;
case 'h':
Hflag = false;
hflag = true;
break;
case 'I':
binbehave = BINFILE_SKIP;
break;
case 'i':
case 'y':
iflag = true;
cflags |= REG_ICASE;
break;
case 'J':
#ifdef WITHOUT_BZIP2
errno = EOPNOTSUPP;
err(2, "bzip2 support was disabled at compile-time");
#endif
filebehave = FILE_BZIP;
break;
case 'L':
lflag = false;
Lflag = true;
break;
case 'l':
Lflag = false;
lflag = true;
break;
case 'm':
mflag = true;
errno = 0;
mlimit = mcount = strtoll(optarg, &ep, 10);
if (((errno == ERANGE) && (mcount == LLONG_MAX)) ||
((errno == EINVAL) && (mcount == 0)))
err(2, NULL);
else if (ep[0] != '\0') {
errno = EINVAL;
err(2, NULL);
}
break;
case 'M':
filebehave = FILE_LZMA;
break;
case 'n':
nflag = true;
break;
case 'O':
linkbehave = LINK_EXPLICIT;
break;
case 'o':
oflag = true;
cflags &= ~REG_NOSUB;
break;
case 'p':
linkbehave = LINK_SKIP;
break;
case 'q':
qflag = true;
break;
case 'S':
linkbehave = LINK_READ;
break;
case 'R':
case 'r':
dirbehave = DIR_RECURSE;
Hflag = true;
break;
case 's':
sflag = true;
break;
case 'U':
binbehave = BINFILE_BIN;
break;
case 'u':
case MMAP_OPT:
filebehave = FILE_MMAP;
break;
case 'V':
printf(getstr(9), getprogname(), VERSION);
exit(0);
case 'v':
vflag = true;
break;
case 'w':
wflag = true;
cflags &= ~REG_NOSUB;
break;
case 'x':
xflag = true;
cflags &= ~REG_NOSUB;
break;
case 'X':
filebehave = FILE_XZ;
break;
case 'z':
fileeol = '\0';
break;
case 'Z':
filebehave = FILE_GZIP;
break;
case BIN_OPT:
if (strcasecmp("binary", optarg) == 0)
binbehave = BINFILE_BIN;
else if (strcasecmp("without-match", optarg) == 0)
binbehave = BINFILE_SKIP;
else if (strcasecmp("text", optarg) == 0)
binbehave = BINFILE_TEXT;
else
errx(2, getstr(3), "--binary-files");
break;
case COLOR_OPT:
color = NULL;
if (optarg == NULL || strcasecmp("auto", optarg) == 0 ||
strcasecmp("tty", optarg) == 0 ||
strcasecmp("if-tty", optarg) == 0) {
char *term;
term = getenv("TERM");
if (isatty(STDOUT_FILENO) && term != NULL &&
strcasecmp(term, "dumb") != 0)
color = init_color("01;31");
} else if (strcasecmp("always", optarg) == 0 ||
strcasecmp("yes", optarg) == 0 ||
strcasecmp("force", optarg) == 0) {
color = init_color("01;31");
} else if (strcasecmp("never", optarg) != 0 &&
strcasecmp("none", optarg) != 0 &&
strcasecmp("no", optarg) != 0)
errx(2, getstr(3), "--color");
cflags &= ~REG_NOSUB;
break;
case LABEL_OPT:
label = optarg;
break;
case LINEBUF_OPT:
lbflag = true;
break;
case NULL_OPT:
nullflag = true;
break;
case R_INCLUDE_OPT:
finclude = true;
add_fpattern(optarg, INCL_PAT);
break;
case R_EXCLUDE_OPT:
fexclude = true;
add_fpattern(optarg, EXCL_PAT);
break;
case R_DINCLUDE_OPT:
dinclude = true;
add_dpattern(optarg, INCL_PAT);
break;
case R_DEXCLUDE_OPT:
dexclude = true;
add_dpattern(optarg, EXCL_PAT);
break;
case HELP_OPT:
default:
usage();
}
lastc = c;
newarg = optind != prevoptind;
prevoptind = optind;
}
aargc -= optind;
aargv += optind;
/* Empty pattern file matches nothing */
if (!needpattern && (patterns == 0))
exit(1);
/* Fail if we don't have any pattern */
if (aargc == 0 && needpattern)
usage();
/* Process patterns from command line */
if (aargc != 0 && needpattern) {
char *token;
char *string = *aargv;
while ((token = strsep(&string, "\n")) != NULL)
add_pattern(token, strlen(token));
--aargc;
++aargv;
}
switch (grepbehave) {
case GREP_BASIC:
break;
case GREP_FIXED:
/* XXX: header mess, REG_LITERAL not defined in gnu/regex.h */
cflags |= 0020;
break;
case GREP_EXTENDED:
cflags |= REG_EXTENDED;
break;
default:
/* NOTREACHED */
usage();
}
+#ifndef WITHOUT_FASTMATCH
fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern));
+#endif
r_pattern = grep_calloc(patterns, sizeof(*r_pattern));
/* Check if cheating is allowed (always is for fgrep). */
for (i = 0; i < patterns; ++i) {
+#ifndef WITHOUT_FASTMATCH
+ /* Attempt compilation with fastmatch regex and fallback to
+ regex(3) if it fails. */
if (fastncomp(&fg_pattern[i], pattern[i].pat,
- pattern[i].len, cflags) != 0) {
- /* Fall back to full regex library */
- c = regcomp(&r_pattern[i], pattern[i].pat, cflags);
- if (c != 0) {
- regerror(c, &r_pattern[i], re_error,
- RE_ERROR_BUF);
- errx(2, "%s", re_error);
- }
+ pattern[i].len, cflags) == 0)
+ continue;
+#endif
+ c = regcomp(&r_pattern[i], pattern[i].pat, cflags);
+ if (c != 0) {
+ regerror(c, &r_pattern[i], re_error,
+ RE_ERROR_BUF);
+ errx(2, "%s", re_error);
}
}
if (lbflag)
setlinebuf(stdout);
if ((aargc == 0 || aargc == 1) && !Hflag)
hflag = true;
if (aargc == 0 && dirbehave != DIR_RECURSE)
exit(!procfile("-"));
if (dirbehave == DIR_RECURSE)
c = grep_tree(aargv);
else
for (c = 0; aargc--; ++aargv) {
if ((finclude || fexclude) && !file_matching(*aargv))
continue;
c+= procfile(*aargv);
}
#ifndef WITHOUT_NLS
catclose(catalog);
#endif
/* Find out the correct return value according to the
results and the command line option. */
exit(c ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1));
}
Index: stable/11/usr.bin/grep/grep.h
===================================================================
--- stable/11/usr.bin/grep/grep.h (revision 322581)
+++ stable/11/usr.bin/grep/grep.h (revision 322582)
@@ -1,154 +1,158 @@
/* $NetBSD: grep.h,v 1.5 2011/02/27 17:33:37 joerg Exp $ */
/* $OpenBSD: grep.h,v 1.15 2010/04/05 03:03:55 tedu Exp $ */
/* $FreeBSD$ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
* Copyright (c) 2008-2009 Gabor Kovesdan <gabor@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <bzlib.h>
#include <limits.h>
#include <regex.h>
#include <stdbool.h>
#include <stdio.h>
#include <zlib.h>
+#ifndef WITHOUT_FASTMATCH
#include "fastmatch.h"
+#endif
#ifdef WITHOUT_NLS
#define getstr(n) errstr[n]
#else
#include <nl_types.h>
extern nl_catd catalog;
#define getstr(n) catgets(catalog, 1, n, errstr[n])
#endif
extern const char *errstr[];
#define VERSION "2.5.1-FreeBSD"
#define GREP_FIXED 0
#define GREP_BASIC 1
#define GREP_EXTENDED 2
#define BINFILE_BIN 0
#define BINFILE_SKIP 1
#define BINFILE_TEXT 2
#define FILE_STDIO 0
#define FILE_MMAP 1
#define FILE_GZIP 2
#define FILE_BZIP 3
#define FILE_XZ 4
#define FILE_LZMA 5
#define DIR_READ 0
#define DIR_SKIP 1
#define DIR_RECURSE 2
#define DEV_READ 0
#define DEV_SKIP 1
#define LINK_READ 0
#define LINK_EXPLICIT 1
#define LINK_SKIP 2
#define EXCL_PAT 0
#define INCL_PAT 1
#define MAX_LINE_MATCHES 32
struct file {
int fd;
bool binary;
};
struct str {
off_t off;
size_t len;
char *dat;
char *file;
int line_no;
};
struct pat {
char *pat;
int len;
};
struct epat {
char *pat;
int mode;
};
/* Flags passed to regcomp() and regexec() */
extern int cflags, eflags;
/* Command line flags */
extern bool Eflag, Fflag, Gflag, Hflag, Lflag,
bflag, cflag, hflag, iflag, lflag, mflag, nflag, oflag,
qflag, sflag, vflag, wflag, xflag;
extern bool dexclude, dinclude, fexclude, finclude, lbflag, nullflag;
extern unsigned long long Aflag, Bflag;
extern long long mcount;
extern long long mlimit;
extern char fileeol;
extern char *label;
extern const char *color;
extern int binbehave, devbehave, dirbehave, filebehave, grepbehave, linkbehave;
extern bool file_err, first, matchall, prev;
extern int tail;
extern unsigned int dpatterns, fpatterns, patterns;
extern struct pat *pattern;
extern struct epat *dpattern, *fpattern;
extern regex_t *er_pattern, *r_pattern;
+#ifndef WITHOUT_FASTMATCH
extern fastmatch_t *fg_pattern;
+#endif
/* For regex errors */
#define RE_ERROR_BUF 512
extern char re_error[RE_ERROR_BUF + 1]; /* Seems big enough */
/* util.c */
bool file_matching(const char *fname);
int procfile(const char *fn);
int grep_tree(char **argv);
void *grep_malloc(size_t size);
void *grep_calloc(size_t nmemb, size_t size);
void *grep_realloc(void *ptr, size_t size);
char *grep_strdup(const char *str);
void printline(struct str *line, int sep, regmatch_t *matches, int m);
/* queue.c */
void enqueue(struct str *x);
void printqueue(void);
void clearqueue(void);
/* file.c */
void grep_close(struct file *f);
struct file *grep_open(const char *path);
char *grep_fgetln(struct file *f, size_t *len);
Index: stable/11/usr.bin/grep/util.c
===================================================================
--- stable/11/usr.bin/grep/util.c (revision 322581)
+++ stable/11/usr.bin/grep/util.c (revision 322582)
@@ -1,559 +1,567 @@
/* $NetBSD: util.c,v 1.9 2011/02/27 17:33:37 joerg Exp $ */
/* $FreeBSD$ */
/* $OpenBSD: util.c,v 1.39 2010/07/02 22:18:03 tedu Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
* Copyright (C) 2008-2010 Gabor Kovesdan <gabor@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <sys/types.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fnmatch.h>
#include <fts.h>
#include <libgen.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
+#ifndef WITHOUT_FASTMATCH
#include "fastmatch.h"
+#endif
#include "grep.h"
static int linesqueued;
static int procline(struct str *l, int);
static int lasta;
static bool ctxover;
bool
file_matching(const char *fname)
{
char *fname_base, *fname_buf;
bool ret;
ret = finclude ? false : true;
fname_buf = strdup(fname);
if (fname_buf == NULL)
err(2, "strdup");
fname_base = basename(fname_buf);
for (unsigned int i = 0; i < fpatterns; ++i) {
if (fnmatch(fpattern[i].pat, fname, 0) == 0 ||
fnmatch(fpattern[i].pat, fname_base, 0) == 0) {
if (fpattern[i].mode == EXCL_PAT) {
ret = false;
break;
} else
ret = true;
}
}
free(fname_buf);
return (ret);
}
static inline bool
dir_matching(const char *dname)
{
bool ret;
ret = dinclude ? false : true;
for (unsigned int i = 0; i < dpatterns; ++i) {
if (dname != NULL &&
fnmatch(dpattern[i].pat, dname, 0) == 0) {
if (dpattern[i].mode == EXCL_PAT)
return (false);
else
ret = true;
}
}
return (ret);
}
/*
* Processes a directory when a recursive search is performed with
* the -R option. Each appropriate file is passed to procfile().
*/
int
grep_tree(char **argv)
{
FTS *fts;
FTSENT *p;
int c, fts_flags;
bool ok;
const char *wd[] = { ".", NULL };
c = fts_flags = 0;
switch(linkbehave) {
case LINK_EXPLICIT:
fts_flags = FTS_COMFOLLOW;
break;
case LINK_SKIP:
fts_flags = FTS_PHYSICAL;
break;
default:
fts_flags = FTS_LOGICAL;
}
fts_flags |= FTS_NOSTAT | FTS_NOCHDIR;
fts = fts_open((argv[0] == NULL) ?
__DECONST(char * const *, wd) : argv, fts_flags, NULL);
if (fts == NULL)
err(2, "fts_open");
while ((p = fts_read(fts)) != NULL) {
switch (p->fts_info) {
case FTS_DNR:
/* FALLTHROUGH */
case FTS_ERR:
file_err = true;
if(!sflag)
warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
break;
case FTS_D:
/* FALLTHROUGH */
case FTS_DP:
if (dexclude || dinclude)
if (!dir_matching(p->fts_name) ||
!dir_matching(p->fts_path))
fts_set(fts, p, FTS_SKIP);
break;
case FTS_DC:
/* Print a warning for recursive directory loop */
warnx("warning: %s: recursive directory loop",
p->fts_path);
break;
default:
/* Check for file exclusion/inclusion */
ok = true;
if (fexclude || finclude)
ok &= file_matching(p->fts_path);
if (ok)
c += procfile(p->fts_path);
break;
}
}
fts_close(fts);
return (c);
}
/*
* Opens a file and processes it. Each file is processed line-by-line
* passing the lines to procline().
*/
int
procfile(const char *fn)
{
struct file *f;
struct stat sb;
struct str ln;
mode_t s;
int c, t;
mcount = mlimit;
if (strcmp(fn, "-") == 0) {
fn = label != NULL ? label : getstr(1);
f = grep_open(NULL);
} else {
if (!stat(fn, &sb)) {
/* Check if we need to process the file */
s = sb.st_mode & S_IFMT;
if (s == S_IFDIR && dirbehave == DIR_SKIP)
return (0);
if ((s == S_IFIFO || s == S_IFCHR || s == S_IFBLK
|| s == S_IFSOCK) && devbehave == DEV_SKIP)
return (0);
}
f = grep_open(fn);
}
if (f == NULL) {
file_err = true;
if (!sflag)
warn("%s", fn);
return (0);
}
ln.file = grep_malloc(strlen(fn) + 1);
strcpy(ln.file, fn);
ln.line_no = 0;
ln.len = 0;
ctxover = false;
linesqueued = 0;
tail = 0;
lasta = 0;
ln.off = -1;
for (c = 0; c == 0 || !(lflag || qflag); ) {
ln.off += ln.len + 1;
if ((ln.dat = grep_fgetln(f, &ln.len)) == NULL || ln.len == 0) {
if (ln.line_no == 0 && matchall)
exit(0);
else
break;
}
if (ln.len > 0 && ln.dat[ln.len - 1] == fileeol)
--ln.len;
ln.line_no++;
/* Return if we need to skip a binary file */
if (f->binary && binbehave == BINFILE_SKIP) {
grep_close(f);
free(ln.file);
free(f);
return (0);
}
/* Process the file line-by-line, enqueue non-matching lines */
if ((t = procline(&ln, f->binary)) == 0 && Bflag > 0) {
/* Except don't enqueue lines that appear in -A ctx */
if (ln.line_no == 0 || lasta != ln.line_no) {
/* queue is maxed to Bflag number of lines */
enqueue(&ln);
linesqueued++;
ctxover = false;
} else {
/*
* Indicate to procline() that we have ctx
* overlap and make sure queue is empty.
*/
if (!ctxover)
clearqueue();
ctxover = true;
}
}
c += t;
if (mflag && mcount <= 0)
break;
}
if (Bflag > 0)
clearqueue();
grep_close(f);
if (cflag) {
if (!hflag)
printf("%s:", ln.file);
printf("%u\n", c);
}
if (lflag && !qflag && c != 0)
printf("%s%c", fn, nullflag ? 0 : '\n');
if (Lflag && !qflag && c == 0)
printf("%s%c", fn, nullflag ? 0 : '\n');
if (c && !cflag && !lflag && !Lflag &&
binbehave == BINFILE_BIN && f->binary && !qflag)
printf(getstr(8), fn);
free(ln.file);
free(f);
return (c);
}
#define iswword(x) (iswalnum((x)) || (x) == L'_')
/*
* Processes a line comparing it with the specified patterns. Each pattern
* is looped to be compared along with the full string, saving each and every
* match, which is necessary to colorize the output and to count the
* matches. The matching lines are passed to printline() to display the
* appropriate output.
*/
static int
procline(struct str *l, int nottext)
{
regmatch_t matches[MAX_LINE_MATCHES];
regmatch_t pmatch, lastmatch;
size_t st = 0, nst = 0;
unsigned int i;
int c = 0, m = 0, r = 0, lastmatches = 0, leflags = eflags;
int startm = 0;
/* Initialize to avoid a false positive warning from GCC. */
lastmatch.rm_so = lastmatch.rm_eo = 0;
/* Loop to process the whole line */
while (st <= l->len) {
lastmatches = 0;
startm = m;
if (st > 0)
leflags |= REG_NOTBOL;
/* Loop to compare with all the patterns */
for (i = 0; i < patterns; i++) {
pmatch.rm_so = st;
pmatch.rm_eo = l->len;
+#ifndef WITHOUT_FASTMATCH
if (fg_pattern[i].pattern)
r = fastexec(&fg_pattern[i],
l->dat, 1, &pmatch, leflags);
else
+#endif
r = regexec(&r_pattern[i], l->dat, 1,
&pmatch, leflags);
r = (r == 0) ? 0 : REG_NOMATCH;
if (r == REG_NOMATCH)
continue;
/* Check for full match */
if (r == 0 && xflag)
if (pmatch.rm_so != 0 ||
(size_t)pmatch.rm_eo != l->len)
r = REG_NOMATCH;
/* Check for whole word match */
+#ifndef WITHOUT_FASTMATCH
if (r == 0 && (wflag || fg_pattern[i].word)) {
+#else
+ if (r == 0 && wflag) {
+#endif
wchar_t wbegin, wend;
wbegin = wend = L' ';
if (pmatch.rm_so != 0 &&
sscanf(&l->dat[pmatch.rm_so - 1],
"%lc", &wbegin) != 1)
r = REG_NOMATCH;
else if ((size_t)pmatch.rm_eo !=
l->len &&
sscanf(&l->dat[pmatch.rm_eo],
"%lc", &wend) != 1)
r = REG_NOMATCH;
else if (iswword(wbegin) ||
iswword(wend))
r = REG_NOMATCH;
}
if (r == 0) {
lastmatches++;
lastmatch = pmatch;
if (m == 0)
c++;
if (m < MAX_LINE_MATCHES) {
/* Replace previous match if the new one is earlier and/or longer */
if (m > startm) {
if (pmatch.rm_so < matches[m-1].rm_so ||
(pmatch.rm_so == matches[m-1].rm_so && (pmatch.rm_eo - pmatch.rm_so) > (matches[m-1].rm_eo - matches[m-1].rm_so))) {
matches[m-1] = pmatch;
nst = pmatch.rm_eo;
}
} else {
/* Advance as normal if not */
matches[m++] = pmatch;
nst = pmatch.rm_eo;
}
}
/* matches - skip further patterns */
if ((color == NULL && !oflag) ||
qflag || lflag)
break;
}
}
if (vflag) {
c = !c;
break;
}
/* One pass if we are not recording matches */
if (!wflag && ((color == NULL && !oflag) || qflag || lflag || Lflag))
break;
/* If we didn't have any matches or REG_NOSUB set */
if (lastmatches == 0 || (cflags & REG_NOSUB))
nst = l->len;
if (lastmatches == 0)
/* No matches */
break;
else if (st == nst && lastmatch.rm_so == lastmatch.rm_eo)
/* Zero-length match -- advance one more so we don't get stuck */
nst++;
/* Advance st based on previous matches */
st = nst;
}
/* Count the matches if we have a match limit */
if (mflag)
mcount -= c;
if (c && binbehave == BINFILE_BIN && nottext)
return (c); /* Binary file */
/* Dealing with the context */
if ((tail || c) && !cflag && !qflag && !lflag && !Lflag) {
if (c) {
if (!first && !prev && !tail && (Bflag || Aflag) &&
!ctxover)
printf("--\n");
tail = Aflag;
if (Bflag > 0) {
printqueue();
ctxover = false;
}
linesqueued = 0;
printline(l, ':', matches, m);
} else {
/* Print -A lines following matches */
lasta = l->line_no;
printline(l, '-', matches, m);
tail--;
}
}
if (c) {
prev = true;
first = false;
} else
prev = false;
return (c);
}
/*
* Safe malloc() for internal use.
*/
void *
grep_malloc(size_t size)
{
void *ptr;
if ((ptr = malloc(size)) == NULL)
err(2, "malloc");
return (ptr);
}
/*
* Safe calloc() for internal use.
*/
void *
grep_calloc(size_t nmemb, size_t size)
{
void *ptr;
if ((ptr = calloc(nmemb, size)) == NULL)
err(2, "calloc");
return (ptr);
}
/*
* Safe realloc() for internal use.
*/
void *
grep_realloc(void *ptr, size_t size)
{
if ((ptr = realloc(ptr, size)) == NULL)
err(2, "realloc");
return (ptr);
}
/*
* Safe strdup() for internal use.
*/
char *
grep_strdup(const char *str)
{
char *ret;
if ((ret = strdup(str)) == NULL)
err(2, "strdup");
return (ret);
}
/*
* Prints a matching line according to the command line options.
*/
void
printline(struct str *line, int sep, regmatch_t *matches, int m)
{
size_t a = 0;
int i, n = 0;
/* If matchall, everything matches but don't actually print for -o */
if (oflag && matchall)
return;
if (!hflag) {
if (!nullflag) {
fputs(line->file, stdout);
++n;
} else {
printf("%s", line->file);
putchar(0);
}
}
if (nflag) {
if (n > 0)
putchar(sep);
printf("%d", line->line_no);
++n;
}
if (bflag) {
if (n > 0)
putchar(sep);
printf("%lld", (long long)line->off);
++n;
}
if (n)
putchar(sep);
/* --color and -o */
if ((oflag || color) && m > 0) {
for (i = 0; i < m; i++) {
/* Don't output zero length matches */
if (matches[i].rm_so == matches[i].rm_eo)
continue;
if (!oflag)
fwrite(line->dat + a, matches[i].rm_so - a, 1,
stdout);
if (color)
fprintf(stdout, "\33[%sm\33[K", color);
fwrite(line->dat + matches[i].rm_so,
matches[i].rm_eo - matches[i].rm_so, 1,
stdout);
if (color)
fprintf(stdout, "\33[m\33[K");
a = matches[i].rm_eo;
if (oflag)
putchar('\n');
}
if (!oflag) {
if (line->len - a > 0)
fwrite(line->dat + a, line->len - a, 1, stdout);
putchar('\n');
}
} else {
fwrite(line->dat, line->len, 1, stdout);
putchar(fileeol);
}
}
Index: stable/11
===================================================================
--- stable/11 (revision 322581)
+++ stable/11 (revision 322582)
Property changes on: stable/11
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
Merged /head:r317254

File Metadata

Mime Type
text/x-diff
Expires
Sun, Dec 21, 4:00 PM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27098620
Default Alt Text
(92 KB)

Event Timeline