makefile编写---单个子目录编译自动变量模板ok
1.自动化变量通配符http://blog.sina.com.cn/s/blog_7c95e5850101b38l.html
2.wildcard 使用http://blog.csdn.net/liangkaiming/article/details/6267357
3.srcs=(wildcard:%。o=%。c)说明
http://os.chinaunix.net/a2008/0312/978/000000978004.shtml
4.$(srcs):%.o:%.c说明==$(patsubst %.c,%.o $(wildcard *.c))==$($(wildcard *.c):%.c=%.o)
http://bbs.csdn.net/topics/380082064
http://www.linuxsir.org/bbs/thread205437.html
http://guliqun1983.blog.163.com/blog/static/50111685201171842740793/
5.规则http://www.cnblogs.com/pied/archive/2012/11/02/2751476.html
me:
Target = auto
Cc = gcc
Cflags = -Wall -O
Lflags = -lpthread
Include = -I
Ar = ar
Libs =
Srcs = $(wildcard *.c)
#$(wildcard,./sub/*.c) qudiao ','
Incs = $(wildcard *.h)
Objects = $(Srcs:%.c=%.o)
.PHONY:clean release install
all: release
print:
@echo $(Srcs)
@echo $(Incs)
@echo $(Objects)
@echo "why???"
release:$(Target)
$(Target):$(Objects)
$(Cc) $^ -o $@
@echo $@
@echo "pkf"
$(Objects):%.o:%.c $(Incs) // this is not need!!!!!
$(Cc) -c $< -o $@
@echo $@
@echo $<
clean:
-rm *.o
-rm $(Target)
exmple:
==============================================================
Target = TestIni
GCC = gcc
G++ = g++
CInc = $(wildcard *.h)
CSrc = $(wildcard *.c)
Cobjects =$(CSrc:%.c=%.o)
#Cobjects =$(patsubst %.c,%.o,$(CSrc))
release:$(Target)
$(Target): $(Cobjects)
$(GCC) -o $@ $^
##################test######################
#CInc += iniparser.h dictionary.h
#CSrc += iniparser.c dictionary.c
#Cobjects += iniparser.o dictionary.o
#CppObejects =
#$(Cobjects):$(Csrc)
# $(GCC) $(CInc) -c $<
#$(Target): iniparser.o dictionary.o
# $(GCC) -o $@ $^
#iniparser.o: iniparser.c
# $(GCC) $(CInc) -c $<
#dictionary.o: dictionary.c
# $(GCC) $(CInc) -c $<
clean:
rm -rf *.o $(Target) *.gch
===================================================
http://blog.csdn.net/liangkaiming/article/details/6267357
wildcard netdir patsubst
make -f makefile release