aboutsummaryrefslogtreecommitdiff
path: root/devel/arduino-mk
diff options
context:
space:
mode:
authorMichael Scheidell <scheidell@FreeBSD.org>2012-02-23 14:20:36 +0000
committerMichael Scheidell <scheidell@FreeBSD.org>2012-02-23 14:20:36 +0000
commit20c764411325cd53e20cf05f6453ca93b1e1da9b (patch)
tree20f6398ed4d65d43008d6c2ccc9976bf0fec8ea3 /devel/arduino-mk
parent9d538b3c207899efb4a63a1bcf16116c10b55058 (diff)
downloadports-20c764411325cd53e20cf05f6453ca93b1e1da9b.tar.gz
ports-20c764411325cd53e20cf05f6453ca93b1e1da9b.zip
Notes
Diffstat (limited to 'devel/arduino-mk')
-rw-r--r--devel/arduino-mk/Makefile60
-rw-r--r--devel/arduino-mk/distinfo2
-rw-r--r--devel/arduino-mk/files/Makefile16
-rw-r--r--devel/arduino-mk/files/blink2.pde30
-rw-r--r--devel/arduino-mk/files/patch-Arduino.mk111
-rw-r--r--devel/arduino-mk/files/version.sh23
-rw-r--r--devel/arduino-mk/pkg-descr7
7 files changed, 249 insertions, 0 deletions
diff --git a/devel/arduino-mk/Makefile b/devel/arduino-mk/Makefile
new file mode 100644
index 000000000000..96d8af455e87
--- /dev/null
+++ b/devel/arduino-mk/Makefile
@@ -0,0 +1,60 @@
+# New ports collection makefile for: arduino-mk
+# Date created: 27 Feb 2011
+# Whom: Craig Leres <leres@ee.lbl.gov>
+#
+# $FreeBSD$
+#
+
+PORTNAME= arduino-mk
+PORTVERSION= 0.6
+CATEGORIES= devel
+MASTER_SITES= http://mjo.tc/atelier/2009/02/acli/
+DISTNAME= ${PORTNAME}_${PORTVERSION}
+
+MAINTAINER= leres@ee.lbl.gov
+COMMENT= Build Arduino sketches from the command line
+
+LICENSE= LGPL21
+
+# gmake is needed to use the port, not to build it
+RUN_DEPENDS= gmake:${PORTSDIR}/devel/gmake \
+ ${SITE_PERL}/YAML/Any.pm:${PORTSDIR}/textproc/p5-YAML \
+ arduino:${PORTSDIR}/devel/arduino
+PATCH_DEPENDS= ${LOCALBASE}/arduino/lib/version.txt:${PORTSDIR}/devel/arduino
+
+WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION}
+
+NO_BUILD= yes
+
+PLIST_FILES= arduino/lib/Arduino.mk \
+ arduino/tools/ard-parse-boards
+
+.if !defined(NOPORTEXAMPLES)
+PLIST_FILES+= ${EXAMPLESDIR_REL}/Makefile \
+ ${EXAMPLESDIR_REL}/blink2.pde
+PLIST_DIRS+= ${EXAMPLESDIR_REL}
+.endif
+
+.include <bsd.port.pre.mk>
+
+ARDUINO_CMD= ${FILESDIR}/version.sh ${PREFIX}/arduino/lib/version.txt
+OLD_BOARDS_TXT= /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt
+NEW_BOARDS_TXT= ${PREFIX}/arduino/hardware/arduino/boards.txt
+
+post-patch:
+ @ARDUINO="`$(ARDUINO_CMD)`" && \
+ ${REINPLACE_CMD} -e "s|%%ARDUINO%%|$${ARDUINO}|g" \
+ ${WRKSRC}/Arduino.mk
+ @${REINPLACE_CMD} -e "s|'${OLD_BOARDS_TXT}'|'${NEW_BOARDS_TXT}'|g" \
+ ${WRKSRC}/ard-parse-boards
+
+do-install:
+ ${INSTALL_DATA} ${WRKSRC}/Arduino.mk ${PREFIX}/arduino/lib
+ ${INSTALL_SCRIPT} ${WRKSRC}/ard-parse-boards ${PREFIX}/arduino/tools
+.if !defined(NOPORTEXAMPLES)
+ ${MKDIR} ${EXAMPLESDIR}
+ ${INSTALL_DATA} ${FILESDIR}/Makefile ${EXAMPLESDIR}
+ ${INSTALL_DATA} ${FILESDIR}/blink2.pde ${EXAMPLESDIR}
+.endif
+
+.include <bsd.port.post.mk>
diff --git a/devel/arduino-mk/distinfo b/devel/arduino-mk/distinfo
new file mode 100644
index 000000000000..82ed98b36e01
--- /dev/null
+++ b/devel/arduino-mk/distinfo
@@ -0,0 +1,2 @@
+SHA256 (arduino-mk_0.6.tar.gz) = f691d8157bd3be978c832d37a452cb7e371d0f3b96a5bf70abd870f8afcb7cab
+SIZE (arduino-mk_0.6.tar.gz) = 15756
diff --git a/devel/arduino-mk/files/Makefile b/devel/arduino-mk/files/Makefile
new file mode 100644
index 000000000000..73431f39377c
--- /dev/null
+++ b/devel/arduino-mk/files/Makefile
@@ -0,0 +1,16 @@
+# @(#) $Id: Makefile 13 2011-12-31 00:07:36Z leres $ (XSE)
+# $FreeBSD$
+
+TARGET= blink2
+
+BOARD_TAG= atmega328
+
+ARDUINO_DIR= /usr/local/arduino
+
+AVRDUDE_ARD_PROGRAMMER= arduino
+AVRDUDE_ARD_BAUDRATE= 57600
+ARDUINO_PORT= /dev/arduino
+
+include $(ARDUINO_DIR)/lib/Arduino.mk
+
+CPPFLAGS+= -Werror
diff --git a/devel/arduino-mk/files/blink2.pde b/devel/arduino-mk/files/blink2.pde
new file mode 100644
index 000000000000..9add9ab871ff
--- /dev/null
+++ b/devel/arduino-mk/files/blink2.pde
@@ -0,0 +1,30 @@
+/* @(#) $Id: blink2.pde 18 2012-02-05 20:38:31Z leres $ (XSE) */
+
+/*
+ * This is a example sketch that blinks the LED like a heartbeat
+ */
+
+/* SCK is usually connected to the LED */
+#define PIN_LED_OUT SCK
+
+void
+setup()
+{
+ pinMode(PIN_LED_OUT, OUTPUT);
+}
+
+void
+loop()
+{
+ digitalWrite(PIN_LED_OUT, HIGH);
+ delay(25);
+
+ digitalWrite(PIN_LED_OUT, LOW);
+ delay(50);
+
+ digitalWrite(PIN_LED_OUT, HIGH);
+ delay(25);
+
+ digitalWrite(PIN_LED_OUT, LOW);
+ delay(900);
+}
diff --git a/devel/arduino-mk/files/patch-Arduino.mk b/devel/arduino-mk/files/patch-Arduino.mk
new file mode 100644
index 000000000000..5ae8ea4caf64
--- /dev/null
+++ b/devel/arduino-mk/files/patch-Arduino.mk
@@ -0,0 +1,111 @@
+--- Arduino.mk.orig 2011-06-23 06:32:03.000000000 -0700
++++ Arduino.mk 2011-12-28 17:19:57.000000000 -0800
+@@ -67,7 +67,7 @@
+ # 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
++# these are in $(ARDUINO_DIR)/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
+@@ -155,6 +155,7 @@
+
+ ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries
+ ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino
++ARDUINO_VARIANT_PATH = $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT)
+
+ endif
+
+@@ -170,7 +171,7 @@
+ endif
+
+ ifndef PARSE_BOARD
+-PARSE_BOARD = ard-parse-boards --boards_txt=$(BOARDS_TXT)
++PARSE_BOARD = $(ARDUINO_DIR)/tools/ard-parse-boards --boards_txt=$(BOARDS_TXT)
+ endif
+
+ # processor stuff
+@@ -182,6 +183,10 @@
+ F_CPU = $(shell $(PARSE_BOARD) $(BOARD_TAG) build.f_cpu)
+ endif
+
++ifndef VARIANT
++VARIANT = $(shell $(PARSE_BOARD) $(BOARD_TAG) build.variant)
++endif
++
+ # normal programming info
+ ifndef AVRDUDE_ARD_PROGRAMMER
+ AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD) $(BOARD_TAG) upload.protocol)
+@@ -221,11 +226,11 @@
+ ########################################################################
+ # 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_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)
+@@ -278,10 +283,14 @@
+ 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) \
++LIB_SRC2 = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS)))
++LIB_OBJS = $(patsubst $(ARDUINO_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(LIB_SRC)) \
++ $(patsubst $(ARDUINO_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(LIB_SRC2))
++
++ARDUINO = %%ARDUINO%%
++CPPFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO) \
++ -D__DELAY_BACKWARD_COMPATIBLE__ \
++ -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VARIANT_PATH) \
+ $(SYS_INCLUDES) -g -Os -w -Wall \
+ -ffunction-sections -fdata-sections
+ CFLAGS = -std=gnu99
+@@ -289,8 +298,9 @@
+ 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\"
++# Rules for making a CPP file from the main sketch (.pde)
++NEWPDEHEADER = \\\#include \"Arduino.h\"
++OLDPDEHEADER = \\\#include \"WProgram.h\"
+
+ # Expand and pick the first port
+ ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT)))
+@@ -308,6 +318,10 @@
+ mkdir -p $(dir $@)
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
+
++$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.c
++ 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!!!
+@@ -343,7 +357,11 @@
+
+ # the pde -> cpp -> o file
+ $(OBJDIR)/%.cpp: %.pde
+- $(ECHO) $(PDEHEADER) > $@
++ $(ECHO) \#if $(ARDUINO) \>= 100 > $@
++ $(ECHO) $(NEWPDEHEADER) >> $@
++ $(ECHO) \#else >> $@
++ $(ECHO) $(OLDPDEHEADER) >> $@
++ $(ECHO) \#endif >> $@
+ $(CAT) $< >> $@
+
+ $(OBJDIR)/%.o: $(OBJDIR)/%.cpp
diff --git a/devel/arduino-mk/files/version.sh b/devel/arduino-mk/files/version.sh
new file mode 100644
index 000000000000..18d94d3b859d
--- /dev/null
+++ b/devel/arduino-mk/files/version.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# @(#) $Id: version.sh 5 2011-12-28 18:41:41Z leres $ (XSE)
+
+# The ARDUINO version should (a) be in an include file and
+# (b) should (at a minimum) be cpp friendly
+
+if [ $# -ne 1 ]; then
+ echo "usage: $0 version.txt" 1>&2
+ exit 1
+fi
+
+version="`cat $1`" || exit 1
+
+case "${version}" in
+
+0*)
+ echo "${version}"
+ ;;
+
+*)
+ echo "${version}" | /usr/bin/awk '{ print 100 * $0 }'
+ ;;
+esac
diff --git a/devel/arduino-mk/pkg-descr b/devel/arduino-mk/pkg-descr
new file mode 100644
index 000000000000..bfa3cf9f4bbb
--- /dev/null
+++ b/devel/arduino-mk/pkg-descr
@@ -0,0 +1,7 @@
+Arduino from the command line
+
+This is a makefile written by Martin Atelier that makes it possible
+to build Arduino sketches with gmake. An example sketch and Makefile;
+it is installed in share/examples/arduino-mk
+
+WWW: http://mjo.tc/atelier/2009/02/arduino-cli.html