help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

weird rm command caused by pattern rules?


From: Can Finner
Subject: weird rm command caused by pattern rules?
Date: Sun, 10 Jul 2011 01:13:52 +0800

Hi,
I constructed following simple example, including a Makefile and a.c
source file in ./src directory, like

#./Makefile
#-------------------------------------
TEST_OBJ = $(patsubst %.c,%.o,$(TEST_SRC))
%.o  : %.c
        gcc -c -o address@hidden ${<}
%.exe : ${TEST_OBJ}
        gcc $^ -o $@
.PHONY: all clean
all: a.exe
clean:
        @rm -f src/a.o a.exe

#./src/a.c source file
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
    printf("hello make\n");
    return 0;
}

Then I ran following command in cmd:
$ make TEST_SRC=src/a.c all
the out put is like:

gcc -c -o src/a.o src/a.c
gcc src/a.o -o a.exe
rm src/a.o

I am very curious where the last rm command comes from? seems some
kind of relate to the pattern rules.
So  any advice? Thanks very much.

BTW, I am using make 3.81 under ubuntu 8.10, following is the version
information:

GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i486-pc-linux-gnu
-- 
Regards.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]