NetBSD/sys/lib/libkern/Makefile.libkern

118 lines
3.2 KiB
Makefile
Raw Normal View History

# $NetBSD: Makefile.libkern,v 1.26 2013/07/23 14:52:07 skrll Exp $
#
# 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
#
.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"
.include "${.PARSEDIR}/../../../common/lib/libppath/Makefile.inc"
CPPFLAGS+= -I${KERNDIR}/../../../common/include
.PATH.c: ${KERNDIR}
.if exists ($M/Makefile.inc)
.PATH.c: $M
.PATH.S: $M
.include "$M/Makefile.inc"
.endif
.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)) && \
(${MACHINE_ARCH} != "powerpc64") && \
(${MACHINE_ARCH} != "sparc64") && \
(${MACHINE_ARCH} != "x86_64" || !empty(CFLAGS:M-m32))
# 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
SRCS+= kern_assert.c __main.c
SRCS+= cpuset.c inet_addr.c intoa.c
.if empty(SRCS:Mbyte_swap_8.*)
SRCS+= bswap64.c
.endif
2013-06-29 20:02:01 +04:00
SRCS+= md4c.c md5c.c rmd160.c sha1.c sha2.c murmurhash.c
SRCS+= pmatch.c arc4random.c bcd.c mcount.c mertwist.c crc32.c
SRCS+= ppath_kmem_alloc.c
SRCS+= strsep.c strstr.c
SRCS+= strlcpy.c strlcat.c
SRCS+= imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c
SRCS+= memmove.c
SRCS+= strchr.c strrchr.c
SRCS+= memcmp.c
SRCS+= memcpy.c
.if empty(SRCS:Mmemset2.*)
SRCS+= memset.c
.endif
2013-03-17 04:47:13 +04:00
SRCS+= popcount32.c popcount64.c
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
SRCS+= memchr.c
SRCS+= strcat.c strcmp.c strcpy.c strlen.c strnlen.c
SRCS+= strncmp.c strncpy.c
SRCS+= strcasecmp.c strncasecmp.c
SRCS+= xlat_mbr_fstype.c
SRCS+= heapsort.c ptree.c rb.c
# for crypto
SRCS+= explicit_memset.c consttime_memequal.c
# Files to clean up
CLEANFILES+= lib${LIB}.o lib${LIB}.po
# Remove from SRCS the .c files for any .S files added by the MD makefiles,
# also remove from SRCS the .c files for the .c files in NO_SRCS.
# (Unlike libc, we don't worry about lint)
.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}}
.endif
.endfor
.if ${HAVE_GCC:U} == "45" && ${MACHINE_CPU} == "hppa"
COPTS.md5c.c += ${${ACTIVE_CC} == "gcc" :? -O0 :}
.endif