Fix build on macOS Sierra
authorAndres Notzli <andres.noetzli@gmail.com>
Fri, 14 Oct 2016 00:34:38 +0000 (17:34 -0700)
committerAndres Notzli <andres.noetzli@gmail.com>
Fri, 2 Dec 2016 00:31:50 +0000 (16:31 -0800)
Before this fix, the build died with `ar: no archive members specified
when linking the empty libreplacements.la.` because macOS Sierra does
not require the replacements anymore. With this fix, `ffs.c` and
`strtok_r.c` are always getting compiled (even when they are empty) to
prevent the error. Also removed the unused
`CVC4_NEEDS_REPLACEMENT_FUNCTIONS` from `configure.ac` and added an
`#ifndef HAVE_FFS` to `ffs.c` for consistency with `strtok_r.c`.

configure.ac
src/lib/ffs.c

index 2f343368a0eda016f2d62b61bd3ad1ac830db180..3d645b24ed7aa2497e5b373ebca390f58dd9ee00 100644 (file)
@@ -1004,11 +1004,11 @@ AC_SEARCH_LIBS([clock_gettime], [rt],
                           [Defined to 1 if clock_gettime() is supported by the platform.])],
                [AC_LIBOBJ([clock_gettime])])
 AC_CHECK_FUNC([strtok_r], [AC_DEFINE([HAVE_STRTOK_R], [1],
-                                     [Defined to 1 if strtok_r() is supported by the platform.])],
-                          [AC_LIBOBJ([strtok_r])])
+                                     [Defined to 1 if strtok_r() is supported by the platform.])])
 AC_CHECK_FUNC([ffs], [AC_DEFINE([HAVE_FFS], [1],
-                                [Defined to 1 if ffs() is supported by the platform.])],
-                     [AC_LIBOBJ([ffs])])
+                                [Defined to 1 if ffs() is supported by the platform.])])
+
+AC_LIBOBJ([strtok_r ffs])
 
 # Check for antlr C++ runtime (defined in config/antlr.m4)
 AC_LIB_ANTLR
@@ -1338,8 +1338,6 @@ else
   AC_SUBST([CVC4_HAS_THREADS], 0)
 fi
 
-AM_CONDITIONAL([CVC4_NEEDS_REPLACEMENT_FUNCTIONS], [test -n "$LIBOBJS"])
-
 # Final information to the user
 gpl=no
 licensewarn=
index 81228be63bf79cef585999f91ec4d789722f0396..d42f9da94dd6babc310a3761cfbe6018560afa35 100644 (file)
@@ -21,6 +21,7 @@
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
+#ifndef HAVE_FFS
 
 int ffs(int i) {
   long mask = 0x1;
@@ -35,6 +36,7 @@ int ffs(int i) {
   return 0;
 }
 
+#endif /* ifndef HAVE_FFS */
 #ifdef __cplusplus
 }/* extern "C" */
 #endif /* __cplusplus */