clean:
@echo "always be executed"
helloworld:file1.o file2.o
gcc file1.o file2.o -o helloworld
file1.o:file1.c file2.h
gcc -c file1.c -o file1.o
file2.o:file2.c file2.h
gcc -c file2.c -o file2.o
PHONY += clean
.PHONY: $(PHONY)
[beyes@SLinux Makefile]$ make
always be executed
[beyes@SLinux Makefile]$ make helloworld
gcc -c file1.c -o file1.o
gcc -c file2.c -o file2.o
gcc file1.o file2.o -o helloworld
PHONY := __build
.PHONY: $(PHONY)
__build:
obj-y := timesheet
obj-m := hello
__build:
lib-y := world
__build:
@echo $(obj-y)
@echo $(lib-y)
$ make
timesheet
world
$ make
make: Nothing to be done for `__build'.
PHONY := __build
.PHONY: $(PHONY)
__build:
obj-y := timesheet
obj-m := hello
temp:
@echo "--------------------------"
__build:
@echo "i am here"
all: hello world ok
.PHONY:all
hello : hello.o
gcc hello.o -o hello
hello.o: hello.c
gcc -c hello.c -o hello.o
world : world.o
gcc world.o -o world
world.o : world.c
gcc -c world.c -o world.o
ok : ok.o
gcc ok.o -o ok
ok.o : ok.c
gcc -c ok.c -o ok.o
clean:
-rm -f *.o hello world ok
[beyes@SLinux temp2]$ make
make: Nothing to be done for `all'.
PHONY += all
all: hello world ok
hello : hello.o
gcc hello.o -o hello
hello.o: hello.c
gcc -c hello.c -o hello.o
world : world.o
gcc world.o -o world
world.o : world.c
gcc -c world.c -o world.o
ok : ok.o
gcc ok.o -o ok
ok.o : ok.c
gcc -c ok.c -o ok.o
PHONY += cleanall clwanobj cleanexe
cleanall:cleanobj cleanexe
cleanobj:
rm *.o
cleanexe:
rm hello world ok
.PHONY: $(PHONY)
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |