ArduinoAm29F010

Makefile

4:47737a873a56
2015-01-19 Paul Boddie Renamed the source file to reflect the actual IC in use.
     1 TARGET = $(notdir $(CURDIR))     2 INSTALL_DIR = ../arduino-1.0.5     3 PORT = /dev/ttyUSB0     4 UPLOAD_RATE = 57600 # 19200     5 AVRDUDE_PROGRAMMER = stk500v1     6 MCU = atmega328p # atmega168     7 F_CPU = 16000000     8      9 EXTRA_SRC =    10 EXTRA_CXXSRC =    11 EXTRA_CINCS =    12 EXTRA_CXXINCS =    13     14     15 ### Internal definitions.    16     17     18 ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino    19 VARIANT = $(INSTALL_DIR)/hardware/arduino/variants/standard    20 SRC = $(ARDUINO)/wiring.c \    21 	$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \    22 	$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_shift.c \    23 	$(ARDUINO)/WInterrupts.c $(EXTRA_SRC)    24 CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp \    25 	$(ARDUINO)/Print.cpp $(ARDUINO)/WString.cpp \    26 	$(ARDUINO)/Stream.cpp $(EXTRA_CXXSRC)    27 FORMAT = ihex    28     29 # Name of this Makefile (used for "make depend").    30 MAKEFILE = Makefile    31     32 # Debugging format.    33 # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.    34 # AVR (extended) COFF requires stabs, plus an avr-objcopy run.    35 DEBUG = stabs    36     37 # Place -D or -U options here    38 CDEFS = -DF_CPU=$(F_CPU)    39 CXXDEFS = -DF_CPU=$(F_CPU)    40     41 # Place -I options here    42 CINCS = -I$(ARDUINO) -I$(VARIANT) $(EXTRA_CINCS)    43 CXXINCS = -I$(ARDUINO) -I$(VARIANT) $(EXTRA_CXXINCS)    44     45 # Compiler flag to set the C Standard level.    46 # c89   - "ANSI" C    47 # gnu89 - c89 plus GCC extensions    48 # c99   - ISO C99 standard (not yet fully implemented)    49 # gnu99 - c99 plus GCC extensions    50 CSTANDARD = -std=gnu99    51 CDEBUG = -g$(DEBUG)    52 CWARN = -Wall -Wstrict-prototypes    53     54 OPT = s    55     56 CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)    57 CXXFLAGS = $(CXXDEFS) $(CXXINCS) -O$(OPT)    58 LDFLAGS = -lm    59     60 # Combine all necessary flags and optional flags.    61 # Add target processor to flags.    62 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)    63 ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)    64     65 # Programming support using avrdude. Settings and variables.    66 AVRDUDE_PORT = $(PORT)    67 AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex    68 AVRDUDE_FLAGS = -V -F -C /etc/avrdude.conf \    69 	-p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \    70 	-b $(UPLOAD_RATE)    71     72 # Program settings    73 CC = avr-gcc    74 CXX = avr-g++    75 LD = avr-ld    76 OBJCOPY = avr-objcopy    77 OBJDUMP = avr-objdump    78 AR  = avr-ar    79 SIZE = avr-size    80 NM = avr-nm    81 AVRDUDE = avrdude    82 REMOVE = rm -f    83 MV = mv -f    84     85 # Define all object files.    86 OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o)    87     88 # Default target.    89 all: applet_files build sizeafter    90     91 build: elf hex    92     93 applet_files: $(TARGET).cpp    94 	test -d applet || mkdir applet    95 	cat $(ARDUINO)/main.cpp > applet/$(TARGET).cpp    96 	cat $(TARGET).cpp >> applet/$(TARGET).cpp    97     98 elf: applet/$(TARGET).elf    99 hex: applet/$(TARGET).hex   100    101 # Program the device.   102 upload: applet/$(TARGET).hex   103 	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)   104    105 # Display size of file.   106 HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex   107 ELFSIZE = $(SIZE) applet/$(TARGET).elf   108    109 sizebefore:   110 	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi   111    112 sizeafter:   113 	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi   114    115    116 ### File-specific processing.   117    118    119 .SUFFIXES: .elf .hex .eep .lss .sym   120    121 .elf.hex:   122 	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@   123    124 applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a   125 	$(CXX) $(ALL_CXXFLAGS) -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)   126    127 applet/core.a: $(OBJ)   128 	@for i in $(OBJ); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done   129    130 # Compile: create object files from C++ source files.   131 .cpp.o:   132 	$(CXX) -c $(ALL_CXXFLAGS) $< -o $@   133    134 # Compile: create object files from C source files.   135 .c.o:   136 	$(CC) -c $(ALL_CFLAGS) $< -o $@   137    138 # Target: clean project.   139 clean:   140 	$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).elf applet/$(TARGET).cpp \   141 	applet/$(TARGET).map applet/core.a $(OBJ)   142    143 .PHONY: all build elf hex eep lss sym program coff extcoff clean applet_files sizebefore sizeafter