Restructure libs source to support multi platform
[fw/stlink] / example / libs_stm / build / Makefile
diff --git a/example/libs_stm/build/Makefile b/example/libs_stm/build/Makefile
new file mode 100644 (file)
index 0000000..d96e48c
--- /dev/null
@@ -0,0 +1,37 @@
+LIB = libstm32l_discovery.a
+
+CC = arm-none-eabi-gcc
+AR = arm-none-eabi-ar
+RANLIB = arm-none-eabi-ranlib
+
+PLATFORM=stm32l1xx
+
+INC_CORE_SUPPORT=../inc/core_support
+SRC_CORE_SUPPORT=../inc/core_support
+INC_DEVICE_SUPPORT=../inc/device_support
+INC_PLATFORM=../inc/$(PLATFORM)
+SRC_PLATFORM=../src/$(PLATFORM)
+
+CFLAGS = -Wall -O2 -mlittle-endian -mthumb
+CFLAGS += -mcpu=cortex-m3 -ffreestanding -nostdlib -nostdinc
+CFLAGS += -I$(INC_PLATFORM) -I$(INC_DEVICE_SUPPORT) -I$(INC_CORE_SUPPORT) -I../inc/base
+
+SRCS=$(wildcard $(SRC_PLATFORM)/*.c)
+SRCS+=$(SRC_CORE_SUPPORT)/core_cm3.c
+
+OBJS = $(SRCS:.c=.o)
+
+all: $(LIB)
+
+$(LIB): $(OBJS)
+       $(AR) -r $(LIB) $(OBJS)
+       $(RANLIB) $(LIB)
+
+%.o : %.c
+       $(CC) $(CFLAGS) -c -o $@ $^
+
+clean:
+       -rm -f $(OBJS)
+       -rm -f $(LIB)
+
+.PHONY: all clean