Build userland examples separately

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2018-10-02 00:00:00 +00:00
parent bc73cebff1
commit 76b486c274
43 changed files with 175 additions and 79 deletions

View File

@@ -1,4 +1,13 @@
ifeq ($(OBJECT_FILES),)
obj-m += $(addsuffix .o, $(notdir $(basename $(filter-out %.mod.c, $(wildcard $(BR2_EXTERNAL_KERNEL_MODULES_PATH)/*.c)))))
else
# Trying to do:
# $(MAKE) -C '$(LINUX_DIR)' M='$(M)' hello.ko hello2.ko
# to restrict which modules are built leads to failures
# when doing parallel builds. The only solution I could find
# was to let the host select obj-m itself.
obj-m += $(OBJECT_FILES)
endif
ccflags-y := -DDEBUG -g -std=gnu99 -Werror -Wno-declaration-after-statement -Wframe-larger-than=1000000000
.PHONY: all

View File

@@ -19,10 +19,10 @@ ifeq ($(BR2_PACKAGE_OPENBLAS),y)
endif
define KERNEL_MODULES_BUILD_CMDS
$(MAKE) -C '$(@D)/user' $(TARGET_CONFIGURE_OPTS) \
BR2_PACKAGE_EIGEN="$(BR2_PACKAGE_EIGEN)" \
BR2_PACKAGE_LIBDRM="$(BR2_PACKAGE_LIBDRM)" \
BR2_PACKAGE_OPENBLAS="$(BR2_PACKAGE_OPENBLAS)" \
$(MAKE) -C '$(@D)/userland' $(TARGET_CONFIGURE_OPTS) \
HAS_EIGEN="$(BR2_PACKAGE_EIGEN)" \
HAS_LIBDRM="$(BR2_PACKAGE_LIBDRM)" \
HAS_OPENBLAS="$(BR2_PACKAGE_OPENBLAS)" \
;
endef
@@ -33,7 +33,7 @@ define KERNEL_MODULES_INSTALL_TARGET_CMDS
#
# Modules can be still be easily inserted with "modprobe module" however.
$(INSTALL) -D -m 0655 $(@D)/*.ko '$(TARGET_DIR)'
$(INSTALL) -D -m 0755 $(@D)/user/*.out '$(TARGET_DIR)'
$(INSTALL) -D -m 0755 $(@D)/userland/*.out '$(TARGET_DIR)'
endef
$(eval $(kernel-module))

View File

@@ -1,3 +0,0 @@
https://github.com/cirosantilli/linux-kernel-module-cheat#rootfs_overlay
. link:sched_getaffinity.c[]

View File

@@ -10,7 +10,7 @@ OUT_EXT = .out
OUT_DIR = .
OUTS := $(foreach IN_EXT,$(IN_EXT_C) $(IN_EXT_CXX),$(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT)))))
ifeq ($(BR2_PACKAGE_EIGEN),y)
ifeq ($(HAS_EIGEN),y)
CXXFLAGS_EXTRA += -I$(STAGING_DIR)/usr/include/eigen3
# TODO: was failing with:
# fatal error: Eigen/Dense: No such file or directory as of
@@ -20,26 +20,27 @@ ifeq ($(BR2_PACKAGE_EIGEN),y)
else
OUTS := $(filter-out eigen_%$(OUT_EXT),$(OUTS))
endif
ifeq ($(BR2_PACKAGE_LIBDRM),y)
ifeq ($(HAS_LIBDRM),y)
LIBS += $(shell $(PKG_CONFIG) --libs libdrm)
CFLAGS_EXTRA += $(shell $(PKG_CONFIG) --cflags libdrm)
else
OUTS := $(filter-out libdrm_%$(OUT_EXT),$(OUTS))
endif
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
LIBS += -lopenblas
ifeq ($(HAS_OPENBLAS),y)
LIBS += $(shell $(PKG_CONFIG) --libs openblas)
CFLAGS_EXTRA += $(shell $(PKG_CONFIG) --cflags openblas)
else
OUTS := $(filter-out openblas$(OUT_EXT),$(OUTS))
OUTS := $(filter-out openblas_%$(OUT_EXT),$(OUTS))
endif
OUTS := $(addprefix $(OUT_DIR)/,$(OUTS))
all: mkdir $(OUTS)
$(OUT_DIR)/%$(OUT_EXT): %$(IN_EXT_C)
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
$(CC) $(CFLAGS) $(CCFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
$(OUT_DIR)/%$(OUT_EXT): %$(IN_EXT_CXX)
$(CXX) $(CXXFLAGS) $(CXXFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
$(CXX) $(CXXFLAGS) $(CCFLAGS) $(CXXFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
clean:
rm -f *'$(OUT_EXT)'

View File

@@ -0,0 +1 @@
name: USERLAND

View File

@@ -0,0 +1,34 @@
################################################################################
#
# kernel_modules
#
################################################################################
KERNEL_MODULES_VERSION = 1.0
KERNEL_MODULES_SITE = $(BR2_EXTERNAL_KERNEL_MODULES_PATH)
KERNEL_MODULES_SITE_METHOD = local
ifeq ($(BR2_PACKAGE_EIGEN),y)
KERNEL_MODULES_DEPENDENCIES += eigen
endif
ifeq ($(BR2_PACKAGE_LIBDRM),y)
KERNEL_MODULES_DEPENDENCIES += libdrm
endif
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
KERNEL_MODULES_DEPENDENCIES += openblas
endif
define KERNEL_MODULES_BUILD_CMDS
$(MAKE) -C '$(@D)' $(TARGET_CONFIGURE_OPTS) \
BR2_PACKAGE_EIGEN="$(BR2_PACKAGE_EIGEN)" \
BR2_PACKAGE_LIBDRM="$(BR2_PACKAGE_LIBDRM)" \
BR2_PACKAGE_OPENBLAS="$(BR2_PACKAGE_OPENBLAS)" \
;
endef
define KERNEL_MODULES_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0755 $(@D)/*.out '$(TARGET_DIR)'
endef
$(eval $(kernel-module))
$(eval $(generic-package))

View File

@@ -20,7 +20,7 @@ struct msghdr msg;
struct nlmsghdr *nlh;
struct sockaddr_nl src_addr, dest_addr;
int main()
int main(void)
{
sock_fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_USER);
if (sock_fd < 0) {

View File

@@ -6,7 +6,7 @@
#include <assert.h>
#include <cblas.h>
int main()
int main(void)
{
double A[6] = {1.0, 2.0, 1.0, -3.0, 4.0, -1.0};
double B[6] = {1.0, 2.0, 1.0, -3.0, 4.0, -1.0};

View File

@@ -5,7 +5,7 @@
#if defined(__aarch64__)
int main() {}
int main(void) {}
#else
@@ -147,7 +147,7 @@ static void on_sigint(__attribute__ ((unused)) int unused)
need_exit = true;
}
int main()
int main(void)
{
int nl_sock;
int rc = EXIT_SUCCESS;

View File

@@ -66,7 +66,7 @@ int main(int argc, char **argv)
#include <unistd.h>
#include <unistd.h>
int main()
int main(void)
{
int uiofd;
int configfd;