From b583481c4fd078ab68e68843e43acc4e69e50f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 9 Nov 2015 12:41:36 +0100 Subject: [PATCH] add assemly compilation capabililty --- arduino_nano/Makefile | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/arduino_nano/Makefile b/arduino_nano/Makefile index f68c63d..e1b7539 100644 --- a/arduino_nano/Makefile +++ b/arduino_nano/Makefile @@ -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)