makefile 562 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # project data
  2. name=dd_lang
  3. version=0.0
  4. # source files and objects
  5. SRC=lex.yy.c y.tab.c $(wildcard src/*.c)
  6. OBJ=${SRC:.c=.o}
  7. HEADERS=y.tab.h $(wildcard headers/*.h)
  8. # executable
  9. ${name}: ${OBJ}
  10. gcc ${OBJ} -o ${name}
  11. # lexer
  12. lex.yy.c: src/mylex.l
  13. lex src/mylex.l
  14. # yacc
  15. y.tab.c: src/mylex.y
  16. yacc -d src/mylex.y
  17. y.tab.h: src/mylex.y
  18. yacc -d src/mylex.y
  19. # clean
  20. clean:
  21. rm -rf lex.yy.c y.tab.c y.tab.h ${OBJ} ${name}
  22. .PHONY: clean
  23. # recompile after header change
  24. ${OBJ}: ${HEADERS}
  25. # compile object files
  26. .c.o:
  27. gcc -c -o ${<:.c=.o} $< -I headers -I .