title: Makefile for nrf51sdk
body: <p>I am working on programming a nrf51822 evaluation board(<a href="https://www.nordicsemi.com/eng/Products/Bluetooth-R-low-energy/nRF51822-Evaluation-Kit" rel="nofollow">This one</a>). I have been looking at <a href="http://www.funwithelectronics.com/?id=168" rel="nofollow">this</a> site to program it and have gotten the blinking program to work.</p>
  
  <p>I want to modify the makefile provided on the site previously mentioned, such that when I go along I pretty much only have to add to the list of files to compile. Below is what I have been trying to get to work, but I am not very good with makefiles.</p>
  
  <pre><code>CC            := /opt/arm-2012.09/bin/arm-none-eabi-gcc
  OBJCOPY       := /opt/arm-2012.09/bin/arm-none-eabi-objcopy
  
  NRF51_SDK     := /opt/nrf51sdk
  NRF51_INCLUDE := $(NRF51_SDK)/Nordic/nrf51822/Include
  NRF51_SRC     := $(NRF51_SDK)/Nordic/nrf51822/Source
  
  CPU           := cortex-m0
  BOARD         := BOARD_PCA10001
  
  OBJDIR  = .
  OBJDIR += $(SRC)/templates/
  
  INCLUDEDIRS = $(NRF51_INCLUDE)
  INCLUDEDIRS += $(NRF51_INCLUDE)/gcc
  
  DEFINE  = BOARD_PCA10001
  DEFINE += NRF51
  
  CFLAGS  = -mcpu=$(CPU) 
  CFLAGS +=-mthumb
  CFLAGS += $(patsubst %,-D%, $(DEFINE))
  CFLAGS += $(patsubst %,-I%, $(INCLUDEDIRS))
  CFLAGS += -c
  
  SRC  = main.c
  SRC += $(NRF51_SRC)/templates/system_nrf51.c
  SRC += $(NRF51_SRC)/nrf_delay/nrf_delay.c
  
  ASSEMBLY_SRC += $(NRF51_SRC)/templates/gcc/gcc_startup_nrf51.s
  
  
  all: main.bin main.hex
  
  %.o : %.c 
  @echo "Compiling: " $&lt;
    $(CC) $(CFLAGS) $&lt;
  
  %.o : %.s 
    @echo "Compiling: " $&lt;
    $(CC) $(CFLAGS) $&lt;
  
  main.out: $(SRC) $(ASSEMBLY_SRC)
    $(CC) -L"/opt/arm-2012.09/arm-none-eabi/lib/armv6-m" -L"/opt/arm-2012.09/lib/gcc/arm-none-eabi/4.7.2/armv6-m" -Xlinker -Map=main.map -mcpu=$(CPU) -mthumb -mabi=aapcs -T$(NRF51_SDK)/Nordic/nrf51822/Source/templates/gcc/gcc_linker_script_nrf51.ld main.o system_nrf51.o nrf_delay.o gcc_startup_nrf51.o -o main.out
  
  main.bin: main.out
    $(OBJCOPY) -O binary main.out main.bin
  
  main.hex: main.out
    $(OBJCOPY) -O ihex main.out main.hex
  
  install: main.bin
    sed  's#\[\[--filename--\]\]#$(PWD)/main.bin#' segger/burn-template.seg &gt; burn.seg
    ./segger/segger.sh $(PWD)/burn.seg
  
  clean:
    rm *.o *.out *.hex *.seg *.map *.bin *.hex
  </code></pre>
  
  <p>When it runs make it just outputs the following:</p>
  
  <pre><code>/opt/arm-2012.09/bin/arm-none-eabi-gcc -L"/opt/arm-2012.09/arm-none-eabi/lib/armv6-m" -L"/opt/arm-2012.09/lib/gcc/arm-none-eabi/4.7.2/armv6-m" -Xlinker -Map=main.map -mcpu=cortex-m0 -mthumb -mabi=aapcs -T/opt/nrf51sdk/Nordic/nrf51822/Source/templates/gcc/gcc_linker_script_nrf51.ld main.o system_nrf51.o nrf_delay.o gcc_startup_nrf51.o -o main.out
  arm-none-eabi-gcc: error: main.o: No such file or directory
  arm-none-eabi-gcc: error: system_nrf51.o: No such file or directory 
  arm-none-eabi-gcc: error: nrf_delay.o: No such file or directory
  arm-none-eabi-gcc: error: gcc_startup_nrf51.o: No such file or directory
  make: *** [main.out] Error 1
  </code></pre>
  
  <p>Is there anyone around here that can help me with this?</p>