add assemly compilation capabililty

This commit is contained in:
King Kévin 2015-11-09 12:41:36 +01:00
parent 3cfd7ce7b6
commit b583481c4f
1 changed files with 16 additions and 7 deletions

View File

@ -24,9 +24,12 @@ SIZE = avr-size
# library directories, compiler, and linker flags
LIBS = lib
CFLAGS = -g -Wall -Werror -O3 -std=c99
CFLAGS = -g -Wall -Werror -Os -mcall-prologues -std=c99
CFLAGS += -I. $(patsubst %,-I%,$(LIBS))
CFLAGS += -mmcu=$(DEVICE) -DF_CPU=$(F_CPU)
AFLAGS = -Wall -Werror -x assembler-with-cpp
AFLAGS += -I. $(patsubst %,-I%,$(LIBS))
AFLAGS += -mmcu=$(DEVICE)
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -I. $(patsubst %,-I%,$(LIBS))
LDFLAGS += -mmcu=$(DEVICE)
@ -36,14 +39,16 @@ LDFLAGS += -mmcu=$(DEVICE)
#LDFLAGS += -lm
# source files to compile
SRC = $(wildcard *.c)
SRC += $(foreach LIB,$(LIBS),$(wildcard $(LIB)/*.c))
CSRC = $(wildcard *.c) $(foreach LIB,$(LIBS),$(wildcard $(LIB)/*.c))
ASRC = $(wildcard *.S) $(foreach LIB,$(LIBS),$(wildcard $(LIB)/*.S))
# header files
HEADER = $(SRC:.c=.h)
# object files
OBJ = $(SRC:.c=.o)
# listing files.
LST = $(SRC:.c=.lst)
OBJ = $(patsubst %.c,%.o,$(CSRC)) $(patsubst %.S,%.o,$(ASRC))
# listing files
LST = $(patsubst %.c,%.lst,$(CSRC)) $(patsubst %.S,%.lst,$(ASRC))
$(info $(OBJ))
all: compile flash
$(info EEPROM has to be programmed separately)
@ -84,11 +89,15 @@ lst: $(TARGET).lst
map: $(TARGET).map
# compile source files
%.o: %.c %.h
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
%.o: %.S
$(CC) $(AFLAGS) -c -o $@ $<
# link compiled files
%.elf: $(OBJ)
$(info elf)
$(CC) $(LDFLAGS) -o $@ $^
$(TARGET).map: $(OBJ)