Make target for building static library

This commit is contained in:
Ole Martin Ruud 2021-02-07 06:03:14 +01:00
parent 3f67760fed
commit c80f81c43e
No known key found for this signature in database
GPG Key ID: 88F3B6A5850EFDA2
1 changed files with 11 additions and 1 deletions

View File

@ -10,14 +10,19 @@ HEADERS += include/st7735_font.h fonts/tom_thumb.h fonts/free_sans.h
SRC = main.c spi.c st7735.c st7735_gfx.c st7735_font.c
TARGET = st7735_test
OBJDIR = bin
LIB_TARGET = libst7735
LIB_SRC = spi.c st7735.c st7735_gfx.c st7735_font.c
CC = avr-gcc
AR = ar
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
SRC_TMP = $(subst ../,,$(SRC))
OBJ = $(SRC_TMP:%.c=$(OBJDIR)/$(AVRMCU)/%.o)
LIB_SRC_TMP = $(subst ../,,$(LIB_SRC))
LIB_OBJ = $(LIB_SRC_TMP:%.c=$(OBJDIR)/$(AVRMCU)/%.o)
CFLAGS = -I include -I images -I fonts -Os -Wall -Wstrict-prototypes --std=c99
CFLAGS += -ffunction-sections -fdata-sections
@ -26,7 +31,9 @@ CFLAGS += -mmcu=$(AVRMCU) -DF_CPU=$(F_CPU)UL -DVERSION=$(VERSION)
LDFLAGS = -mmcu=$(AVRMCU) -Wl,--gc-sections
all: start $(OBJDIR)/$(AVRMCU)/$(TARGET).hex size
ARFLAGS = -rc
all: start $(OBJDIR)/$(AVRMCU)/$(TARGET).hex $(OBJDIR)/$(AVRMCU)/$(LIB_TARGET).a size
@echo ":: Done !"
start:
@ -48,6 +55,9 @@ $(OBJDIR)/$(AVRMCU)/%.o : %.c $(HEADERS) Makefile
$(OBJDIR)/$(AVRMCU)/$(TARGET).elf : $(OBJ)
$(CC) $(LDFLAGS) $+ -o $@
$(OBJDIR)/$(AVRMCU)/$(LIB_TARGET).a : $(LIB_OBJ)
$(AR) $(ARFLAGS) $@ $+
$(OBJDIR)/$(AVRMCU)/$(TARGET).hex : $(OBJDIR)/$(AVRMCU)/$(TARGET).elf
$(OBJCOPY) -O ihex $< $@