Bug 170242

Summary: [PATCH] devel/arduino: fix avr-libc SIG_USART1_RECV issue (and other fixes)
Product: Ports & Packages Reporter: Craig Leres <leres>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: leres
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
arduino-1.0.1,2.diff
none
patch.txt none

Description Craig Leres freebsd_committer freebsd_triage 2012-07-29 06:00:04 UTC
 	avr-libc-1.8.0 has "poisoned" SIG_USART1_RECV which causes
 	obvious issues when compiling with -Werror.
 
 	The do-install makefile target for this port installs
 	everything and then removes some trees if the DOCS or EXAMPLES
 	options aren't set.
 
 	Some of us use larger ATmega's such as the 644 and it's handy to
 	add values for these to boards.txt.
 
 	portlint complains about whitespace in pkg-message.

Fix: 

Patch HardwareSerial.cpp to avoid touching SIG_USART1_RECV. Also
 	get rid of SIG_USART2_RECV and SIG_USART3_RECV while we're at it
 	(plus it's silly to have a #elif defined() that just does
 	#error!)
 
 	Rework do-install to use COPYTREE_SHARE and option values when
 	installing files (instead of cp -Rp and optional rm -rf's).
 
 	Add an optional patch to add ATmega644 values to boards.txt.
 
 	Remove leading and trailing newlines from pkg-message.in
 
 --- patches.txt begins here ---
 --- Makefile.orig	2012-07-28 21:43:38.000000000 -0700
 +++ Makefile	2012-07-28 21:10:51.000000000 -0700
 @@ -5,7 +5,7 @@
 
   PORTNAME=	arduino
   PORTVERSION=	1.0.1
 -PORTREVISION=	1
 +PORTREVISION=	2
   PORTEPOCH=	1
   CATEGORIES=	devel java lang
   MASTER_SITES=	GOOGLE_CODE
 @@ -34,26 +34,39 @@
   			${PREFIX}/${PORTNAME}/logo.png \
   			"arduino" "Development;IDE;" "false"
 
 -OPTIONS_DEFINE+=	DOCS EXAMPLES
 +OPTIONS_DEFINE+=	ATMEGA644 DOCS EXAMPLES
 +ATMEGA644_DESC=	 	Patch boards.txt adding ATmega644 values
   DOCS_DESC=	 	Install the reference documents
 
 +INSLIST=	arduino hardware lib libraries logo.png revisions.txt tools
 +
   .include <bsd.port.options.mk>
 
 +.if ${PORT_OPTIONS:MATMEGA644}
 +EXTRA_PATCHES+=	${FILESDIR}/extrapatch-hardware-arduino-boards.txt
 +.endif
 +
   .if empty(PORT_OPTIONS:MDOCS)
   PLIST_SUB+=	REFDOCS="@comment "
   .else
   PLIST_SUB+=	REFDOCS=""
 +INSLIST+=	reference
   .endif
 
   .if empty(PORT_OPTIONS:MEXAMPLES)
   PLIST_SUB+=	EXAMPLES="@comment "
   .else
   PLIST_SUB+=	EXAMPLES=""
 +INSLIST+=	examples
   .endif
 
   post-patch:
   	@${RM} ${WRKSRC}/hardware/arduino/bootloaders/atmega8/ATmegaBOOT.c.orig
 +.if ${PORT_OPTIONS:MATMEGA644}
 +	@${RM} ${WRKSRC}/hardware/arduino/boards.txt.orig
 +.endif
   	@${RM} -rf ${WRKSRC}/hardware/tools/
 +	@${RMDIR} ${WRKSRC}/hardware/arduino/firmwares/arduino-usbserial/.dep
   	@${MKDIR} ${WRKSRC}/hardware/tools/avr/
   	@${LN} -s ${PREFIX}/bin ${WRKSRC}/hardware/tools/avr/bin
   	@${LN} -s ${PREFIX}/etc ${WRKSRC}/hardware/tools/avr/etc
 @@ -64,17 +77,9 @@
   	@${MV} ${WRKSRC}/reference/img/logo.png ${WRKSRC}/
   	@${RM} -rf ${WRKSRC}/reference/img/
 
 -.if empty(PORT_OPTIONS:MDOCS)
 -	@${RM} -rf ${WRKSRC}/reference
 -.endif
 -.if empty(PORT_OPTIONS:MEXAMPLES)
 -	@${RM} -rf ${WRKSRC}/examples
 -	@${RM} -rf ${WRKSRC}/libraries/*/examples
 -.endif
 -
   do-install:
   	@${MKDIR} ${PREFIX}/${PORTNAME}
 -	@${CP} -Rp ${WRKSRC}/* ${PREFIX}/${PORTNAME}
 +	@(cd ${WRKSRC}/ && ${COPYTREE_SHARE} "${INSLIST}" ${PREFIX}/${PORTNAME})
   	@${INSTALL_SCRIPT} ${WRKDIR}/arduino ${PREFIX}/bin/
 
   post-install:
 --- /dev/null	2012-07-28 21:15:01.000000000 -0700
 +++ files/extrapatch-hardware-arduino-boards.txt	2012-07-28 
 20:04:16.000000000 -0700
 @@ -0,0 +1,42 @@
 +--- hardware/arduino/boards.txt.orig	2011-11-28 16:56:32.000000000 -0800
 ++++ hardware/arduino/boards.txt	2012-04-22 21:15:11.000000000 -0700
 +@@ -472,3 +472,39 @@
 + atmega8.build.f_cpu=16000000L
 + atmega8.build.core=arduino
 + 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=atmega644
 ++atmega644.build.f_cpu=16000000L
 ++atmega644.build.core=atmega644
 ++atmega644.build.variant=standard
 ++
 ++##############################################################
 ++
 ++atmega644p.name=ATmega644p
 ++atmega644p.upload.protocol=stk500
 ++atmega644p.upload.maximum_size=63488
 ++atmega644p.upload.speed=38400
 ++atmega644p.bootloader.low_fuses=0xFF
 ++atmega644p.bootloader.high_fuses=0xDC
 ++atmega644p.bootloader.extended_fuses=0xFD
 ++atmega644p.bootloader.path=atmega644p
 ++atmega644p.bootloader.file=atmega644p
 ++atmega644p.bootloader.unlock_bits=0x3F
 ++atmega644p.bootloader.lock_bits=0x0F
 ++atmega644p.build.mcu=atmega644p
 ++atmega644p.build.f_cpu=16000000L
 ++atmega644p.build.core=atmega644
 ++atmega644p.build.variant=standard
 --- /dev/null	2012-07-28 21:15:01.000000000 -0700
 +++ files/patch-hardware-arduino-cores-arduino-HardwareSerial.cpp 
 2012-07-28 21:25:27.000000000 -0700
 @@ -0,0 +1,29 @@
 +--- hardware/arduino/cores/arduino/HardwareSerial.cpp.orig	2012-07-28 
 21:20:49.000000000 -0700
 ++++ hardware/arduino/cores/arduino/HardwareSerial.cpp	2012-07-28 
 21:24:52.000000000 -0700
 +@@ -129,8 +129,6 @@
 +     unsigned char c = UDR1;
 +     store_char(c, &rx_buffer1);
 +   }
 +-#elif defined(SIG_USART1_RECV)
 +-  #error SIG_USART1_RECV
 + #endif
 +
 + #if defined(USART2_RX_vect) && defined(UDR2)
 +@@ -142,8 +140,6 @@
 +     unsigned char c = UDR2;
 +     store_char(c, &rx_buffer2);
 +   }
 +-#elif defined(SIG_USART2_RECV)
 +-  #error SIG_USART2_RECV
 + #endif
 +
 + #if defined(USART3_RX_vect) && defined(UDR3)
 +@@ -155,8 +151,6 @@
 +     unsigned char c = UDR3;
 +     store_char(c, &rx_buffer3);
 +   }
 +-#elif defined(SIG_USART3_RECV)
 +-  #error SIG_USART3_RECV
 + #endif
 +
 + void serialEventRun(void)
 --- files/pkg-message.in.orig	2012-07-28 21:44:07.000000000 -0700
 +++ files/pkg-message.in	2012-07-28 21:13:05.000000000 -0700
 @@ -1,4 +1,3 @@
 -
   Notes on using the Arduino IDE:
 
   To allow serial port locking, add your user to the dialer group:
 @@ -17,4 +16,3 @@
 
   To start the IDE:
       %%PREFIX%%/bin/arduino
 -
 --- pkg-plist.orig	2012-07-28 21:43:57.000000000 -0700
 +++ pkg-plist	2012-07-28 21:11:58.000000000 -0700
 @@ -721,7 +721,6 @@
   @dirrm arduino/hardware/arduino/variants
   @dirrm arduino/hardware/arduino/firmwares/arduino-usbserial/Lib
   @dirrm arduino/hardware/arduino/firmwares/arduino-usbserial/Board
 -@dirrm arduino/hardware/arduino/firmwares/arduino-usbserial/.dep
   @dirrm arduino/hardware/arduino/firmwares/arduino-usbserial
   @dirrm arduino/hardware/arduino/firmwares/arduino-usbdfu/Board
   @dirrm arduino/hardware/arduino/firmwares/arduino-usbdfu
 --- patches.txt ends here ---
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2012-07-30 03:17:44 UTC
Class Changed
From-To: sw-bug->change-request

recover from bad formatting. 


Comment 2 Mark Linimon freebsd_committer freebsd_triage 2012-07-30 03:17:44 UTC
Responsible Changed
From-To: gnats-admin->freebsd-ports-bugs
Comment 3 Craig Leres freebsd_committer freebsd_triage 2012-07-30 04:10:33 UTC
It would also be a good idea to add:

     USE_DOS2UNIX= yes

to the Makefile.

		Craig
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2012-10-08 07:14:17 UTC
Responsible Changed
From-To: freebsd-ports-bugs->wblock

Over to maintainer.
Comment 5 Warren Block 2012-10-28 01:42:27 UTC
Slightly modified version of submitted patch attached.
Comment 6 Warren Block 2012-10-28 01:58:58 UTC
Maintainer approved.
Comment 7 Warren Block freebsd_committer freebsd_triage 2012-10-28 02:01:18 UTC
Responsible Changed
From-To: wblock->freebsd-ports-bugs

Back to the ports committers.
Comment 8 Craig Leres freebsd_committer freebsd_triage 2012-11-19 02:20:44 UTC
arduino 1.0.2 was recently released. Here's yet another patchset that
folds upgrading from 1.0.1 to 1.0.2 with the other changes already
approved by the maintainer.

		Craig
Comment 9 Craig Leres freebsd_committer freebsd_triage 2012-12-28 20:23:52 UTC
This PR is obsolete. it has been superseded by this one:

    http://www.freebsd.org/cgi/query-pr.cgi?pr=174783

Please close this one.

		Craig
Comment 10 Mark Linimon freebsd_committer freebsd_triage 2012-12-29 00:50:16 UTC
State Changed
From-To: open->closed

Superseded by ports/174783.