;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 Danny Milosavljevic ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu packages arduino) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix utils) #:use-module (guix download) #:use-module (guix packages) #:use-module (guix build-system gnu) #:use-module (guix build-system python) #:use-module (guix build-system ant) #:use-module (gnu packages) #:use-module (gnu packages avr) #:use-module (gnu packages flashing-tools) #:use-module (gnu packages java) #:use-module (gnu packages python)) (define (arduino-installer filenames) `(lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (out-share (string-append out "/share/arduino"))) (mkdir-p out-share) (for-each (lambda (filename) (let* ((out-share-part (string-append out-share "/" filename))) (copy-recursively filename out-share-part))) (list ,@filenames))))) (define-public arduino-libraries (package (name "arduino-libraries") (version "1.6.10") (source (origin (method url-fetch) (uri (string-append "https://github.com/arduino/Arduino/" "archive/" version ".tar.gz")) (sha256 (base32 "15gbg64i2ac6d0mlnbla567sn26494cvqwf5q53xzf4b5v2rb0jc")) (file-name (string-append name "-" version ".tar.gz")) (modules '((guix build utils))) (snippet '(begin ;; Delete bundled jar archives. (for-each delete-file (find-files "." "\\.jar$")) ;; Delete non-Free Software (delete-file-recursively "libraries/WiFi/extras/wifiHD") (delete-file-recursively "libraries/WiFi/extras/wifi_dnld") #t)) (patches (search-patches "arduino-hardware-patch-out-__cxa_guard_acquire.patch")))) (build-system gnu-build-system) (arguments `(#:tests? #f ; no tests exist #:phases (modify-phases %standard-phases (delete 'configure) (delete 'build) (replace 'install ,(arduino-installer '("libraries" "hardware")))))) (home-page "https://www.arduino.cc/") (synopsis "Arduino Libraries and Hardware Spec Files") (description "{arduino-libraries contains libraries and Arduino hardware spec files (boards.txt).") ;; GPL covers the main body ("app", "core"). lgpl2.1+ covers the remainder mostly. ;; Exceptions are: ;; libraries/Ethernet/src/Dns*: asl2.0 ;; libraries/Ethernet/src/EthernetUdp*: expat ;; libraries/Ethernet/src/utility/w5100*: lgpl2.1 ;; libraries/SD: gpl3+ ;; libraries/TFT: bsd-3 ;; libraries/WiFi: bsd-3 (license (list license:lgpl2.1+ license:asl2.0 license:expat license:bsd-3)))) (define-public arduino-makefile (package (name "arduino-makefile") (version "1.5.1") (source (origin (method url-fetch) (uri (string-append "https://github.com/sudar/Arduino-Makefile/" "archive/" version ".tar.gz")) (sha256 (base32 "1gqmcg2jg62b915akbkivnqf8sx76gv719vx7azm47szd0w1i94i")) (file-name (string-append name "-" version ".tar.gz")))) (build-system python-build-system) (arguments `(#:tests? #f ; no tests exist #:phases (modify-phases %standard-phases (delete 'configure) (add-after 'unpack 'patch-paths (lambda* (#:key inputs outputs #:allow-other-keys) (let ((avr-gcc (assoc-ref inputs "avr-gcc-5")) (avr-binutils (assoc-ref inputs "avr-binutils"))) (substitute* "bin/ard-reset-arduino" (("#!/usr/bin/env python") "#!/usr/bin/python3")) (substitute* "Arduino.mk" (("# => ARDUINO_DIR.*") (string-append "ARDUINO_DIR = " (assoc-ref %build-inputs "arduino-libraries") "/share/arduino\n")) ; ; defaults to "hardware/tools/avr" (("# => AVR_TOOLS_DIR.*") (string-append "AVR_TOOLS_DIR = /\n" ; in order to let the user override CC etc. "AVR_TOOLS_PATH = /\n" "AVRDUDE = " (assoc-ref %build-inputs "avrdude") "\n")) (("CC_NAME[ ]*=.*") (string-append "CC_NAME = " avr-gcc "/bin/avr-gcc\n")) (("CXX_NAME[ ]*=.*") (string-append "CXX_NAME = " avr-gcc "/bin/avr-g++\n")) (("OBJCOPY_NAME[ ]*=.*") (string-append "OBJCOPY_NAME = " avr-binutils "/bin/avr-objcopy\n")) (("OBJDUMP_NAME[ ]*=.*") (string-append "OBJDUMP_NAME = " avr-binutils "/bin/avr-objdump\n")) (("AR_NAME[ ]*=.*") (string-append "AR_NAME = " avr-binutils "/bin/avr-ar\n")) (("SIZE_NAME[ ]*=.*") (string-append "SIZE_NAME = " avr-binutils "/bin/avr-size\n")) (("NM_NAME[ ]*=.*") (string-append "NM_NAME = " avr-binutils "/bin/avr-nm\n")) ; What about ld ? (("# => ARDMK_DIR.*") (string-append "ARDMK_DIR = " (assoc-ref %outputs "out") "/share/arduino\n")))))) (delete 'build) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (out-mk (string-append out "/share/arduino")) (out-doc (string-append out "/share/doc")) (out-bin (string-append out "/bin")) (out-man (string-append out "/share/man/man1"))) (for-each (lambda (name) (install-file name out-mk)) '("Arduino.mk" "arduino-mk-vars.md" "chipKIT.mk" "Common.mk")) (mkdir-p out-doc) (copy-recursively "examples" out-doc) (install-file "bin/ard-reset-arduino" out-bin) (install-file "ard-reset-arduino.1" out-man))))))) (inputs `(("python" ,python) ("python-pyserial" ,python-pyserial) ("arduino-libraries" ,arduino-libraries) ("avrdude" ,avrdude) ("avr-gcc-5" ,avr-gcc-5) ("avr-binutils" ,avr-binutils))) (synopsis "Arduino Makefile Include file") (description "@code{arduino-makefile} allows you to build Arduino sketches using a very tiny Makefile.") (home-page "https://github.com/sudar/Arduino-Makefile") ;(supported-systems '("avr")) (license license:lgpl2.1+)))