Commit 046f081b authored by Diego Biurrun's avatar Diego Biurrun
Browse files

configure: Do not unconditionally add -D_POSIX_C_SOURCE to CPPFLAGS.

Adding _POSIX_C_SOURCE to CPPFLAGS globally produces all sorts of problems
since it causes certain system functions to be hidden on some (BSD) systems.
The solution is to only add the flag on systems that really require it, i.e.
glibc-based ones.

This change makes BSD systems compile out-of-the-box without the need for
adding specific flags manually.  It also allows dropping a number of flags
set manually on a file-per-file basis, but were only present to work around
breakage introduced by the presence of _POSIX_C_SOURCE.

Also add _XOPEN_SOURCE to CPPFLAGS for glibc systems.  We use XSI extensions
in several places already, so it is preferable to define it globally instead
of littering source files with individual #defines only needed for glibc.
parent 45faf7fc
......@@ -1664,7 +1664,7 @@ LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
CC_O='-o $@'
host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
host_cflags='-D_ISOC99_SOURCE -O3 -g -Wall'
host_libs='-lm'
target_path='$(CURDIR)'
......@@ -2316,7 +2316,7 @@ if test "$?" != 0; then
die "C compiler test failed."
fi
add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
add_cppflags -D_ISOC99_SOURCE
check_cflags -std=c99
check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
#include <stdlib.h>
......@@ -2364,7 +2364,6 @@ case $target_os in
disable symver
oss_indev_extralibs="-lossaudio"
oss_outdev_extralibs="-lossaudio"
add_cppflags -D_XOPEN_SOURCE=600
;;
openbsd)
enable malloc_aligned
......@@ -2457,6 +2456,7 @@ case $target_os in
enable dos_paths
;;
linux)
add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
enable dv1394
;;
irix*)
......
......@@ -785,14 +785,6 @@ to configure.
BSD make will not build Libav, you need to install and use GNU Make
(@file{gmake}).
@subsubsection FreeBSD, DragonFly BSD
These systems will not compile out-of-the-box due to broken system headers.
Passing @code{--extra-cflags=-D__BSD_VISIBLE} to configure will work
around the problem. This may have unexpected sideeffects, so use it at
your own risk. If you care about FreeBSD, please make an attempt at
getting the system headers fixed.
@subsection (Open)Solaris
GNU Make is required to build Libav, so you have to invoke (@file{gmake}),
......
......@@ -19,9 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* needed for usleep() */
#define _XOPEN_SOURCE 600
#include "config.h"
#include <ctype.h>
#include <string.h>
......
......@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define _XOPEN_SOURCE 600
#include "config.h"
#include <inttypes.h>
#include <math.h>
......
......@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define _XOPEN_SOURCE 600
#include "config.h"
#if !HAVE_CLOSESOCKET
#define closesocket close
......
......@@ -25,9 +25,6 @@
* @author Adam Thayer (krevnik@comcast.net)
*/
/* needed for mkstemp() */
#define _XOPEN_SOURCE 600
#include <xvid.h>
#include <unistd.h>
#include "avcodec.h"
......
......@@ -24,10 +24,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define _BSD_SOURCE 1
#define _NETBSD_SOURCE
#define _XOPEN_SOURCE 600
#include "libavformat/avformat.h"
#if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H
# include <dev/bktr/ioctl_meteor.h>
......
......@@ -35,8 +35,6 @@
* and Edouard Gomez <ed.gomez@free.fr>.
*/
#define _XOPEN_SOURCE 600
#include "config.h"
#include "libavformat/avformat.h"
#include <time.h>
......
......@@ -25,7 +25,6 @@
* http://tools.ietf.org/html/draft-pantos-http-live-streaming
*/
#define _XOPEN_SOURCE 600
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
......
......@@ -25,7 +25,6 @@
* http://tools.ietf.org/html/draft-pantos-http-live-streaming
*/
#define _XOPEN_SOURCE 600
#include "libavutil/avstring.h"
#include "avformat.h"
#include "internal.h"
......
......@@ -19,9 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* needed for usleep() */
#define _XOPEN_SOURCE 600
#include <unistd.h>
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "os_support.h"
......
......@@ -22,7 +22,6 @@
/* needed by inet_aton() */
#define _SVID_SOURCE
#define _DARWIN_C_SOURCE
#include "config.h"
#include "avformat.h"
......
......@@ -19,9 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* needed for gethostname() */
#define _XOPEN_SOURCE 600
#include "libavcodec/get_bits.h"
#include "avformat.h"
#include "mpegts.h"
......
......@@ -25,7 +25,7 @@
*/
#define _BSD_SOURCE /* Needed for using struct ip_mreq with recent glibc */
#define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */
#include "avformat.h"
#include "avio_internal.h"
#include "libavutil/parseutils.h"
......
......@@ -17,10 +17,8 @@
*/
#ifdef __APPLE__
#undef _POSIX_C_SOURCE
#include <sys/sysctl.h>
#elif defined(__OpenBSD__)
#undef _POSIX_C_SOURCE
#include <sys/param.h>
#include <sys/sysctl.h>
#include <machine/cpu.h>
......
......@@ -18,8 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define _SVID_SOURCE //needed for MAP_ANONYMOUS
#define _DARWIN_C_SOURCE // needed for MAP_ANON
#include <inttypes.h>
#include <string.h>
#include <math.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment