为使用 makefile 执行的 c 代码提供 scanf 输入字符串

give a scanf input string for a c code execution with makefile

我正在尝试编写我的第一个 makefile 以完全自动化我的代码执行。我有一个必须多次执行的 C 代码 (BootstrapCL.c);对于每次执行,我应该在输入中给出(我在 c 代码中有 2 个 scanf)一个文件名(带和不带扩展名)。我必须对文件夹内的所有文件(比如一组 cvs 文件)重复此操作。

这是我的 makefile

SRCS := $(wildcard *.csv)
BINS := $(SRCS:%.csv=%)

all: ${BINS}

%: BootstrapCL.c
    gcc -Wall BootstrapCL.c  -lm -o BootstrapCL
    ./BootstrapCL 
    $@.csv 
    $@

问题是当 makefile 到达行时: ./BootstrapCL shell 等待输入,因此我无法到达下一行以通过 makefile 本身提供此输入。如何解决这个问题并获得自动流程?

通过管道将输入传递给程序。

%: BootstrapCL.c
    gcc -Wall BootstrapCL.c  -lm -o BootstrapCL
    (echo $@.csv ; echo $@) | ./BootstrapCL