]> git.sommitrealweird.co.uk Git - barbilliards.git/blob - src/Makefile
Fixes to usb stack so that it works
[barbilliards.git] / src / Makefile
1 ifneq ($(V), 1)
2 MAKEFLAGS += --no-print-dir
3 Q := @
4 endif
5
6 OPT_FLAGS ?= -Os
7
8 CFLAGS += -Wall -Wextra -Werror -Wno-char-subscripts\
9         $(OPT_FLAGS) -std=gnu99 -g3 -MD \
10         -I.
11 LDFLAGS += $(OPT_FLAGS)
12
13 SRC =                   \
14         timer.c         \
15         usb_cdcacm.c    \
16
17 CROSS_COMPILE ?= arm-none-eabi-
18 CC = $(CROSS_COMPILE)gcc
19 OBJCOPY = $(CROSS_COMPILE)objcopy
20
21 OPT_FLAGS = -Os
22 CFLAGS += -mcpu=cortex-m3 -mthumb \
23         -DSTM32F1 -DDISCOVERY_STLINK \
24         -I../libopencm3/include \
25         -I .
26 LDFLAGS_BOOT := $(LDFLAGS) --specs=nano.specs \
27         -lopencm3_stm32f1 -Wl,--defsym,_stack=0x20005000 \
28         -Wl,-T,bluepill.ld -nostartfiles -lc \
29         -Wl,-Map=mapfile -mthumb -mcpu=cortex-m3 -Wl,-gc-sections \
30         -L../libopencm3/lib
31 LDFLAGS = $(LDFLAGS_BOOT)
32
33 LDFLAGS += --specs=nosys.specs
34
35 all:    timer.bin
36
37 host_clean:
38         -$(Q)$(RM) timer.bin
39
40 OBJ = $(SRC:.c=.o)
41
42 timer.elf: $(OBJ)
43         @echo "  LD      $@"
44         $(Q)$(CC) -o $@ $(OBJ) $(LDFLAGS)
45
46 %.o:    %.c
47         @echo "  CC      $<"
48         $(Q)$(CC) $(CFLAGS) -c $< -o $@
49
50 %.bin:  %.elf
51         @echo "  OBJCOPY $@"
52         $(Q)$(OBJCOPY) -O binary $^ $@
53
54 %.hex:  %
55         @echo "  OBJCOPY $@"
56         $(Q)$(OBJCOPY) -O ihex $^ $@
57
58 .PHONY: clean host_clean FORCE
59
60 clean:  host_clean
61         $(Q)echo "  CLEAN"
62         -$(Q)$(RM) -f *.o *.d *~ *.elf *.bin $(HOSTFILES)
63         -$(Q)$(RM) -f mapfile
64