Makefile 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 -std=c99
  19. LDFLAGS = -g -lreadline -lnfc -lssl
  20. LEX = flex
  21. LEXCFLAGS = \
  22. -g -std=c99 -Wall \
  23. -Wno-unused-function \
  24. -Wno-implicit-function-declaration
  25. LEXFLAGS =
  26. MFTERM_SRCS = \
  27. mfterm.c \
  28. term_cmd.c \
  29. util.c \
  30. tag.c \
  31. mifare.c \
  32. mifare_ctrl.c \
  33. dictionary.c \
  34. spec_syntax.c \
  35. mac.c
  36. MFTERM_LEX = \
  37. dictionary_parser.l \
  38. spec_tokenizer.l
  39. MFTERM_OBJS = $(MFTERM_SRCS:.c=.o) $(MFTERM_LEX:.l=.o) spec_parser.o
  40. .PHONY: clean all
  41. all: mfterm
  42. clean:
  43. rm -f mfterm *.o *~ *.bak $(MFTERM_LEX:.l=.c) spec_parser.c spec_parser.tab.h
  44. mfterm: $(MFTERM_OBJS)
  45. ${CC} ${LDFLAGS} -o $@ $^
  46. # Use the dp_ prefix (instead of yy) for this parser
  47. dictionary_parser.c : dictionary_parser.l Makefile
  48. ${LEX} ${LEXFLAGS} --prefix=dp_ -o $@ $<
  49. # Flex generated source is not Wall clean, skip that flag
  50. dictionary_parser.o : dictionary_parser.c Makefile
  51. ${CC} ${LEXCFLAGS} -c $<
  52. # Use the st_ prefix (instead of yy) for this parser
  53. spec_tokenizer.c : spec_tokenizer.l Makefile
  54. ${LEX} ${LEXFLAGS} --prefix=sp_ -o $@ $<
  55. # Flex generated source is not Wall clean, skip that flag
  56. # the st really depends on the tab.h, but that won't work here,
  57. # so we use the other production sp.c as a dep.
  58. spec_tokenizer.o : spec_tokenizer.c spec_parser.c Makefile
  59. ${CC} ${LEXCFLAGS} -c $<
  60. spec_parser.o : spec_parser.c Makefile
  61. ${CC} ${LEXCFLAGS} -c $<
  62. spec_parser.c spec_parser.tab.h: spec_parser.y Makefile
  63. bison --name-prefix=sp_ --defines=spec_parser.tab.h -o $@ $<
  64. # Generic compilation rule - make file plumbing
  65. %.o : %.c Makefile
  66. ${CC} ${CFLAGS} -c $<
  67. # makedepend section - set up include dependencies
  68. DEPFILE = .depends
  69. DEPTOKEN = '\# MAKEDEPENDS'
  70. DEPFLAGS = -Y -f $(DEPFILE) -s $(DEPTOKEN)
  71. depend:
  72. rm -f $(DEPFILE)
  73. make $(DEPFILE)
  74. $(DEPFILE):
  75. @echo $(DEPTOKEN) > $(DEPFILE)
  76. makedepend $(DEPFLAGS) -- $(CFLAGS) -- *.c 2> /dev/null
  77. sinclude $(DEPFILE)