从 bash 脚本调用时 Make 不起作用

从 bash 脚本调用时 Make 不起作用

所以我只是问了一个问题:for 循环列表

现在效果很好并输出我需要的内容。现在我想将其链接到一个 makefile,该文件应该按列表中的每个变量调用,如下所示:

#!/bin/bash
mylist=(
    '$(call list_samples,AON_9,NT_1,SC_17)'
    '$(call list_samples,AON_10,NT_2,SC_18)'
    '$(call list_samples,AON_11,NT_3,SC_19)'
    '$(call list_samples,AON_12,NT_4,SC_20)'
    '$(call list_samples,AON_13,NT_5,SC_21)'
    '$(call list_samples,AON_14,NT_6,SC_22)'
    '$(call list_samples,AON_15,NT_7,SC_23)'
    '$(call list_samples,AON_16,NT_8,SC_24)'
)



for SAMPLES_out in "${mylist[@]}";
do
make -f make_gene_read_count.mk -n SAMPLES_OUT=\'${SAMPLES_out}\'
done

这给了我一个错误:make_gene_read_count.mk:5: *** unterminated call to function `call': missing `)'. Stop.

如果我将 echo 放在 bash 脚本中的调用前面,它会像这样打印出来:

make -f make_gene_read_count.mk -n SAMPLES_OUT='$(call list_samples,AON_9,NT_1,SC_17)'
make -f make_gene_read_count.mk -n SAMPLES_OUT='$(call list_samples,AON_10,NT_2,SC_18)'
make -f make_gene_read_count.mk -n SAMPLES_OUT='$(call list_samples,AON_11,NT_3,SC_19)'
make -f make_gene_read_count.mk -n SAMPLES_OUT='$(call list_samples,AON_12,NT_4,SC_20)'

如果我将这些回显之一添加到命令行,则 makefile 可以正常工作。我缺少什么?

这是生成文件:

IN_DIR = /data/DIV5/SASC/project-013-motor/analysis/runs/BWA_chipcap/BAMS/namesorted_bams
list_samples = $(shell ls $(IN_DIR)/*$(1)* $(IN_DIR)/*$(2)* $(IN_DIR)/*$(3)* | sed 's/\.namesorted\.bam/\.gene\.read\.count/g')
#SAMPLES_OUT := $(call list_samples,AON_9,NT_1,SC_17)

all: $(SAMPLES_OUT)

GFF := /data/DIV5/SASC/project-013-motor/analysis/runs/BWA_chipcap/BAMS/GFF/H3K4me1.gff
GFF_TEMP := $(GFF).temp.gff

$(GFF_TEMP): $(GFF)
    sed 's/\*/./g' $< > $@

%.gene.read.count: %.namesorted.bam $(GFF_TEMP)
    htseq-count -t exon -m intersection-strict -f bam -r name -s no $^ > $@

我还尝试将 2 个变量传递给我的 makefile,但如果我在 bash 脚本列表中这样做,这似乎也无法正常工作:

'$(call list_samples,AON_9,NT_1,SC_17) GFF=/data/DIV5/SASC/project-013-motor/analysis/runs/BWA_chipcap/BAMS/GFF/H3K4me1‌​.gff'

这是我收到的错误:

qmake: *** No rule to make target `GFF=/data/DIV5/SASC/project-013-motor/analysis/runs/BWA_chipcap/BAMS/GFF/H3K4me1.gff', needed by `all'.  Stop.

答案1

您不希望单引号传播到 makefile。不要引用它们,并将它们替换为双引号 - 这将使变量值在 shell 中保持为一个单词。

make -f make_gene_read_count.mk -n SAMPLES_OUT="$SAMPLES_out"

如果要传递更多变量,请用不带引号的空格分隔它们:

make VAR1="some value containing $val" VAR2='some other value'
#                                     ^

相关内容