to github
[svn42.git] / rf433ctl / Makefile
index 2b06faf..617684b 100755 (executable)
@@ -7,18 +7,24 @@ PORT = /dev/ttyUSB0
 UPLOAD_RATE = 57600
 AVRDUDE_PROGRAMMER = stk500v1
 MCU = atmega328p
+# standard | micro |  mega | leonardo | eightanaloginputs
+VARIANT=standard
 F_CPU = 16000000
 
 ############################################################################
 # Below here nothing should be changed...
 
-ARDUINO = $(INSTALL_DIR)/hardware/cores/arduino
+RESET_TTY_DIR=../reset_tty/
+RESET_TTY=$(RESET_TTY_DIR)reset_tty
+ARDUINO = $(INSTALL_DIR)/hardware/arduino
+ARDUINOCORE = $(ARDUINO)/cores/arduino
+ARDUINOVAR = $(ARDUINO)/variants/$(VARIANT)
 AVR_TOOLS_PATH = /usr/bin
-SRC =  $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
-$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
-$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \
-$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
-CXXSRC = OneWire/OneWire.cpp DallasTemperature/DallasTemperature.cpp  $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/Print.cpp $(ARDUINO)/WMath.cpp IRremote/IRremote.cpp
+SRC =  $(ARDUINOCORE)/wiring.c \
+$(ARDUINOCORE)/wiring_analog.c $(ARDUINOCORE)/wiring_digital.c \
+$(ARDUINOCORE)/wiring_pulse.c  \
+$(ARDUINOCORE)/wiring_shift.c $(ARDUINOCORE)/WInterrupts.c
+CXXSRC = $(ARDUINOCORE)/new.cpp $(ARDUINOCORE)/WString.cpp OneWire/OneWire.cpp DallasTemperature/DallasTemperature.cpp  $(ARDUINOCORE)/HardwareSerial.cpp $(ARDUINOCORE)/Print.cpp $(ARDUINOCORE)/WMath.cpp IRremote/IRremote.cpp
 FORMAT = ihex
 
 
@@ -37,17 +43,19 @@ CDEFS = -DF_CPU=$(F_CPU)
 CXXDEFS = -DF_CPU=$(F_CPU)
 
 # Place -I options here
-CINCS =  -I ./OneWire -I ./DallasTemperature -I ./IRremote -I$(ARDUINO)
-CXXINCS = -I ./OneWire -I ./DallasTemperature -I ./IRremote -I$(ARDUINO)
+CINCS =  -I ./OneWire -I ./DallasTemperature -I ./IRremote -I$(ARDUINOCORE) -I $(ARDUINOVAR)
+CXXINCS = -I ./OneWire -I ./DallasTemperature -I ./IRremote -I$(ARDUINOCORE) -I $(ARDUINOVAR)
 
 # Compiler flag to set the C Standard level.
 # c89   - "ANSI" C
 # gnu89 - c89 plus GCC extensions
 # c99   - ISO C99 standard (not yet fully implemented)
 # gnu99 - c99 plus GCC extensions
-CSTANDARD = -std=gnu99
+#CSTANDARD = -std=gnu99
+CSTANDARD = 
 CDEBUG = -g$(DEBUG)
-CWARN = -Wall -Wstrict-prototypes
+#CWARN = -Wall -Wstrict-prototypes
+CWARN = -Wall 
 CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
 #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
 
@@ -72,7 +80,8 @@ OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
 AR  = $(AVR_TOOLS_PATH)/avr-ar
 SIZE = $(AVR_TOOLS_PATH)/avr-size
 NM = $(AVR_TOOLS_PATH)/avr-nm
-AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
+#AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
+AVRDUDE = $(INSTALL_DIR)/hardware/tools/avrdude
 REMOVE = rm -f
 MV = mv -f
 
@@ -97,15 +106,14 @@ build: elf hex
 applet_files: $(TARGET).pde
        # Here is the "preprocessing".
        # It creates a .cpp file based with the same name as the .pde file.
-       # On top of the new .cpp file comes the WProgram.h header.
        # At the end there is a generic main() function attached.
        # Then the .cpp file will be compiled. Errors during compile will
        # refer to this new, automatically generated, file. 
        # Not the original .pde file you actually edit...
        test -d applet || mkdir applet
-       echo '#include "WProgram.h"' > applet/$(TARGET).cpp
+       echo '#include <Arduino.h>' > applet/$(TARGET).cpp
        cat $(TARGET).pde >> applet/$(TARGET).cpp
-       cat $(ARDUINO)/main.cxx >> applet/$(TARGET).cpp
+       cat $(ARDUINOCORE)/main.cpp >> applet/$(TARGET).cpp
 
 elf: applet/$(TARGET).elf
 hex: applet/$(TARGET).hex
@@ -114,8 +122,8 @@ lss: applet/$(TARGET).lss
 sym: applet/$(TARGET).sym
 
 # Program the device.  
-upload: applet/$(TARGET).hex reset_tty
-       ./reset_tty
+upload: applet/$(TARGET).hex $(RESET_TTY) 
+       $(RESET_TTY) $(PORT)
        $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
 
 
@@ -193,7 +201,7 @@ applet/core.a: $(OBJ)
 
 # Target: clean project.
 clean:
-       $(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
+       $(REMOVE) applet/$(TARGET).cpp applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
        applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \
        $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
 
@@ -208,7 +216,7 @@ depend:
                >> $(MAKEFILE); \
        $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
 
-reset_tty: reset_tty.c
-       $(CC) -o reset_tty reset_tty.c
+$(RESET_TTY): 
+       make -C $(RESET_TTY_DIR)
 
 .PHONY:        all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter