So i just asked a question : for loop over a list

This works perfectly now and outputs what i need. Now i want to link this to a makefile which should be called per variable in my list like this:

    '$(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[@]}";
make -f make_gene_read_count.mk -n SAMPLES_OUT=\'${SAMPLES_out}\'

This give me a make error: make_gene_read_count.mk:5: *** unterminated call to function `call': missing `)'. Stop.

While if i put echo in front of the call to make in my bash script it prints them out like this:

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)'

If i add one of those echos to the commandline the makefile works perfectly. What am i missing?

This is the 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)


GFF := /data/DIV5/SASC/project-013-motor/analysis/runs/BWA_chipcap/BAMS/GFF/H3K4me1.gff
GFF_TEMP := $(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 $^ > $@

I am also trying to pass 2 variables to my makefile but this does not seem to work properly as well if I do it like this in my bash scripts list:

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

This is the error i'm getting:

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 Answer 1


You don't want the single quotes to get propagated to the makefile. Don't quote them, and replace them with double quotes - that would keep the variable value as one word in the shell.

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

If you want to pass more variables, separate them by unquoted whitespace:

make VAR1="some value containing $val" VAR2='some other value'
#                                     ^
  • thanks, i was really confused by this. Strange is that if i try to run the makefile on command line and it is not between ' ' it will not work, so therefor i thought that this is also the case while running from bash script. Feb 13, 2015 at 13:44
  • I have one more question to you can you tell what would happen if i want for example another variable passed to the make file like this: '$(call list_samples,AON_9,NT_1,SC_17) GFF=/data/DIV5/SASC/project-013-motor/analysis/runs/BWA_chipcap/BAMS/GFF/H3K4me1.gff' Feb 13, 2015 at 14:01
  • 1
    @SanderVanderZeeuw: Questions in comments aren't readable.
    – choroba
    Feb 13, 2015 at 14:04
  • Ooh sure sorry ill add it to my question @choroba It should be in the question now ;) thanks for helping me out Feb 13, 2015 at 14:10
  • @SanderVanderZeeuw: Check the update.
    – choroba
    Feb 13, 2015 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.