0

I have the code fragment you can see below in my Makefile I'm trying to write

When I run it, it gives me an unexpected end of file error on the first "do"

I've tried to remove the backslashes, remove as many spaces as I can, etc but I still can't seem to get it to work. Responses to most questions like this here involved people either forgetting to include a "done" or having kerning issues. That doesn't seem to be the case in my code

for i in 1 10 25 50 100 1000 10000;\ do\ for j in 1 10 25 50 100 1000 10000;\ do\ ./myprogram --threads=j iterations=i>>myfile.csv;\ done\ done 

It's supposed to execute the test script above and append the answers to myfile.csv

Instead, I'm getting the following error:

/bin/sh: -c: line 7: syntax error: unexpected end of file make: *** [tests] Error 1 

Thanks!

3
  • 1
    Why even adding all the simicolons and backslashes? Should be fine if you remove the backslash from the myprogram line. Backslashes "escape" the next charackter which would be new line, then done is not interpreted correctly and it fails. Commented Aug 3, 2019 at 6:06
  • Is done\(newline)done evaluated as donedone, and not done;done? Commented Aug 3, 2019 at 13:40
  • Wrong reference to shell variables and missing ; after the first done. See cider response. Commented Aug 3, 2019 at 14:41

1 Answer 1

1

This is a possible duplication of: How to write loop in a Makefile?

I could not get your error running your code, but I did notice you did not refer the variables correctly. In order to get the value of variable i, you should write $$i in a Makefile script.

In your case:

Makefile

target: for i in 1 10 25 50 100 1000 10000; \ do \ for j in 1 10 25 50 100 1000 10000; \ do \ ./myprogram --threads=$$j iterations=$$i>>myfile.csv; \ done ; \ done 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.