From 06c87ae25bafabe9532df613c3d89ae659482b24 Mon Sep 17 00:00:00 2001 From: Anthony Cornehl Date: Thu, 31 Aug 2017 13:16:00 -0700 Subject: [PATCH] Detect FreeBSD FreeBSD requires __BSD_VISIBLE to be set to expose M_PI and mkstemp() in the system includes. This is normally set when _ANSI_SOURCE, _C99_SOURCE, or _C11_SOURCE are undefined. I don't want to dig into what the compiler is setting, so I'm just setting it in the configure script. /bin/sh ./libtool --tag=CC --mode=compile cc -DHAVE_CONFIG_H -I. -fPIC -fvisibility=hidden -pedantic -fno-exceptions -D PATH_ESPEAK_DATA=\"/usr/local/share/espeak-ng-data\" -DLIBESPEAK_NG_EXPORT -Isrc/include -Isrc/include/compat -I src/ucd-tools/src/include -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112L -Wno-endif-labels -g -O2 -std=c99 -MT src/libespeak-ng/src_libespeak_ng_la-wavegen.lo -MD -MP -MF src/libespeak-ng/.deps/src_libespeak_ng_la-wavegen.Tpo -c -o src/libespeak-ng/src_libespeak_ng_la-wavegen.lo `test -f 'src/libespeak-ng/wavegen.c' || echo './'`src/libespeak-ng/wavegen.c libtool: compile: cc -DHAVE_CONFIG_H -I. -fPIC -fvisibility=hidden -pedantic -fno-exceptions -D PATH_ESPEAK_DATA=\"/usr/local/share/espeak-ng-data\" -DLIBESPEAK_NG_EXPORT -Isrc/include -Isrc/include/compat -I src/ucd-tools/src/include -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112L -Wno-endif-labels -g -O2 -std=c99 -MT src/libespeak-ng/src_libespeak_ng_la-wavegen.lo -MD -MP -MF src/libespeak-ng/.deps/src_libespeak_ng_la-wavegen.Tpo -c src/libespeak-ng/wavegen.c -fPIC -DPIC -o src/libespeak-ng/.libs/src_libespeak_ng_la-wavegen.o src/libespeak-ng/wavegen.c:355:24: error: use of undeclared identifier 'M_PI' x = 127*(1.0 - cos((M_PI*2)*ix/wavemult_max)); ^ src/libespeak-ng/wavegen.c:623:16: error: use of undeclared identifier 'M_PI' minus_pi_t = -M_PI / samplerate; ^ 2 errors generated. gmake[1]: *** [Makefile:1690: src/libespeak-ng/src_libespeak_ng_la-wavegen.lo] Error 1 --- configure.ac | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/configure.ac b/configure.ac index 2d28da70..82a83a07 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,23 @@ else AC_MSG_ERROR([C99 is not supported by $CC.]) fi +dnl ================================================================ +dnl FreeBSD check. +dnl ================================================================ +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ + #if ! defined(__FreeBSD__) + #error macro not defined + #endif + ]])], [FREEBSD_FOUND="yes"], [FREEBSD_FOUND="no"]) + +AC_MSG_CHECKING([if targeting FreeBSD]) +if test "$FREEBSD_FOUND" = "yes" ; then + AC_MSG_RESULT([-D__BSD_VISIBLE]) + CFLAGS="$CFLAGS -D__BSD_VISIBLE" +else + AC_MSG_RESULT([no]) +fi + dnl ================================================================ dnl library checks. dnl ================================================================