Template_makefile = <<-EOS

# This file was automagically generated by mbed.org. For more information,
# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded

PROJECT = TEMP
OBJECTS += ./main.o

GCC_BIN = /usr/local/strobo/gcc-arm-none-eabi-4_9-2014q4/bin/
OBJECTS += \\
/usr/local/strobo/BLE_API/common/UUID.o\\
/usr/local/strobo/BLE_API/common/GapAdvertisingData.o\\
/usr/local/strobo/BLE_API/common/BLEDevice.o\\
/usr/local/strobo/BLE_API/common/GapAdvertisingParams.o\\
/usr/local/strobo/BLE_API/common/GattService.o\\
/usr/local/strobo/BLE_API/services/UARTService.o\\
/usr/local/strobo/BLE_API/services/DFUService.o\\
/usr/local/strobo/nRF51822/nRF51Gap.o\\
/usr/local/strobo/nRF51822/nRF51GattServer.o\\
/usr/local/strobo/nRF51822/nRF51822n.o\\
/usr/local/strobo/nRF51822/btle/btle_advertising.o\\
/usr/local/strobo/nRF51822/btle/btle_gap.o\\
/usr/local/strobo/nRF51822/btle/btle.o\\
/usr/local/strobo/nRF51822/btle/custom/custom_helper.o\\
/usr/local/strobo/nRF51822/nordic/softdevice_handler.o\\
/usr/local/strobo/nRF51822/nordic/app_common/pstorage.o\\
/usr/local/strobo/nRF51822/nordic/app_common/crc16.o\\
/usr/local/strobo/nRF51822/nordic/ble/ble_advdata.o\\
/usr/local/strobo/nRF51822/nordic/ble/ble_advdata_parser.o\\
/usr/local/strobo/nRF51822/nordic/ble/ble_error_log.o\\
/usr/local/strobo/nRF51822/nordic/ble/ble_debug_assert_handler.o\\
/usr/local/strobo/nRF51822/nordic/ble/ble_conn_params.o\\
/usr/local/strobo/nRF51822/nordic/ble/ble_bondmngr.o\\
/usr/local/strobo/nRF51822/nordic/ble/ble_services/ble_srv_common.o\\
/usr/local/strobo/nRF51822/nordic/bootloader_dfu/bootloader_util_arm.o\\
/usr/local/strobo/nRF51822/nordic/bootloader_dfu/dfu_app_handler.o\\
/usr/local/strobo/nRF51822/nordic/app_common/hci_mem_pool.o\\
/usr/local/strobo/nRF51822/nordic/app_common/app_scheduler.o\\
/usr/local/strobo/nRF51822/nordic/app_common/app_gpiote.o\\

SYS_OBJECTS = \\
/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/startup_NRF51822.o\\
/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/cmsis_nvic.o\\
/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/board.o\\
/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/system_nrf51822.o\\
/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/retarget.o

INCLUDE_PATHS =\\
-I.\\
-I/usr/local/strobo/mbed\\
-I/usr/local/strobo/mbed/TARGET_HRM1017\\
-I/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM\\
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC\\
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822\\
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib\\
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nrf-sdk\\
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nrf-sdk/sd_common\\
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nrf-sdk/app_common\\
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_1_0\\
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_1_0/s110_nrf51822_7.1.0_API\\
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_1_0/s110_nrf51822_7.1.0_API/include\\
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/TARGET_HRM1017\\
-I/usr/local/strobo/BLE_API\\
-I/usr/local/strobo/BLE_API/common\\
-I/usr/local/strobo/BLE_API/services\\
-I/usr/local/strobo/BLE_API/public\\
-I/usr/local/strobo/nRF51822\\
-I/usr/local/strobo/nRF51822/btle\\
-I/usr/local/strobo/nRF51822/btle/custom\\
-I/usr/local/strobo/nRF51822/common\\
-I/usr/local/strobo/nRF51822/nordic\\
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk\\
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/s110\\
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/sd_common\\
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/bootloader_dfu\\
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/app_common\\
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/ble\\
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/ble/ble_services\\
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/ble/device_manager\\
-I/usr/local/strobo/nRF51822/nordic/bootloader_dfu\\
-I/usr/local/strobo/nRF51822/nordic/app_common\\
-I/usr/local/strobo/nRF51822/nordic/ble\\
-I/usr/local/strobo/nRF51822/nordic/ble/ble_services\\
-I./iot

LIBRARY_PATHS = -L/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM 
LIBRARIES = -lmbed 
LINKER_SCRIPT = /usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/NRF51822.ld
SOFTDEVICE = /usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_1_0/s110_nrf51822_7.1.0_softdevice.hex

###############################################################################
AS      = $(GCC_BIN)arm-none-eabi-as
CC      = $(GCC_BIN)arm-none-eabi-gcc
CPP     = $(GCC_BIN)arm-none-eabi-g++
LD      = $(GCC_BIN)arm-none-eabi-gcc
OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy
OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump
SIZE 	= $(GCC_BIN)arm-none-eabi-size

CPU = -mcpu=cortex-m0 -mthumb
CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer
CC_FLAGS += -MMD -MP
CC_SYMBOLS = -DTARGET_HRM1017 -DTARGET_M0 -DTARGET_CORTEX_M -DTARGET_NORDIC -DTARGET_MCU_NRF51822 -DTARGET_MCU_NORDIC_16K -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M0 -DARM_MATH_CM0 -DMBED_BUILD_TIMESTAMP=1418113723.35 -D__MBED__=1 -DTARGET_NRF51822 

LD_FLAGS = $(CPU) -Wl,--gc-sections -Wl,--wrap=main --specs=nano.specs -u _printf_float -u _scanf_float
LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref
LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys

ifeq ($(DEBUG), 1)
  CC_FLAGS += -DDEBUG -O0
else
  CC_FLAGS += -DNDEBUG -Os
endif

all: $(PROJECT).bin copy

clean:
	rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) combined.hex

.s.o:
	$(AS) $(CPU) -o $@ $<

.c.o:
	$(CC)  $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99   $(INCLUDE_PATHS) -o $@ $<

.cpp.o:
	$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $<


$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
	$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
	$(SIZE) $@

$(PROJECT).bin: $(PROJECT).elf
	@$(OBJCOPY) -O binary $< $@

$(PROJECT).hex: $(PROJECT).elf
	@$(OBJCOPY) -O ihex $< $@

$(PROJECT).lst: $(PROJECT).elf
	@$(OBJDUMP) -Sdh $< > $@

lst: $(PROJECT).lst

size:
	$(SIZE) $(PROJECT).elf

DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d)
-include $(DEPS)

combined.hex: $(PROJECT).hex
	iot mkhex $(SOFTDEVICE) $(PROJECT).hex

copy: combined.hex
	sudo mount -u -w -o sync /Volumes/MBED
	cp -X combined.hex /Volumes/MBED/


EOS
