[[
Fix build for multi-arch macOS binaries

For example, in order to be compatible with both x86-64 and new
Apple M1, serf would be compiled with:
  CFLAGS   ="-arch x86_64 -arch arm64"
  CPPFLAGS ="-arch x86_64 -arch arm64"
  LINKFLAGS="-arch x86_64 -arch arm64"

Counter-intuitively, when scons 'MergeFlags()' is called with
'unique=1', it also affects already present flags and not just the
merged ones. This causes flags to become 'x86_64 -arch arm64', where
the first '-arch' is now gone, which in turn causes build error
  error: no such file or directory: 'x86_64'

Fix that by passing 'unique=0'. In my case, it was sufficient to fix
in 'parse_libs()' only, but I decided to apply it to the other
'ParseConfig()' as well. See also r1712172, which fixed SERF-160. The
bugreport there is not very detailed, but it also involved breaking
linker flags.

* SConstruct
  When merging additional build flags, use 'unique=0' to avoid
  corrupting existing flags.
]]
Index: SConstruct
===================================================================
--- SConstruct  (revision 1893403)
+++ SConstruct  (working copy)
@@ -532,8 +532,8 @@
 
 # If build with gssapi, get its information and define SERF_HAVE_GSSAPI
 if gssapi and CALLOUT_OKAY:
-    env.ParseConfig('$GSSAPI --cflags gssapi')
-    def parse_libs(env, cmd, unique=1):
+    env.ParseConfig('$GSSAPI --cflags gssapi', unique=0)
+    def parse_libs(env, cmd, unique=0):
         env['GSSAPI_LIBS'] = cmd.strip()
         return env.MergeFlags(cmd, unique)
     env.ParseConfig('$GSSAPI --libs gssapi', parse_libs)

Reply via email to