我正在尝试设置一个Makefile,它将搜索并复制一些文件(如果为其他条件),我无法弄清楚到底是什么问题? (您非常确定这是因为在错误的位置写了空格/制表符的组合)。请给我一些帮助吗?
这是我目前的位置:
obj-m = linuxmon.o
KDIR = /lib/modules/$(shell uname -r)/build
UNAME := $(shell uname -m)
all:
$(info Checking if custom header is needed)
ifeq ($(UNAME), x86_64)
$(info Yes)
F1_EXISTS=$(shell [ -e /usr/include/asm/unistd_32.h ] && echo 1 || echo 0 )
ifeq ($(F1_EXISTS), 1)
$(info Copying custom header)
$(shell sed -e 's/__NR_/__NR32_/g' /usr/include/asm/unistd_32.h > unistd_32.h)
else
F2_EXISTS=$(shell [[ -e /usr/include/asm-i386/unistd.h ]] && echo 1 || echo 0 )
ifeq ($(F2_EXISTS), 1)
$(info Copying custom header)
$(shell sed -e 's/__NR_/__NR32_/g' /usr/include/asm-i386/unistd.h > unistd_32.h)
else
$(error asm/unistd_32.h and asm-386/unistd.h does not exist)
endif
endif
$(info No)
endif
@make -C $(KDIR) M=$(PWD) modules
clean:
make -C $(KDIR) M=$(PWD) clean
rm unistd_32.h
无论如何,将打印“是”,“复制标题”两次,然后退出,说sed无法读取/usr/include/asm-i386/unistd.h
(当然,因为我在x64系统上,所以它无法读取) 。我可以说make
只是不了解if / else,而是逐行运行所有内容。
这里有几个问题,所以我将以我通常的高级建议开始:从小而简单开始,一次增加一点复杂性,在每个步骤中进行测试,并且从不添加那些不适合的代码工作。
(我真的应该有这个快捷键。)您可以简单地使用shell命令。如果要抑制回显输出,请使用“ @”符号。例如: