]> git.karo-electronics.de Git - oswald.git/blob - metawatch/Makefile
Some minor improvements.
[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 -DMW_DEBUG_UART
24 APPCONFIG = -DDIGITAL -DMW_DIGITAL_V2
25
26 #BTCC256x_SCRIPT = bluetooth_init_cc2560_2.44.c
27 BTCC256x_SCRIPT = bluetooth_init_cc2564_2.8.c
28
29 # List all the source files here
30 # eg if you have a source file foo.c then list it here
31
32 OSWALD_SRC = ../ui/oswald_main.c ../ui/oswald_screens.c \
33         ../ui/oswald_watch_faces.c \
34         ../ui/oswald_strings.c ../ui/calendar.c \
35         ../ui/oswald_graphics.c ../ui/oswald_fonts.c \
36         ../ui/embedvm.c
37
38 SOURCES = mw_main.c mw_uart.c mw_lcd.c mw_adc.c mw_bt.c \
39         mw_acc.c $(BTCC256x_SCRIPT) \
40         bt_hci.c bt_l2cap.c \
41         oswald_hal.c $(OSWALD_SRC) \
42         F5xx_F6xx_Core_Lib/HAL_PMM.c \
43         F5xx_F6xx_Core_Lib/HAL_UCS.c
44 #       $(BT_SMALLTOOTH_SRC)
45 #       $(BT_STACK_SRC) \
46
47 #BT_STACK_INC = -Ibtstack/ -Ibtstack/include/
48 #BT_SMALLTOOTH_INV = -IBluetooth/
49 # Include are located in the Include directory
50 #INCLUDES = $(BT_STACK_INC)
51 #INCLUDES = $(BT_SMALLTOOTH_INV)
52 INCLUDES = -I../ui/
53
54 # BUILDNO = \"\#$(shell cat .buildno)-$(shell date +%y%m%d)\"
55 BUILDNO = \"$(shell date +%y%m%d)-\#$(shell cat .buildno)\"
56
57 # Add or subtract whatever MSPGCC flags you want. There are plenty more
58 #######################################################################################
59 CFLAGS   = -mmcu=$(MCU) $(MEMMODEL) -g -Os -Wall -Wunused $(INCLUDES) $(APPCONFIG) -DBUILDNO=$(BUILDNO)
60 ASFLAGS  = -mmcu=$(MCU) $(MEMMODEL) -x assembler-with-cpp -Wa,-gstabs
61 LDFLAGS  = -mmcu=$(MCU) $(MEMMODEL) -Wl,-gc-sections -Wl,-Map=$(TARGET).map
62 ########################################################################################
63 CC       = msp430-gcc
64 LD       = msp430-ld
65 AR       = msp430-ar
66 AS       = msp430-gcc
67 GASP     = msp430-gasp
68 NM       = msp430-nm
69 OBJCOPY  = msp430-objcopy
70 RANLIB   = msp430-ranlib
71 STRIP    = msp430-strip
72 SIZE     = msp430-size
73 READELF  = msp430-readelf
74 MAKETXT  = srec_cat
75 CP       = cp -p
76 RM       = rm -f
77 MV       = mv
78 ########################################################################################
79 # the file which will include dependencies
80 DEPEND = $(SOURCES:.c=.d)
81
82 # all the object files
83 OBJECTS = $(SOURCES:.c=.o)
84
85 all: .buildno $(TARGET).elf $(TARGET).hex $(TARGET).txt
86
87 prog: $(TARGET).hex
88         mspdebug tilib -d /dev/ttyACM3 -v 2500 "prog $(TARGET).hex"
89
90 prog_watch: $(TARGET).hex
91         mspdebug rf2500 -v 2500 "prog $(TARGET).hex"
92
93 $(TARGET).elf: $(OBJECTS)
94         echo "Linking $@"
95         $(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@
96         echo
97         echo ">>>> Size of Firmware <<<<"
98         $(SIZE) $(TARGET).elf
99         echo
100
101 %.hex: %.elf
102         $(OBJCOPY) -O ihex $< $@
103
104 %.txt: %.hex
105         $(MAKETXT) -O $@ -TITXT $< -I
106         unix2dos $(TARGET).txt
107 #  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.
108
109 %.o: %.c
110         echo "Compiling $<"
111         $(CC) -c $(CFLAGS) -o $@ $<
112
113 # rule for making assembler source listing, to see the code
114 %.lst: %.c
115         $(CC) -c $(ASFLAGS) -Wa,-anlhd $< > $@
116
117 # include the dependencies unless we're going to clean, then forget about them.
118 ifneq ($(MAKECMDGOALS), clean)
119 -include $(DEPEND)
120 endif
121 # dependencies file
122 # includes also considered, since some of these are our own
123 # (otherwise use -MM instead of -M)
124 %.d: %.c
125         echo "Generating dependencies $@ from $<"
126         $(CC) -M ${CFLAGS} $< >$@
127
128 #.SILENT:
129 .PHONY: clean
130 clean:
131         -$(RM) $(OBJECTS)
132         -$(RM) $(TARGET).*
133         -$(RM) $(SOURCES:.c=.lst)
134         -$(RM) $(DEPEND)
135
136 .buildno: $(OBJECTS)
137         @if ! test -f .buildno; then echo 0 > .buildno; fi
138         @echo $$(($$(cat .buildno) + 1)) > .buildno