git: 8e2ec289a2d8 - main - biology/phyml: fix build on non-x86

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Mon, 08 May 2023 08:26:48 UTC
The branch main has been updated by fuz:

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

commit 8e2ec289a2d8891c9bd3c549319baa9c94cfda27
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-05-07 20:57:10 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-05-08 08:25:50 +0000

    biology/phyml: fix build on non-x86
    
     - only initialise x86-only fields on x86.
     - make code compatible with platforms where char is unsigned
    
    Obtained from:  https://github.com/stephaneguindon/phyml/commit/9c55b683c875fb9923e7cb2a1092596f72040882
    MFH:            2023Q2
---
 biology/phyml/Makefile                    |  4 +--
 biology/phyml/files/patch-src_io.c        | 41 ++++++++++++++++++++++++++++
 biology/phyml/files/patch-src_utilities.c | 44 +++++++++++++++++++++++++++++++
 biology/phyml/files/patch-src_utilities.h | 13 +++++++++
 4 files changed, 100 insertions(+), 2 deletions(-)

diff --git a/biology/phyml/Makefile b/biology/phyml/Makefile
index fc4d36b518b9..b5feff3eaae3 100644
--- a/biology/phyml/Makefile
+++ b/biology/phyml/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	phyml
 DISTVERSIONPREFIX=	v
 DISTVERSION=	3.3.20220408
+PORTREVISION=	1
 PORTEPOCH=	1
 CATEGORIES=	biology
 
@@ -42,11 +43,10 @@ CONFIGURE_ARGS+=	--disable-mpi
 BIN_SUFFIX=		# none
 .endif
 
-post-patch:
 .if ${ARCH} != amd64 && ${ARCH} != i386
+post-patch:
 	@${REINPLACE_CMD} -e 's|VECTOR_FLAG=-march=native|dnl &|' ${WRKSRC}/configure.ac
 .endif
-	@${REINPLACE_CMD} -e 's|malloc.h|stdlib.h|' ${WRKSRC}/src/utilities.h
 
 post-install-DOCS-on:
 	@${MKDIR} ${STAGEDIR}${DOCSDIR}
diff --git a/biology/phyml/files/patch-src_io.c b/biology/phyml/files/patch-src_io.c
new file mode 100644
index 000000000000..6085f3541ebe
--- /dev/null
+++ b/biology/phyml/files/patch-src_io.c
@@ -0,0 +1,41 @@
+--- src/io.c.orig	2023-05-07 20:50:29 UTC
++++ src/io.c
+@@ -1157,7 +1157,7 @@ void Get_Nexus_Data(FILE *fp, option *io)
+ 
+ int Get_Token(FILE *fp, char *token)
+ {
+-  char c;
++  int c;
+ 
+   c = ' ';
+ 
+@@ -1518,7 +1518,8 @@ align **Read_Seq_Interleaved(option *io)
+ 
+ int Read_One_Line_Seq(align ***data, int num_otu, FILE *in)
+ {
+-  char c = ' ';
++  char c_;
++  int c = ' ';
+   int nchar = 0;
+ 
+   while(1)
+@@ -1552,7 +1553,9 @@ int Read_One_Line_Seq(align ***data, int num_otu, FILE
+         }
+       
+       nchar++;
+-      Uppercase(&c);
++      c_ = c;
++      Uppercase(&c_);
++      c = c_;
+ 
+       if(c == '.')
+         {
+@@ -1617,7 +1620,7 @@ char *Return_Tree_String_Phylip(FILE *fp_input_tree)
+ {
+   char *line;
+   int i;
+-  char c;
++  int c;
+   int open,maxopen;
+ 
+   if(fp_input_tree == NULL)
diff --git a/biology/phyml/files/patch-src_utilities.c b/biology/phyml/files/patch-src_utilities.c
new file mode 100644
index 000000000000..2f95b278dd6a
--- /dev/null
+++ b/biology/phyml/files/patch-src_utilities.c
@@ -0,0 +1,44 @@
+--- src/utilities.c.orig	2022-04-08 15:01:10 UTC
++++ src/utilities.c
+@@ -3209,18 +3209,20 @@ void Bootstrap(t_tree *tree)
+       boot_tree->io->print_json_trace = NO;
+       boot_tree->n_root               = NULL;
+       boot_tree->e_root               = NULL;
++      boot_tree->l_ev                 = tree->l_ev;
++      boot_tree->p_lk_left_pi         = tree->p_lk_left_pi;
++
++#if (defined(__AVX__) || defined(__AVX2__) || defined(__SSE__) || defined(__SSE2__) || defined(__SSE3__))
+       boot_tree->_tPij1               = tree->_tPij1;
+       boot_tree->_tPij2               = tree->_tPij2;
+       boot_tree->_pmat1plk1           = tree->_pmat1plk1;
+       boot_tree->_pmat2plk2           = tree->_pmat2plk2;
+       boot_tree->_plk0                = tree->_plk0;
+-      boot_tree->l_ev                 = tree->l_ev;
+-      boot_tree->p_lk_left_pi         = tree->p_lk_left_pi;
+       boot_tree->_l_ev                = tree->_l_ev;
+       boot_tree->_r_ev                = tree->_r_ev;
+       boot_tree->_prod_left           = tree->_prod_left;
+       boot_tree->_prod_rght           = tree->_prod_rght;
+-      
++#endif
+ 
+       Set_Both_Sides(YES,boot_tree);
+ 
+@@ -8902,7 +8904,7 @@ t_edge *Find_Root_Edge(FILE *fp_input_tree, t_tree *tr
+   int l_r, r_l;
+   int score;
+   char *line;
+-  char c;
++  int c;
+   t_edge *root_edge;
+ 
+   line = (char *)mCalloc(T_MAX_LINE,sizeof(char));
+@@ -9206,7 +9208,7 @@ void Translate_Tax_Names(char **tax_names, t_tree *tre
+ void Skip_Comment(FILE *fp)
+ {
+   int in_comment;
+-  char c;
++  int c;
+ 
+   in_comment = 1;
+   do
diff --git a/biology/phyml/files/patch-src_utilities.h b/biology/phyml/files/patch-src_utilities.h
new file mode 100644
index 000000000000..6edbbcb01460
--- /dev/null
+++ b/biology/phyml/files/patch-src_utilities.h
@@ -0,0 +1,13 @@
+--- src/utilities.h.orig	2022-04-08 15:01:10 UTC
++++ src/utilities.h
+@@ -31,8 +31,8 @@ the GNU public licence. See http://www.opensource.org 
+ #include <assert.h>
+ #include <stdbool.h>
+ #include <signal.h>
+-/* #include <malloc/malloc.h> */
+-/* #include <malloc.h> */
++/* #include <malloc/stdlib.h> */
++/* #include <stdlib.h> */
+ 
+ #if (defined(__AVX__) || defined(__AVX2__))
+ #include <xmmintrin.h>