handle own libraries
This commit is contained in:
parent
e50c9a1c49
commit
ebd0bc03b2
21
Makefile
21
Makefile
|
@ -21,10 +21,13 @@ Q := @
|
|||
endif
|
||||
|
||||
# the final binary name (without extension)
|
||||
BINARY = main
|
||||
BINARY = firmware
|
||||
|
||||
# source files
|
||||
OBJS += $(BINARY).o
|
||||
LIBS = lib
|
||||
CSRC = $(wildcard *.c)
|
||||
CSRC += $(foreach LIB,$(LIBS),$(wildcard $(LIB)/*.c))
|
||||
OBJ = $(patsubst %.c,%.o,$(CSRC))
|
||||
|
||||
# executables
|
||||
PREFIX ?= arm-none-eabi
|
||||
|
@ -55,11 +58,12 @@ DEFS += -DSTM32F1
|
|||
|
||||
# C flags
|
||||
CFLAGS += -Os -g
|
||||
CFLAGS += -Wall -Wundef -Wextra -Wshadow -Wimplicit-function-declaration
|
||||
CFLAGS += -Wall -Werror -Wundef -Wextra -Wshadow -Wimplicit-function-declaration
|
||||
CFLAGS += -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
|
||||
CFLAGS += -fno-common -ffunction-sections -fdata-sections
|
||||
CFLAGS += -MD
|
||||
CFLAGS += -I$(INCLUDE_DIR) $(DEFS)
|
||||
CFLAGS += -I. -I$(INCLUDE_DIR) $(patsubst %,-I%,$(LIBS))
|
||||
CFLAGS += $(DEFS)
|
||||
|
||||
# linker script
|
||||
LDSCRIPT = stm32f103x8-dfu.ld
|
||||
|
@ -67,6 +71,7 @@ LDSCRIPT = stm32f103x8-dfu.ld
|
|||
# linker flags
|
||||
LDFLAGS += --static -nostartfiles
|
||||
LDFLAGS += -L$(LIB_DIR)
|
||||
LDFLAGS += -I. $(patsubst %,-I%,$(LIBS))
|
||||
LDFLAGS += -T$(LDSCRIPT)
|
||||
LDFLAGS += -Wl,-Map=$(*).map
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
|
@ -123,9 +128,9 @@ list: $(BINARY).list
|
|||
%.map: %.elf
|
||||
@# it's generated along with the elf
|
||||
|
||||
%.elf: $(OBJS) $(LDSCRIPT) $(LIB_DIR)/lib$(LIBNAME).a
|
||||
%.elf: $(OBJ) $(LDSCRIPT) $(LIB_DIR)/lib$(LIBNAME).a
|
||||
$(info compiling $(@))
|
||||
$(Q)$(LD) $(LDFLAGS) $(ARCH_FLAGS) $(OBJS) $(LDLIBS) -o $(@)
|
||||
$(Q)$(LD) $(LDFLAGS) $(ARCH_FLAGS) $(OBJ) $(LDLIBS) -o $(@)
|
||||
|
||||
%.o: %.c
|
||||
@#printf " CC $(*).c\n"
|
||||
|
@ -154,5 +159,5 @@ flash-dfu: $(BINARY).bin
|
|||
$(Q)dfu-util --device 1eaf:0003 --cfg 1 --intf 0 --alt 2 --reset --download $(<)
|
||||
|
||||
.PHONY: clean elf bin hex srec list bootloader flash flash-swd flash-dfu
|
||||
|
||||
-include $(OBJS:.o=.d)
|
||||
.SECONDARY:
|
||||
-include $(OBJ:.o=.d)
|
||||
|
|
Loading…
Reference in New Issue