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: ...@@ -64,22 +64,23 @@ Third, configure the build. Important options:
default is no (does not build tests) default is no (does not build tests)
--enable-kernel-module -- if you selected PLATFORM=kernel, you can --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 You will be able to install libcap.ko and
use it with other kernel modules (rather than use it with other kernel modules (rather than
statically linking libcap.a into those statically linking libcap.a into those
modules at compile time) modules at compile time). Note that you might get
a kernel build warning that symbols are exported
KERNEL_HEADERS_INSTALL=dir -- if you selected PLATFORM=kernel, this is twice; this is ok, so long as you only install the
where the libcap headers will be installed; kernel module, or only use the library. (You will
the default is (libcap build dir)/include. get an error at module load time if you try to use
If the directory does not exist, it will be both.)
created. Note that the uninstall will not
remove the directory, just the headers.
--prefix -- the installation prefix; you may want to set --prefix -- the installation prefix; you may want to set
it to something out-of-the-way like 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).
E.g.,
$ ../libcap/configure --prefix=/opt/libcap $ ../libcap/configure --prefix=/opt/libcap
......
...@@ -141,22 +141,6 @@ AS_IF([test "x$PLATFORM" = "xkernel"], ...@@ -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"],
[
AC_ARG_VAR([KERNEL_HEADERS_INSTALL],
[Where to install the libcap headers for kernel builds (default is (libcap build dir)/include)])
AS_IF([test "x$KERNEL_HEADERS_INSTALL" = "x"],
[KERNEL_HEADERS_INSTALL=../../../include]) # default
AS_IF([test -e $KERNEL_HEADERS_INSTALL && test ! -d $KERNEL_HEADERS_INSTALL],
[AC_MSG_ERROR([libcap kernel headers install location ($KERNEL_HEADERS_INSTALL) exists and is not a directory. Please choose a different location.])])
AC_SUBST(KERNEL_HEADERS_INSTALL)
AC_MSG_NOTICE([libcap kernel headers install dir = $KERNEL_HEADERS_INSTALL])
])
# Build tests? # Build tests?
AC_ARG_ENABLE([test_build], AC_ARG_ENABLE([test_build],
[AS_HELP_STRING([--enable-test-build], [AS_HELP_STRING([--enable-test-build],
...@@ -182,6 +166,7 @@ AC_PROG_LN_S ...@@ -182,6 +166,7 @@ AC_PROG_LN_S
AC_PROG_MKDIR_P AC_PROG_MKDIR_P
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_AWK # for a calculation below AC_PROG_AWK # for a calculation below
AC_PROG_MKDIR_P
# -------------------------------------------------- # --------------------------------------------------
# Checks for libraries. # Checks for libraries.
......
...@@ -77,7 +77,6 @@ fail1: ...@@ -77,7 +77,6 @@ fail1:
void cap_fini(void) void cap_fini(void)
{ {
int i;
/* /*
* Destroy cdt cache * Destroy cdt cache
*/ */
......
...@@ -8,8 +8,11 @@ SUBDIRS = include src module test ...@@ -8,8 +8,11 @@ SUBDIRS = include src module test
# Kernel files # Kernel files
KERNEL_INCLUDES = -I$(abs_top_srcdir)/src/platform/kernel/include 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.)
AM_CPPFLAGS = \ AM_CPPFLAGS = \
-I$(abs_top_builddir) \
-I$(abs_top_srcdir)/src/include \ -I$(abs_top_srcdir)/src/include \
-I$(abs_top_builddir)/src/include \ -I$(abs_top_builddir)/src/include \
$(KERNEL_INCLUDES) \ $(KERNEL_INCLUDES) \
...@@ -32,6 +35,7 @@ if ENABLE_KERNEL_MODULE ...@@ -32,6 +35,7 @@ if ENABLE_KERNEL_MODULE
MAYBE_ALL_MODULE = all-module MAYBE_ALL_MODULE = all-module
MAYBE_CLEAN_MODULE = clean-module MAYBE_CLEAN_MODULE = clean-module
MAYBE_MODULES_INSTALL = do-modules-install MAYBE_MODULES_INSTALL = do-modules-install
MAYBE_INSTALL_MODULE = install-libcap-module
endif endif
...@@ -52,60 +56,18 @@ all-lib-cp: all-lib ...@@ -52,60 +56,18 @@ all-lib-cp: all-lib
all-lib: all-lib:
$(MAKE) -C $(KDIR) M=$(LIBCAP_KBUILD) $(MAKE) -C $(KDIR) M=$(LIBCAP_KBUILD)
install-headers: # Move libcap.a and libcap.ko into dest dir. Easier to chain with
@echo "Installing libcap kernel headers to $(KERNEL_HEADERS_INSTALL)..." # multiple targets (esp. since we may not have built the module)
mkdir -p $(KERNEL_HEADERS_INSTALL) install-exec-hook: install-libcap $(MAYBE_INSTALL_MODULE)
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)
uninstall-headers:
@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 "----------------------------------------"
install-libcap-module: install-setup-dir
cp module/libcap.ko $(DESTDIR)$(libdir)
install-libcap: install-setup-dir
cp libcap.a $(DESTDIR)$(libdir)
install-setup-dir:
$(MKDIR_P) $(DESTDIR)$(libdir)
do-modules-install: do-modules-install:
$(MAKE) -C $(KDIR) M=$(LIBCAP_KERNEL_MODULE_KBUILD) \ $(MAKE) -C $(KDIR) M=$(LIBCAP_KERNEL_MODULE_KBUILD) \
...@@ -123,4 +85,5 @@ clean-lib: ...@@ -123,4 +85,5 @@ clean-lib:
rm -f libcap.a rm -f libcap.a
.PHONY: all-module all-lib all-lib-cp do-modules-install modules_install \ .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