Clean up Makefile
This commit is contained in:
parent
ea087e182d
commit
2047a07c0a
@ -13,7 +13,6 @@ TARGET = main
|
||||
SRC = $(wildcard $(SRC_DIR)/*.c)
|
||||
OBJ = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
||||
LST = $(SRC:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.lst)
|
||||
OPT = s
|
||||
|
||||
# Name of this Makefile (used for "make depend").
|
||||
MAKEFILE = Makefile
|
||||
@ -21,7 +20,7 @@ MAKEFILE = Makefile
|
||||
# Debugging format.
|
||||
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
|
||||
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
|
||||
DEBUG = stabs
|
||||
DEBUG_FORMAT = stabs
|
||||
|
||||
# Compiler flag to set the C Standard level.
|
||||
# c89 - "ANSI" C
|
||||
@ -36,15 +35,14 @@ CDEFS = -DF_CPU=16000000L -D__AVR__ -D__AVR_ATmega328P__
|
||||
# Place -I options here
|
||||
CINCS = -I $(INC_DIR)
|
||||
|
||||
CDEBUG = -g$(DEBUG)
|
||||
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
||||
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
|
||||
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CSTANDARD) $(CEXTRA)
|
||||
CFLAGS = $(CDEFS) $(CINCS) $(CSTANDARD) $(CEXTRA)
|
||||
|
||||
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
||||
|
||||
ifeq ($(BUILD),debug)
|
||||
CFLAGS += -DDEBUG
|
||||
CFLAGS += -DDEBUG -g$(DEBUG_FORMAT)
|
||||
CFLAGS += -Wall -Wextra -Wformat=2 -Wswitch-default \
|
||||
-Wcast-align -Wpointer-arith -Wbad-function-cast \
|
||||
-Wstrict-prototypes -Winline -Wundef -Wnested-externs \
|
||||
@ -55,8 +53,11 @@ ifeq ($(BUILD),debug)
|
||||
-Wno-unused-but-set-variable -Wmaybe-uninitialized
|
||||
CINCS += -I/usr/include/simavr
|
||||
#
|
||||
else
|
||||
CFLAGS += -DNDEBUG -s -Os
|
||||
endif
|
||||
|
||||
|
||||
#Additional libraries.
|
||||
|
||||
# Minimalistic printf version
|
||||
@ -90,7 +91,7 @@ MATH_LIB = -lm
|
||||
EXTMEMOPTS =
|
||||
|
||||
#LDMAP = $(LDFLAGS) -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
|
||||
# LDFLAGS = $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
|
||||
|
||||
# Programming support using avrdude. Settings and variables.
|
||||
|
||||
@ -177,7 +178,7 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
|
||||
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||
|
||||
%.eep: %.elf
|
||||
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||
$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
||||
|
||||
# Create extended listing file from ELF output file.
|
||||
@ -207,15 +208,4 @@ $(OBJ_DIR)/%.o : $(SRC_DIR)/%.c
|
||||
clean:
|
||||
$(REMOVE) $(BUILD_DIR)/* $(OBJ_DIR)/*
|
||||
|
||||
depend:
|
||||
if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
|
||||
then \
|
||||
sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
|
||||
$(MAKEFILE).$$$$ && \
|
||||
$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
|
||||
fi
|
||||
echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
|
||||
>> $(MAKEFILE); \
|
||||
$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) >> $(MAKEFILE)
|
||||
|
||||
.PHONY: all build elf hex eep lss sym program coff extcoff clean depend
|
||||
|
Loading…
Reference in New Issue
Block a user