Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.11 KB | None | 0 0
  1. # Copyright (c) 2012, Mauro Scomparin
  2. # All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions are met:
  6. # * Redistributions of source code must retain the above copyright
  7. # notice, this list of conditions and the following disclaimer.
  8. # * Redistributions in binary form must reproduce the above copyright
  9. # notice, this list of conditions and the following disclaimer in the
  10. # documentation and/or other materials provided with the distribution.
  11. # * Neither the name of Mauro Scomparin nor the
  12. # names of its contributors may be used to endorse or promote products
  13. # derived from this software without specific prior written permission.
  14. #
  15. # THIS SOFTWARE IS PROVIDED BY Mauro Scomparin ``AS IS'' AND ANY
  16. # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. # DISCLAIMED. IN NO EVENT SHALL Mauro Scomparin BE LIABLE FOR ANY
  19. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. #
  26. # File: Makefile.
  27. # Author: Mauro Scomparin <http://scompoprojects.worpress.com>.
  28. # Version: 1.0.0.
  29. # Description: Sample makefile.
  30.  
  31. #==============================================================================
  32. # Cross compiling toolchain / tools specifications
  33. #==============================================================================
  34.  
  35. # Prefix for the arm-eabi-none toolchain.
  36. # I'm using codesourcery g++ lite compilers available here:
  37. # http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/
  38. PREFIX_ARM = arm-none-eabi
  39.  
  40. # Microcontroller properties.
  41. PART=LM4F120H5QR
  42. CPU=-mcpu=cortex-m4
  43. FPU=-mfpu=fpv4-sp-d16 -mfloat-abi=softfp
  44.  
  45. # Stellarisware path
  46. STELLARISWARE_PATH=../stellarisware/
  47.  
  48. # Program name definition for ARM GNU C compiler.
  49. CC = ${PREFIX_ARM}-gcc
  50. # Program name definition for ARM GNU Linker.
  51. LD = ${PREFIX_ARM}-ld
  52. # Program name definition for ARM GNU Object copy.
  53. CP = ${PREFIX_ARM}-objcopy
  54. # Program name definition for ARM GNU Object dump.
  55. OD = ${PREFIX_ARM}-objdump
  56.  
  57. # Option arguments for C compiler.
  58. CFLAGS=-mthumb ${CPU} ${FPU} -O0 -ffunction-sections -fdata-sections -MD -std=c99 -Wall -pedantic -c -g
  59. # Library stuff passed as flags!
  60. CFLAGS+= -I ${STELLARISWARE_PATH} -DPART_$(PART) -c -DTARGET_IS_BLIZZARD_RA1
  61.  
  62. # Flags for LD
  63. LFLAGS = --gc-sections -specs=nano.specs -u _printf_float -u _scanf_float
  64.  
  65. # Flags for objcopy
  66. CPFLAGS = -Obinary
  67.  
  68. # flags for objectdump
  69. ODFLAGS = -S
  70.  
  71. # I want to save the path to libgcc, libc.a and libm.a for linking.
  72. # I can get them from the gcc frontend, using some options.
  73. # See gcc documentation
  74. LIB_GCC_PATH=${shell ${CC} ${CFLAGS} -print-libgcc-file-name}
  75. LIBC_PATH=${shell ${CC} ${CFLAGS} -print-file-name=libc.a}
  76. LIBM_PATH=${shell ${CC} ${CFLAGS} -print-file-name=libm.a}
  77.  
  78. # Uploader tool path.
  79. # Set a relative or absolute path to the upload tool program.
  80. # I used this project: https://github.com/utzig/lm4tools
  81. FLASHER=~/stellaris/lm4tools/lm4flash/lm4flash
  82. # Flags for the uploader program.
  83. FLASHER_FLAGS=
  84.  
  85. #==============================================================================
  86. # Project properties
  87. #==============================================================================
  88.  
  89. # Project name (W/O .c extension eg. "main")
  90. PROJECT_NAME = main
  91. # Startup file name (W/O .c extension eg. "LM4F_startup")
  92. STARTUP_FILE = LM4F_startup
  93. # Linker file name
  94. LINKER_FILE = LM4F.ld
  95.  
  96. SRC = $(wildcard *.c)
  97. OBJS = $(SRC:.c=.o)
  98.  
  99. #==============================================================================
  100. # Rules to make the target
  101. #==============================================================================
  102.  
  103. #make all rule
  104. all: $(OBJS) ${PROJECT_NAME}.axf ${PROJECT_NAME}
  105.  
  106. %.o: %.c
  107. @echo
  108. @echo Compiling $<...
  109. $(CC) -c $(CFLAGS) ${<} -o ${@}
  110.  
  111. ${PROJECT_NAME}.axf: $(OBJS)
  112. @echo
  113. @echo Making driverlib
  114. $(MAKE) -C ${STELLARISWARE_PATH}driverlib/
  115. @echo
  116. @echo Linking...
  117. $(LD) -T $(LINKER_FILE) $(LFLAGS) -o ${PROJECT_NAME}.axf $(OBJS) ${STELLARISWARE_PATH}driverlib/gcc-cm4f/libdriver-cm4f.a $(LIBM_PATH) $(LIBC_PATH) $(LIB_GCC_PATH)
  118.  
  119. ${PROJECT_NAME}: ${PROJECT_NAME}.axf
  120. @echo
  121. @echo Copying...
  122. $(CP) $(CPFLAGS) ${PROJECT_NAME}.axf ${PROJECT_NAME}.bin
  123. @echo
  124. @echo Creating list file...
  125. $(OD) $(ODFLAGS) ${PROJECT_NAME}.axf > ${PROJECT_NAME}.lst
  126.  
  127. # make clean rule
  128. clean:
  129. rm -f *.bin *.o *.d *.axf *.lst
  130.  
  131. # Rule to load the project to the board
  132. # I added a sudo because it's needed without a rule.
  133. load:
  134. sudo ${FLASHER} ${PROJECT_NAME}.bin ${FLASHER_FLAGS}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement