tags:

views:

466

answers:

4

I have a Makefile of the following content:

NUMBERS = 1 2 3 4
lib:
    $(foreach var,$(NUMBERS),./a.out $(var);)

And this is the command that I run ( in the same directory as the Makefile)

make -f Makefile

But I got an error message saying that "The system cannot find the file specified".

Following the suggestion of one of the answers, I created the following file inside the same directory as the Makefile:

a.out
1.out
2.out
3.out
4.out

Now the error becomes:

./a.out 1; ./a.out 2; ./a.out 3; ./a.out 4; make (e=-1): Error -1 make: * [lib] Error -1

Note: I am running on Windows XP platform

+1  A: 

It seems to me that the error comes because the file a.out cannot be located and not because the makefile could not be found.

Also if the name of your makefile is "Makefile" just invoking "make" is enough (without using -f option) as make by default would look for a file by names: GNUmakefile, makefile, and Makefile in that order.

sateesh
I have created `a.out` in the same folder as the makefile, yet there is still a problem.
Ngu Soon Hui
Note that `a.out` must be an executable file.
Didier Trosset
+2  A: 

The purpose of make is to create (and update) target files that depends on source files by running commands.

Here, the problem is with the command that is run. You are trying to run (through make) the command a.out but it does not exist, or is not an executable command. Try to replace a.out in your makefile by the actual executable command you want to run.

Didier Trosset
A: 

Just what are you trying to do?

It seems to me that a plain script would be better suited rather than using make.

Dave
This is a scale down example of what I want to do.
Ngu Soon Hui
A: 

On Windows/DOS, use && instead of ; to join multiple commands on one line. You have to manually include a final command or the trailing && will throw a syntax error. Try something like:

NUMBERS = 1 2 3 4
lib:
    $(foreach var,$(NUMBERS),.\a.out $(var) && ) echo.
bta