Fixed building error

This commit is contained in:
abausano
2023-06-28 22:09:08 +02:00
committed by GitHub
parent 944932210b
commit 5ad53da25b

View File

@@ -1,24 +1,48 @@
include ../config.mk include ../config.mk
include Kbuild include Kbuild
include $(MODINC) cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
.PHONY: all clean install
ifeq ($(BUILDSYS),kbuild) ifeq ($(BUILDSYS),kbuild)
# dirty workaround to get the RTAI directory module = $(patsubst %.o,%.ko,$(obj-m))
RTAIINCDIR = $(subst /rtai.h,,$(firstword $(wildcard $(foreach i,$(subst -I,,$(filter -I%,$(RTFLAGS))), $(i)/rtai.h))))
ifneq ($(RTAIINCDIR),) ifeq (,$(findstring -Wframe-larger-than=,$(EXTRA_CFLAGS)))
RTAIDIR = $(realpath $(RTAIINCDIR)/..) EXTRA_CFLAGS += $(call cc-option,-Wframe-larger-than=2560)
endif endif
all: $(module):
$(MAKE) EXTRA_CFLAGS="$(EXTRA_CFLAGS)" KBUILD_EXTRA_SYMBOLS="$(RTLIBDIR)/Module.symvers $(RTAIDIR)/modules/ethercat/Module.symvers" -C $(KERNELDIR) SUBDIRS=`pwd` CC=$(CC) V=0 modules $(MAKE) EXTRA_CFLAGS="$(EXTRA_CFLAGS)" KBUILD_EXTRA_SYMBOLS="$(RTLIBDIR)/Module.symvers $(RTAIDIR)/modules/ethercat/Module.symvers" -C $(KERNELDIR) SUBDIRS=`pwd` CC=$(CC) V=0 modules
clean::
rm -f $(obj-m)
rm -f *.mod.c .*.cmd
rm -f modules.order Module.symvers
rm -rf .tmp_versions
else else
LDFLAGS += -Wl,-rpath,$(LIBDIR) -L$(LIBDIR) -llinuxcnchal -lethercat module = $(patsubst %.o,%.so,$(obj-m))
all: modules EXTRA_CFLAGS := $(filter-out -Wframe-larger-than=%,$(EXTRA_CFLAGS))
$(module): $(lcec-objs)
$(CC) -shared -o $@ $(lcec-objs) -Wl,-rpath,$(LIBDIR) -L$(LIBDIR) -llinuxcnchal -lethercat -lrt
%.o: %.c
$(CC) -o $@ $(EXTRA_CFLAGS) -Os -c $<
endif endif
all: $(module)
clean::
rm -f $(module)
rm -f $(lcec-objs)
install: $(module)
mkdir -p $(DESTDIR)$(RTLIBDIR)
cp $(module) $(DESTDIR)$(RTLIBDIR)/