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.

117 lines
2.4KB

  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,$(TARGETS))
  18. TARGETS := $(TARGETS:fxsdk=fxsdk.sh)
  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 := '/^PREFIX=\\$$/ a \$(PREFIX)'
  28. ifeq "$(shell uname)" "Darwin"
  29. sed := "$$(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. # Explicit targets
  36. bin/fxsdk.sh: fxsdk/fxsdk.sh | bin/
  37. sed -e $(sed) $< > $@
  38. bin/fxg1a: $(obj-fxg1a) | bin/
  39. gcc $^ -o $@ $(lflags)
  40. bin/:
  41. mkdir -p $@
  42. #
  43. # Source rules
  44. #
  45. build/%.c.o: %.c
  46. @mkdir -p $(dir $@)
  47. gcc -c $< -o $@ $(cflags) $(dflags)
  48. #
  49. # Dependency system, misc.
  50. #
  51. include $(wildcard build/*/*.d)
  52. # Dependency on configuration file
  53. Makefile.cfg:
  54. @ if [[ ! -f Makefile.cfg ]]; then \
  55. echo "error: Makefile.cfg is missing, did you ./configure?" >&2; \
  56. false; \
  57. fi
  58. .PHONY: all clean distclean
  59. #
  60. # Installing
  61. #
  62. m644 := -m 644
  63. m755 := -m 755
  64. # Disable -m on Mac OS
  65. ifeq "$(shell uname)" "Darwin"
  66. m644 :=
  67. m755 :=
  68. endif
  69. install: $(bin)
  70. install -d $(PREFIX)/bin
  71. install -d $(PREFIX)/share/fxsdk
  72. install $(bin:bin/fxsdk.sh=) $(m755) $(PREFIX)/bin
  73. install -d $(PREFIX)/share/fxsdk/assets
  74. install fxsdk/assets/* $(m644) $(PREFIX)/share/fxsdk/assets
  75. install bin/fxsdk.sh $(m755) $(PREFIX)/bin/fxsdk
  76. install fxconv/fxconv-main.py $(m755) $(PREFIX)/bin/fxconv
  77. install fxconv/fxconv.py $(m644) $(PREFIX)/bin
  78. uninstall:
  79. rm -f $(PREFIX)/bin/{fxsdk,fxg1a,fxconv,fxconv.py}
  80. rm -rf $(PREFIX)/share/fxsdk
  81. #
  82. # Cleaning
  83. #
  84. clean-fxg1a:
  85. @rm -rf build/fxg1a
  86. clean:
  87. @rm -rf build
  88. distclean: clean
  89. @rm -rf bin
  90. @rm -f Makefile.cfg