Advertisement
Guest User

makefile

a guest
Jun 23rd, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.73 KB | None | 0 0
  1. ###############################################################################
  2. #   makefile
  3. #    by Alex Chadwick
  4. #
  5. #   A makefile script for generation of raspberry pi kernel images.
  6. ###############################################################################
  7.  
  8. # The toolchain to use. arm-none-eabi works, but there does exist
  9. # arm-bcm2708-linux-gnueabi.
  10. ARMGNU ?= arm-none-eabi
  11.  
  12. # The intermediate directory for compiled object files.
  13. BUILD = build/
  14.  
  15. # The directory in which source files are stored.
  16. SOURCE = source/
  17.  
  18. # The name of the output file to generate.
  19. TARGET = kernel.img
  20.  
  21. # The name of the assembler listing file to generate.
  22. LIST = kernel.list
  23.  
  24. # The name of the map file to generate.
  25. MAP = kernel.map
  26.  
  27. # The name of the linker script to use.
  28. LINKER = kernel.ld
  29.  
  30. # The names of all object files that must be generated. Deduced from the
  31. # assembly code files in source.
  32.  
  33. OBJECTS := <my objects here>
  34.  
  35. # Rule to make everything.
  36. all: $(TARGET) $(LIST)
  37.  
  38. # Rule to remake everything. Does not include clean.
  39. rebuild: all
  40.  
  41. # Rule to make the listing file.
  42. $(LIST) : $(BUILD)output.elf
  43.     $(ARMGNU)-objdump -d $(BUILD)output.elf > $(LIST)
  44.  
  45. # Rule to make the image file.
  46. $(TARGET) : $(BUILD)output.elf
  47.     $(ARMGNU)-objcopy $(BUILD)output.elf -O binary $(TARGET)
  48.  
  49. # Rule to make the elf file.
  50. $(BUILD)output.elf : $(OBJECTS) $(LINKER)
  51.     $(ARMGNU)-ld --no-undefined $(OBJECTS) -Map $(MAP) -o $(BUILD)output.elf -T $(LINKER)
  52.  
  53. # Rule to make the object files.
  54. $(BUILD)%.o: $(SOURCE)%.s
  55.     $(ARMGNU)-as -I $(SOURCE) $< -o $@
  56. $(BUILD)%.o: $(SOURCE)%.c
  57.     $(ARMGNU)-gcc -I $(SOURCE) $< -c -o $@
  58.  
  59. $(BUILD):
  60.     mkdir $@
  61.  
  62. # Rule to clean files.
  63. clean :
  64.     -rm -rf $(BUILD)
  65.     -rm -f $(TARGET)
  66.     -rm -f $(LIST)
  67.     -rm -f $(MAP)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement