#this make file can auto maticly make all c and cpp files in a folder.
#no need to modify this file, it can work well.
#autor: Chunrui Wang
#date: 2011-07-28
# The executeable file name
APP = Target
# source file name . include C and Cpp
SRCS = $(wildcard *.cpp) $(wildcard *.c)
#object files
OBJS = $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SRCS)))
#header depandence files.
DEPS = $(patsubst %.cpp,%.d~,$(patsubst %.c,%.d~,$(SRCS)))
#support mutiple target here.
.PHONY : all
all : $(APP)
$(APP):$(OBJS)
#$(CXX) $(CFLAGS) -o $(APP) $(OBJS) $(LDFLAGS)
#$(AR) r "lib$(APP).a" $(OBJS)
$(CXX) -shared -o "lib$(APP).so" $(OBJS)
#generate the header depandence for each cpp file.
#Delete the hint rule of makefile for Cpp file.
.SUFFIXES : .cpp
.cpp.o:
$(CXX) $(CFLGAS) -MMD -MF $*.d~ -c -o $@ $<
#generate the header depandence for each c file.
#Delete the hint rule of makefile for C file.
.SUFFIXES : .c
.c.o:
$(CXX) $(CFLGAS) -MMD -MF $*.d~ -c -o $@ $<
#this is very important
-include $(DEPS)
#Deleting some files to make the project clean.
.PHONY : clean
clean :
rm -rf *.o
rm -rf $(APP)
rm -rf *~
|