From f909d121cec573433598c88083a7533c6ad2ffc5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lawrence=20Vel=C3=A1zquez?= <larryv@macports.org>
Date: Wed, 18 Mar 2015 15:17:07 -0400
Subject: [PATCH 5/6] lparse: Make configure respect CXXFLAGS and LDFLAGS

But maintain the default optimization level of -O3.
---
 dports/science/lparse/Portfile                  |  3 +++
 dports/science/lparse/files/respect-flags.patch | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 dports/science/lparse/files/respect-flags.patch

diff --git a/dports/science/lparse/Portfile b/dports/science/lparse/Portfile
index 39b5c64..0547ac1 100644
--- a/dports/science/lparse/Portfile
+++ b/dports/science/lparse/Portfile
@@ -29,9 +29,12 @@ checksums           rmd160  131f6ea6235eeb7529d2564bb9ce904e5bc2358a \
                     sha256  886d29723f7188296e48584a4a32b8f111414acb7ca8490af28ef6b7f1717298
 
 patchfiles          fix-bison-version-detection.patch \
+                    respect-flags.patch \
                     fix-recursive-make.patch \
                     avoid-namespace-collisions.patch
 
+# Match default value from configure.
+configure.optflags  -O3
 # this configure argument is only used for installing
 configure.pre_args  --prefix=${destroot}${prefix}/bin
 configure.args      CC='${configure.cxx}'
diff --git a/dports/science/lparse/files/respect-flags.patch b/dports/science/lparse/files/respect-flags.patch
new file mode 100644
index 0000000..232a4c5
--- /dev/null
+++ b/dports/science/lparse/files/respect-flags.patch
@@ -0,0 +1,18 @@
+Yes, I'm setting the CFLAGS makefile variable to $CXXFLAGS. This build
+system likes to pretend that it's using a C compiler, for some reason.
+
+Index: configure
+===================================================================
+--- configure.orig
++++ configure
+@@ -124,8 +124,8 @@ if ($debug_makefile) {
+   print OUT "CFLAGS=-g -Wall\n";
+   print OUT "LDFLAGS=-g -Wall\n";
+ } else {
+-  print OUT "CFLAGS=-O3\n";
+-  print OUT "LDFLAGS=-O3\n";
++  print OUT "CFLAGS=$ENV{'CXXFLAGS'}\n";
++  print OUT "LDFLAGS=$ENV{'LDFLAGS'}\n";
+ }
+ 
+ close OUT;
-- 
2.3.3

