Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Copyright (C) 2011 Anders Sundman <anders@4zm.org>
  2. #
  3. # This file is part of mfterm.
  4. #
  5. # mfterm is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # mfterm is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with mfterm. If not, see <http://www.gnu.org/licenses/>.
  17. CC = gcc
  18. CFLAGS = -g -Wall -Wconversion -std=c99 -Werror
  19. LDFLAGS = -g -lreadline -lnfc -lssl -lcrypto
  20. LEX = flex
  21. LEXCFLAGS = \
  22. -g -std=c99 -Wall \
  23. -Wno-unused-function \
  24. -Wno-unused-but-set-variable \
  25. -Wno-implicit-function-declaration
  26. LEXFLAGS =
  27. MFTERM_SRCS = \
  28. mfterm.c \
  29. term_cmd.c \
  30. util.c \
  31. tag.c \
  32. mifare.c \
  33. mifare_ctrl.c \
  34. dictionary.c \
  35. spec_syntax.c \
  36. mac.c
  37. MFTERM_LEX = \
  38. dictionary_parser.l \
  39. spec_tokenizer.l
  40. MFTERM_OBJS = $(MFTERM_SRCS:.c=.o) $(MFTERM_LEX:.l=.o) spec_parser.o
  41. .PHONY: clean all
  42. all: mfterm
  43. clean:
  44. rm -f mfterm *.o *~ *.bak $(MFTERM_LEX:.l=.c) spec_parser.c spec_parser.tab.h
  45. mfterm: $(MFTERM_OBJS)
  46. ${CC} -o $@ $^ ${LDFLAGS}
  47. # Use the dp_ prefix (instead of yy) for this parser
  48. dictionary_parser.c : dictionary_parser.l Makefile
  49. ${LEX} ${LEXFLAGS} --prefix=dp_ -o $@ $<
  50. # Flex generated source is not Wall clean, skip that flag
  51. dictionary_parser.o : dictionary_parser.c Makefile
  52. ${CC} ${LEXCFLAGS} -c $<
  53. # Use the st_ prefix (instead of yy) for this parser
  54. spec_tokenizer.c : spec_tokenizer.l Makefile
  55. ${LEX} ${LEXFLAGS} --prefix=sp_ -o $@ $<
  56. # Flex generated source is not Wall clean, skip that flag
  57. # the st really depends on the tab.h, but that won't work here,
  58. # so we use the other production sp.c as a dep.
  59. spec_tokenizer.o : spec_tokenizer.c spec_parser.c Makefile
  60. ${CC} ${LEXCFLAGS} -c $<
  61. spec_parser.o : spec_parser.c Makefile
  62. ${CC} ${LEXCFLAGS} -c $<
  63. spec_parser.c spec_parser.tab.h: spec_parser.y Makefile
  64. bison --name-prefix=sp_ --defines=spec_parser.tab.h -o $@ $<
  65. # Generic compilation rule - make file plumbing
  66. %.o : %.c Makefile
  67. ${CC} ${CFLAGS} -c $<
  68. # makedepend section - set up include dependencies
  69. DEPFILE = .depends
  70. DEPTOKEN = '\# MAKEDEPENDS'
  71. DEPFLAGS = -Y -f $(DEPFILE) -s $(DEPTOKEN)
  72. depend:
  73. rm -f $(DEPFILE)
  74. make $(DEPFILE)
  75. $(DEPFILE):
  76. @echo $(DEPTOKEN) > $(DEPFILE)
  77. makedepend $(DEPFLAGS) -- $(CFLAGS) -- *.c 2> /dev/null
  78. sinclude $(DEPFILE)