# Work around a qmake bug where, in some cases, it will add an
# extraneous '-arch' flag. In other ports (and in previous versions of
# this one), this was handled with reinplace in the post-configure
# step. Unfortunately, Makefile.qmake doesn't exist at post-configure
# so this patch modifies the Makefile rule which creates
# Makefile.qmake to remove the '-arch' flag.

diff -ur ../djview-4.10.5-orig/src/Makefile.am ./src/Makefile.am
--- ../djview-4.10.5-orig/src/Makefile.am	2015-12-27 01:57:08.000000000 +0900
+++ ./src/Makefile.am	2016-02-25 00:04:55.000000000 +0900
@@ -65,7 +65,8 @@
 		QMAKE_CPPFLAGS+='$(CPPFLAGS) $(qmake_allflags)' \
 		LIBS+='$(QMAKELIBS)' \
 		VPATH='$(srcdir)' -o $@0 djview.pro
-	$(AWK) -f $(top_srcdir)/config/qmsilent.awk < $@0 > $@ && ${RM} $@0
+	$(AWK) -f $(top_srcdir)/config/qmsilent.awk < $@0 |\
+  	$(SED) -e 's/-arch *-/-/g' -e 's/-arch *$$//g' > $@ && ${RM} $@0
 
 # cleaning
 
diff -ur ../djview-4.10.5-orig/src/Makefile.in ./src/Makefile.in
--- ../djview-4.10.5-orig/src/Makefile.in	2016-01-07 21:28:37.000000000 +0900
+++ ./src/Makefile.in	2016-02-25 00:05:42.000000000 +0900
@@ -678,7 +678,8 @@
 		QMAKE_CPPFLAGS+='$(CPPFLAGS) $(qmake_allflags)' \
 		LIBS+='$(QMAKELIBS)' \
 		VPATH='$(srcdir)' -o $@0 djview.pro
-	$(AWK) -f $(top_srcdir)/config/qmsilent.awk < $@0 > $@ && ${RM} $@0
+	$(AWK) -f $(top_srcdir)/config/qmsilent.awk < $@0 |\
+	$(SED) -e 's/-arch *-/-/g' -e 's/-arch *$$//g' > $@ && ${RM} $@0
 
 # cleaning