]> git.karo-electronics.de Git - oswald.git/blob - metawatch/Makefile
Power saving changes, add new fonts, bitmaps and screens
[oswald.git] / metawatch / Makefile
1 #
2 # Makefile for msp430
3 # adapted from the example Makefile from the mspgcc project
4 #
5 # 'make' builds everything
6 # 'make clean' deletes everything except source files and Makefile
7 # You need to set TARGET, MCU and SOURCES for your project.
8 # TARGET is the name of the executable file to be produced 
9 # $(TARGET).elf $(TARGET).hex and $(TARGET).txt nad $(TARGET).map are all generated.
10 # The TXT file is used for BSL loading, the ELF can be used for JTAG use
11
12 TARGET     = oswald_mw
13 MCU        = msp430f5438a
14 MEMMODEL   = -mmemory-model=huge -fdata-sections -ffunction-sections # -mdata-region=far
15 # -gdwarf-2 -fdata-sections -ffunction-sections
16 #MEMMODEL   = -mmpy=16 -msr20 -md20 -gdwarf-2 -fdata-sections -ffunction-sections
17 # MEMMODEL   = -mmemory-model=medium -misr20
18 #MEMMODEL   = -mmemory-model=medium
19
20 #APPCONFIG = -DDIGITAL -DMW_DEVBOARD_V2
21 #APPCONFIG = -DDIGITAL -DMW_DEVBOARD_V2 -DWITH_BTSTACK
22 #APPCONFIG = -DDIGITAL -DMW_DEVBOARD_V2 -DCC256x_TRANSP
23 APPCONFIG = -DDIGITAL -DMW_DIGITAL_V2
24
25 #BTCC256x_SCRIPT = bluetooth_init_cc2560_2.44.c
26 BTCC256x_SCRIPT = bluetooth_init_cc2564_2.8.c
27
28 # List all the source files here
29 # eg if you have a source file foo.c then list it here
30
31 OSWALD_SRC = ../ui/oswald_main.c ../ui/oswald_screens.c \
32         ../ui/oswald_watch_faces.c \
33         ../ui/oswald_strings.c ../ui/calendar.c \
34         ../ui/oswald_graphics.c ../ui/oswald_fonts.c \
35         ../ui/embedvm.c
36
37 SOURCES = mw_main.c mw_uart.c mw_lcd.c mw_adc.c mw_bt.c \
38         mw_acc.c $(BTCC256x_SCRIPT) \
39         bt_hci.c bt_l2cap.c \
40         oswald_hal.c $(OSWALD_SRC) \
41         F5xx_F6xx_Core_Lib/HAL_PMM.c \
42         F5xx_F6xx_Core_Lib/HAL_UCS.c
43 #       $(BT_SMALLTOOTH_SRC)
44 #       $(BT_STACK_SRC) \
45
46 #BT_STACK_INC = -Ibtstack/ -Ibtstack/include/
47 #BT_SMALLTOOTH_INV = -IBluetooth/
48 # Include are located in the Include directory
49 #INCLUDES = $(BT_STACK_INC)
50 #INCLUDES = $(BT_SMALLTOOTH_INV)
51 INCLUDES = -I../ui/
52
53 # BUILDNO = \"\#$(shell cat .buildno)-$(shell date +%y%m%d)\"
54 BUILDNO = \"$(shell date +%y%m%d)-\#$(shell cat .buildno)\"
55
56 # Add or subtract whatever MSPGCC flags you want. There are plenty more
57 #######################################################################################
58 CFLAGS   = -mmcu=$(MCU) $(MEMMODEL) -g -Os -Wall -Wunused $(INCLUDES) $(APPCONFIG) -DBUILDNO=$(BUILDNO)
59 ASFLAGS  = -mmcu=$(MCU) $(MEMMODEL) -x assembler-with-cpp -Wa,-gstabs
60 LDFLAGS  = -mmcu=$(MCU) $(MEMMODEL) -Wl,-gc-sections -Wl,-Map=$(TARGET).map
61 ########################################################################################
62 CC       = msp430-gcc
63 LD       = msp430-ld
64 AR       = msp430-ar
65 AS       = msp430-gcc
66 GASP     = msp430-gasp
67 NM       = msp430-nm
68 OBJCOPY  = msp430-objcopy
69 RANLIB   = msp430-ranlib
70 STRIP    = msp430-strip
71 SIZE     = msp430-size
72 READELF  = msp430-readelf
73 MAKETXT  = srec_cat
74 CP       = cp -p
75 RM       = rm -f
76 MV       = mv
77 ########################################################################################
78 # the file which will include dependencies
79 DEPEND = $(SOURCES:.c=.d)
80
81 # all the object files
82 OBJECTS = $(SOURCES:.c=.o)
83
84 all: .buildno $(TARGET).elf $(TARGET).hex $(TARGET).txt
85
86 prog: $(TARGET).hex
87         mspdebug tilib -d /dev/ttyACM3 -v 2500 "prog $(TARGET).hex"
88
89 prog_watch: $(TARGET).hex
90         mspdebug rf2500 -v 2500 "prog $(TARGET).hex"
91
92 $(TARGET).elf: $(OBJECTS)
93         echo "Linking $@"
94         $(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
95         echo
96         echo ">>>> Size of Firmware <<<<"
97         $(SIZE) $(TARGET).elf
98         echo
99
100 %.hex: %.elf
101         $(OBJCOPY) -O ihex $< $@
102
103 %.txt: %.hex
104         $(MAKETXT) -O $@ -TITXT $< -I
105         unix2dos $(TARGET).txt
106 #  The above line is required for the DOS based TI BSL tool to be able to read the txt file generated from linux/unix systems.
107
108 %.o: %.c
109         echo "Compiling $<"
110         $(CC) -c $(CFLAGS) -o $@ $<
111
112 # rule for making assembler source listing, to see the code
113 %.lst: %.c
114         $(CC) -c $(ASFLAGS) -Wa,-anlhd $< > $@
115
116 # include the dependencies unless we're going to clean, then forget about them.
117 ifneq ($(MAKECMDGOALS), clean)
118 -include $(DEPEND)
119 endif
120 # dependencies file
121 # includes also considered, since some of these are our own
122 # (otherwise use -MM instead of -M)
123 %.d: %.c
124         echo "Generating dependencies $@ from $<"
125         $(CC) -M ${CFLAGS} $< >$@
126
127 #.SILENT:
128 .PHONY: clean
129 clean:
130         -$(RM) $(OBJECTS)
131         -$(RM) $(TARGET).*
132         -$(RM) $(SOURCES:.c=.lst)
133         -$(RM) $(DEPEND)
134
135 .buildno: $(OBJECTS)
136         @if ! test -f .buildno; then echo 0 > .buildno; fi
137         @echo $$(($$(cat .buildno) + 1)) > .buildno