Skip to content
Snippets Groups Projects
Makefile 3.35 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jaime Arias's avatar
    Jaime Arias committed
    ################
    # Programm name #
    ################
    
    
    Jaime Arias's avatar
    Jaime Arias committed
    PROGRAM = sog-test-paths
    
    Jaime Arias's avatar
    Jaime Arias committed
    
    ##################
    # Names of file  #
    ##################
    
    ##################### source ########################################
    
    # Source files .c
    
    Jaime Arias's avatar
    Jaime Arias committed
    FILES = main.cpp MDGraph.cpp  Modular_Obs_Graph.cpp RdPBDD.cpp
    
    Jaime Arias's avatar
    Jaime Arias committed
    
    
    # library name
    LIBNAMES = RdP bdd
    
    ######################
    # Names of directory #
    ######################
    
    # Bin directory: where to put program
    BINDIR = .
    
    # Source directory: where to find .c
    SRCDIR = ./Causality ./src
    
    # Include directory: where to find .h
    
    Jaime Arias's avatar
    Jaime Arias committed
    INCDIR =  ./Causality/src ./parser ./buddy22/src ./src  ./buddy22/include
    
    Jaime Arias's avatar
    Jaime Arias committed
    
    # Library directory: where to find library
    LIBDIR =./parser  ./buddy22/src ./buddy22/lib
    
    # Working directory
    OBJDIR = ./obj
    
    ###############
    # extra flags #
    
    Jaime Arias's avatar
    Jaime Arias committed
    ###############
    
    Jaime Arias's avatar
    Jaime Arias committed
    
    # Linker extra flag
    LD_EXTRA_FLAGS =
    
    # Preprocessor defines -D
    DFLAGS =
    # -DNDEBUG
    
    # compiler flag
    
    Jaime Arias's avatar
    Jaime Arias committed
    CFLAGS = -O -Wall -std=c++11
    
    Jaime Arias's avatar
    Jaime Arias committed
    
    #################
    # Program names #
    #################
    
    CC = gcc
    CXX = g++
    # CXX =g++
    LINKER = $(CXX)
    
    
    Jaime Arias's avatar
    Jaime Arias committed
    ############## Automatic ##########################################
    
    Jaime Arias's avatar
    Jaime Arias committed
    # Every Makefile should contain
    SHELL = /bin/sh
    
    # Compute the file list for each type
    
    CCFILES =$(filter %.c,$(FILES))
    CPPFILES =$(filter %.cpp,$(FILES))
    
    
    Jaime Arias's avatar
    Jaime Arias committed
    # OFILES = $(CCFILES:.c=.o)
    
    Jaime Arias's avatar
    Jaime Arias committed
    DFILES = $(addprefix $(OBJDIR)/,$(CCFILES:.c=.d)) $(addprefix $(OBJDIR)/,$(CPPFILES:.cpp=.d))
    OFILES = $(addprefix $(OBJDIR)/,$(CCFILES:.c=.o)) $(addprefix $(OBJDIR)/,$(CPPFILES:.cpp=.o))
    
    Jaime Arias's avatar
    Jaime Arias committed
    # Constructs path to search for
    
    Jaime Arias's avatar
    Jaime Arias committed
    
    vpath %.cpp $(addsuffix :,$(SRCDIR)).
    vpath %.c $(addsuffix :,$(SRCDIR)).
    vpath %.h $(addsuffix :,$(INCDIR)).
    vpath $(PROGRAM) $(BINDIR)
    vpath %.o .
    vpath %.d
    vpath %.a $(LIBDIR)
    
    # Constructs real names for all used libraries
    
    REAL_LIBS	= $(addprefix -l, $(LIBNAMES))
    LIB_FILES	= $(addprefix lib, $(addsuffix .a, $(LIBNAMES)))
    
    # Constructs real name options for directory
    
    REAL_LIBDIR     = $(addprefix -L, $(LIBDIR))
    REAL_INCDIR     = $(addprefix -I,$(INCDIR))
    
    # Compute flags for cpp ld c
    
    CPPFLAGS	= $(DFLAGS) $(REAL_INCDIR)
    LDFLAGS		= $(LD_EXTRA_FLAGS) $(REAL_LIBDIR) $(REAL_LIBS)
    
    # Simple targets
    
    .PHONY:all clean depend parsers parsersclean
    
    all : $(PROGRAM)
    	@echo "all Done"
    
    depend: $(DFILES)
    	@echo "all Done"
    
    clean:
    	@echo -n "Cleaning directory..."
    	@-/bin/rm -f $(OBJDIR)/*.d
    
    Jaime Arias's avatar
    Jaime Arias committed
    	@-/bin/rm -f $(OBJDIR)/*.o
    	@-/bin/rm -f $(BINDIR)/$(PROGRAM)
    
    Jaime Arias's avatar
    Jaime Arias committed
    	@echo clean Done
    
    # Link object files
    
    $(PROGRAM): $(OFILES) $(REAL_LIB)
    	@echo -n "Linking $(PROGRAM) ..."
    	$(LINKER) $(OFILES) $(LDFLAGS) -o $(BINDIR)/$(PROGRAM)
    	@echo "Done"
    
    # Implicite rules
    .SUFFIXES : .tab.c .lex.c .tab.d .lex.d .c .o .d .l .y .cpp
    
    # Rule to compile .c files (handle correctly C++ // comments)
    
    
    Jaime Arias's avatar
    Jaime Arias committed
    $(OBJDIR)/%.o : %.c
    
    Jaime Arias's avatar
    Jaime Arias committed
    	@echo -n "Compiling $< :... "
    	$(CC) $(CFLAGS) -c -I$(<D) $(CPPFLAGS) $<
    	@mv $*.o $(OBJDIR)/.
    	@echo "Done"
    
    
    Jaime Arias's avatar
    Jaime Arias committed
    $(OBJDIR)/%.o : %.cpp
    
    Jaime Arias's avatar
    Jaime Arias committed
    	@echo -n "Compiling $< :... "
    	$(CXX) $(CFLAGS) -c -I$(<D) $(CPPFLAGS) $<
    	@mv $*.o $(OBJDIR)/.
    	@echo "Done"
    
    # Rule to build dependencied for each file when necessary
    
    
    Jaime Arias's avatar
    Jaime Arias committed
    $(OBJDIR)/%.d : %.c
    
    Jaime Arias's avatar
    Jaime Arias committed
    	@echo -n "Computing dependencies for $< ... "
    	@$(SHELL) -ec '$(CC) -M -I$(<D) $(CPPFLAGS) $< | sed '\''s,$*\.o,$(OBJDIR)/$*.d $(OBJDIR)/$*.o,g'\''>$@'
    	@echo "Done"
    
    
    Jaime Arias's avatar
    Jaime Arias committed
    $(OBJDIR)/%.d : %.cpp
    
    Jaime Arias's avatar
    Jaime Arias committed
    	@echo -n "Computing dependencies for $< ... "
    	@$(SHELL) -ec '$(CPP) -M -I$(<D) $(CPPFLAGS) $< | sed '\''s,$*\.o,$(OBJDIR)/$*.d $(OBJDIR)/$*.o,g'\''>$@'
    	@echo "Done"
    
    # include dependance files
    include $(DFILES)