Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. CXX = g++
  2. CXXFLAGS = -std=c++11 -Wall -pedantic -O3
  3. LEX = flex
  4. YAC = bison
  5.  
  6. IDIR = ./include
  7. ODIR = ./obj
  8. SDIR = ./src
  9.  
  10. EXEC = compiler.out
  11. SRCS = $(wildcard $(SDIR)/*.cpp)
  12. OBJS = $(SRCS:$(SDIR)/%.cpp=$(ODIR)/%.o)
  13. DEPS = $(wildcard $(IDIR)/*.h)
  14.  
  15. all: compiler
  16. compiler: $(EXEC)
  17.  
  18. # Create YAC files
  19. $(ODIR)/parser.tab.c $(IDIR)/parser.tab.h: $(SDIR)/parser.y
  20. $(YAC) --defines=$(IDIR)/parser.tab.h $(SDIR)/parser.y -o $(ODIR)/parser.tab.c
  21.  
  22. # Create LEX files
  23. $(ODIR)/parser_lex.yy.c: $(SDIR)/parser.l $(IDIR)/parser.tab.h
  24. $(LEX) -o $@ $(SDIR)/parser.l
  25.  
  26. # To obtain object files#
  27. $(ODIR)/%.o: $(SDIR)/%.cpp $(DEPS)
  28. $(CXX) $(CXXFLAGS) -c $< -o $@ -I$(IDIR)
  29.  
  30. # Compile and link all together
  31. $(EXEC): $(ODIR)/parser_lex.yy.c $(ODIR)/parser.tab.c $(IDIR)/parser.tab.h $(OBJS)
  32. $(CXX) $(CXXFLAGS) -D_GNU_SOURCE -I$(IDIR) $(ODIR)/parser.tab.c $(ODIR)/parser_lex.yy.c $(OBJS) -lcln -lfl -o $@
  33.  
  34.  
  35. clean:
  36. rm -rf $(ODIR)/*
  37. rm -rf $(IDIR)/parser.tab.h
  38. rm -f $(EXEC)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement