Advertisement
tdc218

Makefile and rules.mk for Maple unix command line toolchain

Apr 7th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. Makefile:
  2. #
  3. # tdc218 note: based on https://github.com/mbolivar/example-libmaple-project
  4. # tdc218 note: See discussion on Leaflabs forum starting at
  5. # tdc218 note: http://forums.leaflabs.com/topic.php?id=1008&page=2#post-22974
  6.  
  7. # Root of the project
  8. BASEDIR := $(shell pwd)
  9.  
  10. #
  11. # tdc218 note: LIB_MAPLE_HOME and BOARD should be defined in your shell.
  12. # tdc218 note: If they aren't edit these to the correct values for your setup
  13. #
  14.  
  15. # Libmaple location
  16. LIB_MAPLE_HOME ?= ~/your/custom/path/to/libmaple
  17.  
  18. # Board configuration
  19. BOARD ?= maple
  20. MEMORY_TARGET ?= flash
  21.  
  22. # Custom modules listed here.
  23. #USER_MODULES := $(BASEDIR)/libfoo
  24.  
  25. # === You don't have to edit anything below this line ==========================
  26.  
  27. # Export them to make it available in libmaple Makefile
  28. export BOARD
  29. export MEMORY_TARGET
  30.  
  31. # Convert fs links and '~' to absolute path
  32. export LIB_MAPLE_HOME := $(shell dirname $(LIB_MAPLE_HOME)/stub)
  33.  
  34. # Root of the project should be listed as a user module too,
  35. # custom user modules path fix
  36. export USER_MODULES := $(BASEDIR) $(USER_MODULES)
  37.  
  38. .DEFAULT_GOAL := sketch
  39.  
  40. # To make it compatible with default project settings of Eclipse CDT.
  41. # If it still reporting "No rule to make target `all'" false error
  42. # while project build, then you may fix it this way:
  43. # 1) go to Project proprties -> C/C++ Build -> Behaviour tab
  44. # 2) change build target name from "all" to "sketch"
  45.  
  46. all: sketch
  47.  
  48. # proxy target
  49. %:
  50. $(MAKE) -f $(LIB_MAPLE_HOME)/Makefile $@
  51.  
  52. rules.mk:
  53. #
  54. # tdc218 note: based on https://github.com/mbolivar/example-libmaple-project
  55. # tdc218 note: See discussion on Leaflabs forum starting at
  56. # tdc218 note: http://forums.leaflabs.com/topic.php?id=1008&page=2#post-22974
  57.  
  58. # Template rules.mk file.
  59.  
  60. # First, include the standard libmaple rules.mk header. Leave this
  61. # line alone.
  62. include $(MAKEDIR)/header.mk
  63.  
  64. ###############################################################################
  65.  
  66. ### Change this middle section for your project.
  67.  
  68. ### Source subdirectories
  69.  
  70. # If any subdirectories contain source files, we have to add them to
  71. # the variable BUILDDIRS, like this. $(BUILD_PATH) is the directory
  72. # where compilation output (like object files) goes. The variable $(d)
  73. # gets expanded to the directory containing this rules.mk file.
  74. # PROJECT_BUILD_DIRS := getter
  75. # PROJECT_BUILD_DIRS += randomizer
  76.  
  77. BUILDDIRS += $(addprefix $(BUILD_PATH)/$(d)/, $(PROJECT_BUILD_DIRS))
  78.  
  79. ### Local flags: these control how the compiler gets called.
  80.  
  81. # Here we set a variable for our project's include directories. Note
  82. # that the project top-level directory (i.e., the one containing this
  83. # rules.mk file) is automatically used for include files, so you don't
  84. # need to add it here.
  85. # PROJECT_INCLUDE_DIRS := include
  86. # PROJECT_INCLUDE_DIRS += libfoo/include
  87.  
  88. # EXTERNAL_INCLUDE_DIRS := /some/external/include/dir/with/absolute/path
  89.  
  90. FLAGS_ABS_INCLUDE := $(addprefix -I$(d)/, $(PROJECT_INCLUDE_DIRS))
  91. FLAGS_ABS_INCLUDE += $(addprefix -I/, $(EXTERNAL_INCLUDE_DIRS))
  92.  
  93. # CFLAGS_$(d) are additional flags you want to give the C compiler.
  94. # WIRISH_INCLUDES and LIBMAPLE_INCLUDES provide the appropriate GCC -I
  95. # switches to let you include libmaple headers. FOO_INCLUDES gives the
  96. # include switches you need for the foolib headers.
  97. CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES)
  98.  
  99. # We'll also want our local include directory
  100. CFLAGS_$(d) += $(FLAGS_ABS_INCLUDE)
  101.  
  102. # CXXFLAGS_$(d) are extra flags passed to the C++ compiler. We'll need
  103. # our include directory, and we'll also add an extra definition as a
  104. # demo (look in getter.cpp for how it's used).
  105. CXXFLAGS_$(d) := -DMY_MAGIC_NUMBER=0x1eaf1ab5 $(FLAGS_ABS_INCLUDE)
  106.  
  107. # ASFLAGS_$(d) are extra flags passed to the assembler. We don't
  108. # have any assembly language files in this example, so we'll just
  109. # leave it empty.
  110. ASFLAGS_$(d) :=
  111.  
  112. ### Local rules
  113.  
  114. # You can add any additional rules you want here. We don't have
  115. # any extra rules to add.
  116.  
  117. ### Source files
  118.  
  119. # cSRCS_$(d) are the C source files we want compiled.
  120. # cSRCS_$(d) := randomizer/randomizer.c
  121.  
  122. # cppSRCS_$(d) are the C++ sources we want compiled. We have our own
  123. # main.cpp, and one additional file.
  124. #
  125. # We can't call our main file main.cpp, or libmaple's build system
  126. # will get confused and try to build it without our CXXFLAGS. So call
  127. # it something else. Annoying! Hopefully LeafLabs will fix it soon.
  128. cppSRCS_$(d) := real-main.cpp
  129.  
  130. # cppSRCS_$(d) += getter/getter.cpp
  131.  
  132. #
  133. # tdc218 note: the following are the files from one of my projects
  134. # tdc218 note: to illustrate how a multiple source rojeect works.
  135. # tdc218 note: change them to match your project.
  136. cppSRCS_$(d) += setup.cpp loop.cpp display.cpp inputs.cpp lightlib.cpp
  137. cppSRCS_$(d) += lights.cpp looptimer.cpp nbserialtxlib.cpp utils.cpp
  138.  
  139.  
  140. # sSRCS_$(d) are the assembly sources. We don't have any.
  141. sSRCS_$(d) :=
  142.  
  143. ###############################################################################
  144.  
  145. # Include the libmaple rules.mk footer. Leave this line alone.
  146. include $(MAKEDIR)/footer.mk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement