# ****************************** # * S E T T I N G S * # ****************************** # default target TARGET ?= linux-release ifeq ($(filter %-release,$(TARGET)),) RELEASE := debug else RELEASE := release endif # libxml2 settings XML2CONF ?= xml2-config LIBXML2_INC := `$(XML2CONF) --cflags` # compiler setting ifeq ($(RELEASE),debug) CFLAGS := -O0 -ggdb3 -fno-inline -fno-default-inline else CFLAGS ?= -O2 -ggdb3 CPPFLAGS += -DNDEBUG endif CFLAGS += -Wall -pipe CXXFLAGS += $(CFLAGS) -std=gnu++11 # -fno-rtti -fno-exceptions CPPFLAGS += $(LIBXML2_INC) # ****************************** # * S O U R C E S * # ****************************** # library file LIBDIR := lib/$(TARGET) LIB := $(LIBDIR)/libacmodel.a CCSOURCES := $(wildcard *.cc) OBJECTDIR := ObjFiles/$(TARGET) OBJECTS := $(addprefix $(OBJECTDIR)/,$(CCSOURCES:.cc=.o)) DEPDIR := DepFiles/$(TARGET) DEPS := $(addprefix $(DEPDIR)/,$(CCSOURCES:.cc=.d)) DIRS := $(OBJECTDIR) $(DEPDIR) $(LIBDIR) # ****************************** # * T A R G E T S * # ****************************** all: @$(MAKE) showtarget @$(MAKE) $(LIB) showtarget: @echo "---" @echo Making ACModel library for TARGET=$(TARGET) @echo Compiler = $(CXX) $(CPPFLAGS) $(CXXFLAGS) @echo "---" clean: @echo Cleaning ACModel. @rm -rf core core.* *~ lib DepFiles ObjFiles # ****************************** # * R U L E S * # ****************************** $(LIB): $(OBJECTS) @echo "Creating library $@." @mkdir -p $(LIBDIR) @$(AR) rcs $@ $(OBJECTS) $(OBJECTDIR)/%.o : %.cc @echo Making dependency file $@. @mkdir -p $(DEPDIR) @$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MM -MP -MT $(OBJECTDIR)/$(<:%.cc=%.o) -MT $(DEPDIR)/$(<:%.cc=%.d) $< > $(DEPDIR)/$(<:%.cc=%.d) @echo Making object file $@. @mkdir -p $(OBJECTDIR) @$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< ifneq ($(MAKECMDGOALS),clean) -include $(DEPS) endif .phony: all clean showtarget