Hey,

I have a problem that I'm not sure if its from running on windows or not.

Lets say I have the following MakeFile for compiling and creating the executable of 'target.c':

FLAGS = -Wall -g

all : target

target : target.o
           gcc ${FLAGS} -o $@ $^

target.o : target.c target.h
           gcc ${FLAGS} -c $^

clean :
           rm *.o target

Everything compiles just fine and all seems good with no errors.
Just when I try calling "make clean", it gives me this error:
rm: cannot remove `target': No such file or directory

so I navigated into the working directory that contains the files using cygwin, and saw that my executable was actually called 'target.exe', so I had to change the 'clean' function in my MakeFile into:

rm *.o target.exe

Which worked with no problems, but since I will need this to work on a Linux system as well, I'm not sure if changing to target.exe will also run on Linux with no problems.

Any advice on how to find a solution for this problem?

Thank you for your help.

change "rm *.o target.exe " to "rm *.o target.exe target"

or maybe rm *.o target*.* [edit]:icon_eek: ^^^ That will also delete the source code![/edit]

Do as kaoni317 suggests, but specify the -f flag. rm -f *.o target.exe target This will stop make from terminating just because one of the files don't exist.

how about something like

if exist target rm -f target
if exist target.exe rm -f target.exe
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.