2013-07-23 18:52:07 +04:00
|
|
|
# $NetBSD: Makefile.libkern,v 1.26 2013/07/23 14:52:07 skrll Exp $
|
2009-01-04 21:00:55 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Variable definitions for libkern.
|
|
|
|
#
|
|
|
|
# Before including this, you _must_ set
|
|
|
|
# KERNDIR: location of sys/lib/libkern
|
|
|
|
#
|
|
|
|
# You *may* set:
|
|
|
|
# LIBKERN_ARCH: architecture subdir to be used
|
|
|
|
# KERNCPPFLAGS: see Makefile.inc
|
2010-05-12 01:50:35 +04:00
|
|
|
# KERNMISCCPPFLAGS: see Makefile.inc
|
2009-01-04 21:00:55 +03:00
|
|
|
#
|
|
|
|
|
|
|
|
.include <bsd.own.mk>
|
|
|
|
|
|
|
|
.if defined(LIBKERN_ARCH) && !empty(LIBKERN_ARCH) && \
|
|
|
|
exists(${KERNDIR}/arch/${LIBKERN_ARCH})
|
|
|
|
ARCHSUBDIR= ${LIBKERN_ARCH}
|
|
|
|
.elif defined(MACHINE_ARCH) && !empty(MACHINE_ARCH) && \
|
|
|
|
exists(${KERNDIR}/arch/${MACHINE_ARCH})
|
|
|
|
ARCHSUBDIR= ${MACHINE_ARCH}
|
|
|
|
.elif defined(MACHINE_CPU) && !empty(MACHINE_CPU) && \
|
|
|
|
exists(${KERNDIR}/arch/${MACHINE_CPU})
|
|
|
|
ARCHSUBDIR= ${MACHINE_CPU}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
M= ${KERNDIR}/arch/${ARCHSUBDIR}
|
|
|
|
|
|
|
|
CPPFLAGS+= -I$M ${KERNCPPFLAGS} ${KERNMISCCPPFLAGS}
|
|
|
|
|
|
|
|
.include "${.PARSEDIR}/../../../common/lib/libc/Makefile.inc"
|
|
|
|
.include "${.PARSEDIR}/../../../common/lib/libutil/Makefile.inc"
|
|
|
|
.include "${.PARSEDIR}/../../../common/lib/libprop/Makefile.inc"
|
2011-08-27 01:22:07 +04:00
|
|
|
.include "${.PARSEDIR}/../../../common/lib/libppath/Makefile.inc"
|
2009-01-04 21:00:55 +03:00
|
|
|
|
|
|
|
CPPFLAGS+= -I${KERNDIR}/../../../common/include
|
|
|
|
|
|
|
|
.PATH.c: ${KERNDIR}
|
|
|
|
.if exists ($M/Makefile.inc)
|
|
|
|
.PATH.c: $M
|
|
|
|
.PATH.S: $M
|
|
|
|
.include "$M/Makefile.inc"
|
|
|
|
.endif
|
|
|
|
|
2009-11-21 16:37:18 +03:00
|
|
|
.if (${MACHINE_ARCH} != "alpha") && \
|
2011-02-26 19:28:10 +03:00
|
|
|
(${MACHINE_ARCH} != "mips64eb" || !empty(CFLAGS:M-mabi=32)) && \
|
|
|
|
(${MACHINE_ARCH} != "mips64el" || !empty(CFLAGS:M-mabi=32)) && \
|
2009-11-21 16:37:18 +03:00
|
|
|
(${MACHINE_ARCH} != "powerpc64") && \
|
|
|
|
(${MACHINE_ARCH} != "sparc64") && \
|
2011-02-26 21:17:55 +03:00
|
|
|
(${MACHINE_ARCH} != "x86_64" || !empty(CFLAGS:M-m32))
|
2009-01-04 21:00:55 +03:00
|
|
|
# Quad support
|
|
|
|
SRCS+= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
|
|
|
|
lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
|
|
|
|
subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# Other stuff
|
2010-01-20 01:28:30 +03:00
|
|
|
SRCS+= kern_assert.c __main.c
|
2012-01-20 04:25:29 +04:00
|
|
|
SRCS+= cpuset.c inet_addr.c intoa.c
|
2009-12-14 15:18:14 +03:00
|
|
|
.if empty(SRCS:Mbyte_swap_8.*)
|
2009-08-14 23:23:53 +04:00
|
|
|
SRCS+= bswap64.c
|
2009-12-14 15:18:14 +03:00
|
|
|
.endif
|
2013-06-29 20:02:01 +04:00
|
|
|
SRCS+= md4c.c md5c.c rmd160.c sha1.c sha2.c murmurhash.c
|
2009-03-25 04:26:12 +03:00
|
|
|
SRCS+= pmatch.c arc4random.c bcd.c mcount.c mertwist.c crc32.c
|
2009-01-04 21:00:55 +03:00
|
|
|
|
2011-08-27 01:22:07 +04:00
|
|
|
SRCS+= ppath_kmem_alloc.c
|
|
|
|
|
2009-08-13 01:18:42 +04:00
|
|
|
SRCS+= strsep.c strstr.c
|
|
|
|
SRCS+= strlcpy.c strlcat.c
|
2009-08-14 23:23:53 +04:00
|
|
|
|
|
|
|
SRCS+= imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c
|
2013-03-10 11:31:03 +04:00
|
|
|
SRCS+= memmove.c
|
2009-08-13 01:18:42 +04:00
|
|
|
SRCS+= strchr.c strrchr.c
|
2009-12-14 15:18:14 +03:00
|
|
|
SRCS+= memcmp.c
|
2013-03-10 11:31:03 +04:00
|
|
|
|
|
|
|
SRCS+= memcpy.c
|
2009-12-14 15:18:14 +03:00
|
|
|
.if empty(SRCS:Mmemset2.*)
|
|
|
|
SRCS+= memset.c
|
|
|
|
.endif
|
2013-03-17 04:47:13 +04:00
|
|
|
|
2009-08-13 01:18:42 +04:00
|
|
|
SRCS+= popcount32.c popcount64.c
|
2009-08-14 23:23:53 +04:00
|
|
|
SRCS+= strtoul.c strtoll.c strtoull.c strtoumax.c
|
|
|
|
|
|
|
|
SRCS+= scanc.c skpc.c
|
|
|
|
SRCS+= random.c
|
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:
An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.
A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.
The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.
An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.
A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.
An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.
In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.
The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.
The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.
A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.
The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.
Manual pages for the new kernel interfaces are forthcoming.
2011-11-20 02:51:18 +04:00
|
|
|
SRCS+= rngtest.c
|
2009-01-04 21:00:55 +03:00
|
|
|
|
2009-08-14 23:23:53 +04:00
|
|
|
SRCS+= memchr.c
|
2013-01-24 02:34:37 +04:00
|
|
|
SRCS+= strcat.c strcmp.c strcpy.c strlen.c strnlen.c
|
2009-08-14 23:23:53 +04:00
|
|
|
SRCS+= strncmp.c strncpy.c
|
|
|
|
SRCS+= strcasecmp.c strncasecmp.c
|
2009-01-04 21:00:55 +03:00
|
|
|
|
|
|
|
SRCS+= xlat_mbr_fstype.c
|
|
|
|
|
|
|
|
SRCS+= heapsort.c ptree.c rb.c
|
|
|
|
|
2012-08-30 16:16:48 +04:00
|
|
|
# for crypto
|
2013-06-24 08:21:19 +04:00
|
|
|
SRCS+= explicit_memset.c consttime_memequal.c
|
2012-08-30 16:16:48 +04:00
|
|
|
|
2009-01-04 21:00:55 +03:00
|
|
|
# Files to clean up
|
|
|
|
CLEANFILES+= lib${LIB}.o lib${LIB}.po
|
|
|
|
|
2009-08-13 01:18:42 +04:00
|
|
|
# Remove from SRCS the .c files for any .S files added by the MD makefiles,
|
2009-08-14 23:23:53 +04:00
|
|
|
# also remove from SRCS the .c files for the .c files in NO_SRCS.
|
|
|
|
# (Unlike libc, we don't worry about lint)
|
2009-08-13 01:18:42 +04:00
|
|
|
|
|
|
|
.for check_file in ${SRCS:M*.S} ${NO_SRCS}
|
|
|
|
unwanted_file := ${SRCS:M${check_file:.S=.c}}
|
|
|
|
.if "${unwanted_file}" != ""
|
|
|
|
SRCS := ${SRCS:N${unwanted_file}}
|
2009-07-21 18:55:32 +04:00
|
|
|
.endif
|
2009-08-13 01:18:42 +04:00
|
|
|
.endfor
|
2013-07-23 18:52:07 +04:00
|
|
|
|
|
|
|
.if ${HAVE_GCC:U} == "45" && ${MACHINE_CPU} == "hppa"
|
|
|
|
COPTS.md5c.c += ${${ACTIVE_CC} == "gcc" :? -O0 :}
|
|
|
|
.endif
|