Makefile examples: CDK3

From Wiki**3

<text> LIBNAME=cdk

  1. CXXFLAGS=-O6 -Isemantics -I. -g -Wall -ansi -pedantic

CXXFLAGS=-Isemantics -I. -ggdb -Wall -ansi -pedantic

ROOT = ${HOME}/compiladores/root

  1. * * * DO NOT CHANGE ANYTHING AFTER THIS LINE * * *

INST_INC_DIR = $(ROOT)/usr/include/$(LIBNAME) INST_LIB_DIR = $(ROOT)/usr/lib INST_DOC_DIR = $(ROOT)/usr/share/doc/packages/$(LIBNAME)

SRC_CPP = \

       $(wildcard generators/*.cpp) \
       $(wildcard nodes/*.cpp) $(wildcard nodes/expressions/*.cpp) \
       $(wildcard semantics/*.cpp) \
       Compiler.cpp CompilerFactory.cpp Symbol.cpp SymbolTable.cpp main.cpp

OFILES = $(SRC_CPP:%.cpp=%.o)

YACC=byacc LEX=flex

%.o:: %.cpp

       $(CXX) $(CXXFLAGS) -c $< -o $@

all: link lib$(LIBNAME).a docs

  1. dirty hack

link:

       -ln -s . cdk

docs: doc/.docsdone

doc/.docsdone: $(LIBNAME).doxyfile

       $(RM) cdk
       doxygen $<
       touch $@
       -ln -s . cdk

$(LIBNAME).doxyfile: $(SRC_CPP)

lib$(LIBNAME).a: $(OFILES)

       ar crl $@ $^

clean:

       rm -f lib$(LIBNAME).a $(OFILES) a.out core y.tab.[ch] lex.yy.c

install: all

       mkdir -p $(INST_LIB_DIR) $(INST_DOC_DIR)
       mkdir -p $(INST_INC_DIR) $(INST_INC_DIR)/nodes
       mkdir -p $(INST_INC_DIR) $(INST_INC_DIR)/nodes/expressions
       mkdir -p $(INST_INC_DIR) $(INST_INC_DIR)/semantics
       #mkdir -p $(INST_INC_DIR)/semantics
       mkdir -p $(INST_INC_DIR)/generators
       cp -a Compiler.h CompilerFactory.h Symbol.h SymbolTable.h $(INST_INC_DIR)
       cp -a generators/*.h $(INST_INC_DIR)/generators
       cp -a nodes/*.h $(INST_INC_DIR)/nodes
       cp -a nodes/expressions/*.h $(INST_INC_DIR)/nodes/expressions
       cp -a semantics/Evaluator.h $(INST_INC_DIR)/semantics
       cp -a lib$(LIBNAME).a $(INST_LIB_DIR)
       #DOC cp -a doc/. $(INST_DOC_DIR)/

depend:

       $(CXX) $(CXXFLAGS) -MM $(SRC_CPP) > .makedeps

-include .makedeps </text>