From 2cfd754796114e39090c69a0555b015c00da4fb7 Mon Sep 17 00:00:00 2001 From: Bas Wijnen Date: Mon, 9 Jun 2014 23:00:30 -0400 Subject: [PATCH] Support system installation --- .gitignore | 7 +++++++ Arduino.mk | 10 ++++++++++ Makefile.am | 29 +++++++++++++++++++++++++++++ arduino-mk-tool.in | 42 ++++++++++++++++++++++++++++++++++++++++++ configure.ac | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 123 insertions(+) create mode 100644 Makefile.am create mode 100644 arduino-mk-tool.in create mode 100644 configure.ac diff --git a/.gitignore b/.gitignore index 06cff06..cc67375 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ *.o build-cli /.project +Makefile.in +aclocal.m4 +config.guess +config.sub +configure +install-sh +missing diff --git a/Arduino.mk b/Arduino.mk index 7f2e8db..0854008 100644 --- a/Arduino.mk +++ b/Arduino.mk @@ -228,6 +228,16 @@ # ######################################################################## +ifneq ($(shell which arduino-mk-tool),) + # use defaults as set by installation. + # When using this file without installing it, those variables must be set manually. + ARDMK_DIR ?= `arduino-mk-tool ARDMK_DIR` + ARDUINO_DIR ?= `arduino-mk-tool ARDUINO_DIR` + AVR_TOOLS_DIR ?= `arduino-mk-tool AVR_TOOLS_DIR` + AVRDUDE ?= `arduino-mk-tool AVRDUDE` + MONITOR_PORT ?= `arduino-mk-tool MONITOR_PORT` +endif + arduino_output = # When output is not suppressed and we're in the top-level makefile, # running for the first time (i.e., not after a restart after diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..7873bd0 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,29 @@ +######################################################################## +# +# Makefile for compiling Arduino sketches from command line +# System part (i.e. project independent) +# Makefile.am for installing Arduino.mk on the system +# +# Copyright (C) 2014 Bas Wijnen +# +# 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. +# +######################################################################## + +AUTOMAKE_OPTIONS = foreign + +ardmkdir = ${ARDMK_DIR} +bin_SCRIPTS = arduino-mk-tool bin/ard-reset-arduino +ardmk_DATA = Arduino.mk chipKIT.mk Common.mk +man_MANS = ard-reset-arduino.1 + +# Allow cleaning up all the junk that autotools create. +JUNK = Makefile.in aclocal.m4 config.guess config.sub configure install-sh missing + +autoclean: maintainer-clean + ifneq ($(wildcard $(JUNK)),) + rm -r $(wildcard $(JUNK)) + endif diff --git a/arduino-mk-tool.in b/arduino-mk-tool.in new file mode 100644 index 0000000..f0a7fec --- /dev/null +++ b/arduino-mk-tool.in @@ -0,0 +1,42 @@ +#!/bin/sh +# @configure_input@ +######################################################################## +# +# Makefile for compiling Arduino sketches from command line +# System part (i.e. project independent) +# arduino-mk-tool, for finding system details when installed to system +# +# Copyright (C) 2014 Bas Wijnen +# +# 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. +# +######################################################################## + +prefix=@prefix@ + +case "$1" in + '') + echo '@ARDMK_DIR@/Arduino.mk' + ;; + ARDMK_DIR) + echo '@ARDMK_DIR@' + ;; + ARDUINO_DIR) + echo '@ARDUINO_DIR@' + ;; + AVR_TOOLS_DIR) + echo '@AVR_TOOLS_DIR@' + ;; + AVRDUDE) + echo '@AVRDUDE@' + ;; + MONITOR_PORT) + echo '@MONITOR_PORT@' + ;; + *) + echo >&2 "usage: $0 []" + exit 1 +esac diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..754aed4 --- /dev/null +++ b/configure.ac @@ -0,0 +1,35 @@ +######################################################################## +# +# Makefile for compiling Arduino sketches from command line +# System part (i.e. project independent) +# configure.ac for installing Arduino.mk on the system +# +# Copyright (C) 2014 Bas Wijnen +# +# 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. +# +######################################################################## + +AC_PREREQ(2.53) +AC_INIT([arduino-mk],[0.1],[https://github.com/sudar/Arduino-Makefile]) +AM_INIT_AUTOMAKE + +AC_PATH_PROG([AVRDUDE], [avrdude]) +AC_PATH_PROG([CC_NAME], [avr-gcc]) +AC_SUBST([AVR_TOOLS_DIR], `AS_DIRNAME([${CC_NAME}])`/..) +AC_CANONICAL_HOST +AS_CASE([$host], + [*-linux-*], [ARDUINO_DIR=${datarootdir}/arduino; MONITOR_PORT="/dev/ttyACM* /dev/ttyUSB*"], + [*-darwin-*], [ARDUINO_DIR=/Applications/Arduino.app/Contents/Resources/Java; MONITOR_PORT=/dev/cu.usb*], + [*-cygwin-*], [MONITOR_PORT=com1]) +AS_IF([test "x$ARDUINO_DIR" = x], [AC_MSG_ERROR(["ARDUINO_DIR is not defined for your platform; please define it manually"])]) +AS_IF([test "x$MONITOR_PORT" = x], [AC_MSG_ERROR(["MONITOR_PORT is not defined for your platform; please define it manually"])]) +AC_SUBST([ARDUINO_DIR]) +AC_SUBST([MONITOR_PORT]) +AC_SUBST([ARDMK_DIR], [${datarootdir}/arduino]) +AC_CONFIG_FILES([arduino-mk-tool] [Makefile]) + +AC_OUTPUT