Add-in development tools for fx-9860G and fx-CG 50, to use with GCC and gint.
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.

Makefile 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #! /usr/bin/make -f
  2. # Require config file if not cleaning up
  3. ifeq "$(filter clean distclean,$(MAKECMDGOALS))" ""
  4. include Makefile.cfg
  5. endif
  6. # Compiler flags
  7. cflags = -Wall -Wextra -std=c11 -g -I $(dir $<) -D_GNU_SOURCE \
  8. -DFXSDK_PREFIX='"$(PREFIX)"' $(CFLAGS)
  9. # Linker flags
  10. lflags = -lpng
  11. # Dependency generation flags
  12. dflags = -MT $@ -MMD -MP -MF $(@:%.o=%.d)
  13. #
  14. # Main targets and symbolic targets
  15. # $TARGETS is provided by Makefile.cfg.
  16. #
  17. TARGETS := $(filter-out fxconv fxsdk,$(TARGETS))
  18. bin = $(TARGETS:%=bin/%)
  19. # fxconv has no sources files because it's written in Python, and fxsdk has no
  20. # source either because it's written in Bash.
  21. src = $(wildcard $1/*.c)
  22. src-fxg1a := $(call src,fxg1a)
  23. src-fxos := $(call src,fxos)
  24. lex-fxos := $(wildcard fxos/*.l)
  25. obj = $($1:%=build/%.o)
  26. lex = $($1:%.l=build/%.yy.c.o)
  27. obj-fxg1a := $(call obj,src-fxg1a)
  28. obj-fxos := $(call obj,src-fxos) $(call lex,lex-fxos)
  29. # Symbolic targets
  30. all: $(bin)
  31. all-fxg1a: bin/fxg1a
  32. all-fxos: bin/fxos
  33. # Explicit targets
  34. bin/fxg1a: $(obj-fxg1a) | bin/
  35. gcc $^ -o $@ $(lflags)
  36. bin/fxos: $(obj-fxos) | bin/
  37. gcc $^ -o $@ $(lflags)
  38. bin/:
  39. mkdir -p $@
  40. #
  41. # Source rules
  42. #
  43. build/%.c.o: %.c
  44. @mkdir -p $(dir $@)
  45. gcc -c $< -o $@ $(cflags) $(dflags)
  46. # Flex lexers for the fxos database
  47. build/fxos/lexer-%.yy.c: fxos/lexer-%.l
  48. flex -o $@ -s $<
  49. build/fxos/lexer-%.yy.c.o: build/fxos/lexer-%.yy.c
  50. gcc -c $< -o $@ $(cflags) -Wno-unused-function $(dflags) -I fxos
  51. #
  52. # Dependency system, misc.
  53. #
  54. include $(wildcard build/*/*.d)
  55. # Dependency on configuration file
  56. Makefile.cfg:
  57. @ if [[ ! -f Makefile.cfg ]]; then \
  58. echo "error: Makefile.cfg is missing, did you ./configure?" >&2; \
  59. false; \
  60. fi
  61. .PHONY: all clean distclean
  62. .PRECIOUS: build/fxos/lexer-%.yy.c
  63. #
  64. # Installing
  65. #
  66. m644 := -m 644
  67. m755 := -m 755
  68. sed := -i -e '/^PREFIX=\\$$/ a \$(PREFIX)'
  69. # Disable -m on Mac OS and use sed differently
  70. ifeq "$(shell uname)" "Darwin"
  71. m644 :=
  72. m755 :=
  73. sed := -i '' -e "$$(printf '/^PREFIX=/ a \\\n$(PREFIX)')"
  74. endif
  75. install: $(bin)
  76. install -d $(PREFIX)/bin
  77. install -d $(PREFIX)/share/fxsdk
  78. install $(bin) $(m755) $(PREFIX)/bin
  79. install fxos/*.txt $(m644) $(PREFIX)/share/fxsdk
  80. install -d $(PREFIX)/share/fxsdk/assets
  81. install fxsdk/assets/* $(m644) $(PREFIX)/share/fxsdk/assets
  82. install fxsdk/fxsdk.sh $(m755) $(PREFIX)/bin/fxsdk
  83. sed $(sed) $(PREFIX)/bin/fxsdk
  84. install fxconv/fxconv-main.py $(m755) $(PREFIX)/bin/fxconv
  85. install fxconv/fxconv.py $(m644) $(PREFIX)/bin
  86. uninstall:
  87. rm -f $(PREFIX)/bin/{fxsdk,fxg1a,fxos,fxconv,fxconv.py}
  88. rm -rf $(PREFIX)/share/fxsdk
  89. #
  90. # Cleaning
  91. #
  92. clean-fxg1a:
  93. @rm -rf build/fxg1a
  94. clean-fxos:
  95. @rm -rf build/fxos
  96. clean:
  97. @rm -rf build
  98. distclean: clean
  99. @rm -rf bin
  100. @rm -f Makefile.cfg