You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
2.5 KiB

  1. # Some make rules to make output pretty....
  2. # default ARFLAGS also has 'v', but we don't want it to be verbose.
  3. ARFLAGS= -r
  4. # make sure libs from /usr/local/lib are found
  5. VPATH= /lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib
  6. LIBTOOL=libtool
  7. OS= $(shell uname -s)
  8. HW= $(shell uname -m)
  9. ifneq ($(OS), FreeBSD)
  10. FLEX=flex
  11. else
  12. FLEX=/usr/local/bin/flex
  13. endif
  14. BUILDCC:=${CC}
  15. BUILDLIBTOOL:=${LIBTOOL}
  16. ifdef BUILDSYS
  17. BUILDCC:=${BUILDSYS}-gcc
  18. BUILDLIBTOOL:=${BUILDSYS}-libtool
  19. endif
  20. ifdef HOSTSYS
  21. CC=${HOSTSYS}-gcc
  22. LD=${HOSTSYS}-ld
  23. OBJCOPY=${HOSTSYS}-objcopy
  24. OBJDUMP=${HOSTSYS}-objdump
  25. LIBTOOL=${HOSTSYS}-libtool
  26. CONF_HOST=--host=${HOSTSYS}
  27. HW=$(HOSTSYS)
  28. endif
  29. %.o : %.c
  30. @echo " CC $<"
  31. @$(CC) -MMD $(CFLAGS) -c $< -o $@
  32. %.o : %.il2c.c
  33. @echo "LT CCil $<"
  34. @${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $< -o $@
  35. @sed -e "s:\.il2c.c:\.il:" -i -i $*.il2c.d
  36. %.o : %.ctrl
  37. @echo "BLOB LD $@"
  38. @$(LD) -r -b binary $< -o $@
  39. %: %.o
  40. @echo " LD $@"
  41. @${LIBTOOL} --quiet --mode=link --tag=CC $(LINK.o) $(filter %.o,$^) $(LOADLIBS) $(LDLIBS) $($@_LDFLAGS) $(CFLAGS) -o $@
  42. %.lo: %.c
  43. @echo "LT CC $<"
  44. @${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $< -o $@
  45. @cat $(dir $*).libs/$(*F).d | sed -e "s:\.libs/::" -e "s:\.o:\.lo:" > $*.d
  46. %.lo: %.il2c.c
  47. @echo "LT ilCC $<"
  48. @${LIBTOOL} --quiet --mode=compile --tag=CC $(CC) -MMD $(CFLAGS) -c $<
  49. @cat $(dir $*).libs/$(*F).d | sed -e "s:\.libs/::" -e "s:\.o:\.lo:" -e "s:\.il2c.c:\.il:" > $*.d
  50. define LIB_LINK
  51. @echo "LT LD $@"
  52. @${LIBTOOL} --quiet --mode=link --tag=CC $(CC) $(filter %.lo,$^) -o $@ $(LDFLAGS) $($@_LDFLAGS) -static-libtool-libs -rpath $(abspath $(@D))
  53. @echo "LT INST $@"
  54. @${LIBTOOL} --quiet --mode=install install $@ $(abspath $(@D))
  55. @sed -i -i s\|=$(CURDIR)\|$(CURDIR)\|g $@
  56. endef
  57. %.so:
  58. @echo "LT soLD $@"
  59. @${LIBTOOL} --quiet --mode=link --tag=CC $(CC) $(filter %.lo,$^) -o $@ $(LDFLAGS) $($@_LDFLAGS)
  60. (%): %
  61. @echo " AR $^ in $@"
  62. @$(AR) $(ARFLAGS) $@ $^
  63. %.tab.c %.tab.h: %.y
  64. @echo "BISON $<"
  65. @bison --defines=$*.tab.h $< -o $*.tab.c
  66. %.yy.c %.yy.h: %.l %.tab.h
  67. @echo " FLEX $<"
  68. @$(FLEX) --header-file=$*.yy.h -o $*.yy.c $<
  69. # il2c: instruction list 2 c 'compiler'
  70. %.il2c.c: %.il
  71. @echo " IL2C $<"
  72. @$(IL2C) $<
  73. # dot -> pdf
  74. %.pdf: %.dot
  75. @echo " DOT $<"
  76. @dot $< -o $@ -Tpdf
  77. %.dtb: %.dts
  78. @echo " DTC $<"
  79. @dtc -I dts $< -O dtb -o $@
  80. %.dtbo: %.dts
  81. @echo " DTCo $<"
  82. @dtc -I dts $< -O dtb -o $@
  83. %.hex: %
  84. $(OBJCOPY) --strip-debug --strip-unneeded $? -O ihex $?.hex
  85. %.asm: %
  86. $(OBJDUMP) -D $? > $?.asm