Restructure libs source to support multi platform
[fw/stlink] / example / libs_stm / build / Makefile
1 LIB = libstm32l_discovery.a
2
3 CC = arm-none-eabi-gcc
4 AR = arm-none-eabi-ar
5 RANLIB = arm-none-eabi-ranlib
6
7 PLATFORM=stm32l1xx
8
9 INC_CORE_SUPPORT=../inc/core_support
10 SRC_CORE_SUPPORT=../inc/core_support
11 INC_DEVICE_SUPPORT=../inc/device_support
12 INC_PLATFORM=../inc/$(PLATFORM)
13 SRC_PLATFORM=../src/$(PLATFORM)
14
15 CFLAGS = -Wall -O2 -mlittle-endian -mthumb
16 CFLAGS += -mcpu=cortex-m3 -ffreestanding -nostdlib -nostdinc
17 CFLAGS += -I$(INC_PLATFORM) -I$(INC_DEVICE_SUPPORT) -I$(INC_CORE_SUPPORT) -I../inc/base
18
19 SRCS=$(wildcard $(SRC_PLATFORM)/*.c)
20 SRCS+=$(SRC_CORE_SUPPORT)/core_cm3.c
21
22 OBJS = $(SRCS:.c=.o)
23
24 all: $(LIB)
25
26 $(LIB): $(OBJS)
27         $(AR) -r $(LIB) $(OBJS)
28         $(RANLIB) $(LIB)
29
30 %.o : %.c
31         $(CC) $(CFLAGS) -c -o $@ $^
32
33 clean:
34         -rm -f $(OBJS)
35         -rm -f $(LIB)
36
37 .PHONY: all clean