###################################################################################################
## Very generic Makefile:
## It generates the object files from all cpp or cc files in a directory and links them together.
## You only have to supply it with your TARGET, LIBS, FLAGS, PATHS etc.
###################################################################################################
CC := gcc
CXX := g++
CFLAGS := -pipe -Wall -W -g -O3 -fomit-frame-pointer -DDEBUG -D_REENTRANT
CXXFLAGS := -pipe -Wall -g -O3 -frepo -DDEBUG -D_REENTRANT
INCPATH :=
LINK := g++
LFLAGS := -frepo
LIBS := -ldb1
LIBPATH :=
TAR := tar -cf
GZIP := gzip -9f
BZIP := bzip2
RM := rm -vf
TAGS := ctags
DOXYGEN := doxygen
# FILE THAT STORES THE DEPENDENCIES AND IS INCLUDED IN THE MAKEFILE AUTOMATICALLY
DEPS := Makefile.dep
# FLAG HOW TO GENERATE THE DEPENDENCIES
# ( '-M' generates all dependencies '-MM' generates only dependencies of user created source files
DEP_FLAG := -MM
HEADERS := $(wildcard *.h)
SOURCES := $(wildcard *.cpp) $(wildcard *.cc)
OBJECTS := $(patsubst %.cpp,%.o,$(patsubst %.cc,%.o,$(SOURCES)))
TARGET := DB
####### Implicit rules
.SUFFIXES: .cpp .cxx .cc .C .c
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
####### Build rules
.PHONY : all depend objects clean proper world docs
all : $(TARGET)
$(TARGET): $(OBJECTS)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBPATH) $(LIBS)
depend :
$(CXX) $(INCPATH) $(DEP_FLAG) $(SOURCES) > $(DEPS)
objects : $(OBJECTS)
clean :
$(RM) $(TARGET)
$(RM) $(OBJECTS)
$(RM) *.d
$(RM) *~ core
proper: clean
$(RM) *.a
$(RM) *.bak
$(RM) *.old
$(RM) *.rpo
$(RM) $(DEPS)
$(RM) tags
$(RM) *~
$(RM) DATABASE
tags:
$(TAGS) *
docs:
$(DOXYGEN) Doxyfile
world: proper tags depend all docs
-include $(DEPS)