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