Actions

EmSys

Makefile Template

From EdWiki

Revision as of 04:47, 7 March 2012 by Jshankar (Talk | contribs) (1 revision: Importing from edes32)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
  1. #########################################################################
  2. #									#
  3. #           Template Makefile for Assembly Language Programs            #
  4. #									#
  5. #########################################################################
  6. #
  7. #
  8. # This file is meant to be used as a template (in other words, a starting
  9. # point) for any Makefile that you write.  Modify it to suit your needs,
  10. # making sure that the file is called "Makefile"; in most cases, all you
  11. # need to do is replace every occurrence of "template" with the name of
  12. # your file.
  13. #
  14. # Every Makefile should have the targets "all" and "clean", at a minimum.
  15. # See chapter 14 of the GNU Make Reference for other suggestions on how
  16. # Makefiles should be written.
  17. #
  18. # Please note that every line that is indented (or, in the language of
  19. # Makefiles, the command part of the rules) is done so with TAB
  20. # characters, NOT with spaces.  This is important and a subtle trap for
  21. # the unwary!
  22.  
  23.  
  24. all:		template.elf
  25.  
  26. template.elf:	template.o
  27. template.o:	template.s
  28.  
  29. clean:
  30. 	-rm -f template.elf template.o
  31.  
  32.  
  33. # The following variables and implicit rules are required for the GNU
  34. # Assembler for ARM.  You probably do not need to modify anything here.
  35.  
  36. AS        = arm-none-eabi-as
  37. LD        = arm-none-eabi-ld
  38.  
  39. ASFLAGS   = --gdwarf2
  40. LDFLAGS   =
  41. LOADLIBES =
  42. LDLIBS    =
  43.  
  44. # Assemble ARM assembly language source (.s) to an object file (.o)
  45.  
  46. %.o: %.s
  47. 	$(AS) -marm7tdmi $(ASFLAGS) $< -o $@
  48.  
  49. # Link files into an ARM executable (.elf), using the GNU Linker.
  50.  
  51. %.elf:
  52. 	$(LD) $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@
  53.  
  54.  
  55. # Miscellaneous rules
  56.  
  57. .PHONY:	all clean
  58. .DEFAULT:
  59. .SUFFIXES:

Reference

GNU Make Reference