forked from wolfSSL/wolfssl
WIP: autotools support for LKM
This commit is contained in:
@@ -160,9 +160,13 @@ include swig/include.am
|
||||
include src/include.am
|
||||
include support/include.am
|
||||
include wolfcrypt/user-crypto/include.am
|
||||
if !BUILD_LINUXKM
|
||||
include wolfcrypt/benchmark/include.am
|
||||
endif
|
||||
include wolfcrypt/src/include.am
|
||||
if !BUILD_LINUXKM
|
||||
include wolfcrypt/test/include.am
|
||||
endif
|
||||
include examples/include.am
|
||||
include testsuite/include.am
|
||||
include tests/include.am
|
||||
@@ -190,6 +194,10 @@ include IDE/include.am
|
||||
endif
|
||||
include scripts/include.am
|
||||
|
||||
if BUILD_LINUXKM
|
||||
SUBDIRS = . linuxkm
|
||||
endif
|
||||
|
||||
if USE_VALGRIND
|
||||
TESTS_ENVIRONMENT=./valgrind-error.sh
|
||||
endif
|
||||
|
26
configure.ac
26
configure.ac
@@ -3375,9 +3375,27 @@ AC_ARG_ENABLE([linuxkm],
|
||||
if test "x$ENABLED_LINUXKM" = "xyes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LINUXKM"
|
||||
|
||||
AC_PATH_DEFAULT_KERNEL_SOURCE
|
||||
AC_ARG_WITH([linux-source],
|
||||
[AS_HELP_STRING([--with-linux-source=PATH],[PATH to root of Linux kernel build tree])],
|
||||
[KROOT=$withval],
|
||||
[KROOT=$DEFAULT_KROOT])
|
||||
|
||||
AC_DEFAULT_KERNEL_ARCH
|
||||
AC_ARG_WITH([linux-arch],
|
||||
[AS_HELP_STRING([--with-linux-arch=arch],[built arch (SRCARCH) of Linux kernel build tree])],
|
||||
[KARCH=$withval],
|
||||
[KARCH=$DEFAULT_KARCH])
|
||||
|
||||
AC_DEFINE_KERNEL_KFLAGS
|
||||
|
||||
AM_CPPFLAGS="$KFLAGS $AM_CPPFLAGS"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
#valgrind
|
||||
AC_ARG_ENABLE([valgrind],
|
||||
[AS_HELP_STRING([--enable-valgrind],[Enable valgrind for unit tests (default: disabled)])],
|
||||
@@ -5382,6 +5400,7 @@ AM_CONDITIONAL([BUILD_PKI],[test "x$ENABLED_PKI" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_DES3],[test "x$ENABLED_DES3" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_PKCS7],[test "x$ENABLED_PKCS7" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_HASHFLAGS],[test "x$ENABLED_HASHFLAGS" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_LINUXKM],[test "x$ENABLED_LINUXKM" = "xyes"])
|
||||
|
||||
|
||||
CREATE_HEX_VERSION
|
||||
@@ -5394,7 +5413,7 @@ AC_SUBST([LIB_STATIC_ADD])
|
||||
|
||||
# FINAL
|
||||
AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
|
||||
AC_CONFIG_FILES([Makefile wolfssl/version.h wolfssl/options.h cyassl/options.h support/wolfssl.pc rpm/spec])
|
||||
AC_CONFIG_FILES([Makefile wolfssl/version.h wolfssl/options.h cyassl/options.h support/wolfssl.pc rpm/spec linuxkm/Makefile])
|
||||
|
||||
AX_CREATE_GENERIC_CONFIG
|
||||
AX_AM_JOBSERVER([yes])
|
||||
@@ -5644,6 +5663,10 @@ echo " * wolfSCEP $ENABLED_WOLFSCEP"
|
||||
echo " * Secure Remote Password $ENABLED_SRP"
|
||||
echo " * Small Stack: $ENABLED_SMALL_STACK"
|
||||
echo " * Linux Kernel Module: $ENABLED_LINUXKM"
|
||||
test "$ENABLED_LINUXKM" = "yes" && \
|
||||
echo " * Linux Kernel Build Root: $KROOT" && \
|
||||
echo " * Linux Kernel Build Arch: $KARCH" && \
|
||||
echo " * Linux Kernel Build Flags: $KFLAGS"
|
||||
echo " * valgrind unit tests: $ENABLED_VALGRIND"
|
||||
echo " * LIBZ: $ENABLED_LIBZ"
|
||||
echo " * Examples: $ENABLED_EXAMPLES"
|
||||
@@ -5693,4 +5716,3 @@ if test "$MINGW_LIB_WARNING" = "yes"
|
||||
then
|
||||
AC_MSG_WARN([Building with shared and static library at the same time on this system may cause export/import problems when using non contemporary GNU tools.])
|
||||
fi
|
||||
|
||||
|
5
linuxkm/Makefile.am
Normal file
5
linuxkm/Makefile.am
Normal file
@@ -0,0 +1,5 @@
|
||||
EXTRA_PROGRAMS = automake_dummy
|
||||
automake_dummy_SOURCES = wolfssl_linuxkm.c
|
||||
module_DATA = wolfssl_linuxkm.o
|
||||
#include ../Makefile.common
|
||||
include Makefile.common
|
20
linuxkm/Makefile.common
Normal file
20
linuxkm/Makefile.common
Normal file
@@ -0,0 +1,20 @@
|
||||
# Makefile.common
|
||||
moduledir = @moduledir@
|
||||
KERNEL_LOCATION=@kerneldir@
|
||||
KBUILD_VERBOSE = 1
|
||||
MOD_DEVDIR = $(PWD)
|
||||
|
||||
export module_DATA
|
||||
|
||||
$(module_DATA): $(automake_dummy_SOURCES)
|
||||
echo "not building kernel module yet"
|
||||
|
||||
# mv Makefile Makefile.automake
|
||||
# cp $(srcdir)/../Makefile.kernel Makefile
|
||||
# CPPFLAGS="" CFLAGS="" LDFLAGS="" \
|
||||
# $(MAKE) -C $(KROOT) \
|
||||
# ARCH="$KARCH" CC="gcc" M=$(PWD) modules\
|
||||
# KBUILD_VERBOSE=$(KBUILD_VERBOSE)
|
||||
# mv Makefile.automake Makefile
|
||||
|
||||
CLEANFILES = $(module_DATA) .$(module_DATA).flags $(module_DATA:.o=.mod.c) $(module_DATA:.o=.@kernelext@) *~
|
28
linuxkm/wolfssl_linuxkm.c
Normal file
28
linuxkm/wolfssl_linuxkm.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* http://h-wrt.com/en/mini-how-to/autotoolsSimpleModule */
|
||||
|
||||
/* src/module_hello.c */
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
static int __init
|
||||
hello_init(void)
|
||||
{
|
||||
printk("Hello, world!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_init(hello_init);
|
||||
|
||||
static void __exit
|
||||
hello_exit(void)
|
||||
{
|
||||
printk("Goodbye, world!\n");
|
||||
}
|
||||
|
||||
module_exit(hello_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("noname ");
|
||||
MODULE_DESCRIPTION("\"Hello, world!\" test module");
|
||||
MODULE_VERSION("printk");
|
41
m4/ax_linuxkm.m4
Normal file
41
m4/ax_linuxkm.m4
Normal file
@@ -0,0 +1,41 @@
|
||||
AC_DEFUN([AC_PATH_DEFAULT_KERNEL_SOURCE],
|
||||
[
|
||||
AC_MSG_CHECKING([for default kernel build root])
|
||||
if test -d /lib/modules/`uname -r`/build/.config; then
|
||||
DEFAULT_KROOT=/lib/modules/`uname -r`/build
|
||||
AC_MSG_RESULT([$DEFAULT_KROOT])
|
||||
elif test -r /usr/src/linux/.config; then
|
||||
DEFAULT_KROOT=/usr/src/linux
|
||||
AC_MSG_RESULT([$DEFAULT_KROOT])
|
||||
else
|
||||
AC_MSG_RESULT([no default configured kernel found])
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_DEFAULT_KERNEL_ARCH],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_AWK])
|
||||
AC_MSG_CHECKING([for default kernel arch])
|
||||
if test -f ${KROOT}/.config; then
|
||||
# "# Linux/x86 5.8.1-gentoo Kernel Configuration"
|
||||
DEFAULT_KARCH=`$AWK '/^# Linux/\
|
||||
{split($[]2,arch_fields,"/"); print arch_fields[[2]]; exit(0);}' ${KROOT}/.config`
|
||||
fi
|
||||
if test -n "$DEFAULT_KARCH"; then
|
||||
AC_MSG_RESULT([$DEFAULT_KARCH])
|
||||
else
|
||||
AC_MSG_RESULT([no default configured kernel arch found])
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_DEFINE_KERNEL_KFLAGS],
|
||||
[
|
||||
AC_MSG_CHECKING([flags for compiling objects for kernel module])
|
||||
if test -z "${KROOT}" || test -z "${KARCH}"; then
|
||||
AC_MSG_ERROR([Linux kernel configuration incomplete (KROOT=${KROOT}, KARCH=${KARCH}).])
|
||||
else
|
||||
GCC_SHORT_VERSION="$($CC -dumpversion)"
|
||||
KFLAGS="-I${KROOT}/include -I${KROOT}/include/uapi -I${KROOT}/arch/${KARCH}/include -I${KROOT}/arch/${KARCH}/include/generated -I${KROOT}/arch/${KARCH}/include/generated/uapi -I${KROOT}/arch/${KARCH}/include/uapi -I${KROOT}/tools/include -I${KROOT}/tools/arch/${KARCH}/include -I${KROOT}/tools/include/uapi -I/usr/lib/gcc/${host_cpu}-${host_vendor}-${host_os}/${GCC_SHORT_VERSION}/include"
|
||||
AC_MSG_RESULT([$KFLAGS])
|
||||
fi
|
||||
])
|
Reference in New Issue
Block a user