From bb06884290fc4a50a33f7708d337e10835f1252c Mon Sep 17 00:00:00 2001
From: Yuri Victorovich <yuri@FreeBSD.org>
Date: Fri, 21 Dec 2018 01:11:00 +0000
Subject: [PATCH] science/tinker: Fix build on non-Intel architectures by
 adding SSE flags based on architecture

PR:		234223
Reported by:	Piotr Kubaj <pkubaj@anongoth.pl>
---
 science/tinker/Makefile                  | 10 +++++++++-
 science/tinker/files/patch-make_Makefile | 11 ++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/science/tinker/Makefile b/science/tinker/Makefile
index 44f75f32bfc7..2b73f35e6909 100644
--- a/science/tinker/Makefile
+++ b/science/tinker/Makefile
@@ -3,7 +3,7 @@
 
 PORTNAME=	tinker
 DISTVERSION=	8.4.4
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	science
 MASTER_SITES=	https://dasher.wustl.edu/tinker/downloads/
 
@@ -16,6 +16,14 @@ LICENSE_FILE=	${WRKSRC}/doc/license.pdf
 LICENSE_PERMS=	auto-accept # internal academic purposes only, no commercial use
 
 OPTIONS_DEFINE=	OPTIMIZED_FFLAGS DOCS EXAMPLES
+
+OPTIONS_DEFINE_amd64=	SSE
+OPTIONS_DEFINE_i386=	SSE
+OPTIONS_DEFAULT_amd64=	SSE
+OPTIONS_DEFAULT_i386=	SSE
+
+SSE_MAKE_ARGS=	PORT_SIMD_FLAGS="-msse -msse2 -mfpmath=sse"
+
 OPTIMIZED_FFLAGS_DESC=	compilation optimizations
 
 WRKSRC=		${WRKDIR}/${PORTNAME}
diff --git a/science/tinker/files/patch-make_Makefile b/science/tinker/files/patch-make_Makefile
index 3e9f9d05450e..daae1f67378d 100644
--- a/science/tinker/files/patch-make_Makefile
+++ b/science/tinker/files/patch-make_Makefile
@@ -1,5 +1,14 @@
---- make/Makefile.orig	2018-10-06 22:01:02 UTC
+--- make/Makefile.orig	2018-05-01 03:12:05 UTC
 +++ make/Makefile
+@@ -84,7 +84,7 @@ APBS_LIBS = -lapbsmainroutines -lapbs -l
+ 
+ F77 = gfortran
+ F77FLAGS = -c
+-OPTFLAGS = -Ofast -mssse3 -fopenmp
++OPTFLAGS = -Ofast $(PORT_SIMD_FLAGS) -fopenmp
+ LIBDIR = -L. -L$(TINKER_LIBDIR)/macos
+ LIBS = 
+ LIBFLAGS = -crusv
 @@ -754,130 +754,130 @@ listing:
  	cat *.f *.c > tinker.txt