1: ###################################################################################################
     2: ## Very generic Makefile:
     3: ## It generates the object files from all cpp or cc files in a directory and links them together. 
     4: ## You only have to supply it with your TARGET, LIBS, FLAGS, PATHS etc.
     5: ###################################################################################################
     6: 
     7: CC          :=	gcc
     8: CXX         :=	g++
     9: CFLAGS      :=	-pipe -Wall -W -g -O3 -fomit-frame-pointer -DDEBUG -D_REENTRANT 
    10: CXXFLAGS    :=	-pipe -Wall -g -O3 -frepo -DDEBUG -D_REENTRANT
    11: INCPATH     :=  
    12: 
    13: LINK        :=	g++
    14: LFLAGS      :=	-frepo
    15: 
    16: LIBS        :=	-ldb1
    17: LIBPATH     :=	
    18: 
    19: TAR         :=	tar -cf
    20: GZIP        :=	gzip -9f
    21: BZIP        :=	bzip2
    22: RM          :=	rm -vf
    23: TAGS        :=	ctags
    24: DOXYGEN     :=	doxygen
    25: 
    26: # FILE THAT STORES THE DEPENDENCIES AND IS INCLUDED IN THE MAKEFILE AUTOMATICALLY
    27: DEPS        := Makefile.dep
    28: # FLAG HOW TO GENERATE THE DEPENDENCIES 
    29: # ( '-M' generates all dependencies '-MM' generates only dependencies of user created source files
    30: DEP_FLAG    := -MM
    31: HEADERS     := $(wildcard *.h)
    32: SOURCES     := $(wildcard *.cpp) $(wildcard *.cc)
    33: OBJECTS     := $(patsubst %.cpp,%.o,$(patsubst %.cc,%.o,$(SOURCES)))
    34: 
    35: TARGET      := DB
    36: 
    37: ####### Implicit rules
    38: 
    39: .SUFFIXES: .cpp .cxx .cc .C .c
    40: 
    41: .cpp.o:
    42: 	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
    43: 
    44: .cxx.o:
    45: 	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
    46: 
    47: .cc.o:
    48: 	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
    49: 
    50: .C.o:
    51: 	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
    52: 
    53: .c.o:
    54: 	$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
    55: 
    56: ####### Build rules
    57: 
    58: .PHONY : all depend objects clean proper world docs
    59: 
    60: 
    61: all : $(TARGET)
    62: 
    63: $(TARGET): $(OBJECTS) 
    64: 	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBPATH) $(LIBS)
    65: 
    66: depend :
    67: 	$(CXX) $(INCPATH) $(DEP_FLAG) $(SOURCES) > $(DEPS)
    68: 
    69: objects : $(OBJECTS)
    70: 
    71: clean :
    72: 	$(RM) $(TARGET)
    73: 	$(RM) $(OBJECTS)
    74: 	$(RM) *.d
    75: 	$(RM) *~ core
    76: 
    77: proper: clean
    78: 	$(RM) *.a
    79: 	$(RM) *.bak
    80: 	$(RM) *.old
    81: 	$(RM) *.rpo
    82: 	$(RM) $(DEPS)
    83: 	$(RM) tags
    84: 	$(RM) *~
    85: 	$(RM) DATABASE
    86: 
    87: tags:
    88: 	$(TAGS) *
    89: 	
    90: docs:
    91: 	$(DOXYGEN) Doxyfile
    92: 
    93: world: proper tags depend all docs
    94: 
    95: -include $(DEPS)
    96: