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.
 
 
 
 

120 lines
2.5 KiB

  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 := $(TARGETS:fxsdk=fxsdk.sh)
  18. TARGETS := $(TARGETS:fxconv=fxconv-main.py)
  19. bin = $(TARGETS:%=bin/%)
  20. # fxconv has no sources files because it's written in Python, and fxsdk has no
  21. # source either because it's written in Bash.
  22. src-fxg1a := $(wildcard fxg1a/*.c)
  23. obj-fxg1a := $(src-fxg1a:%=build/%.o)
  24. # Sed command to copy install path to fxsdk.sh. On Mac OS, BSD sed is used so
  25. # we need to do it a bit differently with a printf helper to insert a literal
  26. # newline into the command.
  27. sed := -E -e '/^PREFIX=.?.?.?\\$$/ a \$(PREFIX)'
  28. ifeq "$(shell uname)" "Darwin"
  29. sed := -e "$$(printf '/^PREFIX=.?.?.?/ a \\\n$(PREFIX)')"
  30. endif
  31. # Symbolic targets
  32. all: $(bin)
  33. all-fxsdk: bin/fxsdk.sh
  34. all-fxg1a: bin/fxg1a
  35. all-fxconv: bin/fxconv-main.py
  36. # Explicit targets
  37. bin/fxsdk.sh: fxsdk/fxsdk.sh | bin/
  38. sed $(sed) $< > $@
  39. bin/fxconv-main.py: fxconv/fxconv-main.py | bin/
  40. sed $(sed) $< > $@
  41. bin/fxg1a: $(obj-fxg1a) | bin/
  42. gcc $^ -o $@ $(lflags)
  43. bin/:
  44. mkdir -p $@
  45. #
  46. # Source rules
  47. #
  48. build/%.c.o: %.c
  49. @mkdir -p $(dir $@)
  50. gcc -c $< -o $@ $(cflags) $(dflags)
  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. #
  63. # Installing
  64. #
  65. m644 := -m 644
  66. m755 := -m 755
  67. # Disable -m on Mac OS
  68. ifeq "$(shell uname)" "Darwin"
  69. m644 :=
  70. m755 :=
  71. endif
  72. install: $(bin)
  73. install -d $(PREFIX)/bin
  74. install -d $(PREFIX)/share/fxsdk
  75. install $(filter bin/fxg1a,$(bin)) $(m755) $(PREFIX)/bin
  76. install -d $(PREFIX)/share/fxsdk/assets
  77. install fxsdk/assets/* $(m644) $(PREFIX)/share/fxsdk/assets
  78. install bin/fxsdk.sh $(m755) $(PREFIX)/bin/fxsdk
  79. install bin/fxconv-main.py $(m755) $(PREFIX)/bin/fxconv
  80. install fxconv/fxconv.py $(m644) $(PREFIX)/bin
  81. uninstall:
  82. rm -f $(PREFIX)/bin/{fxsdk,fxg1a,fxconv,fxconv.py}
  83. rm -rf $(PREFIX)/share/fxsdk
  84. #
  85. # Cleaning
  86. #
  87. clean-fxg1a:
  88. @rm -rf build/fxg1a
  89. clean:
  90. @rm -rf build
  91. distclean: clean
  92. @rm -rf bin
  93. @rm -f Makefile.cfg