git: b7e58607846e - main - devel/arduino: Update optional ATMEGA644P patches

From: Craig Leres <leres_at_FreeBSD.org>
Date: Mon, 29 Jan 2024 03:56:43 UTC
The branch main has been updated by leres:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b7e58607846ea12bd14d79557d4a245adfcda88d

commit b7e58607846ea12bd14d79557d4a245adfcda88d
Author:     Craig Leres <leres@FreeBSD.org>
AuthorDate: 2024-01-29 03:56:21 +0000
Commit:     Craig Leres <leres@FreeBSD.org>
CommitDate: 2024-01-29 03:56:21 +0000

    devel/arduino:  Update optional ATMEGA644P patches
    
     - Rename patches to match makepatch naming conventions
    
     - Add atmega1284 to boards.txt
    
     - Add digitalPinToInterrupt() to pins_arduino.h
    
     - Minor Makefile inprovements
    
     - Remove unused extrapatch-hardware-arduino-boards.txt-arlcd
---
 devel/arduino/Makefile                             | 51 ++++++++++------------
 .../files/extrapatch-hardware-arduino-boards.txt   | 27 ------------
 .../extrapatch-hardware-arduino-boards.txt-arlcd   | 23 ----------
 .../files/extrapatch-hardware_arduino_boards.txt   | 43 ++++++++++++++++++
 ...h-hardware_arduino_cores_arduino_WInterrupts.c} |  0
 ...re_arduino_variants_atmega644p_pins__arduino.h} | 13 ++++--
 ...dware_arduino_cores_arduino_HardwareSerial.cpp} |  0
 7 files changed, 76 insertions(+), 81 deletions(-)

diff --git a/devel/arduino/Makefile b/devel/arduino/Makefile
index caec5626f34e..c1f5614fd27b 100644
--- a/devel/arduino/Makefile
+++ b/devel/arduino/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	arduino
 PORTVERSION=	1.0.6
-PORTREVISION=	4
+PORTREVISION=	5
 PORTEPOCH=	1
 CATEGORIES=	devel java lang
 MASTER_SITES=	https://arduino.cc/download.php?f=/
@@ -47,23 +47,24 @@ DESKTOP_ENTRIES=	"Arduino" "Arduino IDE" \
 
 OPTIONS_DEFINE=		ATMEGA644P DOCS EXAMPLES UARDUNO
 OPTIONS_SUB=
-ATMEGA644P_DESC=	ATmega644p patches
+ATMEGA644P_DESC=	ATmega644p/ATmega1284p patches
 DOCS_DESC=		Install the reference documents
 UARDUNO_DESC=		Kernel module for Arduino Uno USB interface
 
 INSLIST=	arduino hardware lib libraries logo.png revisions.txt tools
 
+ATMEGA644P_EXTRA_PATCHES= \
+	${FILESDIR}/extrapatch-hardware_arduino_boards.txt \
+	${FILESDIR}/extrapatch-hardware_arduino_cores_arduino_WInterrupts.c \
+	${FILESDIR}/extrapatch-hardware_arduino_variants_atmega644p_pins__arduino.h
+
 # Add serial drivers for those who are new to this.
 UARDUNO_RUN_DEPENDS+=	${KMODDIR}/uarduno.ko:comms/uarduno
 
-.include <bsd.port.options.mk>
+pre-patch-ATMEGA644P-on:
+	${MKDIR} ${WRKSRC}/hardware/arduino/variants/atmega644p
 
-.if ${PORT_OPTIONS:MATMEGA644P}
-EXTRA_PATCHES+=	\
-	${FILESDIR}/extrapatch-hardware-arduino-boards.txt \
-	${FILESDIR}/extrapatch-hardware-arduino-cores-arduino-WInterrupts.c \
-	${FILESDIR}/extrapatch-hardware-arduino-variants-atmega644p-pins_arduino.h
-.endif
+.include <bsd.port.options.mk>
 
 .if ! empty(PORT_OPTIONS:MDOCS)
 INSLIST+=	reference
@@ -79,42 +80,38 @@ INSLIST+=	examples
 
 FIND_EXPR=	"${FIND_EXCLUDES} -prune"
 
-.if ${PORT_OPTIONS:MATMEGA644P}
-pre-patch:
-	@${MKDIR} ${WRKSRC}/hardware/arduino/variants/atmega644p
-.endif
-
 post-patch:
-	@${RM} -r ${WRKSRC}/hardware/tools/
-	@${MKDIR} ${WRKSRC}/hardware/tools/avr/
-	@${LN} -s ${PREFIX}/bin ${WRKSRC}/hardware/tools/avr/bin
-	@${LN} -s ${PREFIX}/etc ${WRKSRC}/hardware/tools/avr/etc
+	${RM} -r ${WRKSRC}/hardware/tools/
+	${MKDIR} ${WRKSRC}/hardware/tools/avr/
+	${LN} -s ${PREFIX}/bin ${WRKSRC}/hardware/tools/avr/bin
+	${LN} -s ${PREFIX}/etc ${WRKSRC}/hardware/tools/avr/etc
 
 	# Remove broken jar, and Linux C6 based libraries.
-	@${RM} ${WRKSRC}/lib/RXTXcomm.jar
+	${RM} ${WRKSRC}/lib/RXTXcomm.jar
 
 	# This port relys on comms/RXTX working without Linux C6 compatibility.
-	@${RM} ${WRKSRC}/lib/librxtxSerial.so
-	@${RM} ${WRKSRC}/lib/librxtxSerial64.so
+	${RM} ${WRKSRC}/lib/librxtxSerial.so
+	${RM} ${WRKSRC}/lib/librxtxSerial64.so
 
 	# Map the RXTX port for our use
-	@${LN} -s ${JAVA_HOME}/jre/lib/ext/RXTXcomm.jar ${WRKSRC}/lib/RXTXcomm.jar
+	${LN} -s ${JAVA_HOME}/jre/lib/ext/RXTXcomm.jar ${WRKSRC}/lib/RXTXcomm.jar
 
 # Add in links to the libraries compiled in RXTX for the above jar to use based on architecture.
 .if ${ARCH} == i386
-	@${LN} -s ${JAVA_HOME}/jre/lib/i386/librxtxSerial.so ${WRKSRC}/lib/librxtxSerial.so
+	${LN} -s ${JAVA_HOME}/jre/lib/i386/librxtxSerial.so ${WRKSRC}/lib/librxtxSerial.so
 .endif
 
 .if ${ARCH} == amd64
-	@${LN} -s ${JAVA_HOME}/jre/lib/amd64/librxtxSerial.so ${WRKSRC}/lib/librxtxSerial64.so
+	${LN} -s ${JAVA_HOME}/jre/lib/amd64/librxtxSerial.so ${WRKSRC}/lib/librxtxSerial64.so
 .endif
 
-	@${MV} ${WRKSRC}/reference/img/logo.png ${WRKSRC}/
-	@${RM} -r ${WRKSRC}/reference/img/
+	${MV} ${WRKSRC}/reference/img/logo.png ${WRKSRC}/
+	${RM} -r ${WRKSRC}/reference/img/
 
 do-install:
 	${MKDIR} ${STAGEDIR}${PREFIX}/${PORTNAME}
-	(cd ${WRKSRC}/ && ${COPYTREE_SHARE} "${INSLIST}" ${STAGEDIR}${PREFIX}/${PORTNAME} ${FIND_EXPR})
+	(cd ${WRKSRC}/ && ${COPYTREE_SHARE} "${INSLIST}" ${STAGEDIR}${PREFIX}/${PORTNAME} \
+	    ${FIND_EXPR})
 	${INSTALL_SCRIPT} ${WRKDIR}/arduino ${STAGEDIR}${PREFIX}/bin/
 
 .include <bsd.port.mk>
diff --git a/devel/arduino/files/extrapatch-hardware-arduino-boards.txt b/devel/arduino/files/extrapatch-hardware-arduino-boards.txt
deleted file mode 100644
index 3fa8bc21ff78..000000000000
--- a/devel/arduino/files/extrapatch-hardware-arduino-boards.txt
+++ /dev/null
@@ -1,27 +0,0 @@
---- hardware/arduino/boards.txt.orig	2017-03-15 17:34:53 UTC
-+++ hardware/arduino/boards.txt
-@@ -525,6 +525,24 @@ atmega8.build.variant=standard
- 
- ##############################################################
- 
-+atmega644.name=ATmega644
-+atmega644.upload.protocol=stk500
-+atmega644.upload.maximum_size=63488
-+atmega644.upload.speed=38400
-+atmega644.bootloader.low_fuses=0xFF
-+atmega644.bootloader.high_fuses=0xDC
-+atmega644.bootloader.extended_fuses=0xFD
-+atmega644.bootloader.path=atmega644p
-+atmega644.bootloader.file=atmega644p
-+atmega644.bootloader.unlock_bits=0x3F
-+atmega644.bootloader.lock_bits=0x0F
-+atmega644.build.mcu=atmega644p
-+atmega644.build.f_cpu=16000000L
-+atmega644.build.core=atmega644
-+atmega644.build.variant=atmega644p
-+
-+##############################################################
-+
- robotControl.name=Arduino Robot Control
- robotControl.upload.protocol=avr109
- robotControl.upload.maximum_size=28672
diff --git a/devel/arduino/files/extrapatch-hardware-arduino-boards.txt-arlcd b/devel/arduino/files/extrapatch-hardware-arduino-boards.txt-arlcd
deleted file mode 100644
index 97cc41ece469..000000000000
--- a/devel/arduino/files/extrapatch-hardware-arduino-boards.txt-arlcd
+++ /dev/null
@@ -1,23 +0,0 @@
---- hardware/arduino/boards.txt.orig	2013-07-14 10:31:43.000000000 -0700
-+++ hardware/arduino/boards.txt	2013-07-21 12:43:56.000000000 -0700
-@@ -601,3 +601,20 @@
- robotMotor.build.core=robot
- robotMotor.build.variant=robot_motor
- 
-+##############################################################
-+
-+arlcd.name=EarthLCD arLCD
-+arlcd.upload.protocol=arduino
-+arlcd.upload.maximum_size=32256
-+arlcd.upload.speed=115200
-+arlcd.bootloader.low_fuses=0xff
-+arlcd.bootloader.high_fuses=0xde
-+arlcd.bootloader.extended_fuses=0x05
-+arlcd.bootloader.path=optiboot
-+arlcd.bootloader.file=optiboot_atmega328.hex
-+arlcd.bootloader.unlock_bits=0x3F
-+arlcd.bootloader.lock_bits=0x0F
-+arlcd.build.mcu=atmega328
-+arlcd.build.f_cpu=16000000L
-+arlcd.build.core=arduino
-+arlcd.build.variant=standard
diff --git a/devel/arduino/files/extrapatch-hardware_arduino_boards.txt b/devel/arduino/files/extrapatch-hardware_arduino_boards.txt
new file mode 100644
index 000000000000..51d32c307b06
--- /dev/null
+++ b/devel/arduino/files/extrapatch-hardware_arduino_boards.txt
@@ -0,0 +1,43 @@
+--- hardware/arduino/boards.txt.orig	2024-01-29 02:52:44 UTC
++++ hardware/arduino/boards.txt
+@@ -565,3 +565,40 @@ robotMotor.build.pid=0x8039
+ robotMotor.build.core=robot
+ robotMotor.build.variant=robot_motor
+ 
++##############################################################
++
++atmega644.name=ATmega644
++atmega644.upload.protocol=stk500
++atmega644.upload.maximum_size=63488
++atmega644.upload.speed=38400
++atmega644.bootloader.low_fuses=0xFF
++atmega644.bootloader.high_fuses=0xDC
++atmega644.bootloader.extended_fuses=0xFD
++atmega644.bootloader.path=atmega644p
++atmega644.bootloader.file=atmega644p
++atmega644.bootloader.unlock_bits=0x3F
++atmega644.bootloader.lock_bits=0x0F
++atmega644.build.mcu=atmega644p
++atmega644.build.f_cpu=16000000L
++atmega644.build.core=atmega644
++atmega644.build.variant=atmega644p
++
++##############################################################
++
++atmega1284.name=ATmega1284
++atmega1284.upload.protocol=stk500
++atmega1284.upload.maximum_size=129024
++atmega1284.upload.speed=38400
++atmega1284.bootloader.low_fuses=0xFF
++atmega1284.bootloader.high_fuses=0xDC
++atmega1284.bootloader.extended_fuses=0xFD
++atmega1284.bootloader.path=atmega1284p
++atmega1284.bootloader.file=atmega1284p
++atmega1284.bootloader.unlock_bits=0x3F
++atmega1284.bootloader.lock_bits=0x0F
++atmega1284.build.mcu=atmega1284p
++atmega1284.build.f_cpu=16000000L
++atmega1284.build.core=atmega1284
++atmega1284.build.variant=atmega644p
++
++##############################################################
diff --git a/devel/arduino/files/extrapatch-hardware-arduino-cores-arduino-WInterrupts.c b/devel/arduino/files/extrapatch-hardware_arduino_cores_arduino_WInterrupts.c
similarity index 100%
rename from devel/arduino/files/extrapatch-hardware-arduino-cores-arduino-WInterrupts.c
rename to devel/arduino/files/extrapatch-hardware_arduino_cores_arduino_WInterrupts.c
diff --git a/devel/arduino/files/extrapatch-hardware-arduino-variants-atmega644p-pins_arduino.h b/devel/arduino/files/extrapatch-hardware_arduino_variants_atmega644p_pins__arduino.h
similarity index 94%
rename from devel/arduino/files/extrapatch-hardware-arduino-variants-atmega644p-pins_arduino.h
rename to devel/arduino/files/extrapatch-hardware_arduino_variants_atmega644p_pins__arduino.h
index 2035d4aa45df..7e70247eb6e4 100644
--- a/devel/arduino/files/extrapatch-hardware-arduino-variants-atmega644p-pins_arduino.h
+++ b/devel/arduino/files/extrapatch-hardware_arduino_variants_atmega644p_pins__arduino.h
@@ -1,6 +1,6 @@
---- /dev/null	2012-12-26 20:59:44.000000000 -0800
-+++ hardware/arduino/variants/atmega644p/pins_arduino.h	2012-12-26 21:12:00.000000000 -0800
-@@ -0,0 +1,224 @@
+--- hardware/arduino/variants/atmega644p/pins_arduino.h.orig	2024-01-29 03:40:21 UTC
++++ hardware/arduino/variants/atmega644p/pins_arduino.h
+@@ -0,0 +1,229 @@
 +/*
 +  pins_arduino.h - Pin definition functions for Arduino
 +  Part of Arduino - http://www.arduino.cc/
@@ -22,7 +22,7 @@
 +  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 +  Boston, MA  02111-1307  USA
 +
-+  $Id: pins_arduino.h 5 2012-07-30 03:39:31Z leres $
++  $Id: pins_arduino.h,v 1.2 2021/06/20 20:01:08 leres Exp $
 +*/
 +
 +#ifndef Pins_Arduino_h
@@ -60,6 +60,11 @@
 +#define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14)))
 +#endif
 +
++#define digitalPinToInterrupt(p) \
++    ((p) == 2 ? 2 : \
++    ((p) == 10 ? 0 : \
++    ((p) == 11 ? 1 : NOT_AN_INTERRUPT)))
++
 +#ifdef ARDUINO_MAIN
 +
 +// Digital pins are also used for the analog output (software PWM).
diff --git a/devel/arduino/files/patch-hardware-arduino-cores-arduino-HardwareSerial.cpp b/devel/arduino/files/patch-hardware_arduino_cores_arduino_HardwareSerial.cpp
similarity index 100%
rename from devel/arduino/files/patch-hardware-arduino-cores-arduino-HardwareSerial.cpp
rename to devel/arduino/files/patch-hardware_arduino_cores_arduino_HardwareSerial.cpp