plugin_c_src.mk 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # C source plugin.
  2. C_SRC_CASES = cpp custom dir env nif port
  3. C_SRC_TARGETS = $(addprefix c-src-,$(C_SRC_CASES))
  4. C_SRC_CLEAN_TARGETS = $(addprefix clean-,$(C_SRC_TARGETS))
  5. .PHONY: c-src $(C_SRC_TARGETS) clean-c-src $(C_SRC_CLEAN_TARGETS)
  6. clean-c-src: $(C_SRC_CLEAN_TARGETS)
  7. clean-c_src: clean-c-src
  8. $(C_SRC_CLEAN_TARGETS):
  9. $t rm -rf $(APP_TO_CLEAN)/
  10. c-src: $(C_SRC_TARGETS)
  11. c_src: c-src
  12. c-src-nif: build clean-c-src-nif
  13. $i "Bootstrap a new OTP library named $(APP)"
  14. $t mkdir $(APP)/
  15. $t cp ../erlang.mk $(APP)/
  16. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  17. $i "Generate a NIF from templates"
  18. $t $(MAKE) -C $(APP) new-nif n=$(APP) $v
  19. $i "Build the application"
  20. $t $(MAKE) -C $(APP) $v
  21. $i "Check that all compiled files exist"
  22. $t test -f $(APP)/$(APP).d
  23. $t test -f $(APP)/c_src/$(APP).o
  24. $t test -f $(APP)/c_src/env.mk
  25. $t test -f $(APP)/ebin/$(APP).app
  26. $t test -f $(APP)/ebin/$(APP).beam
  27. $t test -f $(APP)/priv/$(APP).so
  28. $i "Check that the application was compiled correctly"
  29. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  30. ok = application:start($(APP)), \
  31. {ok, [$(APP)]} = application:get_key($(APP), modules), \
  32. {module, $(APP)} = code:load_file($(APP)), \
  33. {hello, joe} = $(APP):hello(joe), \
  34. {hello, mike} = $(APP):hello(mike), \
  35. {hello, robert} = $(APP):hello(robert), \
  36. halt()"
  37. $i "Re-build the application"
  38. $t $(MAKE) -C $(APP) $v
  39. $i "Check that all compiled files exist"
  40. $t test -f $(APP)/$(APP).d
  41. $t test -f $(APP)/c_src/$(APP).o
  42. $t test -f $(APP)/c_src/env.mk
  43. $t test -f $(APP)/ebin/$(APP).app
  44. $t test -f $(APP)/ebin/$(APP).beam
  45. $t test -f $(APP)/priv/$(APP).so
  46. $i "Check that the application was compiled correctly"
  47. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  48. ok = application:start($(APP)), \
  49. {ok, [$(APP)]} = application:get_key($(APP), modules), \
  50. {module, $(APP)} = code:load_file($(APP)), \
  51. {hello, joe} = $(APP):hello(joe), \
  52. {hello, mike} = $(APP):hello(mike), \
  53. {hello, robert} = $(APP):hello(robert), \
  54. halt()"
  55. $i "Clean the application"
  56. $t $(MAKE) -C $(APP) clean $v
  57. $i "Check that all intermediate files were removed"
  58. $t test ! -e $(APP)/$(APP).d
  59. $t test ! -e $(APP)/c_src/$(APP).o
  60. $t test ! -e $(APP)/ebin/$(APP).app
  61. $t test ! -e $(APP)/ebin/$(APP).beam
  62. $t test ! -e $(APP)/priv/$(APP).so
  63. $i "Distclean the application"
  64. $t $(MAKE) -C $(APP) distclean $v
  65. $i "Check that all files were removed"
  66. $t test ! -e $(APP)/c_src/env.mk