最佳答案
我正在尝试设置一个 Makefile,它将搜索和复制一些文件(if-else 条件) ,我不能找出它到底出了什么问题?(我很确定这是因为空格/制表符的组合写错了地方)。 能帮帮我吗?
以下是我目前拥有的:
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,而是逐行运行所有内容。