Skip to content

Commit b550901

Browse files
makefile: Add several compiler flags, change optimization to 's'
1 parent 64624f1 commit b550901

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

firmware/Makefile

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ MAIN = main
4444
MCU ?= atmega328p
4545
F_CPU ?= 16000000UL
4646
# Optimization
47-
OPT = 2
47+
OPT = s
4848
# Debug
4949
DEBUG = dwarf-2
5050
# documentation (auto generated)
@@ -100,42 +100,47 @@ $(foreach i,$(SPECIAL_DEFS),$(eval $(call CHECK_ANSWER,$(i))))
100100
# -Wa,...: tell GCC to pass this to the assembler.
101101
# -adhlns...: create assembler listing
102102
# INFO: https://www.nongnu.org/avr-libc/user-manual/using_tools.html
103-
#CFLAGS += $(CDEFS)
104103
CFLAGS += -O$(OPT)
105104
#CFLAGS += -g$(DEBUG)
105+
CGLAGS += -pedantic -Wall -Wextra
106+
CGLAGS += -Wconversion
107+
CGLAGS += -Wshadow
108+
CGLAGS += -Wunsafe-loop-optimizations
109+
CGLAGS += -Waddress
110+
CGLAGS += -Wlogical-op
111+
CGLAGS += -Wstrict-prototypes
112+
CGLAGS += -Wold-style-definition
113+
CGLAGS += -Wmissing-prototypes
114+
CGLAGS += -Wmissing-declarations
115+
CGLAGS += -Wpacked
116+
CGLAGS += -Wundef
117+
CGLAGS += -Wredundant-decls
118+
CGLAGS += -Wnested-externs
119+
CGLAGS += -Wunreachable-code
120+
CGLAGS += -Winline
121+
CGLAGS += -Woverlength-strings
122+
CGLAGS += -Wpointer-sign
123+
CGLAGS += -Wdisabled-optimization
124+
CGLAGS += -Wvariadic-macros
125+
CGLAGS += -fstrict-aliasing
126+
CGLAGS += -Wstrict-overflow=5 -fstrict-overflow
106127
#CFLAGS += -funsigned-char
107128
#CFLAGS += -funsigned-bitfields
108129
#CFLAGS += -fpack-struct
109130
#CFLAGS += -fshort-enums
110-
CFLAGS += -Wall
111-
#CFLAGS += -Wstrict-prototypes
112-
#CFLAGS += -mshort-calls
113-
#CFLAGS += -ffunction-sections
114-
#CFLAGS += -fdata-sections
115-
#CFLAGS += -ffreestanding
116-
#CFLAGS += -mcall-prologues
117-
#CFLAGS += --param inline-call-cost=2
118-
#CFLAGS += -finline-limit=3
119-
#CFLAGS += -fno-inline-small-functions
120-
#CFLAGS += -fno-unit-at-a-time
121-
#CFLAGS += -Wundef
122-
#CFLAGS += -Wunreachable-code
123-
#CFLAGS += -Wsign-compare
124-
#CFLAGS += -Waddr-space-convert
125-
#CFLAGS += -Wmisspelled-isr
126-
#CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
127-
#CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
131+
CFLAGS += -Wformat=2
132+
CFLAGS += -ffunction-sections
133+
CFLAGS += -fdata-sections
128134
CFLAGS += -mmcu=$(MCU)
129135
CFLAGS += -std=gnu99
130136
CFLAGS += -DF_CPU=$(F_CPU)
131-
#CFLAGS += -finput-charset=utf-8 -fexec-charset=iso-8859-15
132137

133138
CFLAGSALT += \
134139
-D__AVR_DEV_LIB_NAME__=m328pb
135140

136141
LDFLAGS = -Wl,-Map=$(OBJDIR)/$(TARGET).map,--cref
137142
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
138-
#LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB)
143+
#LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB)
139144
LDFLAGS += $(MATH_LIB)
140145
LDFLAGS += -static -Llib/avr-can-lib/src/ -lcan
141146
#LDFLAGS += -static -Llib/DISPLAYS/SSD1306_AVR/ -lssd1306
@@ -157,7 +162,7 @@ HEX_EEPROM_FLAGS = \
157162
all: directories $(TARGET).elf size
158163

159164
# directories
160-
directories:
165+
directories:
161166
$(SILENT) $(MKDIR_P) $(BINDIR) $(OBJDIR) $(DOCDIR) $(LIBDIR) $(SRCDIR)
162167

163168
# size
@@ -187,7 +192,7 @@ MKDIR_P := mkdir -p
187192
@echo "hex..:"
188193
@echo ""
189194
$(SILENT) $(OBJCPY) -O ihex $(HEX_FLASH_FLAGS)
190-
195+
191196
## Compile
192197
$(OBJDIR)/%.o: $(SRCDIR)/%.c
193198
@echo "[$(TARGET)] Compiling:" $@...

0 commit comments

Comments
 (0)