It looks like you are trying to run basic2
in your third make
block. If your intent was to have the first make target do both compile and run, you probably meant to do this:
# All depends on write, which depends on basic2, which depends on basic2.c
all: write
# Command to run
write: basic2
./basic2 data
# Command to compile
basic2: basic2.c
gcc -o basic2 basic2.o
Then, using the command make
will build basic2
if it has changed, and then run the code.
The command make write
will do the same as just make
.
The command make basic2
will just compile if necessary.
Of course, all: write
is not necessary in this case, but if you have other things you want to build together, it would be useful to add more dependencies after write
.