-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
73 lines (56 loc) · 3.11 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
ORACCRSC := ../../OpenRoberta/ora-cc-rsc/RobotMbed/libs2017
BUILD := build
HEX := hex
MICROBITPATH := $(ORACCRSC)/microbit
MICROBITDALPATH := $(ORACCRSC)/microbit-dal
MBEDCLASSICPATH := $(ORACCRSC)/mbed-classic
BLEPATH := $(ORACCRSC)/ble
BLE_BOOTLOADER_RESERVED_HEX := $(ORACCRSC)/BLE_BOOTLOADER_RESERVED.hex
S110NRF51822_HEX := $(ORACCRSC)/s110_nrf51822_8.0.0_softdevice.hex
NRF51822 := $(ORACCRSC)/NRF51822.ld
CPPLAGS := -fno-exceptions -fno-unwind-tables -ffunction-sections -fdata-sections -Wdeprecated -Wno-unused-variable -Wall -Wextra -fno-rtti -fno-threadsafe-statics -mtune=cortex-m0 -mthumb -D__thumb2__ -std=c++11 -fwrapv -Os -g -gdwarf-3 -DNDEBUG -DTOOLCHAIN_GCC -DTOOLCHAIN_GCC_ARM -DMBED_OPERATORS -DNRF51 -DTARGET_NORDIC -DTARGET_M0 -D__MBED__=1 -DMCU_NORDIC_16K -DTARGET_NRF51_CALLIOPE -DTARGET_MCU_NORDIC_16K -DTARGET_MCU_NRF51_16K_S110 -DTARGET_NRF_LFCLK_RC -DTARGET_MCU_NORDIC_16K -D__CORTEX_M0 -DARM_MATH_CM0 -MMD
LDFLAGS := -fno-exceptions -fno-unwind-tables -Wl,--no-wchar-size-warning -Wl,--gc-sections -Wl,--sort-common -Wl,--sort-section=alignment -Wl,-wrap,main -mcpu=cortex-m0 -mthumb --specs=nano.specs
INCLIB := -I $(MICROBITDALPATH)/inc/drivers \
-I $(MICROBITDALPATH)/inc/core \
-I $(MICROBITDALPATH)/inc/platform \
-I $(MBEDCLASSICPATH)/api \
-I $(MBEDCLASSICPATH)/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/TARGET_NRF51_CALLIOPE \
-I $(MBEDCLASSICPATH)/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822 \
-I $(MBEDCLASSICPATH)/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822 \
-I $(MBEDCLASSICPATH)/targets/cmsis \
-I $(MBEDCLASSICPATH)/hal
INCDEMO := $(INCLIB) \
-I $(MICROBITPATH)/inc \
-I $(BLEPATH) \
-I $(MICROBITDALPATH)/inc/types \
-I $(MICROBITDALPATH)/inc/bluetooth \
-I lib
LDLIBS := -lnosys -lstdc++ -lsupc++ -lm -lc -lgcc -lstdc++ -lsupc++ -lm -lc -lgcc
CALLIOPELIBS := $(ORACCRSC)/microbit.a \
$(ORACCRSC)/ble.a \
$(ORACCRSC)/microbit-dal.a \
$(ORACCRSC)/ble-nrf51822.a \
$(ORACCRSC)/nrf51-sdk.a \
$(ORACCRSC)/mbed-classic.a
DEMOS := CarControl.hex MotorTest.hex SimpleMotorTest.hex
all: directories lib $(DEMOS)
directories:
mkdir -p $(BUILD)
mkdir -p $(HEX)
lib: DcMotor.a
%.hex: %.ihex
srec_cat $(BLE_BOOTLOADER_RESERVED_HEX) -intel $(S110NRF51822_HEX) -intel $(BUILD)/$< -intel -o $(HEX)/$@ -intel --line-length=44
%.ihex: %.a
arm-none-eabi-objcopy -O ihex $(BUILD)/$< $(BUILD)/$@
%.a: %.o DcMotor.a
arm-none-eabi-g++ $(LDFLAGS) -T $(NRF51822) -Wl,-Map,$(BUILD)/MotorTest.map -Wl,--start-group $(foreach i,$^,$(BUILD)/$(i)) $(LDLIBS) $(CALLIOPELIBS) -Wl,-end-group -o $(BUILD)/$@
%.o: src/%.cpp
arm-none-eabi-g++ $(INCDEMO) $(CPPLAGS) -MT $(BUILD)/$@.cpp.o -MF $(BUILD)/$@.cpp.o.d -o $(BUILD)/$@ -c $<
DcMotor.a: DcMotor.o
ar rvs $(BUILD)/$@ $(BUILD)/$^
DcMotor.o: lib/DcMotor.cpp
arm-none-eabi-g++ $(INCLIB) $(CPPLAGS) -MT $(BUILD)/$@.o -MF $(BUILD)/$@.o.d -c -o $(BUILD)/$@ $<
clean:
-rm $(HEX)/* $(BUILD)/*
-rmdir $(HEX)
-rmdir $(BUILD)