Makefile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # SPDX-License-Identifier: GPL-2.0
  2. PROG= aicasm
  3. OUTDIR ?= ./
  4. .SUFFIXES= .l .y .c .h
  5. CSRCS= aicasm.c aicasm_symbol.c
  6. YSRCS= aicasm_gram.y aicasm_macro_gram.y
  7. LSRCS= aicasm_scan.l aicasm_macro_scan.l
  8. GENHDRS= $(addprefix ${OUTDIR}/,aicdb.h $(YSRCS:.y=.h))
  9. GENSRCS= $(addprefix ${OUTDIR}/,$(YSRCS:.y=.c) $(LSRCS:.l=.c))
  10. SRCS= ${CSRCS} ${GENSRCS}
  11. LIBS= -ldb
  12. clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
  13. # Override default kernel CFLAGS. This is a userland app.
  14. AICASM_CFLAGS:= -I/usr/include -I. -I$(OUTDIR)
  15. LEX= flex
  16. YACC= bison
  17. YFLAGS= -d
  18. NOMAN= noman
  19. ifneq ($(HOSTCC),)
  20. AICASM_CC= $(HOSTCC)
  21. else
  22. AICASM_CC= $(CC)
  23. endif
  24. ifdef DEBUG
  25. CFLAGS+= -DDEBUG -g
  26. YFLAGS+= -t -v
  27. LFLAGS= -d
  28. endif
  29. $(PROG): $(OUTDIR) ${GENHDRS} $(SRCS)
  30. $(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(OUTDIR)/$(PROG) $(LIBS)
  31. $(OUTDIR):
  32. mkdir -p $(OUTDIR)
  33. $(OUTDIR)/aicdb.h:
  34. @if [ -e "/usr/include/db4/db_185.h" ]; then \
  35. echo "#include <db4/db_185.h>" > $@; \
  36. elif [ -e "/usr/include/db3/db_185.h" ]; then \
  37. echo "#include <db3/db_185.h>" > $@; \
  38. elif [ -e "/usr/include/db2/db_185.h" ]; then \
  39. echo "#include <db2/db_185.h>" > $@; \
  40. elif [ -e "/usr/include/db1/db_185.h" ]; then \
  41. echo "#include <db1/db_185.h>" > $@; \
  42. elif [ -e "/usr/include/db/db_185.h" ]; then \
  43. echo "#include <db/db_185.h>" > $@; \
  44. elif [ -e "/usr/include/db_185.h" ]; then \
  45. echo "#include <db_185.h>" > $@; \
  46. else \
  47. echo "*** Install db development libraries"; \
  48. fi
  49. clean:
  50. rm -f $(clean-files)
  51. # Create a dependency chain in generated files
  52. # to avoid concurrent invocations of the single
  53. # rule that builds them all.
  54. $(OUTDIR)/aicasm_gram.c: $(OUTDIR)/aicasm_gram.h
  55. $(OUTDIR)/aicasm_gram.c $(OUTDIR)/aicasm_gram.h: aicasm_gram.y
  56. $(YACC) $(YFLAGS) -b $(<:.y=) $<
  57. mv $(<:.y=).tab.c $(OUTDIR)/$(<:.y=.c)
  58. mv $(<:.y=).tab.h $(OUTDIR)/$(<:.y=.h)
  59. # Create a dependency chain in generated files
  60. # to avoid concurrent invocations of the single
  61. # rule that builds them all.
  62. $(OUTDIR)/aicasm_macro_gram.c: $(OUTDIR)/aicasm_macro_gram.h
  63. $(OUTDIR)/aicasm_macro_gram.c $(OUTDIR)/aicasm_macro_gram.h: aicasm_macro_gram.y
  64. $(YACC) $(YFLAGS) -b $(<:.y=) -p mm $<
  65. mv $(<:.y=).tab.c $(OUTDIR)/$(<:.y=.c)
  66. mv $(<:.y=).tab.h $(OUTDIR)/$(<:.y=.h)
  67. $(OUTDIR)/aicasm_scan.c: aicasm_scan.l
  68. $(LEX) $(LFLAGS) -o $@ $<
  69. $(OUTDIR)/aicasm_macro_scan.c: aicasm_macro_scan.l
  70. $(LEX) $(LFLAGS) -Pmm -o $@ $<