Commit d6dc6cb7 authored by Charlie Jacobsen's avatar Charlie Jacobsen

Add kernel build fixes.

I got rid of the KERNEL_HEADERS_INSTALL thing. Kind of silly. The
user is just expected to set their prefix right. We still have to
do a hook in order to install the kernel-specific stuff. libcap.a
and libcap.ko (kernel binaries) go in prefix/lib.
parent c4f37bb6
Pipeline #416 passed with stage
......@@ -64,22 +64,23 @@ Third, configure the build. Important options:
default is no (does not build tests)
--enable-kernel-module -- if you selected PLATFORM=kernel, you can
build libcap as a kernel module (default no).
build libcap as a kernel module (default yes).
You will be able to install libcap.ko and
use it with other kernel modules (rather than
statically linking libcap.a into those
modules at compile time)
KERNEL_HEADERS_INSTALL=dir -- if you selected PLATFORM=kernel, this is
where the libcap headers will be installed;
the default is (libcap build dir)/include.
If the directory does not exist, it will be
created. Note that the uninstall will not
remove the directory, just the headers.
modules at compile time). Note that you might get
a kernel build warning that symbols are exported
twice; this is ok, so long as you only install the
kernel module, or only use the library. (You will
get an error at module load time if you try to use
--prefix -- the installation prefix; you may want to set
it to something out-of-the-way like
/opt/libcap, or you might not. E.g.,
/opt/libcap, or you might not, especially if you're
doing a kernel build (you probably shouldn't install
kernel headers and code in /usr, but it's up to you).
$ ../libcap/configure --prefix=/opt/libcap
......@@ -141,22 +141,6 @@ AS_IF([test "x$PLATFORM" = "xkernel"],
# libcap headers install for kernel land (user probably doesn't want
# them going in the user-level include dirs)
AS_IF([test "x$PLATFORM" = "xkernel"],
[Where to install the libcap headers for kernel builds (default is (libcap build dir)/include)])
[KERNEL_HEADERS_INSTALL=../../../include]) # default
[AC_MSG_ERROR([libcap kernel headers install location ($KERNEL_HEADERS_INSTALL) exists and is not a directory. Please choose a different location.])])
AC_MSG_NOTICE([libcap kernel headers install dir = $KERNEL_HEADERS_INSTALL])
# Build tests?
......@@ -182,6 +166,7 @@ AC_PROG_LN_S
AC_PROG_AWK # for a calculation below
# --------------------------------------------------
# Checks for libraries.
......@@ -77,7 +77,6 @@ fail1:
void cap_fini(void)
int i;
* Destroy cdt cache
......@@ -8,8 +8,11 @@ SUBDIRS = include src module test
# Kernel files
KERNEL_INCLUDES = -I$(abs_top_srcdir)/src/platform/kernel/include
# Add includes to include search path
# Add includes to include search path. (The root of the builddir is necessary to
# add explicitly for the kernel build, because we pass the include paths to the kernel
# build system. It won't check in the root of the build dir unless we tell it to.)
-I$(abs_top_builddir) \
-I$(abs_top_srcdir)/src/include \
-I$(abs_top_builddir)/src/include \
......@@ -32,6 +35,7 @@ if ENABLE_KERNEL_MODULE
MAYBE_ALL_MODULE = all-module
MAYBE_CLEAN_MODULE = clean-module
MAYBE_MODULES_INSTALL = do-modules-install
MAYBE_INSTALL_MODULE = install-libcap-module
......@@ -52,60 +56,18 @@ all-lib-cp: all-lib
@echo "Installing libcap kernel headers to $(KERNEL_HEADERS_INSTALL)..."
cp $(top_srcdir)/src/platform/kernel/include/libcap_platform.h $(KERNEL_HEADERS_INSTALL)
cp $(top_srcdir)/src/platform/kernel/include/libcap_platform_types.h $(KERNEL_HEADERS_INSTALL)
cp $(top_srcdir)/src/include/libcap.h $(KERNEL_HEADERS_INSTALL)
cp $(top_builddir)/src/include/libcap_config.h $(KERNEL_HEADERS_INSTALL)
cp $(top_srcdir)/src/include/libcap_types.h $(KERNEL_HEADERS_INSTALL)
cp $(top_srcdir)/src/include/libcap_list.h $(KERNEL_HEADERS_INSTALL)
@echo "Uninstalling libcap kernel headers from $(KERNEL_HEADERS_INSTALL)..."
rm -f $(KERNEL_HEADERS_INSTALL)/libcap_platform.h
rm -f $(KERNEL_HEADERS_INSTALL)/libcap_platform_types.h
rm -f $(KERNEL_HEADERS_INSTALL)/libcap.h
rm -f $(KERNEL_HEADERS_INSTALL)/libcap_config.h
rm -f $(KERNEL_HEADERS_INSTALL)/libcap_types.h
rm -f $(KERNEL_HEADERS_INSTALL)/libcap_list.h
# Don't do regular install; user probably doesn't want kernel stuff in
# user-level directories. (In retrospect, maybe a regular install isn't
# a bad idea. User can always uninstall if they mess up and choose the
# wrong prefix. Of course, we have to manually spell out the install
# rule using $DESTDIR.)
install: install-headers
@echo ""; \
echo "----------------------------------------"; \
echo " NOTE"; \
echo ""; \
echo "We only install the kernel headers (according to the"; \
echo "KERNEL_HEADERS_INSTALL variable). You probably don't want"; \
echo "e.g. kernel headers mixed up in your user include directories"; \
echo "and stuff. You can find libcap.a and libcap.ko in"; \
echo "(libcap build dir)/src/platform/kernel."; \
echo "To install the kernel module, do 'make modules_install'"; \
echo "in the root of the libcap build tree."; \
echo ""; \
echo "----------------------------------------"
uninstall: uninstall-headers
@echo "----------------------------------------"; \
echo " NOTE"; \
echo ""; \
echo "Skipping uninstall of libcap.a and libcap.ko."; \
echo "If you installed the libcap.ko kernel module via"; \
echo "modules_install (in the root of the libcap build tree)"; \
echo "then there really isn't an easy way (that I know of) to"; \
echo "remove the kernel module. It was installed somewhere in"; \
echo ' /lib/modules/`uname -r`/build'; \
echo "(or something similar)."; \
echo "You will have to manually remove it."; \
echo ""; \
echo "----------------------------------------"
# Move libcap.a and libcap.ko into dest dir. Easier to chain with
# multiple targets (esp. since we may not have built the module)
install-exec-hook: install-libcap $(MAYBE_INSTALL_MODULE)
install-libcap-module: install-setup-dir
cp module/libcap.ko $(DESTDIR)$(libdir)
install-libcap: install-setup-dir
cp libcap.a $(DESTDIR)$(libdir)
$(MKDIR_P) $(DESTDIR)$(libdir)
......@@ -123,4 +85,5 @@ clean-lib:
rm -f libcap.a
.PHONY: all-module all-lib all-lib-cp do-modules-install modules_install \
clean-module clean-lib install-headers uninstall-headers
clean-module clean-lib install-headers uninstall-headers \
install-libcap-module install-libcap install-setup-dir
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment