Skip to content
Browse files

Arduino compiling from Makefile

  • Loading branch information...
1 parent ac73908 commit 27eff3aeb97b3e56219406f4a6facb60a7ae5f28 @dougbradbury committed
Showing with 478 additions and 262 deletions.
  1. +1 −0 .gitignore
  2. +453 −0 Arduino.mk
  3. +16 −241 Makefile
  4. +0 −13 main.cpp → cslim.pde
  5. +7 −7 fixtures/FixtureInCpp.cpp
  6. +1 −1 fixtures/Fixtures.c
View
1 .gitignore
@@ -18,3 +18,4 @@ CSlim.tmproj
*.ilk
*.pdb
*.lib
+build-cli
View
453 Arduino.mk
@@ -0,0 +1,453 @@
+########################################################################
+#
+# Arduino command line tools Makefile
+# System part (i.e. project independent)
+#
+# Copyright (C) 2010 Martin Oldfield <m@mjo.tc>, based on work that is
+# Copyright Nicholas Zambetti, David A. Mellis & Hernando Barragan
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of the
+# License, or (at your option) any later version.
+#
+# Adapted from Arduino 0011 Makefile by M J Oldfield
+#
+# Original Arduino adaptation by mellis, eighthave, oli.keller
+#
+# Version 0.1 17.ii.2009 M J Oldfield
+#
+# 0.2 22.ii.2009 M J Oldfield
+# - fixes so that the Makefile actually works!
+# - support for uploading via ISP
+# - orthogonal choices of using the Arduino for
+# tools, libraries and uploading
+#
+# 0.3 21.v.2010 M J Oldfield
+# - added proper license statement
+# - added code from Philip Hands to reset
+# Arduino prior to upload
+#
+# 0.4 25.v.2010 M J Oldfield
+# - tweaked reset target on Philip Hands' advice
+#
+# 0.5 23.iii.2011 Stefan Tomanek
+# - added ad-hoc library building
+# 17.v.2011 M J Oldfield
+# - grabbed said version from Ubuntu
+#
+# 0.6 22.vi.2011 M J Oldfield
+# - added ard-parse-boards supports
+# - added -lc to linker opts,
+# on Fabien Le Lez's advice
+#
+########################################################################
+#
+# STANDARD ARDUINO WORKFLOW
+#
+# Given a normal sketch directory, all you need to do is to create
+# a small Makefile which defines a few things, and then includes this one.
+#
+# For example:
+#
+# ARDUINO_DIR = /Applications/arduino-0013
+#
+# TARGET = CLItest
+# ARDUINO_LIBS = LiquidCrystal
+#
+# BOARD_TAG = uno
+# ARDUINO_PORT = /dev/cu.usb*
+#
+# include /usr/local/share/Arduino.mk
+#
+# Hopefully these will be self-explanatory but in case they're not:
+#
+# ARDUINO_DIR - Where the Arduino software has been unpacked
+# TARGET - The basename used for the final files. Canonically
+# this would match the .pde file, but it's not needed
+# here: you could always set it to xx if you wanted!
+# ARDUINO_LIBS - A list of any libraries used by the sketch (we assume
+# these are in $(ARDUINO_DIR)/hardware/libraries
+# ARDUINO_PORT - The port where the Arduino can be found (only needed
+# when uploading
+# BOARD_TAG - The ard-parse-boards tag for the board e.g. uno or mega
+# 'make show_boards' shows a list
+#
+# You might also want to specify these, but normally they'll be read from the
+# boards.txt file i.e. implied by BOARD_TAG
+#
+# MCU,F_CPU - The target processor description
+#
+# Once this file has been created the typical workflow is just
+#
+# $ make upload
+#
+# All of the object files are created in the build-cli subdirectory
+# All sources should be in the current directory and can include:
+# - at most one .pde file which will be treated as C++ after the standard
+# Arduino header and footer have been affixed.
+# - any number of .c, .cpp, .s and .h files
+#
+# Included libraries are built in the build-cli/libs subdirectory.
+#
+# Besides make upload you can also
+# make - no upload
+# make clean - remove all our dependencies
+# make depends - update dependencies
+# make reset - reset the Arduino by tickling DTR on the serial port
+# make raw_upload - upload without first resetting
+# make show_boards - list all the boards defined in boards.txt
+#
+########################################################################
+#
+# ARDUINO WITH OTHER TOOLS
+#
+# If the tools aren't in the Arduino distribution, then you need to
+# specify their location:
+#
+# AVR_TOOLS_PATH = /usr/bin
+# AVRDUDE_CONF = /etc/avrdude/avrdude.conf
+#
+########################################################################
+#
+# ARDUINO WITH ISP
+#
+# You need to specify some details of your ISP programmer and might
+# also need to specify the fuse values:
+#
+# ISP_PROG = -c stk500v2
+# ISP_PORT = /dev/ttyACM0
+#
+# You might also need to set the fuse bits, but typically they'll be
+# read from boards.txt, based on the BOARD_TAG variable:
+#
+# ISP_LOCK_FUSE_PRE = 0x3f
+# ISP_LOCK_FUSE_POST = 0xcf
+# ISP_HIGH_FUSE = 0xdf
+# ISP_LOW_FUSE = 0xff
+# ISP_EXT_FUSE = 0x01
+#
+# I think the fuses here are fine for uploading to the ATmega168
+# without bootloader.
+#
+# To actually do this upload use the ispload target:
+#
+# make ispload
+#
+#
+########################################################################
+# Some paths
+#
+
+ifneq (ARDUINO_DIR,)
+
+ifndef AVR_TOOLS_PATH
+AVR_TOOLS_PATH = $(ARDUINO_DIR)/hardware/tools/avr/bin
+endif
+
+ifndef ARDUINO_ETC_PATH
+ARDUINO_ETC_PATH = $(ARDUINO_DIR)/hardware/tools/avr/etc
+endif
+
+ifndef AVRDUDE_CONF
+AVRDUDE_CONF = $(ARDUINO_ETC_PATH)/avrdude.conf
+endif
+
+ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries
+ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino
+
+endif
+
+########################################################################
+# boards.txt parsing
+#
+ifndef BOARD_TAG
+BOARD_TAG = uno
+endif
+
+ifndef BOARDS_TXT
+BOARDS_TXT = $(ARDUINO_DIR)/hardware/arduino/boards.txt
+endif
+
+ifndef PARSE_BOARD
+PARSE_BOARD = ard-parse-boards --boards_txt=$(BOARDS_TXT)
+endif
+
+# processor stuff
+ifndef MCU
+MCU = $(shell $(PARSE_BOARD) $(BOARD_TAG) build.mcu)
+endif
+
+ifndef F_CPU
+F_CPU = $(shell $(PARSE_BOARD) $(BOARD_TAG) build.f_cpu)
+endif
+
+# normal programming info
+ifndef AVRDUDE_ARD_PROGRAMMER
+AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD) $(BOARD_TAG) upload.protocol)
+endif
+
+ifndef AVRDUDE_ARD_BAUDRATE
+AVRDUDE_ARD_BAUDRATE = $(shell $(PARSE_BOARD) $(BOARD_TAG) upload.speed)
+endif
+
+# fuses if you're using e.g. ISP
+ifndef ISP_LOCK_FUSE_PRE
+ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD) $(BOARD_TAG) bootloader.unlock_bits)
+endif
+
+ifndef ISP_LOCK_FUSE_POST
+ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD) $(BOARD_TAG) bootloader.lock_bits)
+endif
+
+ifndef ISP_HIGH_FUSE
+ISP_HIGH_FUSE = $(shell $(PARSE_BOARD) $(BOARD_TAG) bootloader.high_fuses)
+endif
+
+ifndef ISP_LOW_FUSE
+ISP_LOW_FUSE = $(shell $(PARSE_BOARD) $(BOARD_TAG) bootloader.low_fuses)
+endif
+
+ifndef ISP_EXT_FUSE
+ISP_EXT_FUSE = $(shell $(PARSE_BOARD) $(BOARD_TAG) bootloader.extended_fuses)
+endif
+
+
+
+
+# Everything gets built in here
+OBJDIR = build-cli
+
+########################################################################
+# Local sources
+#
+LOCAL_C_SRCS += $(wildcard *.c)
+LOCAL_CPP_SRCS += $(wildcard *.cpp)
+LOCAL_CC_SRCS = $(wildcard *.cc)
+LOCAL_PDE_SRCS = $(wildcard *.pde)
+LOCAL_AS_SRCS = $(wildcard *.S)
+LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \
+ $(LOCAL_CC_SRCS:.cc=.o) $(LOCAL_PDE_SRCS:.pde=.o) \
+ $(LOCAL_AS_SRCS:.S=.o)
+LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES))
+
+# Dependency files
+DEPS = $(LOCAL_OBJS:.o=.d)
+
+# core sources
+ifeq ($(strip $(NO_CORE)),)
+ifdef ARDUINO_CORE_PATH
+CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c)
+CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp)
+CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o)
+CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \
+ $(OBJDIR)/%,$(CORE_OBJ_FILES))
+endif
+endif
+
+# all the objects!
+OBJS = $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS)
+
+########################################################################
+# Rules for making stuff
+#
+
+# The name of the main targets
+TARGET_HEX = $(OBJDIR)/$(TARGET).hex
+TARGET_ELF = $(OBJDIR)/$(TARGET).elf
+TARGETS = $(OBJDIR)/$(TARGET).*
+
+# A list of dependencies
+DEP_FILE = $(OBJDIR)/depends.mk
+
+# Names of executables
+CC = $(AVR_TOOLS_PATH)/avr-gcc
+CXX = $(AVR_TOOLS_PATH)/avr-g++
+OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy
+OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
+AR = $(AVR_TOOLS_PATH)/avr-ar
+SIZE = $(AVR_TOOLS_PATH)/avr-size
+NM = $(AVR_TOOLS_PATH)/avr-nm
+REMOVE = rm -f
+MV = mv -f
+CAT = cat
+ECHO = echo
+
+# General arguments
+SYS_LIBS = $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS))
+SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS))
+SYS_OBJS = $(wildcard $(patsubst %,%/*.o,$(SYS_LIBS)))
+LIB_SRC = $(wildcard $(patsubst %,%/*.cpp,$(SYS_LIBS)))
+LIB_OBJS = $(patsubst $(ARDUINO_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(LIB_SRC))
+
+CPPFLAGS += -mmcu=$(MCU) -DF_CPU=$(F_CPU) \
+ -I. -I$(ARDUINO_CORE_PATH) \
+ $(SYS_INCLUDES) -g -Os -w -Wall \
+ -ffunction-sections -fdata-sections
+CFLAGS = -std=gnu99
+CXXFLAGS = -fno-exceptions
+ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp
+LDFLAGS = -mmcu=$(MCU) -lm -Wl,--gc-sections -Os
+
+# Rules for making a CPP file from the main sketch (.cpe)
+PDEHEADER = \\\#include \"WProgram.h\"
+
+# Expand and pick the first port
+ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT)))
+
+# Implicit rules for building everything (needed to get everything in
+# the right directory)
+#
+# Rather than mess around with VPATH there are quasi-duplicate rules
+# here for building e.g. a system C++ file and a local C++
+# file. Besides making things simpler now, this would also make it
+# easy to change the build options in future
+
+# library sources
+$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.cpp
+ mkdir -p $(dir $@)
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+
+# normal local sources
+# .o rules are for objects, .d for dependency tracking
+# there seems to be an awful lot of duplication here!!!
+$(OBJDIR)/%.o: %.c
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+
+$(OBJDIR)/%.o: %.cc
+ $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
+
+$(OBJDIR)/%.o: %.cpp
+ $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
+
+$(OBJDIR)/%.o: %.S
+ $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
+
+$(OBJDIR)/%.o: %.s
+ $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
+
+$(OBJDIR)/%.d: %.c
+ $(CC) -MM $(CPPFLAGS) $(CFLAGS) $< -MF $@ -MT $(@:.d=.o)
+
+$(OBJDIR)/%.d: %.cc
+ $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o)
+
+$(OBJDIR)/%.d: %.cpp
+ $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o)
+
+$(OBJDIR)/%.d: %.S
+ $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o)
+
+$(OBJDIR)/%.d: %.s
+ $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o)
+
+# the pde -> cpp -> o file
+$(OBJDIR)/%.cpp: %.pde
+ $(ECHO) $(PDEHEADER) > $@
+ $(CAT) $< >> $@
+
+$(OBJDIR)/%.o: $(OBJDIR)/%.cpp
+ $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
+
+$(OBJDIR)/%.d: $(OBJDIR)/%.cpp
+ $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o)
+
+# core files
+$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+
+$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp
+ $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
+
+# various object conversions
+$(OBJDIR)/%.hex: $(OBJDIR)/%.elf
+ $(OBJCOPY) -O ihex -R .eeprom $< $@
+
+$(OBJDIR)/%.eep: $(OBJDIR)/%.elf
+ -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+ --change-section-lma .eeprom=0 -O ihex $< $@
+
+$(OBJDIR)/%.lss: $(OBJDIR)/%.elf
+ $(OBJDUMP) -h -S $< > $@
+
+$(OBJDIR)/%.sym: $(OBJDIR)/%.elf
+ $(NM) -n $< > $@
+
+########################################################################
+#
+# Avrdude
+#
+ifndef AVRDUDE
+AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
+endif
+
+AVRDUDE_COM_OPTS = -q -V -p $(MCU)
+ifdef AVRDUDE_CONF
+AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF)
+endif
+
+AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(ARD_PORT)
+
+ifndef ISP_PROG
+ISP_PROG = -c stk500v2
+endif
+
+AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG)
+
+
+########################################################################
+#
+# Explicit targets start here
+#
+
+all: $(OBJDIR) $(TARGET_HEX)
+
+$(OBJDIR):
+ mkdir $(OBJDIR)
+
+$(TARGET_ELF): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(SYS_OBJS) -lc
+
+$(DEP_FILE): $(OBJDIR) $(DEPS)
+ cat $(DEPS) > $(DEP_FILE)
+
+upload: reset raw_upload
+
+raw_upload: $(TARGET_HEX)
+ $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \
+ -U flash:w:$(TARGET_HEX):i
+
+# stty on MacOS likes -F, but on Debian it likes -f redirecting
+# stdin/out appears to work but generates a spurious error on MacOS at
+# least. Perhaps it would be better to just do it in perl ?
+reset:
+ for STTYF in 'stty --file' 'stty -f' 'stty <' ; \
+ do $$STTYF /dev/tty >/dev/null 2>/dev/null && break ; \
+ done ;\
+ $$STTYF $(ARD_PORT) hupcl ;\
+ (sleep 0.1 || sleep 1) ;\
+ $$STTYF $(ARD_PORT) -hupcl
+
+ispload: $(TARGET_HEX)
+ $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \
+ -U lock:w:$(ISP_LOCK_FUSE_PRE):m \
+ -U hfuse:w:$(ISP_HIGH_FUSE):m \
+ -U lfuse:w:$(ISP_LOW_FUSE):m \
+ -U efuse:w:$(ISP_EXT_FUSE):m
+ $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -D \
+ -U flash:w:$(TARGET_HEX):i
+ $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) \
+ -U lock:w:$(ISP_LOCK_FUSE_POST):m
+
+clean:
+ $(REMOVE) $(OBJS) $(TARGETS) $(DEP_FILE) $(DEPS)
+
+depends: $(DEPS)
+ cat $(DEPS) > $(DEP_FILE)
+
+show_boards:
+ $(PARSE_BOARD) --boards
+
+.PHONY: all clean depends upload raw_upload reset show_boards
+
+include $(DEP_FILE)
View
257 Makefile
@@ -1,248 +1,23 @@
-# Arduino makefile
-#
-# This makefile allows you to build sketches from the command line
-# without the Arduino environment (or Java).
-#
-# The Arduino environment does preliminary processing on a sketch before
-# compiling it. If you're using this makefile instead, you'll need to do
-# a few things differently:
-#
-# - Give your program's file a .cpp extension (e.g. foo.cpp).
-#
-# - Put this line at top of your code: #include <WProgram.h>
-#
-# - Write prototypes for all your functions (or define them before you
-# call them). A prototype declares the types of parameters a
-# function will take and what type of value it will return. This
-# means that you can have a call to a function before the definition
-# of the function. A function prototype looks like the first line of
-# the function, with a semi-colon at the end. For example:
-# int digitalRead(int pin);
-#
-# - Write a main() function for your program that returns an int, calls
-# init() and setup() once (in that order), and then calls loop()
-# repeatedly():
-#
-# int main()
-# {
-# init();
-# setup();
-#
-# for (;;)
-# loop();
-#
-# return 0;
-# }
-#
-# Instructions for using the makefile:
-#
-# 1. Copy this file into the folder with your sketch.
-#
-# 2. Below, modify the line containing "TARGET" to refer to the name of
-# of your program's file without an extension (e.g. TARGET = foo).
-#
-# 3. Modify the line containg "ARDUINO" to point the directory that
-# contains the Arduino core (for normal Arduino installations, this
-# is the hardware/cores/arduino sub-directory).
-#
-# 4. Modify the line containing "PORT" to refer to the filename
-# representing the USB or serial connection to your Arduino board
-# (e.g. PORT = /dev/tty.USB0). If the exact name of this file
-# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*).
-#
-# 5. At the command line, change to the directory containing your
-# program's file and the makefile.
-#
-# 6. Type "make" and press enter to compile/verify your program.
-#
-# 7. Type "make upload", reset your Arduino board, and press enter to
-# upload your program to the Arduino board.
-#
-# $Id$
+ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java
-# Update these to reflect the location of the Arduino IDE and avrdude installations, respectively
-ARDUINO = /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino
-ARDUINO_LIB = /Applications/Arduino.app/Contents/Resources/Java/libraries
-AVRDUDE_DIR = /usr/local/CrossPack-AVR/bin
+TARGET = CSlim
+BOARD_TAG = uno
+ARDUINO_PORT = /dev/cu.usb*
-PORT = /dev/tty.usbserial*
-TARGET = main
+ARDUINO_LIBS = Ethernet Spi Ethernet/utility
-CSLIM_SRC = src/CSlim/Slim.c src/CSlim/ListExecutor.c src/CSlim/SlimConnectionHandler.c src/CSlim/SlimList.c src/CSlim/SlimListDeserializer.c \
-src/CSlim/SlimListSerializer.c src/CSlim/SlimUtil.c src/CSlim/StatementExecutor.c src/CSlim/SymbolTable.c
+CSLIM_SRC = src/CSlim/Slim.c src/CSlim/ListExecutor.c src/CSlim/SlimConnectionHandler.c src/CSlim/SlimList.c \
+src/CSlim/SlimListDeserializer.c src/CSlim/SlimListSerializer.c src/CSlim/SlimUtil.c src/CSlim/StatementExecutor.c \
+src/CSlim/SymbolTable.c
-SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
-$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
-$(ARDUINO)/wiring_pulse.c \
-$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c \
-$(CSLIM_SRC)
+FIXTURE_C_SRC = fixtures/Fixtures.c fixtures/DecisionTableExample.c fixtures/ExceptionsExample.c fixtures/QueryTableExample.c \
+fixtures/ScriptTableExample.c
+FIXTURE_CPP_SRC = fixtures/FixtureInCpp.cpp
-CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp $(ARDUINO)/Print.cpp src/ComArduino/TcpComLink.cpp \
-$(ARDUINO_LIB)/Ethernet/Client.cpp $(ARDUINO_LIB)/Ethernet/Ethernet.cpp $(ARDUINO_LIB)/Ethernet/Server.cpp $(ARDUINO_LIB)/Ethernet/Udp.cpp
-MCU = atmega328p
-F_CPU = 16000000
-FORMAT = ihex
-UPLOAD_RATE = 57600
+CPP_COMPILING = 1
+CPPFLAGS += -Iinclude/CSlim -Iinclude/ComArduino
+LOCAL_C_SRCS += $(CSLIM_SRC) $(FIXTURE_C_SRC)
+LOCAL_CPP_SRCS += src/ComArduino/TcpComLink.cpp $(FIXTURE_CPP_SRC)
-# Name of this Makefile (used for "make depend").
-MAKEFILE = Makefile
+include Arduino.mk
-# 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
-
-OPT = s
-
-# Place -D or -U options here
-CDEFS = -DF_CPU=$(F_CPU)
-CXXDEFS = -DF_CPU=$(F_CPU)
-
-# Place -I options here
-CINCS = -I$(ARDUINO) -Iinclude/CSlim -Iinclude/ComArduino -I$(ARDUINO_LIB)/Ethernet
-CXXINCS = -I$(ARDUINO)
-
-# 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
-CDEBUG = -g$(DEBUG)
-CWARN = -Wall -Wstrict-prototypes
-CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -Wl,-gc-sections
-
-CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) $(CTUNING)
-CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) $(CTUNING)
-LDFLAGS = -lm -Wl,-gc-sections -mmcu=$(MCU)
-
-# Programming support using avrdude. Settings and variables.
-AVRDUDE_PROGRAMMER = stk500v1
-AVRDUDE_PORT = $(PORT)
-AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
-AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
- -b $(UPLOAD_RATE) -D
-
-
-# Program settings
-CC = $(AVRDUDE_DIR)/avr-gcc
-CXX = $(AVRDUDE_DIR)/avr-g++
-OBJCOPY = $(AVRDUDE_DIR)/avr-objcopy
-OBJDUMP = $(AVRDUDE_DIR)/avr-objdump
-AR = $(AVRDUDE_DIR)/avr-ar
-SIZE = $(AVRDUDE_DIR)/avr-size
-NM = $(AVRDUDE_DIR)/avr-nm
-AVRDUDE = $(AVRDUDE_DIR)/avrdude
-REMOVE = rm -f
-MV = mv -f
-
-# Define all object files.
-OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
-
-# Define all listing files.
-LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
-
-# Combine all necessary flags and optional flags.
-# Add target processor to flags.
-ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
-ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
-ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
-
-
-# Default target.
-all: build
-
-build: elf hex
-
-elf: $(TARGET).elf
-hex: $(TARGET).hex
-eep: $(TARGET).eep
-lss: $(TARGET).lss
-sym: $(TARGET).sym
-
-# Program the device.
-upload: $(TARGET).hex
- $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
-
-
-
-
-# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
-COFFCONVERT=$(OBJCOPY) --debugging \
---change-section-address .data-0x800000 \
---change-section-address .bss-0x800000 \
---change-section-address .noinit-0x800000 \
---change-section-address .eeprom-0x810000
-
-
-coff: $(TARGET).elf
- $(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof
-
-
-extcoff: $(TARGET).elf
- $(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof
-
-
-.SUFFIXES: .elf .hex .eep .lss .sym
-
-.elf.hex:
- $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
-
-.elf.eep:
- -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
- --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-
-# Create extended listing file from ELF output file.
-.elf.lss:
- $(OBJDUMP) -h -S $< > $@
-
-# Create a symbol table from ELF output file.
-.elf.sym:
- $(NM) -n $< > $@
-
-
-core.a: $(OBJ)
- @for i in $(OBJ); do echo $(AR) rcs core.a $$i; $(AR) rcs core.a $$i; done
-
-# Link: create ELF output file from library.
-$(TARGET).elf: core.a
- $(CC) $(ALL_CFLAGS) -o $@ $(TARGET).cpp -L. core.a $(LDFLAGS)
-
-# Compile: create object files from C++ source files.
-.cpp.o:
- $(CXX) -c $(ALL_CXXFLAGS) $< -o $@
-
-# Compile: create object files from C source files.
-.c.o:
- $(CC) -c $(ALL_CFLAGS) $< -o $@
-
-
-# Compile: create assembler files from C source files.
-.c.s:
- $(CC) -S $(ALL_CFLAGS) $< -o $@
-
-
-# Assemble: create object files from assembler source files.
-.S.o:
- $(CC) -c $(ALL_ASFLAGS) $< -o $@
-
-
-
-# Target: clean project.
-clean:
- $(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \
- $(TARGET).map $(TARGET).sym $(TARGET).lss core.a \
- $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
-
-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) $(ASRC) >> $(MAKEFILE)
-
-.PHONY: all build elf hex eep lss sym program coff extcoff clean depend
View
13 main.cpp → cslim.pde
@@ -1,4 +1,3 @@
-#include <WProgram.h>
#include <SPI.h>
#include <Client.h>
@@ -41,15 +40,3 @@ void loop()
-
-
-
-int main(int ac, char** av)
-{
- setup()
- while(true)
- {
- loop();
- }
-}
-
View
14 fixtures/FixtureInCpp.cpp
@@ -23,7 +23,7 @@ extern "C" {
#endif
typedef struct Multiplication
{
- cMultiplication * multiplication;
+ cMultiplication multiplication;
char result[32];
} Multiplication;
@@ -31,32 +31,32 @@ void* Multiplication_Create(StatementExecutor* errorHandler, SlimList* args)
{
Multiplication* self = (Multiplication*)malloc(sizeof(Multiplication));
self->result[0] = 0;
- self->multiplication = new cMultiplication();
+ // self->multiplication = new cMultiplication();
return self;
}
void Multiplication_Destroy(void* void_self)
{
Multiplication* self = (Multiplication*)void_self;
- delete self->multiplication;
+ // delete self->multiplication;
free(self);
}
static char* setMultiplicand1(void* void_self, SlimList* args) {
Multiplication* self = (Multiplication*)void_self;
- self->multiplication->m1 = atof(SlimList_GetStringAt(args, 0));
+ self->multiplication.m1 = atof(SlimList_GetStringAt(args, 0));
return self->result;
}
static char* setMultiplicand2(void* void_self, SlimList* args) {
Multiplication* self = (Multiplication*)void_self;
- self->multiplication->m2 = atof(SlimList_GetStringAt(args, 0));
+ self->multiplication.m2 = atof(SlimList_GetStringAt(args, 0));
return self->result;
}
static char* Product(void* void_self, SlimList* args) {
Multiplication* self = (Multiplication*)void_self;
- float product = self->multiplication->product();
+ float product = self->multiplication.product();
snprintf(self->result, 32, "%g", product);
return self->result;
}
@@ -70,4 +70,4 @@ SLIM_END
#ifndef CPP_COMPILING
}
-#endif
+#endif
View
2 fixtures/Fixtures.c
@@ -5,6 +5,6 @@ SLIM_FIXTURES
SLIM_FIXTURE(Count)
SLIM_FIXTURE(EmployeePayRecordsRow)
SLIM_FIXTURE(ExceptionsExample)
- SLIM_FIXTURE(Multiplication)
+ SLIM_FIXTURE(Multiplication)
SLIM_END

0 comments on commit 27eff3a

Please sign in to comment.
Something went wrong with that request. Please try again.